aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-01-02 19:26:05 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-01-02 19:26:05 +0000
commit14f1b3e8826ce43b978db93a62d1166055db5394 (patch)
tree0a00ad8d3498783fe0193f3b656bca17c4c8697d /include
parent4ee8c119c71a06dcad1e0fecc8c675e480e59337 (diff)
downloadsrc-14f1b3e8826ce43b978db93a62d1166055db5394.tar.gz
src-14f1b3e8826ce43b978db93a62d1166055db5394.zip
Vendor import of lldb trunk r290819:vendor/lldb/lldb-trunk-r290819
Notes
Notes: svn path=/vendor/lldb/dist/; revision=311128 svn path=/vendor/lldb/lldb-trunk-r290819/; revision=311129; tag=vendor/lldb/lldb-trunk-r290819
Diffstat (limited to 'include')
-rw-r--r--include/lldb/API/LLDB.h5
-rw-r--r--include/lldb/API/SBAddress.h162
-rw-r--r--include/lldb/API/SBAttachInfo.h358
-rw-r--r--include/lldb/API/SBBlock.h153
-rw-r--r--include/lldb/API/SBBreakpoint.h313
-rw-r--r--include/lldb/API/SBBreakpointLocation.h149
-rw-r--r--include/lldb/API/SBBroadcaster.h94
-rw-r--r--include/lldb/API/SBCommandInterpreter.h482
-rw-r--r--include/lldb/API/SBCommandReturnObject.h182
-rw-r--r--include/lldb/API/SBCommunication.h96
-rw-r--r--include/lldb/API/SBCompileUnit.h163
-rw-r--r--include/lldb/API/SBData.h283
-rw-r--r--include/lldb/API/SBDebugger.h492
-rw-r--r--include/lldb/API/SBDeclaration.h123
-rw-r--r--include/lldb/API/SBDefines.h4
-rw-r--r--include/lldb/API/SBError.h98
-rw-r--r--include/lldb/API/SBEvent.h91
-rw-r--r--include/lldb/API/SBExecutionContext.h92
-rw-r--r--include/lldb/API/SBExpressionOptions.h201
-rw-r--r--include/lldb/API/SBFileSpec.h118
-rw-r--r--include/lldb/API/SBFileSpecList.h74
-rw-r--r--include/lldb/API/SBFrame.h383
-rw-r--r--include/lldb/API/SBFunction.h88
-rw-r--r--include/lldb/API/SBHostOS.h44
-rw-r--r--include/lldb/API/SBInstruction.h89
-rw-r--r--include/lldb/API/SBInstructionList.h57
-rw-r--r--include/lldb/API/SBLanguageRuntime.h11
-rw-r--r--include/lldb/API/SBLaunchInfo.h282
-rw-r--r--include/lldb/API/SBLineEntry.h82
-rw-r--r--include/lldb/API/SBListener.h141
-rw-r--r--include/lldb/API/SBMemoryRegionInfo.h173
-rw-r--r--include/lldb/API/SBMemoryRegionInfoList.h39
-rw-r--r--include/lldb/API/SBModule.h611
-rw-r--r--include/lldb/API/SBModuleSpec.h219
-rw-r--r--include/lldb/API/SBPlatform.h330
-rw-r--r--include/lldb/API/SBProcess.h774
-rw-r--r--include/lldb/API/SBQueue.h71
-rw-r--r--include/lldb/API/SBQueueItem.h41
-rw-r--r--include/lldb/API/SBSection.h132
-rw-r--r--include/lldb/API/SBSourceManager.h41
-rw-r--r--include/lldb/API/SBStream.h145
-rw-r--r--include/lldb/API/SBStringList.h56
-rw-r--r--include/lldb/API/SBStructuredData.h45
-rw-r--r--include/lldb/API/SBSymbol.h105
-rw-r--r--include/lldb/API/SBSymbolContext.h84
-rw-r--r--include/lldb/API/SBSymbolContextList.h54
-rw-r--r--include/lldb/API/SBTarget.h1607
-rw-r--r--include/lldb/API/SBThread.h417
-rw-r--r--include/lldb/API/SBThreadCollection.h81
-rw-r--r--include/lldb/API/SBThreadPlan.h138
-rw-r--r--include/lldb/API/SBType.h517
-rw-r--r--include/lldb/API/SBTypeCategory.h234
-rw-r--r--include/lldb/API/SBTypeEnumMember.h76
-rw-r--r--include/lldb/API/SBTypeFilter.h131
-rw-r--r--include/lldb/API/SBTypeFormat.h133
-rw-r--r--include/lldb/API/SBTypeNameSpecifier.h107
-rw-r--r--include/lldb/API/SBTypeSummary.h274
-rw-r--r--include/lldb/API/SBTypeSynthetic.h143
-rw-r--r--include/lldb/API/SBUnixSignals.h67
-rw-r--r--include/lldb/API/SBValue.h898
-rw-r--r--include/lldb/API/SBValueList.h96
-rw-r--r--include/lldb/API/SBVariablesOptions.h127
-rw-r--r--include/lldb/API/SBWatchpoint.h90
-rw-r--r--include/lldb/API/SystemInitializerFull.h20
-rw-r--r--include/lldb/Breakpoint/Breakpoint.h1392
-rw-r--r--include/lldb/Breakpoint/BreakpointID.h179
-rw-r--r--include/lldb/Breakpoint/BreakpointIDList.h65
-rw-r--r--include/lldb/Breakpoint/BreakpointList.h360
-rw-r--r--include/lldb/Breakpoint/BreakpointLocation.h812
-rw-r--r--include/lldb/Breakpoint/BreakpointLocationCollection.h360
-rw-r--r--include/lldb/Breakpoint/BreakpointLocationList.h472
-rw-r--r--include/lldb/Breakpoint/BreakpointOptions.h674
-rw-r--r--include/lldb/Breakpoint/BreakpointResolver.h356
-rw-r--r--include/lldb/Breakpoint/BreakpointResolverAddress.h81
-rw-r--r--include/lldb/Breakpoint/BreakpointResolverFileLine.h77
-rw-r--r--include/lldb/Breakpoint/BreakpointResolverFileRegex.h80
-rw-r--r--include/lldb/Breakpoint/BreakpointResolverName.h140
-rw-r--r--include/lldb/Breakpoint/BreakpointSite.h512
-rw-r--r--include/lldb/Breakpoint/BreakpointSiteList.h350
-rw-r--r--include/lldb/Breakpoint/Stoppoint.h49
-rw-r--r--include/lldb/Breakpoint/StoppointCallbackContext.h63
-rw-r--r--include/lldb/Breakpoint/StoppointLocation.h191
-rw-r--r--include/lldb/Breakpoint/Watchpoint.h426
-rw-r--r--include/lldb/Breakpoint/WatchpointList.h442
-rw-r--r--include/lldb/Breakpoint/WatchpointOptions.h422
-rw-r--r--include/lldb/Core/Address.h984
-rw-r--r--include/lldb/Core/AddressRange.h465
-rw-r--r--include/lldb/Core/AddressResolver.h54
-rw-r--r--include/lldb/Core/AddressResolverFileLine.h41
-rw-r--r--include/lldb/Core/AddressResolverName.h52
-rw-r--r--include/lldb/Core/ArchSpec.h1264
-rw-r--r--include/lldb/Core/Baton.h67
-rw-r--r--include/lldb/Core/Broadcaster.h1059
-rw-r--r--include/lldb/Core/ClangForward.h233
-rw-r--r--include/lldb/Core/Communication.h644
-rw-r--r--include/lldb/Core/Connection.h342
-rw-r--r--include/lldb/Core/ConnectionMachPort.h97
-rw-r--r--include/lldb/Core/ConnectionSharedMemory.h74
-rw-r--r--include/lldb/Core/ConstString.h911
-rw-r--r--include/lldb/Core/CxaDemangle.h21
-rw-r--r--include/lldb/Core/DataBuffer.h89
-rw-r--r--include/lldb/Core/DataBufferHeap.h199
-rw-r--r--include/lldb/Core/DataBufferMemoryMap.h237
-rw-r--r--include/lldb/Core/DataEncoder.h783
-rw-r--r--include/lldb/Core/DataExtractor.h2498
-rw-r--r--include/lldb/Core/Debugger.h784
-rw-r--r--include/lldb/Core/Disassembler.h880
-rw-r--r--include/lldb/Core/EmulateInstruction.h981
-rw-r--r--include/lldb/Core/Error.h518
-rw-r--r--include/lldb/Core/Event.h373
-rw-r--r--include/lldb/Core/FastDemangle.h14
-rw-r--r--include/lldb/Core/FileLineResolver.h81
-rw-r--r--include/lldb/Core/FileSpecList.h395
-rw-r--r--include/lldb/Core/Flags.h389
-rw-r--r--include/lldb/Core/FormatEntity.h426
-rw-r--r--include/lldb/Core/History.h180
-rw-r--r--include/lldb/Core/IOHandler.h1341
-rw-r--r--include/lldb/Core/IOStreamMacros.h42
-rw-r--r--include/lldb/Core/Listener.h274
-rw-r--r--include/lldb/Core/LoadedModuleInfoList.h203
-rw-r--r--include/lldb/Core/Log.h208
-rw-r--r--include/lldb/Core/Logging.h109
-rw-r--r--include/lldb/Core/Mangled.h574
-rw-r--r--include/lldb/Core/MappedHash.h933
-rw-r--r--include/lldb/Core/Module.h2281
-rw-r--r--include/lldb/Core/ModuleChild.h109
-rw-r--r--include/lldb/Core/ModuleList.h1082
-rw-r--r--include/lldb/Core/ModuleSpec.h924
-rw-r--r--include/lldb/Core/Opcode.h499
-rw-r--r--include/lldb/Core/PluginInterface.h15
-rw-r--r--include/lldb/Core/PluginManager.h1002
-rw-r--r--include/lldb/Core/RangeMap.h2467
-rw-r--r--include/lldb/Core/RegisterValue.h616
-rw-r--r--include/lldb/Core/RegularExpression.h347
-rw-r--r--include/lldb/Core/STLUtils.h67
-rw-r--r--include/lldb/Core/Scalar.h654
-rw-r--r--include/lldb/Core/SearchFilter.h718
-rw-r--r--include/lldb/Core/Section.h544
-rw-r--r--include/lldb/Core/SourceManager.h290
-rw-r--r--include/lldb/Core/State.h22
-rw-r--r--include/lldb/Core/Stream.h1114
-rw-r--r--include/lldb/Core/StreamAsynchronousIO.h31
-rw-r--r--include/lldb/Core/StreamBuffer.h81
-rw-r--r--include/lldb/Core/StreamCallback.h34
-rw-r--r--include/lldb/Core/StreamFile.h56
-rw-r--r--include/lldb/Core/StreamGDBRemote.h56
-rw-r--r--include/lldb/Core/StreamString.h43
-rw-r--r--include/lldb/Core/StreamTee.h237
-rw-r--r--include/lldb/Core/StringList.h255
-rw-r--r--include/lldb/Core/StructuredData.h1223
-rw-r--r--include/lldb/Core/ThreadSafeDenseMap.h97
-rw-r--r--include/lldb/Core/ThreadSafeDenseSet.h88
-rw-r--r--include/lldb/Core/ThreadSafeSTLMap.h239
-rw-r--r--include/lldb/Core/ThreadSafeSTLVector.h136
-rw-r--r--include/lldb/Core/ThreadSafeValue.h83
-rw-r--r--include/lldb/Core/Timer.h128
-rw-r--r--include/lldb/Core/UUID.h148
-rw-r--r--include/lldb/Core/UniqueCStringMap.h522
-rw-r--r--include/lldb/Core/UserID.h154
-rw-r--r--include/lldb/Core/UserSettingsController.h134
-rw-r--r--include/lldb/Core/VMRange.h213
-rw-r--r--include/lldb/Core/Value.h432
-rw-r--r--include/lldb/Core/ValueObject.h2165
-rw-r--r--include/lldb/Core/ValueObjectCast.h79
-rw-r--r--include/lldb/Core/ValueObjectChild.h155
-rw-r--r--include/lldb/Core/ValueObjectConstResult.h268
-rw-r--r--include/lldb/Core/ValueObjectConstResultCast.h60
-rw-r--r--include/lldb/Core/ValueObjectConstResultChild.h93
-rw-r--r--include/lldb/Core/ValueObjectConstResultImpl.h97
-rw-r--r--include/lldb/Core/ValueObjectDynamicValue.h235
-rw-r--r--include/lldb/Core/ValueObjectList.h107
-rw-r--r--include/lldb/Core/ValueObjectMemory.h84
-rw-r--r--include/lldb/Core/ValueObjectRegister.h237
-rw-r--r--include/lldb/Core/ValueObjectSyntheticFilter.h301
-rw-r--r--include/lldb/Core/ValueObjectVariable.h115
-rw-r--r--include/lldb/Core/dwarf.h68
-rw-r--r--include/lldb/DataFormatters/CXXFunctionPointer.h9
-rw-r--r--include/lldb/DataFormatters/DataVisualization.h243
-rw-r--r--include/lldb/DataFormatters/DumpValueObjectOptions.h289
-rw-r--r--include/lldb/DataFormatters/FormatCache.h197
-rw-r--r--include/lldb/DataFormatters/FormatClasses.h303
-rw-r--r--include/lldb/DataFormatters/FormatManager.h496
-rw-r--r--include/lldb/DataFormatters/FormattersContainer.h671
-rw-r--r--include/lldb/DataFormatters/FormattersHelpers.h385
-rw-r--r--include/lldb/DataFormatters/LanguageCategory.h121
-rw-r--r--include/lldb/DataFormatters/StringPrinter.h821
-rw-r--r--include/lldb/DataFormatters/TypeCategory.h914
-rw-r--r--include/lldb/DataFormatters/TypeCategoryMap.h224
-rw-r--r--include/lldb/DataFormatters/TypeFormat.h505
-rw-r--r--include/lldb/DataFormatters/TypeSummary.h927
-rw-r--r--include/lldb/DataFormatters/TypeSynthetic.h1028
-rw-r--r--include/lldb/DataFormatters/TypeValidator.h418
-rw-r--r--include/lldb/DataFormatters/ValueObjectPrinter.h303
-rw-r--r--include/lldb/DataFormatters/VectorIterator.h56
-rw-r--r--include/lldb/DataFormatters/VectorType.h15
-rw-r--r--include/lldb/Expression/DWARFExpression.h850
-rw-r--r--include/lldb/Expression/DiagnosticManager.h288
-rw-r--r--include/lldb/Expression/Expression.h170
-rw-r--r--include/lldb/Expression/ExpressionParser.h211
-rw-r--r--include/lldb/Expression/ExpressionSourceCode.h99
-rw-r--r--include/lldb/Expression/ExpressionTypeSystemHelper.h48
-rw-r--r--include/lldb/Expression/ExpressionVariable.h487
-rw-r--r--include/lldb/Expression/FunctionCaller.h656
-rw-r--r--include/lldb/Expression/IRDynamicChecks.h232
-rw-r--r--include/lldb/Expression/IRExecutionUnit.h757
-rw-r--r--include/lldb/Expression/IRInterpreter.h45
-rw-r--r--include/lldb/Expression/IRMemoryMap.h196
-rw-r--r--include/lldb/Expression/LLVMUserExpression.h188
-rw-r--r--include/lldb/Expression/Materializer.h262
-rw-r--r--include/lldb/Expression/REPL.h325
-rw-r--r--include/lldb/Expression/UserExpression.h571
-rw-r--r--include/lldb/Expression/UtilityFunction.h235
-rw-r--r--include/lldb/Host/Condition.h123
-rw-r--r--include/lldb/Host/Config.h7
-rw-r--r--include/lldb/Host/Debug.h320
-rw-r--r--include/lldb/Host/Editline.h640
-rw-r--r--include/lldb/Host/Endian.h19
-rw-r--r--include/lldb/Host/File.h969
-rw-r--r--include/lldb/Host/FileCache.h33
-rw-r--r--include/lldb/Host/FileSpec.h1547
-rw-r--r--include/lldb/Host/FileSystem.h107
-rw-r--r--include/lldb/Host/Host.h474
-rw-r--r--include/lldb/Host/HostGetOpt.h2
-rw-r--r--include/lldb/Host/HostInfo.h5
-rw-r--r--include/lldb/Host/HostInfoBase.h207
-rw-r--r--include/lldb/Host/HostNativeProcess.h6
-rw-r--r--include/lldb/Host/HostNativeProcessBase.h44
-rw-r--r--include/lldb/Host/HostNativeThreadBase.h41
-rw-r--r--include/lldb/Host/HostNativeThreadForward.h3
-rw-r--r--include/lldb/Host/HostProcess.h33
-rw-r--r--include/lldb/Host/HostThread.h42
-rw-r--r--include/lldb/Host/IOObject.h49
-rw-r--r--include/lldb/Host/LockFile.h6
-rw-r--r--include/lldb/Host/LockFileBase.h60
-rw-r--r--include/lldb/Host/MainLoop.h6
-rw-r--r--include/lldb/Host/MainLoopBase.h93
-rw-r--r--include/lldb/Host/MonitoringProcessLauncher.h19
-rw-r--r--include/lldb/Host/Mutex.h313
-rw-r--r--include/lldb/Host/OptionParser.h56
-rw-r--r--include/lldb/Host/Pipe.h6
-rw-r--r--include/lldb/Host/PipeBase.h62
-rw-r--r--include/lldb/Host/PosixApi.h23
-rw-r--r--include/lldb/Host/Predicate.h857
-rw-r--r--include/lldb/Host/ProcessLauncher.h13
-rw-r--r--include/lldb/Host/ProcessRunLock.h107
-rw-r--r--include/lldb/Host/Socket.h149
-rw-r--r--include/lldb/Host/SocketAddress.h407
-rw-r--r--include/lldb/Host/StringConvert.h22
-rw-r--r--include/lldb/Host/Symbols.h76
-rw-r--r--include/lldb/Host/Terminal.h369
-rw-r--r--include/lldb/Host/ThisThread.h25
-rw-r--r--include/lldb/Host/ThreadLauncher.h49
-rw-r--r--include/lldb/Host/Time.h4
-rw-r--r--include/lldb/Host/TimeValue.h129
-rw-r--r--include/lldb/Host/XML.h350
-rw-r--r--include/lldb/Host/android/Android.h28
-rw-r--r--include/lldb/Host/android/HostInfoAndroid.h22
-rw-r--r--include/lldb/Host/common/GetOptInc.h53
-rw-r--r--include/lldb/Host/common/NativeBreakpoint.h62
-rw-r--r--include/lldb/Host/common/NativeBreakpointList.h45
-rw-r--r--include/lldb/Host/common/NativeProcessProtocol.h730
-rw-r--r--include/lldb/Host/common/NativeRegisterContext.h261
-rw-r--r--include/lldb/Host/common/NativeRegisterContextRegisterInfo.h53
-rw-r--r--include/lldb/Host/common/NativeThreadProtocol.h79
-rw-r--r--include/lldb/Host/common/NativeWatchpointList.h51
-rw-r--r--include/lldb/Host/common/SoftwareBreakpoint.h56
-rw-r--r--include/lldb/Host/common/TCPSocket.h57
-rw-r--r--include/lldb/Host/common/UDPSocket.h37
-rw-r--r--include/lldb/Host/freebsd/Config.h2
-rw-r--r--include/lldb/Host/freebsd/HostInfoFreeBSD.h18
-rw-r--r--include/lldb/Host/freebsd/HostThreadFreeBSD.h16
-rw-r--r--include/lldb/Host/linux/AbstractSocket.h18
-rw-r--r--include/lldb/Host/linux/Config.h2
-rw-r--r--include/lldb/Host/linux/HostInfoLinux.h53
-rw-r--r--include/lldb/Host/linux/HostThreadLinux.h18
-rw-r--r--include/lldb/Host/linux/Personality.h25
-rw-r--r--include/lldb/Host/linux/ProcessLauncherLinux.h (renamed from include/lldb/Host/android/ProcessLauncherAndroid.h)11
-rw-r--r--include/lldb/Host/linux/Ptrace.h26
-rw-r--r--include/lldb/Host/linux/Uio.h10
-rw-r--r--include/lldb/Host/macosx/Config.h2
-rw-r--r--include/lldb/Host/macosx/HostInfoMacOSX.h51
-rw-r--r--include/lldb/Host/macosx/HostThreadMacOSX.h18
-rw-r--r--include/lldb/Host/mingw/Config.h2
-rw-r--r--include/lldb/Host/msvc/Config.h8
-rw-r--r--include/lldb/Host/netbsd/HostInfoNetBSD.h18
-rw-r--r--include/lldb/Host/netbsd/HostThreadNetBSD.h18
-rw-r--r--include/lldb/Host/posix/ConnectionFileDescriptorPosix.h124
-rw-r--r--include/lldb/Host/posix/DomainSocket.h40
-rw-r--r--include/lldb/Host/posix/Fcntl.h2
-rw-r--r--include/lldb/Host/posix/HostInfoPosix.h40
-rw-r--r--include/lldb/Host/posix/HostProcessPosix.h32
-rw-r--r--include/lldb/Host/posix/HostThreadPosix.h22
-rw-r--r--include/lldb/Host/posix/LockFilePosix.h22
-rw-r--r--include/lldb/Host/posix/MainLoopPosix.h134
-rw-r--r--include/lldb/Host/posix/PipePosix.h100
-rw-r--r--include/lldb/Host/posix/ProcessLauncherPosix.h11
-rw-r--r--include/lldb/Host/windows/AutoHandle.h33
-rw-r--r--include/lldb/Host/windows/ConnectionGenericFileWindows.h58
-rw-r--r--include/lldb/Host/windows/HostInfoWindows.h74
-rw-r--r--include/lldb/Host/windows/HostProcessWindows.h34
-rw-r--r--include/lldb/Host/windows/HostThreadWindows.h30
-rw-r--r--include/lldb/Host/windows/LockFileWindows.h31
-rw-r--r--include/lldb/Host/windows/PipeWindows.h97
-rw-r--r--include/lldb/Host/windows/PosixApi.h107
-rw-r--r--include/lldb/Host/windows/ProcessLauncherWindows.h15
-rw-r--r--include/lldb/Host/windows/editlinewin.h175
-rw-r--r--include/lldb/Host/windows/win32.h107
-rw-r--r--include/lldb/Host/windows/windows.h4
-rw-r--r--include/lldb/Initialization/SystemInitializer.h16
-rw-r--r--include/lldb/Initialization/SystemInitializerCommon.h16
-rw-r--r--include/lldb/Initialization/SystemLifetimeManager.h32
-rw-r--r--include/lldb/Interpreter/Args.h854
-rw-r--r--include/lldb/Interpreter/CommandAlias.h159
-rw-r--r--include/lldb/Interpreter/CommandCompletions.h490
-rw-r--r--include/lldb/Interpreter/CommandHistory.h80
-rw-r--r--include/lldb/Interpreter/CommandInterpreter.h1130
-rw-r--r--include/lldb/Interpreter/CommandObject.h972
-rw-r--r--include/lldb/Interpreter/CommandObjectMultiword.h285
-rw-r--r--include/lldb/Interpreter/CommandObjectRegexCommand.h74
-rw-r--r--include/lldb/Interpreter/CommandOptionValidators.h10
-rw-r--r--include/lldb/Interpreter/CommandReturnObject.h286
-rw-r--r--include/lldb/Interpreter/OptionGroupArchitecture.h50
-rw-r--r--include/lldb/Interpreter/OptionGroupBoolean.h90
-rw-r--r--include/lldb/Interpreter/OptionGroupFile.h142
-rw-r--r--include/lldb/Interpreter/OptionGroupFormat.h149
-rw-r--r--include/lldb/Interpreter/OptionGroupOutputFile.h59
-rw-r--r--include/lldb/Interpreter/OptionGroupPlatform.h133
-rw-r--r--include/lldb/Interpreter/OptionGroupString.h87
-rw-r--r--include/lldb/Interpreter/OptionGroupUInt64.h87
-rw-r--r--include/lldb/Interpreter/OptionGroupUUID.h43
-rw-r--r--include/lldb/Interpreter/OptionGroupValueObjectDisplay.h85
-rw-r--r--include/lldb/Interpreter/OptionGroupVariable.h61
-rw-r--r--include/lldb/Interpreter/OptionGroupWatchpoint.h66
-rw-r--r--include/lldb/Interpreter/OptionValue.h737
-rw-r--r--include/lldb/Interpreter/OptionValueArch.h175
-rw-r--r--include/lldb/Interpreter/OptionValueArgs.h29
-rw-r--r--include/lldb/Interpreter/OptionValueArray.h238
-rw-r--r--include/lldb/Interpreter/OptionValueBoolean.h184
-rw-r--r--include/lldb/Interpreter/OptionValueChar.h137
-rw-r--r--include/lldb/Interpreter/OptionValueDictionary.h177
-rw-r--r--include/lldb/Interpreter/OptionValueEnumeration.h154
-rw-r--r--include/lldb/Interpreter/OptionValueFileSpec.h180
-rw-r--r--include/lldb/Interpreter/OptionValueFileSpecList.h120
-rw-r--r--include/lldb/Interpreter/OptionValueFormat.h127
-rw-r--r--include/lldb/Interpreter/OptionValueFormatEntity.h126
-rw-r--r--include/lldb/Interpreter/OptionValueLanguage.h132
-rw-r--r--include/lldb/Interpreter/OptionValuePathMappings.h109
-rw-r--r--include/lldb/Interpreter/OptionValueProperties.h442
-rw-r--r--include/lldb/Interpreter/OptionValueRegex.h110
-rw-r--r--include/lldb/Interpreter/OptionValueSInt64.h215
-rw-r--r--include/lldb/Interpreter/OptionValueString.h285
-rw-r--r--include/lldb/Interpreter/OptionValueUInt64.h176
-rw-r--r--include/lldb/Interpreter/OptionValueUUID.h121
-rw-r--r--include/lldb/Interpreter/OptionValues.h4
-rw-r--r--include/lldb/Interpreter/Options.h701
-rw-r--r--include/lldb/Interpreter/Property.h139
-rw-r--r--include/lldb/Interpreter/ScriptInterpreter.h912
-rw-r--r--include/lldb/Symbol/ArmUnwindInfo.h54
-rw-r--r--include/lldb/Symbol/Block.h827
-rw-r--r--include/lldb/Symbol/ClangASTContext.h2061
-rw-r--r--include/lldb/Symbol/ClangASTImporter.h664
-rw-r--r--include/lldb/Symbol/ClangExternalASTSourceCallbacks.h234
-rw-r--r--include/lldb/Symbol/ClangExternalASTSourceCommon.h217
-rw-r--r--include/lldb/Symbol/ClangUtil.h18
-rw-r--r--include/lldb/Symbol/CompactUnwindInfo.h257
-rw-r--r--include/lldb/Symbol/CompileUnit.h862
-rw-r--r--include/lldb/Symbol/CompilerDecl.h173
-rw-r--r--include/lldb/Symbol/CompilerDeclContext.h210
-rw-r--r--include/lldb/Symbol/CompilerType.h932
-rw-r--r--include/lldb/Symbol/DWARFCallFrameInfo.h243
-rw-r--r--include/lldb/Symbol/DebugMacros.h134
-rw-r--r--include/lldb/Symbol/DeclVendor.h81
-rw-r--r--include/lldb/Symbol/Declaration.h416
-rw-r--r--include/lldb/Symbol/FuncUnwinders.h231
-rw-r--r--include/lldb/Symbol/Function.h1189
-rw-r--r--include/lldb/Symbol/GoASTContext.h575
-rw-r--r--include/lldb/Symbol/JavaASTContext.h477
-rw-r--r--include/lldb/Symbol/LineEntry.h337
-rw-r--r--include/lldb/Symbol/LineTable.h693
-rw-r--r--include/lldb/Symbol/OCamlASTContext.h324
-rw-r--r--include/lldb/Symbol/ObjectContainer.h347
-rw-r--r--include/lldb/Symbol/ObjectFile.h1632
-rw-r--r--include/lldb/Symbol/Symbol.h569
-rw-r--r--include/lldb/Symbol/SymbolContext.h1045
-rw-r--r--include/lldb/Symbol/SymbolContextScope.h103
-rw-r--r--include/lldb/Symbol/SymbolFile.h341
-rw-r--r--include/lldb/Symbol/SymbolVendor.h323
-rw-r--r--include/lldb/Symbol/Symtab.h313
-rw-r--r--include/lldb/Symbol/TaggedASTType.h57
-rw-r--r--include/lldb/Symbol/Type.h1522
-rw-r--r--include/lldb/Symbol/TypeList.h86
-rw-r--r--include/lldb/Symbol/TypeMap.h91
-rw-r--r--include/lldb/Symbol/TypeSystem.h1079
-rw-r--r--include/lldb/Symbol/UnwindPlan.h1044
-rw-r--r--include/lldb/Symbol/UnwindTable.h82
-rw-r--r--include/lldb/Symbol/Variable.h287
-rw-r--r--include/lldb/Symbol/VariableList.h135
-rw-r--r--include/lldb/Symbol/VerifyDecl.h5
-rw-r--r--include/lldb/Target/ABI.h236
-rw-r--r--include/lldb/Target/CPPLanguageRuntime.h51
-rw-r--r--include/lldb/Target/DynamicLoader.h527
-rw-r--r--include/lldb/Target/ExecutionContext.h1297
-rw-r--r--include/lldb/Target/ExecutionContextScope.h48
-rw-r--r--include/lldb/Target/FileAction.h71
-rw-r--r--include/lldb/Target/InstrumentationRuntime.h99
-rw-r--r--include/lldb/Target/InstrumentationRuntimeStopInfo.h46
-rw-r--r--include/lldb/Target/JITLoader.h94
-rw-r--r--include/lldb/Target/JITLoaderList.h33
-rw-r--r--include/lldb/Target/Language.h409
-rw-r--r--include/lldb/Target/LanguageRuntime.h292
-rw-r--r--include/lldb/Target/Memory.h309
-rw-r--r--include/lldb/Target/MemoryHistory.h26
-rw-r--r--include/lldb/Target/MemoryRegionInfo.h232
-rw-r--r--include/lldb/Target/ObjCLanguageRuntime.h796
-rw-r--r--include/lldb/Target/OperatingSystem.h120
-rw-r--r--include/lldb/Target/PathMappingList.h252
-rw-r--r--include/lldb/Target/Platform.h2443
-rw-r--r--include/lldb/Target/Process.h6328
-rw-r--r--include/lldb/Target/ProcessInfo.h251
-rw-r--r--include/lldb/Target/ProcessLaunchInfo.h356
-rw-r--r--include/lldb/Target/Queue.h305
-rw-r--r--include/lldb/Target/QueueItem.h324
-rw-r--r--include/lldb/Target/QueueList.h196
-rw-r--r--include/lldb/Target/RegisterCheckpoint.h88
-rw-r--r--include/lldb/Target/RegisterContext.h438
-rw-r--r--include/lldb/Target/SectionLoadHistory.h130
-rw-r--r--include/lldb/Target/SectionLoadList.h85
-rw-r--r--include/lldb/Target/StackFrame.h998
-rw-r--r--include/lldb/Target/StackFrameList.h203
-rw-r--r--include/lldb/Target/StackID.h176
-rw-r--r--include/lldb/Target/StopInfo.h394
-rw-r--r--include/lldb/Target/StructuredDataPlugin.h188
-rw-r--r--include/lldb/Target/SystemRuntime.h593
-rw-r--r--include/lldb/Target/Target.h2711
-rw-r--r--include/lldb/Target/TargetList.h429
-rw-r--r--include/lldb/Target/Thread.h2701
-rw-r--r--include/lldb/Target/ThreadCollection.h85
-rw-r--r--include/lldb/Target/ThreadList.h282
-rw-r--r--include/lldb/Target/ThreadPlan.h1029
-rw-r--r--include/lldb/Target/ThreadPlanBase.h53
-rw-r--r--include/lldb/Target/ThreadPlanCallFunction.h292
-rw-r--r--include/lldb/Target/ThreadPlanCallFunctionUsingABI.h34
-rw-r--r--include/lldb/Target/ThreadPlanCallOnFunctionExit.h56
-rw-r--r--include/lldb/Target/ThreadPlanCallUserExpression.h79
-rw-r--r--include/lldb/Target/ThreadPlanPython.h54
-rw-r--r--include/lldb/Target/ThreadPlanRunToAddress.h72
-rw-r--r--include/lldb/Target/ThreadPlanShouldStopHere.h216
-rw-r--r--include/lldb/Target/ThreadPlanStepInRange.h171
-rw-r--r--include/lldb/Target/ThreadPlanStepInstruction.h58
-rw-r--r--include/lldb/Target/ThreadPlanStepOut.h135
-rw-r--r--include/lldb/Target/ThreadPlanStepOverBreakpoint.h53
-rw-r--r--include/lldb/Target/ThreadPlanStepOverRange.h50
-rw-r--r--include/lldb/Target/ThreadPlanStepRange.h119
-rw-r--r--include/lldb/Target/ThreadPlanStepThrough.h70
-rw-r--r--include/lldb/Target/ThreadPlanStepUntil.h82
-rw-r--r--include/lldb/Target/ThreadPlanTracer.h152
-rw-r--r--include/lldb/Target/ThreadSpec.h217
-rw-r--r--include/lldb/Target/UnixSignals.h167
-rw-r--r--include/lldb/Target/Unwind.h129
-rw-r--r--include/lldb/Target/UnwindAssembly.h51
-rw-r--r--include/lldb/Utility/AnsiTerminal.h236
-rw-r--r--include/lldb/Utility/CleanUp.h446
-rw-r--r--include/lldb/Utility/ConvertEnum.h3
-rw-r--r--include/lldb/Utility/Either.h240
-rw-r--r--include/lldb/Utility/Iterable.h350
-rw-r--r--include/lldb/Utility/JSON.h589
-rw-r--r--include/lldb/Utility/LLDBAssert.h14
-rw-r--r--include/lldb/Utility/NameMatches.h8
-rw-r--r--include/lldb/Utility/PriorityPointerPair.h176
-rw-r--r--include/lldb/Utility/ProcessStructReader.h152
-rw-r--r--include/lldb/Utility/PseudoTerminal.h444
-rw-r--r--include/lldb/Utility/Range.h108
-rw-r--r--include/lldb/Utility/RegisterNumber.h53
-rw-r--r--include/lldb/Utility/SafeMachO.h170
-rw-r--r--include/lldb/Utility/SelectHelper.h76
-rw-r--r--include/lldb/Utility/SharedCluster.h133
-rw-r--r--include/lldb/Utility/SharingPtr.h1140
-rw-r--r--include/lldb/Utility/StringExtractor.h265
-rw-r--r--include/lldb/Utility/StringLexer.h89
-rw-r--r--include/lldb/Utility/TaskPool.h283
-rw-r--r--include/lldb/Utility/Timeout.h55
-rw-r--r--include/lldb/lldb-defines.h156
-rw-r--r--include/lldb/lldb-enumerations.h1954
-rw-r--r--include/lldb/lldb-forward.h885
-rw-r--r--include/lldb/lldb-private-defines.h11
-rw-r--r--include/lldb/lldb-private-enumerations.h286
-rw-r--r--include/lldb/lldb-private-forward.h42
-rw-r--r--include/lldb/lldb-private-interfaces.h134
-rw-r--r--include/lldb/lldb-private-types.h200
-rw-r--r--include/lldb/lldb-private.h21
-rw-r--r--include/lldb/lldb-public.h2
-rw-r--r--include/lldb/lldb-types.h130
-rw-r--r--include/lldb/lldb-versioning.h226
493 files changed, 69583 insertions, 84003 deletions
diff --git a/include/lldb/API/LLDB.h b/include/lldb/API/LLDB.h
index b6278160dbc0..d8604cd07114 100644
--- a/include/lldb/API/LLDB.h
+++ b/include/lldb/API/LLDB.h
@@ -14,7 +14,6 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/API/SBDefines.h"
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBAttachInfo.h"
#include "lldb/API/SBBlock.h"
@@ -28,6 +27,7 @@
#include "lldb/API/SBData.h"
#include "lldb/API/SBDebugger.h"
#include "lldb/API/SBDeclaration.h"
+#include "lldb/API/SBDefines.h"
#include "lldb/API/SBError.h"
#include "lldb/API/SBEvent.h"
#include "lldb/API/SBExecutionContext.h"
@@ -55,6 +55,7 @@
#include "lldb/API/SBSourceManager.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBStringList.h"
+#include "lldb/API/SBStructuredData.h"
#include "lldb/API/SBSymbol.h"
#include "lldb/API/SBSymbolContext.h"
#include "lldb/API/SBSymbolContextList.h"
@@ -76,4 +77,4 @@
#include "lldb/API/SBVariablesOptions.h"
#include "lldb/API/SBWatchpoint.h"
-#endif // LLDB_LLDB_h_
+#endif // LLDB_LLDB_h_
diff --git a/include/lldb/API/SBAddress.h b/include/lldb/API/SBAddress.h
index 4cbbee9fd132..ddbe5a742786 100644
--- a/include/lldb/API/SBAddress.h
+++ b/include/lldb/API/SBAddress.h
@@ -15,138 +15,108 @@
namespace lldb {
-class LLDB_API SBAddress
-{
+class LLDB_API SBAddress {
public:
+ SBAddress();
- SBAddress ();
+ SBAddress(const lldb::SBAddress &rhs);
- SBAddress (const lldb::SBAddress &rhs);
+ SBAddress(lldb::SBSection section, lldb::addr_t offset);
- SBAddress (lldb::SBSection section, lldb::addr_t offset);
+ // Create an address by resolving a load address using the supplied target
+ SBAddress(lldb::addr_t load_addr, lldb::SBTarget &target);
- // Create an address by resolving a load address using the supplied target
- SBAddress (lldb::addr_t load_addr, lldb::SBTarget &target);
+ ~SBAddress();
- ~SBAddress ();
+ const lldb::SBAddress &operator=(const lldb::SBAddress &rhs);
- const lldb::SBAddress &
- operator = (const lldb::SBAddress &rhs);
+ bool IsValid() const;
- bool
- IsValid () const;
+ void Clear();
- void
- Clear ();
+ addr_t GetFileAddress() const;
- addr_t
- GetFileAddress () const;
+ addr_t GetLoadAddress(const lldb::SBTarget &target) const;
- addr_t
- GetLoadAddress (const lldb::SBTarget &target) const;
+ void SetAddress(lldb::SBSection section, lldb::addr_t offset);
- void
- SetAddress (lldb::SBSection section, lldb::addr_t offset);
+ void SetLoadAddress(lldb::addr_t load_addr, lldb::SBTarget &target);
+ bool OffsetAddress(addr_t offset);
- void
- SetLoadAddress (lldb::addr_t load_addr,
- lldb::SBTarget &target);
- bool
- OffsetAddress (addr_t offset);
+ bool GetDescription(lldb::SBStream &description);
- bool
- GetDescription (lldb::SBStream &description);
+ // The following queries can lookup symbol information for a given address.
+ // An address might refer to code or data from an existing module, or it
+ // might refer to something on the stack or heap. The following functions
+ // will only return valid values if the address has been resolved to a code
+ // or data address using "void SBAddress::SetLoadAddress(...)" or
+ // "lldb::SBAddress SBTarget::ResolveLoadAddress (...)".
+ lldb::SBSymbolContext GetSymbolContext(uint32_t resolve_scope);
- // The following queries can lookup symbol information for a given address.
- // An address might refer to code or data from an existing module, or it
- // might refer to something on the stack or heap. The following functions
- // will only return valid values if the address has been resolved to a code
- // or data address using "void SBAddress::SetLoadAddress(...)" or
- // "lldb::SBAddress SBTarget::ResolveLoadAddress (...)".
- lldb::SBSymbolContext
- GetSymbolContext (uint32_t resolve_scope);
+ // The following functions grab individual objects for a given address and
+ // are less efficient if you want more than one symbol related objects.
+ // Use one of the following when you want multiple debug symbol related
+ // objects for an address:
+ // lldb::SBSymbolContext SBAddress::GetSymbolContext (uint32_t
+ // resolve_scope);
+ // lldb::SBSymbolContext SBTarget::ResolveSymbolContextForAddress (const
+ // SBAddress &addr, uint32_t resolve_scope);
+ // One or more bits from the SymbolContextItem enumerations can be logically
+ // OR'ed together to more efficiently retrieve multiple symbol objects.
-
- // The following functions grab individual objects for a given address and
- // are less efficient if you want more than one symbol related objects.
- // Use one of the following when you want multiple debug symbol related
- // objects for an address:
- // lldb::SBSymbolContext SBAddress::GetSymbolContext (uint32_t resolve_scope);
- // lldb::SBSymbolContext SBTarget::ResolveSymbolContextForAddress (const SBAddress &addr, uint32_t resolve_scope);
- // One or more bits from the SymbolContextItem enumerations can be logically
- // OR'ed together to more efficiently retrieve multiple symbol objects.
+ lldb::SBSection GetSection();
- lldb::SBSection
- GetSection ();
+ lldb::addr_t GetOffset();
- lldb::addr_t
- GetOffset ();
+ lldb::SBModule GetModule();
- lldb::SBModule
- GetModule ();
-
- lldb::SBCompileUnit
- GetCompileUnit ();
+ lldb::SBCompileUnit GetCompileUnit();
- lldb::SBFunction
- GetFunction ();
+ lldb::SBFunction GetFunction();
- lldb::SBBlock
- GetBlock ();
+ lldb::SBBlock GetBlock();
- lldb::SBSymbol
- GetSymbol ();
+ lldb::SBSymbol GetSymbol();
- lldb::SBLineEntry
- GetLineEntry ();
-
- lldb::AddressClass
- GetAddressClass ();
+ lldb::SBLineEntry GetLineEntry();
-protected:
+ lldb::AddressClass GetAddressClass();
- friend class SBBlock;
- friend class SBBreakpointLocation;
- friend class SBFrame;
- friend class SBFunction;
- friend class SBLineEntry;
- friend class SBInstruction;
- friend class SBModule;
- friend class SBSection;
- friend class SBSymbol;
- friend class SBSymbolContext;
- friend class SBTarget;
- friend class SBThread;
- friend class SBThreadPlan;
- friend class SBValue;
- friend class SBQueueItem;
+protected:
+ friend class SBBlock;
+ friend class SBBreakpointLocation;
+ friend class SBFrame;
+ friend class SBFunction;
+ friend class SBLineEntry;
+ friend class SBInstruction;
+ friend class SBModule;
+ friend class SBSection;
+ friend class SBSymbol;
+ friend class SBSymbolContext;
+ friend class SBTarget;
+ friend class SBThread;
+ friend class SBThreadPlan;
+ friend class SBValue;
+ friend class SBQueueItem;
- lldb_private::Address *
- operator->();
+ lldb_private::Address *operator->();
- const lldb_private::Address *
- operator->() const;
+ const lldb_private::Address *operator->() const;
- lldb_private::Address *
- get ();
+ lldb_private::Address *get();
- lldb_private::Address &
- ref();
+ lldb_private::Address &ref();
- const lldb_private::Address &
- ref() const;
+ const lldb_private::Address &ref() const;
- SBAddress (const lldb_private::Address *lldb_object_ptr);
+ SBAddress(const lldb_private::Address *lldb_object_ptr);
- void
- SetAddress (const lldb_private::Address *lldb_object_ptr);
+ void SetAddress(const lldb_private::Address *lldb_object_ptr);
private:
-
- std::unique_ptr<lldb_private::Address> m_opaque_ap;
+ std::unique_ptr<lldb_private::Address> m_opaque_ap;
};
-
} // namespace lldb
#endif // LLDB_SBAddress_h_
diff --git a/include/lldb/API/SBAttachInfo.h b/include/lldb/API/SBAttachInfo.h
index a246d9919cfa..6c3561615990 100644
--- a/include/lldb/API/SBAttachInfo.h
+++ b/include/lldb/API/SBAttachInfo.h
@@ -16,209 +16,175 @@ namespace lldb {
class SBTarget;
-class LLDB_API SBAttachInfo
-{
+class LLDB_API SBAttachInfo {
public:
- SBAttachInfo ();
-
- SBAttachInfo (lldb::pid_t pid);
-
- //------------------------------------------------------------------
- /// Attach to a process by name.
- ///
- /// This function implies that a future call to SBTarget::Attach(...)
- /// will be synchronous.
- ///
- /// @param[in] path
- /// A full or partial name for the process to attach to.
- ///
- /// @param[in] wait_for
- /// If \b false, attach to an existing process whose name matches.
- /// If \b true, then wait for the next process whose name matches.
- //------------------------------------------------------------------
- SBAttachInfo (const char *path, bool wait_for);
-
- //------------------------------------------------------------------
- /// Attach to a process by name.
- ///
- /// Future calls to SBTarget::Attach(...) will be synchronous or
- /// asynchronous depending on the \a async argument.
- ///
- /// @param[in] path
- /// A full or partial name for the process to attach to.
- ///
- /// @param[in] wait_for
- /// If \b false, attach to an existing process whose name matches.
- /// If \b true, then wait for the next process whose name matches.
- ///
- /// @param[in] async
- /// If \b false, then the SBTarget::Attach(...) call will be a
- /// synchronous call with no way to cancel the attach in
- /// progress.
- /// If \b true, then the SBTarget::Attach(...) function will
- /// return immediately and clients are expected to wait for a
- /// process eStateStopped event if a suitable process is
- /// eventually found. If the client wants to cancel the event,
- /// SBProcess::Stop() can be called and an eStateExited process
- /// event will be delivered.
- //------------------------------------------------------------------
- SBAttachInfo (const char *path, bool wait_for, bool async);
-
- SBAttachInfo (const SBAttachInfo &rhs);
-
- ~SBAttachInfo();
-
- SBAttachInfo &
- operator = (const SBAttachInfo &rhs);
-
- lldb::pid_t
- GetProcessID ();
-
- void
- SetProcessID (lldb::pid_t pid);
-
- void
- SetExecutable (const char *path);
-
- void
- SetExecutable (lldb::SBFileSpec exe_file);
-
- bool
- GetWaitForLaunch ();
-
- //------------------------------------------------------------------
- /// Set attach by process name settings.
- ///
- /// Designed to be used after a call to SBAttachInfo::SetExecutable().
- /// This function implies that a call to SBTarget::Attach(...) will
- /// be synchronous.
- ///
- /// @param[in] wait_for
- /// If \b false, attach to an existing process whose name matches.
- /// If \b true, then wait for the next process whose name matches.
- //------------------------------------------------------------------
- void
- SetWaitForLaunch (bool b);
-
- //------------------------------------------------------------------
- /// Set attach by process name settings.
- ///
- /// Designed to be used after a call to SBAttachInfo::SetExecutable().
- /// Future calls to SBTarget::Attach(...) will be synchronous or
- /// asynchronous depending on the \a async argument.
- ///
- /// @param[in] wait_for
- /// If \b false, attach to an existing process whose name matches.
- /// If \b true, then wait for the next process whose name matches.
- ///
- /// @param[in] async
- /// If \b false, then the SBTarget::Attach(...) call will be a
- /// synchronous call with no way to cancel the attach in
- /// progress.
- /// If \b true, then the SBTarget::Attach(...) function will
- /// return immediately and clients are expected to wait for a
- /// process eStateStopped event if a suitable process is
- /// eventually found. If the client wants to cancel the event,
- /// SBProcess::Stop() can be called and an eStateExited process
- /// event will be delivered.
- //------------------------------------------------------------------
- void
- SetWaitForLaunch (bool b, bool async);
-
- bool
- GetIgnoreExisting ();
-
- void
- SetIgnoreExisting (bool b);
-
- uint32_t
- GetResumeCount ();
-
- void
- SetResumeCount (uint32_t c);
-
- const char *
- GetProcessPluginName ();
-
- void
- SetProcessPluginName (const char *plugin_name);
-
- uint32_t
- GetUserID();
-
- uint32_t
- GetGroupID();
-
- bool
- UserIDIsValid ();
-
- bool
- GroupIDIsValid ();
-
- void
- SetUserID (uint32_t uid);
-
- void
- SetGroupID (uint32_t gid);
-
- uint32_t
- GetEffectiveUserID();
-
- uint32_t
- GetEffectiveGroupID();
-
- bool
- EffectiveUserIDIsValid ();
-
- bool
- EffectiveGroupIDIsValid ();
-
- void
- SetEffectiveUserID (uint32_t uid);
-
- void
- SetEffectiveGroupID (uint32_t gid);
-
- lldb::pid_t
- GetParentProcessID ();
-
- void
- SetParentProcessID (lldb::pid_t pid);
-
- bool
- ParentProcessIDIsValid();
-
- //----------------------------------------------------------------------
- /// Get the listener that will be used to receive process events.
- ///
- /// If no listener has been set via a call to
- /// SBLaunchInfo::SetListener(), then an invalid SBListener will be
- /// returned (SBListener::IsValid() will return false). If a listener
- /// has been set, then the valid listener object will be returned.
- //----------------------------------------------------------------------
- SBListener
- GetListener ();
-
- //----------------------------------------------------------------------
- /// Set the listener that will be used to receive process events.
- ///
- /// By default the SBDebugger, which has a listener, that the SBTarget
- /// belongs to will listen for the process events. Calling this function
- /// allows a different listener to be used to listen for process events.
- //----------------------------------------------------------------------
- void
- SetListener (SBListener &listener);
+ SBAttachInfo();
+
+ SBAttachInfo(lldb::pid_t pid);
+
+ //------------------------------------------------------------------
+ /// Attach to a process by name.
+ ///
+ /// This function implies that a future call to SBTarget::Attach(...)
+ /// will be synchronous.
+ ///
+ /// @param[in] path
+ /// A full or partial name for the process to attach to.
+ ///
+ /// @param[in] wait_for
+ /// If \b false, attach to an existing process whose name matches.
+ /// If \b true, then wait for the next process whose name matches.
+ //------------------------------------------------------------------
+ SBAttachInfo(const char *path, bool wait_for);
+
+ //------------------------------------------------------------------
+ /// Attach to a process by name.
+ ///
+ /// Future calls to SBTarget::Attach(...) will be synchronous or
+ /// asynchronous depending on the \a async argument.
+ ///
+ /// @param[in] path
+ /// A full or partial name for the process to attach to.
+ ///
+ /// @param[in] wait_for
+ /// If \b false, attach to an existing process whose name matches.
+ /// If \b true, then wait for the next process whose name matches.
+ ///
+ /// @param[in] async
+ /// If \b false, then the SBTarget::Attach(...) call will be a
+ /// synchronous call with no way to cancel the attach in
+ /// progress.
+ /// If \b true, then the SBTarget::Attach(...) function will
+ /// return immediately and clients are expected to wait for a
+ /// process eStateStopped event if a suitable process is
+ /// eventually found. If the client wants to cancel the event,
+ /// SBProcess::Stop() can be called and an eStateExited process
+ /// event will be delivered.
+ //------------------------------------------------------------------
+ SBAttachInfo(const char *path, bool wait_for, bool async);
+
+ SBAttachInfo(const SBAttachInfo &rhs);
+
+ ~SBAttachInfo();
+
+ SBAttachInfo &operator=(const SBAttachInfo &rhs);
+
+ lldb::pid_t GetProcessID();
+
+ void SetProcessID(lldb::pid_t pid);
+
+ void SetExecutable(const char *path);
+
+ void SetExecutable(lldb::SBFileSpec exe_file);
+
+ bool GetWaitForLaunch();
+
+ //------------------------------------------------------------------
+ /// Set attach by process name settings.
+ ///
+ /// Designed to be used after a call to SBAttachInfo::SetExecutable().
+ /// This function implies that a call to SBTarget::Attach(...) will
+ /// be synchronous.
+ ///
+ /// @param[in] wait_for
+ /// If \b false, attach to an existing process whose name matches.
+ /// If \b true, then wait for the next process whose name matches.
+ //------------------------------------------------------------------
+ void SetWaitForLaunch(bool b);
+
+ //------------------------------------------------------------------
+ /// Set attach by process name settings.
+ ///
+ /// Designed to be used after a call to SBAttachInfo::SetExecutable().
+ /// Future calls to SBTarget::Attach(...) will be synchronous or
+ /// asynchronous depending on the \a async argument.
+ ///
+ /// @param[in] wait_for
+ /// If \b false, attach to an existing process whose name matches.
+ /// If \b true, then wait for the next process whose name matches.
+ ///
+ /// @param[in] async
+ /// If \b false, then the SBTarget::Attach(...) call will be a
+ /// synchronous call with no way to cancel the attach in
+ /// progress.
+ /// If \b true, then the SBTarget::Attach(...) function will
+ /// return immediately and clients are expected to wait for a
+ /// process eStateStopped event if a suitable process is
+ /// eventually found. If the client wants to cancel the event,
+ /// SBProcess::Stop() can be called and an eStateExited process
+ /// event will be delivered.
+ //------------------------------------------------------------------
+ void SetWaitForLaunch(bool b, bool async);
+
+ bool GetIgnoreExisting();
+
+ void SetIgnoreExisting(bool b);
+
+ uint32_t GetResumeCount();
+
+ void SetResumeCount(uint32_t c);
+
+ const char *GetProcessPluginName();
+
+ void SetProcessPluginName(const char *plugin_name);
+
+ uint32_t GetUserID();
+
+ uint32_t GetGroupID();
+
+ bool UserIDIsValid();
+
+ bool GroupIDIsValid();
+ void SetUserID(uint32_t uid);
+
+ void SetGroupID(uint32_t gid);
+
+ uint32_t GetEffectiveUserID();
+
+ uint32_t GetEffectiveGroupID();
+
+ bool EffectiveUserIDIsValid();
+
+ bool EffectiveGroupIDIsValid();
+
+ void SetEffectiveUserID(uint32_t uid);
+
+ void SetEffectiveGroupID(uint32_t gid);
+
+ lldb::pid_t GetParentProcessID();
+
+ void SetParentProcessID(lldb::pid_t pid);
+
+ bool ParentProcessIDIsValid();
+
+ //----------------------------------------------------------------------
+ /// Get the listener that will be used to receive process events.
+ ///
+ /// If no listener has been set via a call to
+ /// SBLaunchInfo::SetListener(), then an invalid SBListener will be
+ /// returned (SBListener::IsValid() will return false). If a listener
+ /// has been set, then the valid listener object will be returned.
+ //----------------------------------------------------------------------
+ SBListener GetListener();
+
+ //----------------------------------------------------------------------
+ /// Set the listener that will be used to receive process events.
+ ///
+ /// By default the SBDebugger, which has a listener, that the SBTarget
+ /// belongs to will listen for the process events. Calling this function
+ /// allows a different listener to be used to listen for process events.
+ //----------------------------------------------------------------------
+ void SetListener(SBListener &listener);
protected:
- friend class SBTarget;
+ friend class SBTarget;
- lldb_private::ProcessAttachInfo &
- ref ();
+ lldb_private::ProcessAttachInfo &ref();
- ProcessAttachInfoSP m_opaque_sp;
+ ProcessAttachInfoSP m_opaque_sp;
};
} // namespace lldb
-#endif // LLDB_SBAttachInfo_h_
+#endif // LLDB_SBAttachInfo_h_
diff --git a/include/lldb/API/SBBlock.h b/include/lldb/API/SBBlock.h
index a18eab02088b..112de9673423 100644
--- a/include/lldb/API/SBBlock.h
+++ b/include/lldb/API/SBBlock.h
@@ -17,107 +17,80 @@
namespace lldb {
-class LLDB_API SBBlock
-{
+class LLDB_API SBBlock {
public:
+ SBBlock();
- SBBlock ();
-
- SBBlock (const lldb::SBBlock &rhs);
-
- ~SBBlock ();
-
- const lldb::SBBlock &
- operator = (const lldb::SBBlock &rhs);
-
- bool
- IsInlined () const;
-
- bool
- IsValid () const;
-
- const char *
- GetInlinedName () const;
-
- lldb::SBFileSpec
- GetInlinedCallSiteFile () const;
-
- uint32_t
- GetInlinedCallSiteLine () const;
-
- uint32_t
- GetInlinedCallSiteColumn () const;
-
- lldb::SBBlock
- GetParent ();
-
- lldb::SBBlock
- GetSibling ();
-
- lldb::SBBlock
- GetFirstChild ();
-
- uint32_t
- GetNumRanges ();
-
- lldb::SBAddress
- GetRangeStartAddress (uint32_t idx);
-
- lldb::SBAddress
- GetRangeEndAddress (uint32_t idx);
-
- uint32_t
- GetRangeIndexForBlockAddress (lldb::SBAddress block_addr);
-
- lldb::SBValueList
- GetVariables (lldb::SBFrame& frame,
- bool arguments,
- bool locals,
- bool statics,
- lldb::DynamicValueType use_dynamic);
-
- lldb::SBValueList
- GetVariables (lldb::SBTarget& target,
- bool arguments,
- bool locals,
- bool statics);
- //------------------------------------------------------------------
- /// Get the inlined block that contains this block.
- ///
- /// @return
- /// If this block is inlined, it will return this block, else
- /// parent blocks will be searched to see if any contain this
- /// block and are themselves inlined. An invalid SBBlock will
- /// be returned if this block nor any parent blocks are inlined
- /// function blocks.
- //------------------------------------------------------------------
- lldb::SBBlock
- GetContainingInlinedBlock ();
-
- bool
- GetDescription (lldb::SBStream &description);
+ SBBlock(const lldb::SBBlock &rhs);
+
+ ~SBBlock();
+
+ const lldb::SBBlock &operator=(const lldb::SBBlock &rhs);
+
+ bool IsInlined() const;
+
+ bool IsValid() const;
+
+ const char *GetInlinedName() const;
+
+ lldb::SBFileSpec GetInlinedCallSiteFile() const;
+
+ uint32_t GetInlinedCallSiteLine() const;
+
+ uint32_t GetInlinedCallSiteColumn() const;
+
+ lldb::SBBlock GetParent();
+
+ lldb::SBBlock GetSibling();
+
+ lldb::SBBlock GetFirstChild();
+
+ uint32_t GetNumRanges();
+
+ lldb::SBAddress GetRangeStartAddress(uint32_t idx);
+
+ lldb::SBAddress GetRangeEndAddress(uint32_t idx);
+
+ uint32_t GetRangeIndexForBlockAddress(lldb::SBAddress block_addr);
+
+ lldb::SBValueList GetVariables(lldb::SBFrame &frame, bool arguments,
+ bool locals, bool statics,
+ lldb::DynamicValueType use_dynamic);
+
+ lldb::SBValueList GetVariables(lldb::SBTarget &target, bool arguments,
+ bool locals, bool statics);
+ //------------------------------------------------------------------
+ /// Get the inlined block that contains this block.
+ ///
+ /// @return
+ /// If this block is inlined, it will return this block, else
+ /// parent blocks will be searched to see if any contain this
+ /// block and are themselves inlined. An invalid SBBlock will
+ /// be returned if this block nor any parent blocks are inlined
+ /// function blocks.
+ //------------------------------------------------------------------
+ lldb::SBBlock GetContainingInlinedBlock();
+
+ bool GetDescription(lldb::SBStream &description);
private:
- friend class SBAddress;
- friend class SBFrame;
- friend class SBFunction;
- friend class SBSymbolContext;
+ friend class SBAddress;
+ friend class SBFrame;
+ friend class SBFunction;
+ friend class SBSymbolContext;
- lldb_private::Block *
- GetPtr ();
+ lldb_private::Block *GetPtr();
- void
- SetPtr (lldb_private::Block *lldb_object_ptr);
+ void SetPtr(lldb_private::Block *lldb_object_ptr);
- SBBlock (lldb_private::Block *lldb_object_ptr);
+ SBBlock(lldb_private::Block *lldb_object_ptr);
- void
- AppendVariables (bool can_create, bool get_parent_variables, lldb_private::VariableList *var_list);
+ void AppendVariables(bool can_create, bool get_parent_variables,
+ lldb_private::VariableList *var_list);
- lldb_private::Block *m_opaque_ptr;
+ lldb_private::Block *m_opaque_ptr;
};
-
} // namespace lldb
#endif // LLDB_SBBlock_h_
diff --git a/include/lldb/API/SBBreakpoint.h b/include/lldb/API/SBBreakpoint.h
index c244ab8a9b48..56509c903c2d 100644
--- a/include/lldb/API/SBBreakpoint.h
+++ b/include/lldb/API/SBBreakpoint.h
@@ -12,182 +12,171 @@
#include "lldb/API/SBDefines.h"
+class SBBreakpointListImpl;
+
namespace lldb {
-class LLDB_API SBBreakpoint
-{
+class LLDB_API SBBreakpoint {
public:
+ typedef bool (*BreakpointHitCallback)(void *baton, SBProcess &process,
+ SBThread &thread,
+ lldb::SBBreakpointLocation &location);
+
+ SBBreakpoint();
+
+ SBBreakpoint(const lldb::SBBreakpoint &rhs);
+
+ ~SBBreakpoint();
+
+ const lldb::SBBreakpoint &operator=(const lldb::SBBreakpoint &rhs);
+
+ // Tests to see if the opaque breakpoint object in this object matches the
+ // opaque breakpoint object in "rhs".
+ bool operator==(const lldb::SBBreakpoint &rhs);
+
+ bool operator!=(const lldb::SBBreakpoint &rhs);
+
+ break_id_t GetID() const;
+
+ bool IsValid() const;
+
+ void ClearAllBreakpointSites();
+
+ lldb::SBBreakpointLocation FindLocationByAddress(lldb::addr_t vm_addr);
+
+ lldb::break_id_t FindLocationIDByAddress(lldb::addr_t vm_addr);
+
+ lldb::SBBreakpointLocation FindLocationByID(lldb::break_id_t bp_loc_id);
+
+ lldb::SBBreakpointLocation GetLocationAtIndex(uint32_t index);
+
+ void SetEnabled(bool enable);
+
+ bool IsEnabled();
+
+ void SetOneShot(bool one_shot);
+
+ bool IsOneShot() const;
+
+ bool IsInternal();
+
+ uint32_t GetHitCount() const;
+
+ void SetIgnoreCount(uint32_t count);
+
+ uint32_t GetIgnoreCount() const;
+
+ void SetCondition(const char *condition);
+
+ const char *GetCondition();
+
+ void SetThreadID(lldb::tid_t sb_thread_id);
+
+ lldb::tid_t GetThreadID();
+
+ void SetThreadIndex(uint32_t index);
+
+ uint32_t GetThreadIndex() const;
+
+ void SetThreadName(const char *thread_name);
+
+ const char *GetThreadName() const;
+
+ void SetQueueName(const char *queue_name);
+
+ const char *GetQueueName() const;
- typedef bool (*BreakpointHitCallback) (void *baton,
- SBProcess &process,
- SBThread &thread,
- lldb::SBBreakpointLocation &location);
-
- SBBreakpoint ();
-
- SBBreakpoint (const lldb::SBBreakpoint& rhs);
-
- ~SBBreakpoint();
-
- const lldb::SBBreakpoint &
- operator = (const lldb::SBBreakpoint& rhs);
-
- // Tests to see if the opaque breakpoint object in this object matches the
- // opaque breakpoint object in "rhs".
- bool
- operator == (const lldb::SBBreakpoint& rhs);
-
- bool
- operator != (const lldb::SBBreakpoint& rhs);
-
- break_id_t
- GetID () const;
-
- bool
- IsValid() const;
-
- void
- ClearAllBreakpointSites ();
-
- lldb::SBBreakpointLocation
- FindLocationByAddress (lldb::addr_t vm_addr);
-
- lldb::break_id_t
- FindLocationIDByAddress (lldb::addr_t vm_addr);
-
- lldb::SBBreakpointLocation
- FindLocationByID (lldb::break_id_t bp_loc_id);
-
- lldb::SBBreakpointLocation
- GetLocationAtIndex (uint32_t index);
-
- void
- SetEnabled (bool enable);
-
- bool
- IsEnabled ();
-
- void
- SetOneShot (bool one_shot);
-
- bool
- IsOneShot () const;
-
- bool
- IsInternal ();
-
- uint32_t
- GetHitCount () const;
-
- void
- SetIgnoreCount (uint32_t count);
-
- uint32_t
- GetIgnoreCount () const;
-
- void
- SetCondition (const char *condition);
-
- const char *
- GetCondition ();
-
- void
- SetThreadID (lldb::tid_t sb_thread_id);
-
- lldb::tid_t
- GetThreadID ();
-
- void
- SetThreadIndex (uint32_t index);
-
- uint32_t
- GetThreadIndex() const;
-
- void
- SetThreadName (const char *thread_name);
-
- const char *
- GetThreadName () const;
-
- void
- SetQueueName (const char *queue_name);
-
- const char *
- GetQueueName () const;
-
- void
- SetCallback (BreakpointHitCallback callback, void *baton);
-
- void
- SetScriptCallbackFunction (const char *callback_function_name);
-
- SBError
- SetScriptCallbackBody (const char *script_body_text);
-
- bool
- AddName (const char *new_name);
-
- void
- RemoveName (const char *name_to_remove);
-
- bool
- MatchesName (const char *name);
-
- void
- GetNames (SBStringList &names);
-
- size_t
- GetNumResolvedLocations() const;
-
- size_t
- GetNumLocations() const;
-
- bool
- GetDescription (lldb::SBStream &description);
-
- static bool
- EventIsBreakpointEvent (const lldb::SBEvent &event);
-
- static lldb::BreakpointEventType
- GetBreakpointEventTypeFromEvent (const lldb::SBEvent& event);
-
- static lldb::SBBreakpoint
- GetBreakpointFromEvent (const lldb::SBEvent& event);
-
- static lldb::SBBreakpointLocation
- GetBreakpointLocationAtIndexFromEvent (const lldb::SBEvent& event, uint32_t loc_idx);
-
- static uint32_t
- GetNumBreakpointLocationsFromEvent (const lldb::SBEvent &event_sp);
+ void SetCallback(BreakpointHitCallback callback, void *baton);
+ void SetScriptCallbackFunction(const char *callback_function_name);
+
+ void SetCommandLineCommands(SBStringList &commands);
+
+ bool GetCommandLineCommands(SBStringList &commands);
+
+ SBError SetScriptCallbackBody(const char *script_body_text);
+
+ bool AddName(const char *new_name);
+
+ void RemoveName(const char *name_to_remove);
+
+ bool MatchesName(const char *name);
+
+ void GetNames(SBStringList &names);
+
+ size_t GetNumResolvedLocations() const;
+
+ size_t GetNumLocations() const;
+
+ bool GetDescription(lldb::SBStream &description);
+
+ bool GetDescription(lldb::SBStream &description, bool include_locations);
+
+ static bool EventIsBreakpointEvent(const lldb::SBEvent &event);
+
+ static lldb::BreakpointEventType
+ GetBreakpointEventTypeFromEvent(const lldb::SBEvent &event);
+
+ static lldb::SBBreakpoint GetBreakpointFromEvent(const lldb::SBEvent &event);
+
+ static lldb::SBBreakpointLocation
+ GetBreakpointLocationAtIndexFromEvent(const lldb::SBEvent &event,
+ uint32_t loc_idx);
+
+ static uint32_t
+ GetNumBreakpointLocationsFromEvent(const lldb::SBEvent &event_sp);
private:
- friend class SBBreakpointLocation;
- friend class SBTarget;
+ friend class SBBreakpointList;
+ friend class SBBreakpointLocation;
+ friend class SBTarget;
- SBBreakpoint (const lldb::BreakpointSP &bp_sp);
+ SBBreakpoint(const lldb::BreakpointSP &bp_sp);
- lldb_private::Breakpoint *
- operator->() const;
+ lldb_private::Breakpoint *operator->() const;
- lldb_private::Breakpoint *
- get() const;
+ lldb_private::Breakpoint *get() const;
- lldb::BreakpointSP &
- operator *();
+ lldb::BreakpointSP &operator*();
- const lldb::BreakpointSP &
- operator *() const;
+ const lldb::BreakpointSP &operator*() const;
- static bool
- PrivateBreakpointHitCallback (void *baton,
- lldb_private::StoppointCallbackContext *context,
- lldb::user_id_t break_id,
- lldb::user_id_t break_loc_id);
-
- lldb::BreakpointSP m_opaque_sp;
+ static bool PrivateBreakpointHitCallback(
+ void *baton, lldb_private::StoppointCallbackContext *context,
+ lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
+
+ lldb::BreakpointSP m_opaque_sp;
+};
+
+class LLDB_API SBBreakpointList {
+public:
+ SBBreakpointList(SBTarget &target);
+
+ ~SBBreakpointList();
+
+ size_t GetSize() const;
+
+ SBBreakpoint GetBreakpointAtIndex(size_t idx);
+
+ SBBreakpoint FindBreakpointByID(lldb::break_id_t);
+
+ void Append(const SBBreakpoint &sb_file);
+
+ bool AppendIfUnique(const SBBreakpoint &sb_file);
+
+ void AppendByID(lldb::break_id_t id);
+
+ void Clear();
+
+protected:
+ friend class SBTarget;
+
+ void CopyToBreakpointIDList(lldb_private::BreakpointIDList &bp_id_list);
+
+private:
+ std::shared_ptr<SBBreakpointListImpl> m_opaque_sp;
};
} // namespace lldb
-#endif // LLDB_SBBreakpoint_h_
+#endif // LLDB_SBBreakpoint_h_
diff --git a/include/lldb/API/SBBreakpointLocation.h b/include/lldb/API/SBBreakpointLocation.h
index ab7049739c0b..344c39c7bfd3 100644
--- a/include/lldb/API/SBBreakpointLocation.h
+++ b/include/lldb/API/SBBreakpointLocation.h
@@ -10,105 +10,78 @@
#ifndef LLDB_SBBreakpointLocation_h_
#define LLDB_SBBreakpointLocation_h_
-#include "lldb/API/SBDefines.h"
#include "lldb/API/SBBreakpoint.h"
+#include "lldb/API/SBDefines.h"
namespace lldb {
-class LLDB_API SBBreakpointLocation
-{
+class LLDB_API SBBreakpointLocation {
public:
+ SBBreakpointLocation();
- SBBreakpointLocation ();
-
- SBBreakpointLocation (const lldb::SBBreakpointLocation &rhs);
-
- ~SBBreakpointLocation ();
-
- const lldb::SBBreakpointLocation &
- operator = (const lldb::SBBreakpointLocation &rhs);
-
- break_id_t
- GetID ();
-
- bool
- IsValid() const;
-
- lldb::SBAddress
- GetAddress ();
-
- lldb::addr_t
- GetLoadAddress ();
-
- void
- SetEnabled(bool enabled);
-
- bool
- IsEnabled ();
-
- uint32_t
- GetIgnoreCount ();
-
- void
- SetIgnoreCount (uint32_t n);
-
- void
- SetCondition (const char *condition);
-
- const char *
- GetCondition ();
-
- void
- SetScriptCallbackFunction (const char *callback_function_name);
-
- SBError
- SetScriptCallbackBody (const char *script_body_text);
-
- void
- SetThreadID (lldb::tid_t sb_thread_id);
-
- lldb::tid_t
- GetThreadID ();
-
- void
- SetThreadIndex (uint32_t index);
-
- uint32_t
- GetThreadIndex() const;
-
- void
- SetThreadName (const char *thread_name);
-
- const char *
- GetThreadName () const;
-
- void
- SetQueueName (const char *queue_name);
-
- const char *
- GetQueueName () const;
-
- bool
- IsResolved ();
-
- bool
- GetDescription (lldb::SBStream &description, DescriptionLevel level);
-
- SBBreakpoint
- GetBreakpoint ();
-
- SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp);
+ SBBreakpointLocation(const lldb::SBBreakpointLocation &rhs);
-private:
- friend class SBBreakpoint;
+ ~SBBreakpointLocation();
+
+ const lldb::SBBreakpointLocation &
+ operator=(const lldb::SBBreakpointLocation &rhs);
+
+ break_id_t GetID();
+
+ bool IsValid() const;
+
+ lldb::SBAddress GetAddress();
+
+ lldb::addr_t GetLoadAddress();
+
+ void SetEnabled(bool enabled);
+
+ bool IsEnabled();
+
+ uint32_t GetIgnoreCount();
+
+ void SetIgnoreCount(uint32_t n);
+
+ void SetCondition(const char *condition);
+
+ const char *GetCondition();
+
+ void SetScriptCallbackFunction(const char *callback_function_name);
- void
- SetLocation (const lldb::BreakpointLocationSP &break_loc_sp);
+ SBError SetScriptCallbackBody(const char *script_body_text);
+
+ void SetThreadID(lldb::tid_t sb_thread_id);
+
+ lldb::tid_t GetThreadID();
+
+ void SetThreadIndex(uint32_t index);
+
+ uint32_t GetThreadIndex() const;
+
+ void SetThreadName(const char *thread_name);
+
+ const char *GetThreadName() const;
+
+ void SetQueueName(const char *queue_name);
+
+ const char *GetQueueName() const;
+
+ bool IsResolved();
+
+ bool GetDescription(lldb::SBStream &description, DescriptionLevel level);
+
+ SBBreakpoint GetBreakpoint();
+
+ SBBreakpointLocation(const lldb::BreakpointLocationSP &break_loc_sp);
+
+private:
+ friend class SBBreakpoint;
- lldb::BreakpointLocationSP m_opaque_sp;
+ void SetLocation(const lldb::BreakpointLocationSP &break_loc_sp);
+ lldb::BreakpointLocationSP m_opaque_sp;
};
} // namespace lldb
-#endif // LLDB_SBBreakpointLocation_h_
+#endif // LLDB_SBBreakpointLocation_h_
diff --git a/include/lldb/API/SBBroadcaster.h b/include/lldb/API/SBBroadcaster.h
index 28b6686b79b3..3fc47af65513 100644
--- a/include/lldb/API/SBBroadcaster.h
+++ b/include/lldb/API/SBBroadcaster.h
@@ -14,84 +14,70 @@
namespace lldb {
-class LLDB_API SBBroadcaster
-{
+class LLDB_API SBBroadcaster {
public:
- SBBroadcaster ();
+ SBBroadcaster();
- SBBroadcaster (const char *name);
+ SBBroadcaster(const char *name);
- SBBroadcaster (const SBBroadcaster &rhs);
-
- const SBBroadcaster &
- operator = (const SBBroadcaster &rhs);
+ SBBroadcaster(const SBBroadcaster &rhs);
- ~SBBroadcaster();
+ const SBBroadcaster &operator=(const SBBroadcaster &rhs);
- bool
- IsValid () const;
+ ~SBBroadcaster();
- void
- Clear ();
+ bool IsValid() const;
- void
- BroadcastEventByType (uint32_t event_type, bool unique = false);
+ void Clear();
- void
- BroadcastEvent (const lldb::SBEvent &event, bool unique = false);
+ void BroadcastEventByType(uint32_t event_type, bool unique = false);
- void
- AddInitialEventsToListener (const lldb::SBListener &listener, uint32_t requested_events);
+ void BroadcastEvent(const lldb::SBEvent &event, bool unique = false);
- uint32_t
- AddListener (const lldb::SBListener &listener, uint32_t event_mask);
+ void AddInitialEventsToListener(const lldb::SBListener &listener,
+ uint32_t requested_events);
- const char *
- GetName () const;
+ uint32_t AddListener(const lldb::SBListener &listener, uint32_t event_mask);
- bool
- EventTypeHasListeners (uint32_t event_type);
+ const char *GetName() const;
- bool
- RemoveListener (const lldb::SBListener &listener, uint32_t event_mask = UINT32_MAX);
+ bool EventTypeHasListeners(uint32_t event_type);
- // This comparison is checking if the internal opaque pointer value
- // is equal to that in "rhs".
- bool
- operator == (const lldb::SBBroadcaster &rhs) const;
+ bool RemoveListener(const lldb::SBListener &listener,
+ uint32_t event_mask = UINT32_MAX);
- // This comparison is checking if the internal opaque pointer value
- // is not equal to that in "rhs".
- bool
- operator != (const lldb::SBBroadcaster &rhs) const;
+ // This comparison is checking if the internal opaque pointer value
+ // is equal to that in "rhs".
+ bool operator==(const lldb::SBBroadcaster &rhs) const;
- // This comparison is checking if the internal opaque pointer value
- // is less than that in "rhs" so SBBroadcaster objects can be contained
- // in ordered containers.
- bool
- operator < (const lldb::SBBroadcaster &rhs) const;
+ // This comparison is checking if the internal opaque pointer value
+ // is not equal to that in "rhs".
+ bool operator!=(const lldb::SBBroadcaster &rhs) const;
+
+ // This comparison is checking if the internal opaque pointer value
+ // is less than that in "rhs" so SBBroadcaster objects can be contained
+ // in ordered containers.
+ bool operator<(const lldb::SBBroadcaster &rhs) const;
protected:
- friend class SBCommandInterpreter;
- friend class SBCommunication;
- friend class SBEvent;
- friend class SBListener;
- friend class SBProcess;
- friend class SBTarget;
+ friend class SBCommandInterpreter;
+ friend class SBCommunication;
+ friend class SBEvent;
+ friend class SBListener;
+ friend class SBProcess;
+ friend class SBTarget;
- SBBroadcaster (lldb_private::Broadcaster *broadcaster, bool owns);
+ SBBroadcaster(lldb_private::Broadcaster *broadcaster, bool owns);
- lldb_private::Broadcaster *
- get () const;
+ lldb_private::Broadcaster *get() const;
- void
- reset (lldb_private::Broadcaster *broadcaster, bool owns);
+ void reset(lldb_private::Broadcaster *broadcaster, bool owns);
private:
- lldb::BroadcasterSP m_opaque_sp;
- lldb_private::Broadcaster *m_opaque_ptr;
+ lldb::BroadcasterSP m_opaque_sp;
+ lldb_private::Broadcaster *m_opaque_ptr;
};
} // namespace lldb
-#endif // LLDB_SBBroadcaster_h_
+#endif // LLDB_SBBroadcaster_h_
diff --git a/include/lldb/API/SBCommandInterpreter.h b/include/lldb/API/SBCommandInterpreter.h
index a8e9bf7ed769..f684071740e3 100644
--- a/include/lldb/API/SBCommandInterpreter.h
+++ b/include/lldb/API/SBCommandInterpreter.h
@@ -16,305 +16,267 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/API/SBDefines.h"
#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBDefines.h"
namespace lldb {
-class LLDB_API SBCommandInterpreterRunOptions
-{
-friend class SBDebugger;
-friend class SBCommandInterpreter;
+class LLDB_API SBCommandInterpreterRunOptions {
+ friend class SBDebugger;
+ friend class SBCommandInterpreter;
public:
- SBCommandInterpreterRunOptions();
- ~SBCommandInterpreterRunOptions();
+ SBCommandInterpreterRunOptions();
+ ~SBCommandInterpreterRunOptions();
- bool
- GetStopOnContinue () const;
+ bool GetStopOnContinue() const;
- void
- SetStopOnContinue (bool);
+ void SetStopOnContinue(bool);
- bool
- GetStopOnError () const;
+ bool GetStopOnError() const;
- void
- SetStopOnError (bool);
+ void SetStopOnError(bool);
- bool
- GetStopOnCrash () const;
+ bool GetStopOnCrash() const;
- void
- SetStopOnCrash (bool);
+ void SetStopOnCrash(bool);
- bool
- GetEchoCommands () const;
+ bool GetEchoCommands() const;
- void
- SetEchoCommands (bool);
+ void SetEchoCommands(bool);
- bool
- GetPrintResults () const;
+ bool GetPrintResults() const;
- void
- SetPrintResults (bool);
+ void SetPrintResults(bool);
- bool
- GetAddToHistory () const;
+ bool GetAddToHistory() const;
- void
- SetAddToHistory (bool);
+ void SetAddToHistory(bool);
private:
- lldb_private::CommandInterpreterRunOptions *
- get () const;
+ lldb_private::CommandInterpreterRunOptions *get() const;
- lldb_private::CommandInterpreterRunOptions &
- ref () const;
+ lldb_private::CommandInterpreterRunOptions &ref() const;
- // This is set in the constructor and will always be valid.
- mutable std::unique_ptr<lldb_private::CommandInterpreterRunOptions> m_opaque_up;
+ // This is set in the constructor and will always be valid.
+ mutable std::unique_ptr<lldb_private::CommandInterpreterRunOptions>
+ m_opaque_up;
};
-class SBCommandInterpreter
-{
+class SBCommandInterpreter {
public:
- enum
- {
- eBroadcastBitThreadShouldExit = (1 << 0),
- eBroadcastBitResetPrompt = (1 << 1),
- eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit
- eBroadcastBitAsynchronousOutputData = (1 << 3),
- eBroadcastBitAsynchronousErrorData = (1 << 4)
- };
-
- SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs);
-
- ~SBCommandInterpreter ();
-
- const lldb::SBCommandInterpreter &
- operator = (const lldb::SBCommandInterpreter &rhs);
-
- static const char *
- GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type);
-
- static const char *
- GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type);
-
- static bool
- EventIsCommandInterpreterEvent (const lldb::SBEvent &event);
-
- bool
- IsValid() const;
-
- bool
- CommandExists (const char *cmd);
-
- bool
- AliasExists (const char *cmd);
-
- lldb::SBBroadcaster
- GetBroadcaster ();
-
- static const char *
- GetBroadcasterClass ();
-
- bool
- HasCommands ();
-
- bool
- HasAliases ();
-
- bool
- HasAliasOptions ();
-
- lldb::SBProcess
- GetProcess ();
-
- lldb::SBDebugger
- GetDebugger ();
-
- lldb::SBCommand
- AddMultiwordCommand (const char* name, const char* help);
-
- lldb::SBCommand
- AddCommand (const char* name, lldb::SBCommandPluginInterface *impl, const char* help);
-
- void
- SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result);
-
- void
- SourceInitFileInCurrentWorkingDirectory (lldb::SBCommandReturnObject &result);
-
- lldb::ReturnStatus
- HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history = false);
-
- lldb::ReturnStatus
- HandleCommand (const char *command_line, SBExecutionContext &exe_ctx, SBCommandReturnObject &result, bool add_to_history = false);
-
- void
- HandleCommandsFromFile (lldb::SBFileSpec &file,
- lldb::SBExecutionContext &override_context,
- lldb::SBCommandInterpreterRunOptions &options,
- lldb::SBCommandReturnObject result);
-
- // The pointer based interface is not useful in SWIG, since the cursor & last_char arguments are string pointers INTO current_line
- // and you can't do that in a scripting language interface in general...
-
- // In either case, the way this works is that the you give it a line and cursor position in the line. The function
- // will return the number of completions. The matches list will contain number_of_completions + 1 elements. The first
- // element is the common substring after the cursor position for all the matches. The rest of the elements are the
- // matches. The first element is useful if you are emulating the common shell behavior where the tab completes
- // to the string that is common among all the matches, then you should first check if the first element is non-empty,
- // and if so just insert it and move the cursor to the end of the insertion. The next tab will return an empty
- // common substring, and a list of choices (if any), at which point you should display the choices and let the user
- // type further to disambiguate.
-
- int
- HandleCompletion (const char *current_line,
- const char *cursor,
- const char *last_char,
- int match_start_point,
- int max_return_elements,
- lldb::SBStringList &matches);
-
- int
- HandleCompletion (const char *current_line,
- uint32_t cursor_pos,
- int match_start_point,
- int max_return_elements,
- lldb::SBStringList &matches);
-
- // Catch commands before they execute by registering a callback that will
- // get called when the command gets executed. This allows GUI or command
- // line interfaces to intercept a command and stop it from happening
- bool
- SetCommandOverrideCallback (const char *command_name,
- lldb::CommandOverrideCallback callback,
- void *baton);
-
- SBCommandInterpreter(lldb_private::CommandInterpreter *interpreter_ptr = nullptr); // Access using SBDebugger::GetCommandInterpreter();
-
- //----------------------------------------------------------------------
- /// Return true if the command interpreter is the active IO handler.
- ///
- /// This indicates that any input coming into the debugger handles will
- /// go to the command interpreter and will result in LLDB command line
- /// commands being executed.
- //----------------------------------------------------------------------
- bool
- IsActive ();
-
- //----------------------------------------------------------------------
- /// Get the string that needs to be written to the debugger stdin file
- /// handle when a control character is typed.
- ///
- /// Some GUI programs will intercept "control + char" sequences and want
- /// to have them do what normally would happen when using a real
- /// terminal, so this function allows GUI programs to emulate this
- /// functionality.
- ///
- /// @param[in] ch
- /// The character that was typed along with the control key
- ///
- /// @return
- /// The string that should be written into the file handle that is
- /// feeding the input stream for the debugger, or nullptr if there is
- /// no string for this control key.
- //----------------------------------------------------------------------
- const char *
- GetIOHandlerControlSequence(char ch);
-
- bool
- GetPromptOnQuit();
-
- void
- SetPromptOnQuit(bool b);
-
- //----------------------------------------------------------------------
- /// Resolve the command just as HandleCommand would, expanding abbreviations
- /// and aliases. If successful, result->GetOutput has the full expansion.
- //----------------------------------------------------------------------
- void
- ResolveCommand(const char *command_line, SBCommandReturnObject &result);
+ enum {
+ eBroadcastBitThreadShouldExit = (1 << 0),
+ eBroadcastBitResetPrompt = (1 << 1),
+ eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit
+ eBroadcastBitAsynchronousOutputData = (1 << 3),
+ eBroadcastBitAsynchronousErrorData = (1 << 4)
+ };
+
+ SBCommandInterpreter(const lldb::SBCommandInterpreter &rhs);
+
+ ~SBCommandInterpreter();
+
+ const lldb::SBCommandInterpreter &
+ operator=(const lldb::SBCommandInterpreter &rhs);
+
+ static const char *
+ GetArgumentTypeAsCString(const lldb::CommandArgumentType arg_type);
+
+ static const char *
+ GetArgumentDescriptionAsCString(const lldb::CommandArgumentType arg_type);
+
+ static bool EventIsCommandInterpreterEvent(const lldb::SBEvent &event);
+
+ bool IsValid() const;
+
+ bool CommandExists(const char *cmd);
+
+ bool AliasExists(const char *cmd);
+
+ lldb::SBBroadcaster GetBroadcaster();
+
+ static const char *GetBroadcasterClass();
+
+ bool HasCommands();
+
+ bool HasAliases();
+
+ bool HasAliasOptions();
+
+ lldb::SBProcess GetProcess();
+
+ lldb::SBDebugger GetDebugger();
+
+ lldb::SBCommand AddMultiwordCommand(const char *name, const char *help);
+
+ lldb::SBCommand AddCommand(const char *name,
+ lldb::SBCommandPluginInterface *impl,
+ const char *help);
+
+ lldb::SBCommand AddCommand(const char *name,
+ lldb::SBCommandPluginInterface *impl,
+ const char *help, const char *syntax);
+
+ void SourceInitFileInHomeDirectory(lldb::SBCommandReturnObject &result);
+
+ void
+ SourceInitFileInCurrentWorkingDirectory(lldb::SBCommandReturnObject &result);
+
+ lldb::ReturnStatus HandleCommand(const char *command_line,
+ lldb::SBCommandReturnObject &result,
+ bool add_to_history = false);
+
+ lldb::ReturnStatus HandleCommand(const char *command_line,
+ SBExecutionContext &exe_ctx,
+ SBCommandReturnObject &result,
+ bool add_to_history = false);
+
+ void HandleCommandsFromFile(lldb::SBFileSpec &file,
+ lldb::SBExecutionContext &override_context,
+ lldb::SBCommandInterpreterRunOptions &options,
+ lldb::SBCommandReturnObject result);
+
+ // The pointer based interface is not useful in SWIG, since the cursor &
+ // last_char arguments are string pointers INTO current_line
+ // and you can't do that in a scripting language interface in general...
+
+ // In either case, the way this works is that the you give it a line and
+ // cursor position in the line. The function
+ // will return the number of completions. The matches list will contain
+ // number_of_completions + 1 elements. The first
+ // element is the common substring after the cursor position for all the
+ // matches. The rest of the elements are the
+ // matches. The first element is useful if you are emulating the common shell
+ // behavior where the tab completes
+ // to the string that is common among all the matches, then you should first
+ // check if the first element is non-empty,
+ // and if so just insert it and move the cursor to the end of the insertion.
+ // The next tab will return an empty
+ // common substring, and a list of choices (if any), at which point you should
+ // display the choices and let the user
+ // type further to disambiguate.
+
+ int HandleCompletion(const char *current_line, const char *cursor,
+ const char *last_char, int match_start_point,
+ int max_return_elements, lldb::SBStringList &matches);
+
+ int HandleCompletion(const char *current_line, uint32_t cursor_pos,
+ int match_start_point, int max_return_elements,
+ lldb::SBStringList &matches);
+
+ // Catch commands before they execute by registering a callback that will
+ // get called when the command gets executed. This allows GUI or command
+ // line interfaces to intercept a command and stop it from happening
+ bool SetCommandOverrideCallback(const char *command_name,
+ lldb::CommandOverrideCallback callback,
+ void *baton);
+
+ SBCommandInterpreter(
+ lldb_private::CommandInterpreter *interpreter_ptr =
+ nullptr); // Access using SBDebugger::GetCommandInterpreter();
+
+ //----------------------------------------------------------------------
+ /// Return true if the command interpreter is the active IO handler.
+ ///
+ /// This indicates that any input coming into the debugger handles will
+ /// go to the command interpreter and will result in LLDB command line
+ /// commands being executed.
+ //----------------------------------------------------------------------
+ bool IsActive();
+
+ //----------------------------------------------------------------------
+ /// Get the string that needs to be written to the debugger stdin file
+ /// handle when a control character is typed.
+ ///
+ /// Some GUI programs will intercept "control + char" sequences and want
+ /// to have them do what normally would happen when using a real
+ /// terminal, so this function allows GUI programs to emulate this
+ /// functionality.
+ ///
+ /// @param[in] ch
+ /// The character that was typed along with the control key
+ ///
+ /// @return
+ /// The string that should be written into the file handle that is
+ /// feeding the input stream for the debugger, or nullptr if there is
+ /// no string for this control key.
+ //----------------------------------------------------------------------
+ const char *GetIOHandlerControlSequence(char ch);
+
+ bool GetPromptOnQuit();
+
+ void SetPromptOnQuit(bool b);
+
+ //----------------------------------------------------------------------
+ /// Resolve the command just as HandleCommand would, expanding abbreviations
+ /// and aliases. If successful, result->GetOutput has the full expansion.
+ //----------------------------------------------------------------------
+ void ResolveCommand(const char *command_line, SBCommandReturnObject &result);
protected:
- lldb_private::CommandInterpreter &
- ref ();
+ lldb_private::CommandInterpreter &ref();
- lldb_private::CommandInterpreter *
- get ();
+ lldb_private::CommandInterpreter *get();
- void
- reset (lldb_private::CommandInterpreter *);
+ void reset(lldb_private::CommandInterpreter *);
private:
- friend class SBDebugger;
+ friend class SBDebugger;
- static void
- InitializeSWIG ();
+ static void InitializeSWIG();
- lldb_private::CommandInterpreter *m_opaque_ptr;
+ lldb_private::CommandInterpreter *m_opaque_ptr;
};
-class SBCommandPluginInterface
-{
+class SBCommandPluginInterface {
public:
- virtual
- ~SBCommandPluginInterface() = default;
-
- virtual bool
- DoExecute (lldb::SBDebugger /*debugger*/,
- char** /*command*/,
- lldb::SBCommandReturnObject & /*result*/)
- {
- return false;
- }
+ virtual ~SBCommandPluginInterface() = default;
+
+ virtual bool DoExecute(lldb::SBDebugger /*debugger*/, char ** /*command*/,
+ lldb::SBCommandReturnObject & /*result*/) {
+ return false;
+ }
};
-
-class SBCommand
-{
+
+class SBCommand {
public:
- SBCommand ();
-
- bool
- IsValid ();
-
- const char*
- GetName ();
-
- const char*
- GetHelp ();
-
- const char*
- GetHelpLong ();
-
- void
- SetHelp (const char*);
-
- void
- SetHelpLong (const char*);
-
- uint32_t
- GetFlags ();
-
- void
- SetFlags (uint32_t flags);
-
- lldb::SBCommand
- AddMultiwordCommand(const char* name, const char* help = nullptr);
-
- lldb::SBCommand
- AddCommand(const char* name, lldb::SBCommandPluginInterface* impl, const char* help = nullptr);
-
+ SBCommand();
+
+ bool IsValid();
+
+ const char *GetName();
+
+ const char *GetHelp();
+
+ const char *GetHelpLong();
+
+ void SetHelp(const char *);
+
+ void SetHelpLong(const char *);
+
+ uint32_t GetFlags();
+
+ void SetFlags(uint32_t flags);
+
+ lldb::SBCommand AddMultiwordCommand(const char *name,
+ const char *help = nullptr);
+
+ lldb::SBCommand AddCommand(const char *name,
+ lldb::SBCommandPluginInterface *impl,
+ const char *help = nullptr);
+
+ lldb::SBCommand AddCommand(const char *name,
+ lldb::SBCommandPluginInterface *impl,
+ const char *help, const char *syntax);
+
private:
- friend class SBDebugger;
- friend class SBCommandInterpreter;
-
- SBCommand (lldb::CommandObjectSP cmd_sp);
-
- lldb::CommandObjectSP m_opaque_sp;
+ friend class SBDebugger;
+ friend class SBCommandInterpreter;
+
+ SBCommand(lldb::CommandObjectSP cmd_sp);
+
+ lldb::CommandObjectSP m_opaque_sp;
};
} // namespace lldb
diff --git a/include/lldb/API/SBCommandReturnObject.h b/include/lldb/API/SBCommandReturnObject.h
index 2b7cce5ded59..c73e3f7cf1f2 100644
--- a/include/lldb/API/SBCommandReturnObject.h
+++ b/include/lldb/API/SBCommandReturnObject.h
@@ -22,122 +22,90 @@
namespace lldb {
-class LLDB_API SBCommandReturnObject
-{
+class LLDB_API SBCommandReturnObject {
public:
- SBCommandReturnObject ();
-
- SBCommandReturnObject (const lldb::SBCommandReturnObject &rhs);
-
- ~SBCommandReturnObject ();
-
- const lldb::SBCommandReturnObject &
- operator = (const lldb::SBCommandReturnObject &rhs);
-
- SBCommandReturnObject (lldb_private::CommandReturnObject *ptr);
-
- lldb_private::CommandReturnObject *
- Release ();
-
- bool
- IsValid() const;
-
- const char *
- GetOutput ();
-
- const char *
- GetError ();
-
- size_t
- PutOutput (FILE *fh);
-
- size_t
- GetOutputSize ();
-
- size_t
- GetErrorSize ();
-
- size_t
- PutError (FILE *fh);
-
- void
- Clear();
-
- lldb::ReturnStatus
- GetStatus();
-
- void
- SetStatus (lldb::ReturnStatus status);
-
- bool
- Succeeded ();
-
- bool
- HasResult ();
-
- void
- AppendMessage (const char *message);
-
- void
- AppendWarning (const char *message);
-
- bool
- GetDescription (lldb::SBStream &description);
-
- // deprecated, these two functions do not take
- // ownership of file handle
- void
- SetImmediateOutputFile (FILE *fh);
-
- void
- SetImmediateErrorFile (FILE *fh);
-
- void
- SetImmediateOutputFile (FILE *fh, bool transfer_ownership);
-
- void
- SetImmediateErrorFile (FILE *fh, bool transfer_ownership);
-
- void
- PutCString(const char* string, int len = -1);
-
- size_t
- Printf(const char* format, ...) __attribute__ ((format (printf, 2, 3)));
-
- const char *
- GetOutput (bool only_if_no_immediate);
-
- const char *
- GetError (bool only_if_no_immediate);
-
- void
- SetError(lldb::SBError &error,
- const char *fallback_error_cstr = nullptr);
-
- void
- SetError (const char* error_cstr);
-
+ SBCommandReturnObject();
+
+ SBCommandReturnObject(const lldb::SBCommandReturnObject &rhs);
+
+ ~SBCommandReturnObject();
+
+ const lldb::SBCommandReturnObject &
+ operator=(const lldb::SBCommandReturnObject &rhs);
+
+ SBCommandReturnObject(lldb_private::CommandReturnObject *ptr);
+
+ lldb_private::CommandReturnObject *Release();
+
+ bool IsValid() const;
+
+ const char *GetOutput();
+
+ const char *GetError();
+
+ size_t PutOutput(FILE *fh);
+
+ size_t GetOutputSize();
+
+ size_t GetErrorSize();
+
+ size_t PutError(FILE *fh);
+
+ void Clear();
+
+ lldb::ReturnStatus GetStatus();
+
+ void SetStatus(lldb::ReturnStatus status);
+
+ bool Succeeded();
+
+ bool HasResult();
+
+ void AppendMessage(const char *message);
+
+ void AppendWarning(const char *message);
+
+ bool GetDescription(lldb::SBStream &description);
+
+ // deprecated, these two functions do not take
+ // ownership of file handle
+ void SetImmediateOutputFile(FILE *fh);
+
+ void SetImmediateErrorFile(FILE *fh);
+
+ void SetImmediateOutputFile(FILE *fh, bool transfer_ownership);
+
+ void SetImmediateErrorFile(FILE *fh, bool transfer_ownership);
+
+ void PutCString(const char *string, int len = -1);
+
+ size_t Printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
+
+ const char *GetOutput(bool only_if_no_immediate);
+
+ const char *GetError(bool only_if_no_immediate);
+
+ void SetError(lldb::SBError &error,
+ const char *fallback_error_cstr = nullptr);
+
+ void SetError(const char *error_cstr);
+
protected:
- friend class SBCommandInterpreter;
- friend class SBOptions;
+ friend class SBCommandInterpreter;
+ friend class SBOptions;
- lldb_private::CommandReturnObject *
- operator->() const;
+ lldb_private::CommandReturnObject *operator->() const;
- lldb_private::CommandReturnObject *
- get() const;
+ lldb_private::CommandReturnObject *get() const;
- lldb_private::CommandReturnObject &
- operator*() const;
+ lldb_private::CommandReturnObject &operator*() const;
- lldb_private::CommandReturnObject &
- ref() const;
+ lldb_private::CommandReturnObject &ref() const;
- void
- SetLLDBObjectPtr (lldb_private::CommandReturnObject *ptr);
+ void SetLLDBObjectPtr(lldb_private::CommandReturnObject *ptr);
private:
- std::unique_ptr<lldb_private::CommandReturnObject> m_opaque_ap;
+ std::unique_ptr<lldb_private::CommandReturnObject> m_opaque_ap;
};
} // namespace lldb
diff --git a/include/lldb/API/SBCommunication.h b/include/lldb/API/SBCommunication.h
index c4b2709de8ab..f0016275b634 100644
--- a/include/lldb/API/SBCommunication.h
+++ b/include/lldb/API/SBCommunication.h
@@ -15,86 +15,68 @@
namespace lldb {
-class LLDB_API SBCommunication
-{
+class LLDB_API SBCommunication {
public:
- FLAGS_ANONYMOUS_ENUM()
- {
- eBroadcastBitDisconnected = (1 << 0), ///< Sent when the communications connection is lost.
- eBroadcastBitReadThreadGotBytes = (1 << 1), ///< Sent by the read thread when bytes become available.
- eBroadcastBitReadThreadDidExit = (1 << 2), ///< Sent by the read thread when it exits to inform clients.
- eBroadcastBitReadThreadShouldExit = (1 << 3), ///< Sent by clients that need to cancel the read thread.
- eBroadcastBitPacketAvailable = (1 << 4), ///< Sent when data received makes a complete packet.
- eAllEventBits = 0xffffffff
- };
+ FLAGS_ANONYMOUS_ENUM(){
+ eBroadcastBitDisconnected =
+ (1 << 0), ///< Sent when the communications connection is lost.
+ eBroadcastBitReadThreadGotBytes =
+ (1 << 1), ///< Sent by the read thread when bytes become available.
+ eBroadcastBitReadThreadDidExit =
+ (1
+ << 2), ///< Sent by the read thread when it exits to inform clients.
+ eBroadcastBitReadThreadShouldExit =
+ (1 << 3), ///< Sent by clients that need to cancel the read thread.
+ eBroadcastBitPacketAvailable =
+ (1 << 4), ///< Sent when data received makes a complete packet.
+ eAllEventBits = 0xffffffff};
- typedef void (*ReadThreadBytesReceived) (void *baton, const void *src, size_t src_len);
+ typedef void (*ReadThreadBytesReceived)(void *baton, const void *src,
+ size_t src_len);
- SBCommunication ();
- SBCommunication (const char * broadcaster_name);
- ~SBCommunication ();
+ SBCommunication();
+ SBCommunication(const char *broadcaster_name);
+ ~SBCommunication();
+ bool IsValid() const;
- bool
- IsValid () const;
+ lldb::SBBroadcaster GetBroadcaster();
- lldb::SBBroadcaster
- GetBroadcaster ();
-
- static const char *GetBroadcasterClass();
+ static const char *GetBroadcasterClass();
- lldb::ConnectionStatus
- AdoptFileDesriptor (int fd, bool owns_fd);
+ lldb::ConnectionStatus AdoptFileDesriptor(int fd, bool owns_fd);
- lldb::ConnectionStatus
- Connect (const char *url);
+ lldb::ConnectionStatus Connect(const char *url);
- lldb::ConnectionStatus
- Disconnect ();
+ lldb::ConnectionStatus Disconnect();
- bool
- IsConnected () const;
+ bool IsConnected() const;
- bool
- GetCloseOnEOF ();
+ bool GetCloseOnEOF();
- void
- SetCloseOnEOF (bool b);
+ void SetCloseOnEOF(bool b);
- size_t
- Read (void *dst,
- size_t dst_len,
- uint32_t timeout_usec,
- lldb::ConnectionStatus &status);
+ size_t Read(void *dst, size_t dst_len, uint32_t timeout_usec,
+ lldb::ConnectionStatus &status);
- size_t
- Write (const void *src,
- size_t src_len,
- lldb::ConnectionStatus &status);
+ size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status);
- bool
- ReadThreadStart ();
+ bool ReadThreadStart();
- bool
- ReadThreadStop ();
+ bool ReadThreadStop();
- bool
- ReadThreadIsRunning ();
-
- bool
- SetReadThreadBytesReceivedCallback (ReadThreadBytesReceived callback,
- void *callback_baton);
+ bool ReadThreadIsRunning();
+ bool SetReadThreadBytesReceivedCallback(ReadThreadBytesReceived callback,
+ void *callback_baton);
private:
+ DISALLOW_COPY_AND_ASSIGN(SBCommunication);
- DISALLOW_COPY_AND_ASSIGN (SBCommunication);
-
- lldb_private::Communication *m_opaque;
- bool m_opaque_owned;
+ lldb_private::Communication *m_opaque;
+ bool m_opaque_owned;
};
-
} // namespace lldb
#endif // LLDB_SBCommunication_h_
diff --git a/include/lldb/API/SBCompileUnit.h b/include/lldb/API/SBCompileUnit.h
index a53d556679c4..4d5f9f36f246 100644
--- a/include/lldb/API/SBCompileUnit.h
+++ b/include/lldb/API/SBCompileUnit.h
@@ -15,104 +15,81 @@
namespace lldb {
-class LLDB_API SBCompileUnit
-{
+class LLDB_API SBCompileUnit {
public:
+ SBCompileUnit();
- SBCompileUnit ();
-
- SBCompileUnit (const lldb::SBCompileUnit &rhs);
-
- ~SBCompileUnit ();
-
- const lldb::SBCompileUnit &
- operator = (const lldb::SBCompileUnit &rhs);
-
- bool
- IsValid () const;
-
- lldb::SBFileSpec
- GetFileSpec () const;
-
- uint32_t
- GetNumLineEntries () const;
-
- lldb::SBLineEntry
- GetLineEntryAtIndex (uint32_t idx) const;
-
- uint32_t
- FindLineEntryIndex (uint32_t start_idx,
- uint32_t line,
- lldb::SBFileSpec *inline_file_spec) const;
-
- uint32_t
- FindLineEntryIndex (uint32_t start_idx,
- uint32_t line,
- lldb::SBFileSpec *inline_file_spec,
- bool exact) const;
-
- SBFileSpec
- GetSupportFileAtIndex (uint32_t idx) const;
-
- uint32_t
- GetNumSupportFiles () const;
-
- uint32_t
- FindSupportFileIndex (uint32_t start_idx, const SBFileSpec &sb_file, bool full);
-
- //------------------------------------------------------------------
- /// Get all types matching \a type_mask from debug info in this
- /// compile unit.
- ///
- /// @param[in] type_mask
- /// A bitfield that consists of one or more bits logically OR'ed
- /// together from the lldb::TypeClass enumeration. This allows
- /// you to request only structure types, or only class, struct
- /// and union types. Passing in lldb::eTypeClassAny will return
- /// all types found in the debug information for this compile
- /// unit.
- ///
- /// @return
- /// A list of types in this compile unit that match \a type_mask
- //------------------------------------------------------------------
- lldb::SBTypeList
- GetTypes (uint32_t type_mask = lldb::eTypeClassAny);
-
- lldb::LanguageType
- GetLanguage ();
-
- bool
- operator == (const lldb::SBCompileUnit &rhs) const;
-
- bool
- operator != (const lldb::SBCompileUnit &rhs) const;
-
- bool
- GetDescription (lldb::SBStream &description);
+ SBCompileUnit(const lldb::SBCompileUnit &rhs);
+
+ ~SBCompileUnit();
+
+ const lldb::SBCompileUnit &operator=(const lldb::SBCompileUnit &rhs);
+
+ bool IsValid() const;
+
+ lldb::SBFileSpec GetFileSpec() const;
+
+ uint32_t GetNumLineEntries() const;
+
+ lldb::SBLineEntry GetLineEntryAtIndex(uint32_t idx) const;
+
+ uint32_t FindLineEntryIndex(uint32_t start_idx, uint32_t line,
+ lldb::SBFileSpec *inline_file_spec) const;
+
+ uint32_t FindLineEntryIndex(uint32_t start_idx, uint32_t line,
+ lldb::SBFileSpec *inline_file_spec,
+ bool exact) const;
+
+ SBFileSpec GetSupportFileAtIndex(uint32_t idx) const;
+
+ uint32_t GetNumSupportFiles() const;
+
+ uint32_t FindSupportFileIndex(uint32_t start_idx, const SBFileSpec &sb_file,
+ bool full);
+
+ //------------------------------------------------------------------
+ /// Get all types matching \a type_mask from debug info in this
+ /// compile unit.
+ ///
+ /// @param[in] type_mask
+ /// A bitfield that consists of one or more bits logically OR'ed
+ /// together from the lldb::TypeClass enumeration. This allows
+ /// you to request only structure types, or only class, struct
+ /// and union types. Passing in lldb::eTypeClassAny will return
+ /// all types found in the debug information for this compile
+ /// unit.
+ ///
+ /// @return
+ /// A list of types in this compile unit that match \a type_mask
+ //------------------------------------------------------------------
+ lldb::SBTypeList GetTypes(uint32_t type_mask = lldb::eTypeClassAny);
+
+ lldb::LanguageType GetLanguage();
+
+ bool operator==(const lldb::SBCompileUnit &rhs) const;
+
+ bool operator!=(const lldb::SBCompileUnit &rhs) const;
+
+ bool GetDescription(lldb::SBStream &description);
private:
- friend class SBAddress;
- friend class SBFrame;
- friend class SBSymbolContext;
- friend class SBModule;
-
- SBCompileUnit (lldb_private::CompileUnit *lldb_object_ptr);
-
- const lldb_private::CompileUnit *
- operator->() const;
-
- const lldb_private::CompileUnit &
- operator*() const;
-
- lldb_private::CompileUnit *
- get ();
-
- void
- reset (lldb_private::CompileUnit *lldb_object_ptr);
-
- lldb_private::CompileUnit *m_opaque_ptr;
-};
+ friend class SBAddress;
+ friend class SBFrame;
+ friend class SBSymbolContext;
+ friend class SBModule;
+
+ SBCompileUnit(lldb_private::CompileUnit *lldb_object_ptr);
+ const lldb_private::CompileUnit *operator->() const;
+
+ const lldb_private::CompileUnit &operator*() const;
+
+ lldb_private::CompileUnit *get();
+
+ void reset(lldb_private::CompileUnit *lldb_object_ptr);
+
+ lldb_private::CompileUnit *m_opaque_ptr;
+};
} // namespace lldb
diff --git a/include/lldb/API/SBData.h b/include/lldb/API/SBData.h
index a2bd72fad570..7aa4ea0ff8d0 100644
--- a/include/lldb/API/SBData.h
+++ b/include/lldb/API/SBData.h
@@ -14,168 +14,143 @@
namespace lldb {
-class LLDB_API SBData
-{
+class LLDB_API SBData {
public:
+ SBData();
+
+ SBData(const SBData &rhs);
+
+ const SBData &operator=(const SBData &rhs);
+
+ ~SBData();
+
+ uint8_t GetAddressByteSize();
+
+ void SetAddressByteSize(uint8_t addr_byte_size);
+
+ void Clear();
+
+ bool IsValid();
+
+ size_t GetByteSize();
+
+ lldb::ByteOrder GetByteOrder();
+
+ void SetByteOrder(lldb::ByteOrder endian);
+
+ float GetFloat(lldb::SBError &error, lldb::offset_t offset);
+
+ double GetDouble(lldb::SBError &error, lldb::offset_t offset);
+
+ long double GetLongDouble(lldb::SBError &error, lldb::offset_t offset);
+
+ lldb::addr_t GetAddress(lldb::SBError &error, lldb::offset_t offset);
+
+ uint8_t GetUnsignedInt8(lldb::SBError &error, lldb::offset_t offset);
+
+ uint16_t GetUnsignedInt16(lldb::SBError &error, lldb::offset_t offset);
+
+ uint32_t GetUnsignedInt32(lldb::SBError &error, lldb::offset_t offset);
+
+ uint64_t GetUnsignedInt64(lldb::SBError &error, lldb::offset_t offset);
+
+ int8_t GetSignedInt8(lldb::SBError &error, lldb::offset_t offset);
+
+ int16_t GetSignedInt16(lldb::SBError &error, lldb::offset_t offset);
+
+ int32_t GetSignedInt32(lldb::SBError &error, lldb::offset_t offset);
+
+ int64_t GetSignedInt64(lldb::SBError &error, lldb::offset_t offset);
+
+ const char *GetString(lldb::SBError &error, lldb::offset_t offset);
+
+ size_t ReadRawData(lldb::SBError &error, lldb::offset_t offset, void *buf,
+ size_t size);
+
+ bool GetDescription(lldb::SBStream &description,
+ lldb::addr_t base_addr = LLDB_INVALID_ADDRESS);
+
+ // it would be nice to have SetData(SBError, const void*, size_t) when
+ // endianness and address size can be
+ // inferred from the existing DataExtractor, but having two SetData()
+ // signatures triggers a SWIG bug where
+ // the typemap isn't applied before resolving the overload, and thus the right
+ // function never gets called
+ void SetData(lldb::SBError &error, const void *buf, size_t size,
+ lldb::ByteOrder endian, uint8_t addr_size);
+
+ // see SetData() for why we don't have Append(const void* buf, size_t size)
+ bool Append(const SBData &rhs);
+
+ static lldb::SBData CreateDataFromCString(lldb::ByteOrder endian,
+ uint32_t addr_byte_size,
+ const char *data);
+
+ // in the following CreateData*() and SetData*() prototypes, the two
+ // parameters array and array_len
+ // should not be renamed or rearranged, because doing so will break the SWIG
+ // typemap
+ static lldb::SBData CreateDataFromUInt64Array(lldb::ByteOrder endian,
+ uint32_t addr_byte_size,
+ uint64_t *array,
+ size_t array_len);
+
+ static lldb::SBData CreateDataFromUInt32Array(lldb::ByteOrder endian,
+ uint32_t addr_byte_size,
+ uint32_t *array,
+ size_t array_len);
+
+ static lldb::SBData CreateDataFromSInt64Array(lldb::ByteOrder endian,
+ uint32_t addr_byte_size,
+ int64_t *array,
+ size_t array_len);
+
+ static lldb::SBData CreateDataFromSInt32Array(lldb::ByteOrder endian,
+ uint32_t addr_byte_size,
+ int32_t *array,
+ size_t array_len);
+
+ static lldb::SBData CreateDataFromDoubleArray(lldb::ByteOrder endian,
+ uint32_t addr_byte_size,
+ double *array,
+ size_t array_len);
+
+ bool SetDataFromCString(const char *data);
+
+ bool SetDataFromUInt64Array(uint64_t *array, size_t array_len);
+
+ bool SetDataFromUInt32Array(uint32_t *array, size_t array_len);
+
+ bool SetDataFromSInt64Array(int64_t *array, size_t array_len);
+
+ bool SetDataFromSInt32Array(int32_t *array, size_t array_len);
+
+ bool SetDataFromDoubleArray(double *array, size_t array_len);
- SBData ();
-
- SBData (const SBData &rhs);
-
- const SBData &
- operator = (const SBData &rhs);
-
- ~SBData ();
-
- uint8_t
- GetAddressByteSize ();
-
- void
- SetAddressByteSize (uint8_t addr_byte_size);
-
- void
- Clear ();
-
- bool
- IsValid();
-
- size_t
- GetByteSize ();
-
- lldb::ByteOrder
- GetByteOrder();
-
- void
- SetByteOrder (lldb::ByteOrder endian);
-
- float
- GetFloat (lldb::SBError& error, lldb::offset_t offset);
-
- double
- GetDouble (lldb::SBError& error, lldb::offset_t offset);
-
- long double
- GetLongDouble (lldb::SBError& error, lldb::offset_t offset);
-
- lldb::addr_t
- GetAddress (lldb::SBError& error, lldb::offset_t offset);
-
- uint8_t
- GetUnsignedInt8 (lldb::SBError& error, lldb::offset_t offset);
-
- uint16_t
- GetUnsignedInt16 (lldb::SBError& error, lldb::offset_t offset);
-
- uint32_t
- GetUnsignedInt32 (lldb::SBError& error, lldb::offset_t offset);
-
- uint64_t
- GetUnsignedInt64 (lldb::SBError& error, lldb::offset_t offset);
-
- int8_t
- GetSignedInt8 (lldb::SBError& error, lldb::offset_t offset);
-
- int16_t
- GetSignedInt16 (lldb::SBError& error, lldb::offset_t offset);
-
- int32_t
- GetSignedInt32 (lldb::SBError& error, lldb::offset_t offset);
-
- int64_t
- GetSignedInt64 (lldb::SBError& error, lldb::offset_t offset);
-
- const char*
- GetString (lldb::SBError& error, lldb::offset_t offset);
-
- size_t
- ReadRawData (lldb::SBError& error,
- lldb::offset_t offset,
- void *buf,
- size_t size);
-
- bool
- GetDescription (lldb::SBStream &description, lldb::addr_t base_addr = LLDB_INVALID_ADDRESS);
-
- // it would be nice to have SetData(SBError, const void*, size_t) when endianness and address size can be
- // inferred from the existing DataExtractor, but having two SetData() signatures triggers a SWIG bug where
- // the typemap isn't applied before resolving the overload, and thus the right function never gets called
- void
- SetData (lldb::SBError& error, const void *buf, size_t size, lldb::ByteOrder endian, uint8_t addr_size);
-
- // see SetData() for why we don't have Append(const void* buf, size_t size)
- bool
- Append (const SBData& rhs);
-
- static lldb::SBData
- CreateDataFromCString (lldb::ByteOrder endian, uint32_t addr_byte_size, const char* data);
-
- // in the following CreateData*() and SetData*() prototypes, the two parameters array and array_len
- // should not be renamed or rearranged, because doing so will break the SWIG typemap
- static lldb::SBData
- CreateDataFromUInt64Array (lldb::ByteOrder endian, uint32_t addr_byte_size, uint64_t* array, size_t array_len);
-
- static lldb::SBData
- CreateDataFromUInt32Array (lldb::ByteOrder endian, uint32_t addr_byte_size, uint32_t* array, size_t array_len);
-
- static lldb::SBData
- CreateDataFromSInt64Array (lldb::ByteOrder endian, uint32_t addr_byte_size, int64_t* array, size_t array_len);
-
- static lldb::SBData
- CreateDataFromSInt32Array (lldb::ByteOrder endian, uint32_t addr_byte_size, int32_t* array, size_t array_len);
-
- static lldb::SBData
- CreateDataFromDoubleArray (lldb::ByteOrder endian, uint32_t addr_byte_size, double* array, size_t array_len);
-
- bool
- SetDataFromCString (const char* data);
-
- bool
- SetDataFromUInt64Array (uint64_t* array, size_t array_len);
-
- bool
- SetDataFromUInt32Array (uint32_t* array, size_t array_len);
-
- bool
- SetDataFromSInt64Array (int64_t* array, size_t array_len);
-
- bool
- SetDataFromSInt32Array (int32_t* array, size_t array_len);
-
- bool
- SetDataFromDoubleArray (double* array, size_t array_len);
-
-
protected:
-
- // Mimic shared pointer...
- lldb_private::DataExtractor *
- get() const;
-
- lldb_private::DataExtractor *
- operator->() const;
-
- lldb::DataExtractorSP &
- operator*();
-
- const lldb::DataExtractorSP &
- operator*() const;
-
- SBData (const lldb::DataExtractorSP &data_sp);
-
- void
- SetOpaque (const lldb::DataExtractorSP &data_sp);
+ // Mimic shared pointer...
+ lldb_private::DataExtractor *get() const;
+
+ lldb_private::DataExtractor *operator->() const;
+
+ lldb::DataExtractorSP &operator*();
+
+ const lldb::DataExtractorSP &operator*() const;
+
+ SBData(const lldb::DataExtractorSP &data_sp);
+
+ void SetOpaque(const lldb::DataExtractorSP &data_sp);
private:
- friend class SBInstruction;
- friend class SBProcess;
- friend class SBSection;
- friend class SBTarget;
- friend class SBValue;
+ friend class SBInstruction;
+ friend class SBProcess;
+ friend class SBSection;
+ friend class SBTarget;
+ friend class SBValue;
- lldb::DataExtractorSP m_opaque_sp;
+ lldb::DataExtractorSP m_opaque_sp;
};
-
} // namespace lldb
#endif // LLDB_SBData_h_
diff --git a/include/lldb/API/SBDebugger.h b/include/lldb/API/SBDebugger.h
index 7588cfc9ec42..9084943b9131 100644
--- a/include/lldb/API/SBDebugger.h
+++ b/include/lldb/API/SBDebugger.h
@@ -16,349 +16,255 @@
#include "lldb/API/SBPlatform.h"
namespace lldb {
-
-class LLDB_API SBInputReader
-{
-public:
- SBInputReader() = default;
- ~SBInputReader() = default;
- SBError Initialize(lldb::SBDebugger&, unsigned long (*)(void*, lldb::SBInputReader*, lldb::InputReaderAction, char const*, unsigned long), void*, lldb::InputReaderGranularity, char const*, char const*, bool);
- void SetIsDone(bool);
- bool IsActive() const;
+class LLDB_API SBInputReader {
+public:
+ SBInputReader() = default;
+ ~SBInputReader() = default;
+
+ SBError Initialize(lldb::SBDebugger &,
+ unsigned long (*)(void *, lldb::SBInputReader *,
+ lldb::InputReaderAction, char const *,
+ unsigned long),
+ void *, lldb::InputReaderGranularity, char const *,
+ char const *, bool);
+ void SetIsDone(bool);
+ bool IsActive() const;
};
-class LLDB_API SBDebugger
-{
+class LLDB_API SBDebugger {
public:
- SBDebugger();
+ SBDebugger();
+
+ SBDebugger(const lldb::SBDebugger &rhs);
+
+ SBDebugger(const lldb::DebuggerSP &debugger_sp);
+
+ ~SBDebugger();
+
+ lldb::SBDebugger &operator=(const lldb::SBDebugger &rhs);
+
+ static void Initialize();
+
+ static void Terminate();
+
+ // Deprecated, use the one that takes a source_init_files bool.
+ static lldb::SBDebugger Create();
+
+ static lldb::SBDebugger Create(bool source_init_files);
+
+ static lldb::SBDebugger Create(bool source_init_files,
+ lldb::LogOutputCallback log_callback,
+ void *baton);
+
+ static void Destroy(lldb::SBDebugger &debugger);
+
+ static void MemoryPressureDetected();
+
+ bool IsValid() const;
+
+ void Clear();
+
+ void SetAsync(bool b);
+
+ bool GetAsync();
+
+ void SkipLLDBInitFiles(bool b);
+
+ void SkipAppInitFiles(bool b);
+
+ void SetInputFileHandle(FILE *f, bool transfer_ownership);
+
+ void SetOutputFileHandle(FILE *f, bool transfer_ownership);
+
+ void SetErrorFileHandle(FILE *f, bool transfer_ownership);
+
+ FILE *GetInputFileHandle();
+
+ FILE *GetOutputFileHandle();
+
+ FILE *GetErrorFileHandle();
+
+ void SaveInputTerminalState();
+
+ void RestoreInputTerminalState();
+
+ lldb::SBCommandInterpreter GetCommandInterpreter();
+
+ void HandleCommand(const char *command);
+
+ lldb::SBListener GetListener();
- SBDebugger(const lldb::SBDebugger &rhs);
+ void HandleProcessEvent(const lldb::SBProcess &process,
+ const lldb::SBEvent &event, FILE *out, FILE *err);
- SBDebugger(const lldb::DebuggerSP &debugger_sp);
+ lldb::SBTarget CreateTarget(const char *filename, const char *target_triple,
+ const char *platform_name,
+ bool add_dependent_modules, lldb::SBError &error);
- ~SBDebugger();
+ lldb::SBTarget CreateTargetWithFileAndTargetTriple(const char *filename,
+ const char *target_triple);
- lldb::SBDebugger &
- operator = (const lldb::SBDebugger &rhs);
+ lldb::SBTarget CreateTargetWithFileAndArch(const char *filename,
+ const char *archname);
- static void
- Initialize();
-
- static void
- Terminate();
-
- // Deprecated, use the one that takes a source_init_files bool.
- static lldb::SBDebugger
- Create();
+ lldb::SBTarget CreateTarget(const char *filename);
- static lldb::SBDebugger
- Create(bool source_init_files);
+ // Return true if target is deleted from the target list of the debugger.
+ bool DeleteTarget(lldb::SBTarget &target);
- static lldb::SBDebugger
- Create(bool source_init_files, lldb::LogOutputCallback log_callback, void *baton);
+ lldb::SBTarget GetTargetAtIndex(uint32_t idx);
- static void
- Destroy (lldb::SBDebugger &debugger);
+ uint32_t GetIndexOfTarget(lldb::SBTarget target);
- static void
- MemoryPressureDetected ();
+ lldb::SBTarget FindTargetWithProcessID(pid_t pid);
- bool
- IsValid() const;
+ lldb::SBTarget FindTargetWithFileAndArch(const char *filename,
+ const char *arch);
- void
- Clear ();
+ uint32_t GetNumTargets();
- void
- SetAsync (bool b);
-
- bool
- GetAsync ();
+ lldb::SBTarget GetSelectedTarget();
- void
- SkipLLDBInitFiles (bool b);
+ void SetSelectedTarget(SBTarget &target);
- void
- SkipAppInitFiles (bool b);
+ lldb::SBPlatform GetSelectedPlatform();
- void
- SetInputFileHandle (FILE *f, bool transfer_ownership);
+ void SetSelectedPlatform(lldb::SBPlatform &platform);
- void
- SetOutputFileHandle (FILE *f, bool transfer_ownership);
+ lldb::SBSourceManager GetSourceManager();
- void
- SetErrorFileHandle (FILE *f, bool transfer_ownership);
-
- FILE *
- GetInputFileHandle ();
+ // REMOVE: just for a quick fix, need to expose platforms through
+ // SBPlatform from this class.
+ lldb::SBError SetCurrentPlatform(const char *platform_name);
- FILE *
- GetOutputFileHandle ();
+ bool SetCurrentPlatformSDKRoot(const char *sysroot);
- FILE *
- GetErrorFileHandle ();
+ // FIXME: Once we get the set show stuff in place, the driver won't need
+ // an interface to the Set/Get UseExternalEditor.
+ bool SetUseExternalEditor(bool input);
- void
- SaveInputTerminalState();
-
- void
- RestoreInputTerminalState();
+ bool GetUseExternalEditor();
- lldb::SBCommandInterpreter
- GetCommandInterpreter ();
+ bool SetUseColor(bool use_color);
- void
- HandleCommand (const char *command);
+ bool GetUseColor() const;
- lldb::SBListener
- GetListener ();
+ static bool GetDefaultArchitecture(char *arch_name, size_t arch_name_len);
- void
- HandleProcessEvent (const lldb::SBProcess &process,
- const lldb::SBEvent &event,
- FILE *out,
- FILE *err);
+ static bool SetDefaultArchitecture(const char *arch_name);
- lldb::SBTarget
- CreateTarget (const char *filename,
- const char *target_triple,
- const char *platform_name,
- bool add_dependent_modules,
- lldb::SBError& error);
+ lldb::ScriptLanguage GetScriptingLanguage(const char *script_language_name);
- lldb::SBTarget
- CreateTargetWithFileAndTargetTriple (const char *filename,
- const char *target_triple);
+ static const char *GetVersionString();
- lldb::SBTarget
- CreateTargetWithFileAndArch (const char *filename,
- const char *archname);
+ static const char *StateAsCString(lldb::StateType state);
- lldb::SBTarget
- CreateTarget (const char *filename);
-
- // Return true if target is deleted from the target list of the debugger.
- bool
- DeleteTarget (lldb::SBTarget &target);
-
- lldb::SBTarget
- GetTargetAtIndex (uint32_t idx);
-
- uint32_t
- GetIndexOfTarget (lldb::SBTarget target);
+ static bool StateIsRunningState(lldb::StateType state);
- lldb::SBTarget
- FindTargetWithProcessID (pid_t pid);
+ static bool StateIsStoppedState(lldb::StateType state);
- lldb::SBTarget
- FindTargetWithFileAndArch (const char *filename,
- const char *arch);
+ bool EnableLog(const char *channel, const char **categories);
- uint32_t
- GetNumTargets ();
+ void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton);
- lldb::SBTarget
- GetSelectedTarget ();
+ // DEPRECATED
+ void DispatchInput(void *baton, const void *data, size_t data_len);
- void
- SetSelectedTarget (SBTarget& target);
+ void DispatchInput(const void *data, size_t data_len);
- lldb::SBPlatform
- GetSelectedPlatform();
+ void DispatchInputInterrupt();
- void
- SetSelectedPlatform(lldb::SBPlatform &platform);
-
- lldb::SBSourceManager
- GetSourceManager ();
+ void DispatchInputEndOfFile();
- // REMOVE: just for a quick fix, need to expose platforms through
- // SBPlatform from this class.
- lldb::SBError
- SetCurrentPlatform (const char *platform_name);
-
- bool
- SetCurrentPlatformSDKRoot (const char *sysroot);
-
- // FIXME: Once we get the set show stuff in place, the driver won't need
- // an interface to the Set/Get UseExternalEditor.
- bool
- SetUseExternalEditor (bool input);
-
- bool
- GetUseExternalEditor ();
-
- bool
- SetUseColor (bool use_color);
-
- bool
- GetUseColor () const;
-
- static bool
- GetDefaultArchitecture (char *arch_name, size_t arch_name_len);
-
- static bool
- SetDefaultArchitecture (const char *arch_name);
-
- lldb::ScriptLanguage
- GetScriptingLanguage (const char *script_language_name);
-
- static const char *
- GetVersionString ();
-
- static const char *
- StateAsCString (lldb::StateType state);
-
- static bool
- StateIsRunningState (lldb::StateType state);
-
- static bool
- StateIsStoppedState (lldb::StateType state);
-
- bool
- EnableLog (const char *channel, const char **categories);
-
- void
- SetLoggingCallback (lldb::LogOutputCallback log_callback, void *baton);
-
- // DEPRECATED
- void
- DispatchInput (void* baton,
- const void* data,
- size_t data_len);
-
- void
- DispatchInput (const void *data, size_t data_len);
-
- void
- DispatchInputInterrupt ();
-
- void
- DispatchInputEndOfFile ();
-
- void
- PushInputReader (lldb::SBInputReader &reader);
-
- const char *
- GetInstanceName ();
-
- static SBDebugger
- FindDebuggerWithID (int id);
-
- static lldb::SBError
- SetInternalVariable (const char *var_name, const char *value, const char *debugger_instance_name);
-
- static lldb::SBStringList
- GetInternalVariableValue (const char *var_name, const char *debugger_instance_name);
-
- bool
- GetDescription (lldb::SBStream &description);
-
- uint32_t
- GetTerminalWidth () const;
-
- void
- SetTerminalWidth (uint32_t term_width);
-
- lldb::user_id_t
- GetID ();
-
- const char *
- GetPrompt() const;
-
- void
- SetPrompt (const char *prompt);
-
- lldb::ScriptLanguage
- GetScriptLanguage() const;
-
- void
- SetScriptLanguage (lldb::ScriptLanguage script_lang);
-
- bool
- GetCloseInputOnEOF () const;
-
- void
- SetCloseInputOnEOF (bool b);
-
- SBTypeCategory
- GetCategory (const char* category_name);
-
- SBTypeCategory
- GetCategory (lldb::LanguageType lang_type);
-
- SBTypeCategory
- CreateCategory (const char* category_name);
-
- bool
- DeleteCategory (const char* category_name);
-
- uint32_t
- GetNumCategories ();
-
- SBTypeCategory
- GetCategoryAtIndex (uint32_t);
-
- SBTypeCategory
- GetDefaultCategory();
-
- SBTypeFormat
- GetFormatForType (SBTypeNameSpecifier);
+ void PushInputReader(lldb::SBInputReader &reader);
+
+ const char *GetInstanceName();
+
+ static SBDebugger FindDebuggerWithID(int id);
+
+ static lldb::SBError SetInternalVariable(const char *var_name,
+ const char *value,
+ const char *debugger_instance_name);
+
+ static lldb::SBStringList
+ GetInternalVariableValue(const char *var_name,
+ const char *debugger_instance_name);
+
+ bool GetDescription(lldb::SBStream &description);
+
+ uint32_t GetTerminalWidth() const;
+
+ void SetTerminalWidth(uint32_t term_width);
+
+ lldb::user_id_t GetID();
+
+ const char *GetPrompt() const;
+
+ void SetPrompt(const char *prompt);
+
+ lldb::ScriptLanguage GetScriptLanguage() const;
+
+ void SetScriptLanguage(lldb::ScriptLanguage script_lang);
+
+ bool GetCloseInputOnEOF() const;
+
+ void SetCloseInputOnEOF(bool b);
+
+ SBTypeCategory GetCategory(const char *category_name);
+
+ SBTypeCategory GetCategory(lldb::LanguageType lang_type);
+
+ SBTypeCategory CreateCategory(const char *category_name);
+
+ bool DeleteCategory(const char *category_name);
+
+ uint32_t GetNumCategories();
+
+ SBTypeCategory GetCategoryAtIndex(uint32_t);
+
+ SBTypeCategory GetDefaultCategory();
+
+ SBTypeFormat GetFormatForType(SBTypeNameSpecifier);
#ifndef LLDB_DISABLE_PYTHON
- SBTypeSummary
- GetSummaryForType (SBTypeNameSpecifier);
+ SBTypeSummary GetSummaryForType(SBTypeNameSpecifier);
#endif
- SBTypeFilter
- GetFilterForType (SBTypeNameSpecifier);
+ SBTypeFilter GetFilterForType(SBTypeNameSpecifier);
#ifndef LLDB_DISABLE_PYTHON
- SBTypeSynthetic
- GetSyntheticForType (SBTypeNameSpecifier);
+ SBTypeSynthetic GetSyntheticForType(SBTypeNameSpecifier);
#endif
- void
- RunCommandInterpreter (bool auto_handle_events,
- bool spawn_thread);
-
- void
- RunCommandInterpreter (bool auto_handle_events,
- bool spawn_thread,
- SBCommandInterpreterRunOptions &options,
- int &num_errors,
- bool &quit_requested,
- bool &stopped_for_crash);
-
- SBError
- RunREPL (lldb::LanguageType language, const char *repl_options);
+ void RunCommandInterpreter(bool auto_handle_events, bool spawn_thread);
+
+ void RunCommandInterpreter(bool auto_handle_events, bool spawn_thread,
+ SBCommandInterpreterRunOptions &options,
+ int &num_errors, bool &quit_requested,
+ bool &stopped_for_crash);
+
+ SBError RunREPL(lldb::LanguageType language, const char *repl_options);
private:
- friend class SBCommandInterpreter;
- friend class SBInputReader;
- friend class SBListener;
- friend class SBProcess;
- friend class SBSourceManager;
- friend class SBTarget;
-
- lldb::SBTarget
- FindTargetWithLLDBProcess (const lldb::ProcessSP &processSP);
-
- void
- reset (const lldb::DebuggerSP &debugger_sp);
-
- lldb_private::Debugger *
- get () const;
-
- lldb_private::Debugger &
- ref () const;
-
- const lldb::DebuggerSP &
- get_sp () const;
-
- lldb::DebuggerSP m_opaque_sp;
+ friend class SBCommandInterpreter;
+ friend class SBInputReader;
+ friend class SBListener;
+ friend class SBProcess;
+ friend class SBSourceManager;
+ friend class SBTarget;
+
+ lldb::SBTarget FindTargetWithLLDBProcess(const lldb::ProcessSP &processSP);
+
+ void reset(const lldb::DebuggerSP &debugger_sp);
+
+ lldb_private::Debugger *get() const;
+
+ lldb_private::Debugger &ref() const;
+
+ const lldb::DebuggerSP &get_sp() const;
+
+ lldb::DebuggerSP m_opaque_sp;
}; // class SBDebugger
diff --git a/include/lldb/API/SBDeclaration.h b/include/lldb/API/SBDeclaration.h
index 5461a1f15c2e..42cf76963847 100644
--- a/include/lldb/API/SBDeclaration.h
+++ b/include/lldb/API/SBDeclaration.h
@@ -1,4 +1,5 @@
-//===-- SBDeclaration.h -------------------------------------------*- C++ -*-===//
+//===-- SBDeclaration.h -------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,76 +15,56 @@
#include "lldb/API/SBFileSpec.h"
namespace lldb {
-
- class LLDB_API SBDeclaration
- {
- public:
-
- SBDeclaration ();
-
- SBDeclaration (const lldb::SBDeclaration &rhs);
-
- ~SBDeclaration ();
-
- const lldb::SBDeclaration &
- operator = (const lldb::SBDeclaration &rhs);
-
- bool
- IsValid () const;
-
- lldb::SBFileSpec
- GetFileSpec () const;
-
- uint32_t
- GetLine () const;
-
- uint32_t
- GetColumn () const;
-
- void
- SetFileSpec (lldb::SBFileSpec filespec);
-
- void
- SetLine (uint32_t line);
-
- void
- SetColumn (uint32_t column);
-
- bool
- operator == (const lldb::SBDeclaration &rhs) const;
-
- bool
- operator != (const lldb::SBDeclaration &rhs) const;
-
- bool
- GetDescription (lldb::SBStream &description);
-
- protected:
-
- lldb_private::Declaration *
- get ();
-
- private:
- friend class SBValue;
-
- const lldb_private::Declaration *
- operator->() const;
-
- lldb_private::Declaration &
- ref();
-
- const lldb_private::Declaration &
- ref() const;
-
- SBDeclaration (const lldb_private::Declaration *lldb_object_ptr);
-
- void
- SetDeclaration (const lldb_private::Declaration &lldb_object_ref);
-
- std::unique_ptr<lldb_private::Declaration> m_opaque_ap;
- };
-
-
+
+class LLDB_API SBDeclaration {
+public:
+ SBDeclaration();
+
+ SBDeclaration(const lldb::SBDeclaration &rhs);
+
+ ~SBDeclaration();
+
+ const lldb::SBDeclaration &operator=(const lldb::SBDeclaration &rhs);
+
+ bool IsValid() const;
+
+ lldb::SBFileSpec GetFileSpec() const;
+
+ uint32_t GetLine() const;
+
+ uint32_t GetColumn() const;
+
+ void SetFileSpec(lldb::SBFileSpec filespec);
+
+ void SetLine(uint32_t line);
+
+ void SetColumn(uint32_t column);
+
+ bool operator==(const lldb::SBDeclaration &rhs) const;
+
+ bool operator!=(const lldb::SBDeclaration &rhs) const;
+
+ bool GetDescription(lldb::SBStream &description);
+
+protected:
+ lldb_private::Declaration *get();
+
+private:
+ friend class SBValue;
+
+ const lldb_private::Declaration *operator->() const;
+
+ lldb_private::Declaration &ref();
+
+ const lldb_private::Declaration &ref() const;
+
+ SBDeclaration(const lldb_private::Declaration *lldb_object_ptr);
+
+ void SetDeclaration(const lldb_private::Declaration &lldb_object_ref);
+
+ std::unique_ptr<lldb_private::Declaration> m_opaque_ap;
+};
+
} // namespace lldb
#endif // LLDB_SBDeclaration_h_
diff --git a/include/lldb/API/SBDefines.h b/include/lldb/API/SBDefines.h
index 4a95903ec92c..25443c4761af 100644
--- a/include/lldb/API/SBDefines.h
+++ b/include/lldb/API/SBDefines.h
@@ -71,6 +71,7 @@ class LLDB_API SBSection;
class LLDB_API SBSourceManager;
class LLDB_API SBStream;
class LLDB_API SBStringList;
+class LLDB_API SBStructuredData;
class LLDB_API SBSymbol;
class LLDB_API SBSymbolContext;
class LLDB_API SBSymbolContextList;
@@ -95,7 +96,6 @@ class LLDB_API SBValueList;
class LLDB_API SBVariablesOptions;
class LLDB_API SBWatchpoint;
class LLDB_API SBUnixSignals;
-
}
-#endif // LLDB_SBDefines_h_
+#endif // LLDB_SBDefines_h_
diff --git a/include/lldb/API/SBError.h b/include/lldb/API/SBError.h
index afdec0d3826d..7f2f3a6cc5ec 100644
--- a/include/lldb/API/SBError.h
+++ b/include/lldb/API/SBError.h
@@ -16,93 +16,73 @@ namespace lldb {
class LLDB_API SBError {
public:
- SBError ();
+ SBError();
- SBError (const lldb::SBError &rhs);
+ SBError(const lldb::SBError &rhs);
- ~SBError();
+ ~SBError();
- const SBError &
- operator =(const lldb::SBError &rhs);
+ const SBError &operator=(const lldb::SBError &rhs);
- const char *
- GetCString () const;
+ const char *GetCString() const;
- void
- Clear ();
+ void Clear();
- bool
- Fail () const;
+ bool Fail() const;
- bool
- Success () const;
+ bool Success() const;
- uint32_t
- GetError () const;
+ uint32_t GetError() const;
- lldb::ErrorType
- GetType () const;
+ lldb::ErrorType GetType() const;
- void
- SetError (uint32_t err, lldb::ErrorType type);
+ void SetError(uint32_t err, lldb::ErrorType type);
- void
- SetErrorToErrno ();
+ void SetErrorToErrno();
- void
- SetErrorToGenericError ();
+ void SetErrorToGenericError();
- void
- SetErrorString (const char *err_str);
+ void SetErrorString(const char *err_str);
- int
- SetErrorStringWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
+ int SetErrorStringWithFormat(const char *format, ...)
+ __attribute__((format(printf, 2, 3)));
- bool
- IsValid () const;
+ bool IsValid() const;
- bool
- GetDescription (lldb::SBStream &description);
+ bool GetDescription(lldb::SBStream &description);
protected:
+ friend class SBCommandReturnObject;
+ friend class SBData;
+ friend class SBDebugger;
+ friend class SBCommunication;
+ friend class SBHostOS;
+ friend class SBPlatform;
+ friend class SBProcess;
+ friend class SBStructuredData;
+ friend class SBThread;
+ friend class SBTarget;
+ friend class SBValue;
+ friend class SBWatchpoint;
+ friend class SBBreakpoint;
+ friend class SBBreakpointLocation;
- friend class SBCommandReturnObject;
- friend class SBData;
- friend class SBDebugger;
- friend class SBCommunication;
- friend class SBHostOS;
- friend class SBPlatform;
- friend class SBProcess;
- friend class SBThread;
- friend class SBTarget;
- friend class SBValue;
- friend class SBWatchpoint;
- friend class SBBreakpoint;
- friend class SBBreakpointLocation;
+ lldb_private::Error *get();
- lldb_private::Error *
- get();
+ lldb_private::Error *operator->();
- lldb_private::Error *
- operator->();
+ const lldb_private::Error &operator*() const;
- const lldb_private::Error &
- operator*() const;
+ lldb_private::Error &ref();
- lldb_private::Error &
- ref();
-
- void
- SetError (const lldb_private::Error &lldb_error);
+ void SetError(const lldb_private::Error &lldb_error);
private:
- std::unique_ptr<lldb_private::Error> m_opaque_ap;
+ std::unique_ptr<lldb_private::Error> m_opaque_ap;
- void
- CreateIfNeeded ();
+ void CreateIfNeeded();
};
-
} // namespace lldb
#endif // LLDB_SBError_h_
diff --git a/include/lldb/API/SBEvent.h b/include/lldb/API/SBEvent.h
index 975c365f5916..ff15716d853e 100644
--- a/include/lldb/API/SBEvent.h
+++ b/include/lldb/API/SBEvent.h
@@ -15,91 +15,72 @@
#include <stdio.h>
#include <vector>
-
namespace lldb {
class SBBroadcaster;
-class LLDB_API SBEvent
-{
+class LLDB_API SBEvent {
public:
- SBEvent();
+ SBEvent();
+
+ SBEvent(const lldb::SBEvent &rhs);
- SBEvent (const lldb::SBEvent &rhs);
-
- // Make an event that contains a C string.
- SBEvent (uint32_t event, const char *cstr, uint32_t cstr_len);
+ // Make an event that contains a C string.
+ SBEvent(uint32_t event, const char *cstr, uint32_t cstr_len);
- SBEvent (lldb::EventSP &event_sp);
+ SBEvent(lldb::EventSP &event_sp);
- SBEvent (lldb_private::Event *event_sp);
+ SBEvent(lldb_private::Event *event_sp);
- ~SBEvent();
+ ~SBEvent();
- const SBEvent &
- operator = (const lldb::SBEvent &rhs);
+ const SBEvent &operator=(const lldb::SBEvent &rhs);
- bool
- IsValid() const;
+ bool IsValid() const;
- const char *
- GetDataFlavor ();
+ const char *GetDataFlavor();
- uint32_t
- GetType () const;
+ uint32_t GetType() const;
- lldb::SBBroadcaster
- GetBroadcaster () const;
+ lldb::SBBroadcaster GetBroadcaster() const;
- const char *
- GetBroadcasterClass () const;
+ const char *GetBroadcasterClass() const;
- bool
- BroadcasterMatchesPtr (const lldb::SBBroadcaster *broadcaster);
+ bool BroadcasterMatchesPtr(const lldb::SBBroadcaster *broadcaster);
- bool
- BroadcasterMatchesRef (const lldb::SBBroadcaster &broadcaster);
+ bool BroadcasterMatchesRef(const lldb::SBBroadcaster &broadcaster);
- void
- Clear();
+ void Clear();
- static const char *
- GetCStringFromEvent (const lldb::SBEvent &event);
+ static const char *GetCStringFromEvent(const lldb::SBEvent &event);
- bool
- GetDescription (lldb::SBStream &description);
+ bool GetDescription(lldb::SBStream &description);
- bool
- GetDescription (lldb::SBStream &description) const;
+ bool GetDescription(lldb::SBStream &description) const;
protected:
- friend class SBListener;
- friend class SBBroadcaster;
- friend class SBBreakpoint;
- friend class SBDebugger;
- friend class SBProcess;
- friend class SBTarget;
- friend class SBThread;
- friend class SBWatchpoint;
+ friend class SBListener;
+ friend class SBBroadcaster;
+ friend class SBBreakpoint;
+ friend class SBDebugger;
+ friend class SBProcess;
+ friend class SBTarget;
+ friend class SBThread;
+ friend class SBWatchpoint;
- lldb::EventSP &
- GetSP () const;
+ lldb::EventSP &GetSP() const;
- void
- reset (lldb::EventSP &event_sp);
+ void reset(lldb::EventSP &event_sp);
- void
- reset (lldb_private::Event* event);
+ void reset(lldb_private::Event *event);
- lldb_private::Event *
- get () const;
+ lldb_private::Event *get() const;
private:
-
- mutable lldb::EventSP m_event_sp;
- mutable lldb_private::Event *m_opaque_ptr;
+ mutable lldb::EventSP m_event_sp;
+ mutable lldb_private::Event *m_opaque_ptr;
};
} // namespace lldb
-#endif // LLDB_SBEvent_h_
+#endif // LLDB_SBEvent_h_
diff --git a/include/lldb/API/SBExecutionContext.h b/include/lldb/API/SBExecutionContext.h
index 1d64497ae867..c19d539bc80a 100644
--- a/include/lldb/API/SBExecutionContext.h
+++ b/include/lldb/API/SBExecutionContext.h
@@ -1,4 +1,5 @@
-//===-- SBExecutionContext.h -----------------------------------------*- C++ -*-===//
+//===-- SBExecutionContext.h -----------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -15,60 +16,51 @@
#include <stdio.h>
#include <vector>
-
namespace lldb {
-
-class LLDB_API SBExecutionContext
-{
-friend class SBCommandInterpreter;
+
+class LLDB_API SBExecutionContext {
+ friend class SBCommandInterpreter;
public:
- SBExecutionContext();
-
- SBExecutionContext (const lldb::SBExecutionContext &rhs);
-
- SBExecutionContext (lldb::ExecutionContextRefSP exe_ctx_ref_sp);
-
- SBExecutionContext (const lldb::SBTarget &target);
-
- SBExecutionContext (const lldb::SBProcess &process);
-
- SBExecutionContext (lldb::SBThread thread); // can't be a const& because SBThread::get() isn't itself a const function
-
- SBExecutionContext (const lldb::SBFrame &frame);
-
- ~SBExecutionContext();
-
- const SBExecutionContext &
- operator = (const lldb::SBExecutionContext &rhs);
-
- SBTarget
- GetTarget () const;
-
- SBProcess
- GetProcess () const;
-
- SBThread
- GetThread () const;
-
- SBFrame
- GetFrame () const;
-
+ SBExecutionContext();
+
+ SBExecutionContext(const lldb::SBExecutionContext &rhs);
+
+ SBExecutionContext(lldb::ExecutionContextRefSP exe_ctx_ref_sp);
+
+ SBExecutionContext(const lldb::SBTarget &target);
+
+ SBExecutionContext(const lldb::SBProcess &process);
+
+ SBExecutionContext(lldb::SBThread thread); // can't be a const& because
+ // SBThread::get() isn't itself a
+ // const function
+
+ SBExecutionContext(const lldb::SBFrame &frame);
+
+ ~SBExecutionContext();
+
+ const SBExecutionContext &operator=(const lldb::SBExecutionContext &rhs);
+
+ SBTarget GetTarget() const;
+
+ SBProcess GetProcess() const;
+
+ SBThread GetThread() const;
+
+ SBFrame GetFrame() const;
+
protected:
- ExecutionContextRefSP &
- GetSP () const;
-
- void
- reset (lldb::ExecutionContextRefSP &event_sp);
-
- lldb_private::ExecutionContextRef *
- get () const;
-
+ ExecutionContextRefSP &GetSP() const;
+
+ void reset(lldb::ExecutionContextRefSP &event_sp);
+
+ lldb_private::ExecutionContextRef *get() const;
+
private:
-
- mutable lldb::ExecutionContextRefSP m_exe_ctx_sp;
+ mutable lldb::ExecutionContextRefSP m_exe_ctx_sp;
};
-
+
} // namespace lldb
-#endif // LLDB_SBExecutionContext_h_
+#endif // LLDB_SBExecutionContext_h_
diff --git a/include/lldb/API/SBExpressionOptions.h b/include/lldb/API/SBExpressionOptions.h
index 051ed7220ac8..370811d0c355 100644
--- a/include/lldb/API/SBExpressionOptions.h
+++ b/include/lldb/API/SBExpressionOptions.h
@@ -16,133 +16,100 @@
namespace lldb {
-
-class LLDB_API SBExpressionOptions
-{
+class LLDB_API SBExpressionOptions {
public:
- SBExpressionOptions();
-
- SBExpressionOptions (const lldb::SBExpressionOptions &rhs);
-
- ~SBExpressionOptions();
-
- const SBExpressionOptions &
- operator = (const lldb::SBExpressionOptions &rhs);
-
- bool
- GetCoerceResultToId () const;
-
- void
- SetCoerceResultToId (bool coerce = true);
-
- bool
- GetUnwindOnError () const;
-
- void
- SetUnwindOnError (bool unwind = true);
-
- bool
- GetIgnoreBreakpoints () const;
-
- void
- SetIgnoreBreakpoints (bool ignore = true);
-
- lldb::DynamicValueType
- GetFetchDynamicValue () const;
-
- void
- SetFetchDynamicValue (lldb::DynamicValueType dynamic = lldb::eDynamicCanRunTarget);
-
- uint32_t
- GetTimeoutInMicroSeconds () const;
-
- // Set the timeout for the expression, 0 means wait forever.
- void
- SetTimeoutInMicroSeconds (uint32_t timeout = 0);
-
- uint32_t
- GetOneThreadTimeoutInMicroSeconds () const;
-
- // Set the timeout for running on one thread, 0 means use the default behavior.
- // If you set this higher than the overall timeout, you'll get an error when you
- // try to run the expression.
- void
- SetOneThreadTimeoutInMicroSeconds (uint32_t timeout = 0);
-
- bool
- GetTryAllThreads () const;
-
- void
- SetTryAllThreads (bool run_others = true);
-
- bool
- GetStopOthers() const;
-
- void
- SetStopOthers(bool stop_others = true);
-
- bool
- GetTrapExceptions () const;
-
- void
- SetTrapExceptions (bool trap_exceptions = true);
-
- void
- SetLanguage (lldb::LanguageType language);
-
- void
- SetCancelCallback (lldb::ExpressionCancelCallback callback, void *baton);
-
- bool
- GetGenerateDebugInfo ();
-
- void
- SetGenerateDebugInfo (bool b = true);
-
- bool
- GetSuppressPersistentResult ();
-
- void
- SetSuppressPersistentResult (bool b = false);
-
- const char *
- GetPrefix () const;
-
- void
- SetPrefix (const char *prefix);
-
- void
- SetAutoApplyFixIts(bool b = true);
-
- bool
- GetAutoApplyFixIts();
-
- bool
- GetTopLevel ();
-
- void
- SetTopLevel (bool b = true);
+ SBExpressionOptions();
+ SBExpressionOptions(const lldb::SBExpressionOptions &rhs);
-protected:
+ ~SBExpressionOptions();
+
+ const SBExpressionOptions &operator=(const lldb::SBExpressionOptions &rhs);
+
+ bool GetCoerceResultToId() const;
+
+ void SetCoerceResultToId(bool coerce = true);
+
+ bool GetUnwindOnError() const;
+
+ void SetUnwindOnError(bool unwind = true);
+
+ bool GetIgnoreBreakpoints() const;
+
+ void SetIgnoreBreakpoints(bool ignore = true);
+
+ lldb::DynamicValueType GetFetchDynamicValue() const;
+
+ void SetFetchDynamicValue(
+ lldb::DynamicValueType dynamic = lldb::eDynamicCanRunTarget);
+
+ uint32_t GetTimeoutInMicroSeconds() const;
+
+ // Set the timeout for the expression, 0 means wait forever.
+ void SetTimeoutInMicroSeconds(uint32_t timeout = 0);
+
+ uint32_t GetOneThreadTimeoutInMicroSeconds() const;
+
+ // Set the timeout for running on one thread, 0 means use the default
+ // behavior.
+ // If you set this higher than the overall timeout, you'll get an error when
+ // you
+ // try to run the expression.
+ void SetOneThreadTimeoutInMicroSeconds(uint32_t timeout = 0);
+
+ bool GetTryAllThreads() const;
+
+ void SetTryAllThreads(bool run_others = true);
- SBExpressionOptions (lldb_private::EvaluateExpressionOptions &expression_options);
+ bool GetStopOthers() const;
+
+ void SetStopOthers(bool stop_others = true);
+
+ bool GetTrapExceptions() const;
+
+ void SetTrapExceptions(bool trap_exceptions = true);
+
+ void SetLanguage(lldb::LanguageType language);
+
+ void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton);
+
+ bool GetGenerateDebugInfo();
+
+ void SetGenerateDebugInfo(bool b = true);
+
+ bool GetSuppressPersistentResult();
+
+ void SetSuppressPersistentResult(bool b = false);
+
+ const char *GetPrefix() const;
+
+ void SetPrefix(const char *prefix);
+
+ void SetAutoApplyFixIts(bool b = true);
+
+ bool GetAutoApplyFixIts();
+
+ bool GetTopLevel();
+
+ void SetTopLevel(bool b = true);
+
+protected:
+ SBExpressionOptions(
+ lldb_private::EvaluateExpressionOptions &expression_options);
- lldb_private::EvaluateExpressionOptions *
- get () const;
+ lldb_private::EvaluateExpressionOptions *get() const;
- lldb_private::EvaluateExpressionOptions &
- ref () const;
+ lldb_private::EvaluateExpressionOptions &ref() const;
- friend class SBFrame;
- friend class SBValue;
- friend class SBTarget;
+ friend class SBFrame;
+ friend class SBValue;
+ friend class SBTarget;
private:
- // This auto_pointer is made in the constructor and is always valid.
- mutable std::unique_ptr<lldb_private::EvaluateExpressionOptions> m_opaque_ap;
+ // This auto_pointer is made in the constructor and is always valid.
+ mutable std::unique_ptr<lldb_private::EvaluateExpressionOptions> m_opaque_ap;
};
} // namespace lldb
-#endif // LLDB_SBExpressionOptions_h_
+#endif // LLDB_SBExpressionOptions_h_
diff --git a/include/lldb/API/SBFileSpec.h b/include/lldb/API/SBFileSpec.h
index 2f9d6bab89f3..a31d95abb493 100644
--- a/include/lldb/API/SBFileSpec.h
+++ b/include/lldb/API/SBFileSpec.h
@@ -14,93 +14,75 @@
namespace lldb {
-class LLDB_API SBFileSpec
-{
+class LLDB_API SBFileSpec {
public:
- SBFileSpec ();
+ SBFileSpec();
- SBFileSpec (const lldb::SBFileSpec &rhs);
+ SBFileSpec(const lldb::SBFileSpec &rhs);
- SBFileSpec (const char *path);// Deprecated, use SBFileSpec (const char *path, bool resolve)
+ SBFileSpec(const char *path); // Deprecated, use SBFileSpec (const char *path,
+ // bool resolve)
- SBFileSpec (const char *path, bool resolve);
+ SBFileSpec(const char *path, bool resolve);
- ~SBFileSpec ();
+ ~SBFileSpec();
- const SBFileSpec &
- operator = (const lldb::SBFileSpec &rhs);
+ const SBFileSpec &operator=(const lldb::SBFileSpec &rhs);
- bool
- IsValid() const;
+ bool IsValid() const;
- bool
- Exists () const;
+ bool Exists() const;
- bool
- ResolveExecutableLocation ();
+ bool ResolveExecutableLocation();
- const char *
- GetFilename() const;
+ const char *GetFilename() const;
- const char *
- GetDirectory() const;
+ const char *GetDirectory() const;
- void
- SetFilename(const char *filename);
-
- void
- SetDirectory(const char *directory);
+ void SetFilename(const char *filename);
- uint32_t
- GetPath (char *dst_path, size_t dst_len) const;
+ void SetDirectory(const char *directory);
- static int
- ResolvePath (const char *src_path, char *dst_path, size_t dst_len);
+ uint32_t GetPath(char *dst_path, size_t dst_len) const;
- bool
- GetDescription (lldb::SBStream &description) const;
+ static int ResolvePath(const char *src_path, char *dst_path, size_t dst_len);
- void
- AppendPathComponent (const char *file_or_directory);
+ bool GetDescription(lldb::SBStream &description) const;
+
+ void AppendPathComponent(const char *file_or_directory);
private:
- friend class SBAttachInfo;
- friend class SBBlock;
- friend class SBCommandInterpreter;
- friend class SBCompileUnit;
- friend class SBDeclaration;
- friend class SBFileSpecList;
- friend class SBHostOS;
- friend class SBLaunchInfo;
- friend class SBLineEntry;
- friend class SBModule;
- friend class SBModuleSpec;
- friend class SBPlatform;
- friend class SBProcess;
- friend class SBSourceManager;
- friend class SBThread;
- friend class SBTarget;
-
- SBFileSpec (const lldb_private::FileSpec& fspec);
-
- void
- SetFileSpec (const lldb_private::FileSpec& fspec);
-
- const lldb_private::FileSpec *
- operator->() const;
-
- const lldb_private::FileSpec *
- get() const;
-
- const lldb_private::FileSpec &
- operator*() const;
-
- const lldb_private::FileSpec &
- ref() const;
-
- std::unique_ptr<lldb_private::FileSpec> m_opaque_ap;
-};
+ friend class SBAttachInfo;
+ friend class SBBlock;
+ friend class SBCommandInterpreter;
+ friend class SBCompileUnit;
+ friend class SBDeclaration;
+ friend class SBFileSpecList;
+ friend class SBHostOS;
+ friend class SBLaunchInfo;
+ friend class SBLineEntry;
+ friend class SBModule;
+ friend class SBModuleSpec;
+ friend class SBPlatform;
+ friend class SBProcess;
+ friend class SBSourceManager;
+ friend class SBThread;
+ friend class SBTarget;
+
+ SBFileSpec(const lldb_private::FileSpec &fspec);
+
+ void SetFileSpec(const lldb_private::FileSpec &fspec);
+
+ const lldb_private::FileSpec *operator->() const;
+ const lldb_private::FileSpec *get() const;
+
+ const lldb_private::FileSpec &operator*() const;
+
+ const lldb_private::FileSpec &ref() const;
+
+ std::unique_ptr<lldb_private::FileSpec> m_opaque_ap;
+};
} // namespace lldb
diff --git a/include/lldb/API/SBFileSpecList.h b/include/lldb/API/SBFileSpecList.h
index ff429a1815be..97f843adbb5f 100644
--- a/include/lldb/API/SBFileSpecList.h
+++ b/include/lldb/API/SBFileSpecList.h
@@ -1,4 +1,5 @@
-//===-- SBFileSpecList.h --------------------------------------------*- C++ -*-===//
+//===-- SBFileSpecList.h --------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,58 +15,43 @@
namespace lldb {
-class LLDB_API SBFileSpecList
-{
+class LLDB_API SBFileSpecList {
public:
- SBFileSpecList ();
-
- SBFileSpecList (const lldb::SBFileSpecList &rhs);
-
- ~SBFileSpecList ();
-
- const SBFileSpecList &
- operator = (const lldb::SBFileSpecList &rhs);
-
- uint32_t
- GetSize () const;
-
- bool
- GetDescription (SBStream &description) const;
-
- void
- Append (const SBFileSpec &sb_file);
-
- bool
- AppendIfUnique (const SBFileSpec &sb_file);
-
- void
- Clear();
-
- uint32_t
- FindFileIndex (uint32_t idx, const SBFileSpec &sb_file, bool full);
-
- const SBFileSpec
- GetFileSpecAtIndex (uint32_t idx) const;
+ SBFileSpecList();
-private:
+ SBFileSpecList(const lldb::SBFileSpecList &rhs);
-friend class SBTarget;
+ ~SBFileSpecList();
- const lldb_private::FileSpecList *
- operator->() const;
+ const SBFileSpecList &operator=(const lldb::SBFileSpecList &rhs);
- const lldb_private::FileSpecList *
- get() const;
+ uint32_t GetSize() const;
- const lldb_private::FileSpecList &
- operator*() const;
+ bool GetDescription(SBStream &description) const;
- const lldb_private::FileSpecList &
- ref() const;
+ void Append(const SBFileSpec &sb_file);
- std::unique_ptr<lldb_private::FileSpecList> m_opaque_ap;
-};
+ bool AppendIfUnique(const SBFileSpec &sb_file);
+
+ void Clear();
+
+ uint32_t FindFileIndex(uint32_t idx, const SBFileSpec &sb_file, bool full);
+
+ const SBFileSpec GetFileSpecAtIndex(uint32_t idx) const;
+
+private:
+ friend class SBTarget;
+
+ const lldb_private::FileSpecList *operator->() const;
+
+ const lldb_private::FileSpecList *get() const;
+ const lldb_private::FileSpecList &operator*() const;
+
+ const lldb_private::FileSpecList &ref() const;
+
+ std::unique_ptr<lldb_private::FileSpecList> m_opaque_ap;
+};
} // namespace lldb
diff --git a/include/lldb/API/SBFrame.h b/include/lldb/API/SBFrame.h
index 3177b0cc5a69..be5c0920aee5 100644
--- a/include/lldb/API/SBFrame.h
+++ b/include/lldb/API/SBFrame.h
@@ -15,227 +15,182 @@
namespace lldb {
-class LLDB_API SBFrame
-{
+class LLDB_API SBFrame {
public:
- SBFrame ();
-
- SBFrame (const lldb::SBFrame &rhs);
-
- const lldb::SBFrame &
- operator =(const lldb::SBFrame &rhs);
-
- ~SBFrame();
-
- bool
- IsEqual (const lldb::SBFrame &that) const;
-
- bool
- IsValid() const;
-
- uint32_t
- GetFrameID () const;
-
- lldb::addr_t
- GetCFA () const;
-
- lldb::addr_t
- GetPC () const;
-
- bool
- SetPC (lldb::addr_t new_pc);
-
- lldb::addr_t
- GetSP () const;
-
- lldb::addr_t
- GetFP () const;
-
- lldb::SBAddress
- GetPCAddress () const;
-
- lldb::SBSymbolContext
- GetSymbolContext (uint32_t resolve_scope) const;
-
- lldb::SBModule
- GetModule () const;
-
- lldb::SBCompileUnit
- GetCompileUnit () const;
-
- lldb::SBFunction
- GetFunction () const;
-
- lldb::SBSymbol
- GetSymbol () const;
-
- /// Gets the deepest block that contains the frame PC.
- ///
- /// See also GetFrameBlock().
- lldb::SBBlock
- GetBlock () const;
-
- /// Get the appropriate function name for this frame. Inlined functions in
- /// LLDB are represented by Blocks that have inlined function information, so
- /// just looking at the SBFunction or SBSymbol for a frame isn't enough.
- /// This function will return the appropriate function, symbol or inlined
- /// function name for the frame.
- ///
- /// This function returns:
- /// - the name of the inlined function (if there is one)
- /// - the name of the concrete function (if there is one)
- /// - the name of the symbol (if there is one)
- /// - NULL
- ///
- /// See also IsInlined().
- const char *
- GetFunctionName();
-
- // Get an appropriate function name for this frame that is suitable for display to a user
- const char *
- GetDisplayFunctionName ();
-
- const char *
- GetFunctionName() const;
-
- /// Return true if this frame represents an inlined function.
- ///
- /// See also GetFunctionName().
- bool
- IsInlined();
-
- bool
- IsInlined() const;
-
- /// The version that doesn't supply a 'use_dynamic' value will use the
- /// target's default.
- lldb::SBValue
- EvaluateExpression (const char *expr);
-
- lldb::SBValue
- EvaluateExpression (const char *expr, lldb::DynamicValueType use_dynamic);
-
- lldb::SBValue
- EvaluateExpression (const char *expr, lldb::DynamicValueType use_dynamic, bool unwind_on_error);
-
- lldb::SBValue
- EvaluateExpression (const char *expr, const SBExpressionOptions &options);
-
- /// Gets the lexical block that defines the stack frame. Another way to think
- /// of this is it will return the block that contains all of the variables
- /// for a stack frame. Inlined functions are represented as SBBlock objects
- /// that have inlined function information: the name of the inlined function,
- /// where it was called from. The block that is returned will be the first
- /// block at or above the block for the PC (SBFrame::GetBlock()) that defines
- /// the scope of the frame. When a function contains no inlined functions,
- /// this will be the top most lexical block that defines the function.
- /// When a function has inlined functions and the PC is currently
- /// in one of those inlined functions, this method will return the inlined
- /// block that defines this frame. If the PC isn't currently in an inlined
- /// function, the lexical block that defines the function is returned.
- lldb::SBBlock
- GetFrameBlock () const;
-
- lldb::SBLineEntry
- GetLineEntry () const;
-
- lldb::SBThread
- GetThread () const;
-
- const char *
- Disassemble () const;
-
- void
- Clear();
-
- bool
- operator == (const lldb::SBFrame &rhs) const;
-
- bool
- operator != (const lldb::SBFrame &rhs) const;
-
- /// The version that doesn't supply a 'use_dynamic' value will use the
- /// target's default.
- lldb::SBValueList
- GetVariables (bool arguments,
- bool locals,
- bool statics,
- bool in_scope_only);
-
- lldb::SBValueList
- GetVariables (bool arguments,
- bool locals,
- bool statics,
- bool in_scope_only,
- lldb::DynamicValueType use_dynamic);
-
- lldb::SBValueList
- GetVariables (const lldb::SBVariablesOptions& options);
-
- lldb::SBValueList
- GetRegisters ();
-
- lldb::SBValue
- FindRegister (const char *name);
-
- /// The version that doesn't supply a 'use_dynamic' value will use the
- /// target's default.
- lldb::SBValue
- FindVariable (const char *var_name);
-
- lldb::SBValue
- FindVariable (const char *var_name, lldb::DynamicValueType use_dynamic);
-
- // Find a value for a variable expression path like "rect.origin.x" or
- // "pt_ptr->x", "*self", "*this->obj_ptr". The returned value is _not_
- // and expression result and is not a constant object like
- // SBFrame::EvaluateExpression(...) returns, but a child object of
- // the variable value.
- lldb::SBValue
- GetValueForVariablePath (const char *var_expr_cstr,
- DynamicValueType use_dynamic);
-
- /// The version that doesn't supply a 'use_dynamic' value will use the
- /// target's default.
- lldb::SBValue
- GetValueForVariablePath (const char *var_path);
-
- /// Find variables, register sets, registers, or persistent variables using
- /// the frame as the scope.
- ///
- /// NB. This function does not look up ivars in the function object pointer.
- /// To do that use GetValueForVariablePath.
- ///
- /// The version that doesn't supply a 'use_dynamic' value will use the
- /// target's default.
- lldb::SBValue
- FindValue (const char *name, ValueType value_type);
-
- lldb::SBValue
- FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic);
-
- bool
- GetDescription (lldb::SBStream &description);
-
- SBFrame (const lldb::StackFrameSP &lldb_object_sp);
+ SBFrame();
-protected:
+ SBFrame(const lldb::SBFrame &rhs);
+
+ const lldb::SBFrame &operator=(const lldb::SBFrame &rhs);
+
+ ~SBFrame();
+
+ bool IsEqual(const lldb::SBFrame &that) const;
+
+ bool IsValid() const;
+
+ uint32_t GetFrameID() const;
+
+ lldb::addr_t GetCFA() const;
+
+ lldb::addr_t GetPC() const;
+
+ bool SetPC(lldb::addr_t new_pc);
+
+ lldb::addr_t GetSP() const;
+
+ lldb::addr_t GetFP() const;
+
+ lldb::SBAddress GetPCAddress() const;
+
+ lldb::SBSymbolContext GetSymbolContext(uint32_t resolve_scope) const;
+
+ lldb::SBModule GetModule() const;
+
+ lldb::SBCompileUnit GetCompileUnit() const;
+
+ lldb::SBFunction GetFunction() const;
+
+ lldb::SBSymbol GetSymbol() const;
+
+ /// Gets the deepest block that contains the frame PC.
+ ///
+ /// See also GetFrameBlock().
+ lldb::SBBlock GetBlock() const;
+
+ /// Get the appropriate function name for this frame. Inlined functions in
+ /// LLDB are represented by Blocks that have inlined function information, so
+ /// just looking at the SBFunction or SBSymbol for a frame isn't enough.
+ /// This function will return the appropriate function, symbol or inlined
+ /// function name for the frame.
+ ///
+ /// This function returns:
+ /// - the name of the inlined function (if there is one)
+ /// - the name of the concrete function (if there is one)
+ /// - the name of the symbol (if there is one)
+ /// - NULL
+ ///
+ /// See also IsInlined().
+ const char *GetFunctionName();
+
+ // Get an appropriate function name for this frame that is suitable for
+ // display to a user
+ const char *GetDisplayFunctionName();
+
+ const char *GetFunctionName() const;
+
+ /// Return true if this frame represents an inlined function.
+ ///
+ /// See also GetFunctionName().
+ bool IsInlined();
+
+ bool IsInlined() const;
+
+ /// The version that doesn't supply a 'use_dynamic' value will use the
+ /// target's default.
+ lldb::SBValue EvaluateExpression(const char *expr);
- friend class SBBlock;
- friend class SBExecutionContext;
- friend class SBInstruction;
- friend class SBThread;
- friend class SBValue;
+ lldb::SBValue EvaluateExpression(const char *expr,
+ lldb::DynamicValueType use_dynamic);
+
+ lldb::SBValue EvaluateExpression(const char *expr,
+ lldb::DynamicValueType use_dynamic,
+ bool unwind_on_error);
+
+ lldb::SBValue EvaluateExpression(const char *expr,
+ const SBExpressionOptions &options);
+
+ /// Gets the lexical block that defines the stack frame. Another way to think
+ /// of this is it will return the block that contains all of the variables
+ /// for a stack frame. Inlined functions are represented as SBBlock objects
+ /// that have inlined function information: the name of the inlined function,
+ /// where it was called from. The block that is returned will be the first
+ /// block at or above the block for the PC (SBFrame::GetBlock()) that defines
+ /// the scope of the frame. When a function contains no inlined functions,
+ /// this will be the top most lexical block that defines the function.
+ /// When a function has inlined functions and the PC is currently
+ /// in one of those inlined functions, this method will return the inlined
+ /// block that defines this frame. If the PC isn't currently in an inlined
+ /// function, the lexical block that defines the function is returned.
+ lldb::SBBlock GetFrameBlock() const;
+
+ lldb::SBLineEntry GetLineEntry() const;
+
+ lldb::SBThread GetThread() const;
+
+ const char *Disassemble() const;
+
+ void Clear();
+
+ bool operator==(const lldb::SBFrame &rhs) const;
+
+ bool operator!=(const lldb::SBFrame &rhs) const;
+
+ /// The version that doesn't supply a 'use_dynamic' value will use the
+ /// target's default.
+ lldb::SBValueList GetVariables(bool arguments, bool locals, bool statics,
+ bool in_scope_only);
+
+ lldb::SBValueList GetVariables(bool arguments, bool locals, bool statics,
+ bool in_scope_only,
+ lldb::DynamicValueType use_dynamic);
+
+ lldb::SBValueList GetVariables(const lldb::SBVariablesOptions &options);
+
+ lldb::SBValueList GetRegisters();
+
+ lldb::SBValue FindRegister(const char *name);
+
+ /// The version that doesn't supply a 'use_dynamic' value will use the
+ /// target's default.
+ lldb::SBValue FindVariable(const char *var_name);
+
+ lldb::SBValue FindVariable(const char *var_name,
+ lldb::DynamicValueType use_dynamic);
+
+ // Find a value for a variable expression path like "rect.origin.x" or
+ // "pt_ptr->x", "*self", "*this->obj_ptr". The returned value is _not_
+ // and expression result and is not a constant object like
+ // SBFrame::EvaluateExpression(...) returns, but a child object of
+ // the variable value.
+ lldb::SBValue GetValueForVariablePath(const char *var_expr_cstr,
+ DynamicValueType use_dynamic);
+
+ /// The version that doesn't supply a 'use_dynamic' value will use the
+ /// target's default.
+ lldb::SBValue GetValueForVariablePath(const char *var_path);
+
+ /// Find variables, register sets, registers, or persistent variables using
+ /// the frame as the scope.
+ ///
+ /// NB. This function does not look up ivars in the function object pointer.
+ /// To do that use GetValueForVariablePath.
+ ///
+ /// The version that doesn't supply a 'use_dynamic' value will use the
+ /// target's default.
+ lldb::SBValue FindValue(const char *name, ValueType value_type);
+
+ lldb::SBValue FindValue(const char *name, ValueType value_type,
+ lldb::DynamicValueType use_dynamic);
+
+ bool GetDescription(lldb::SBStream &description);
+
+ SBFrame(const lldb::StackFrameSP &lldb_object_sp);
+
+protected:
+ friend class SBBlock;
+ friend class SBExecutionContext;
+ friend class SBInstruction;
+ friend class SBThread;
+ friend class SBValue;
- lldb::StackFrameSP
- GetFrameSP() const;
+ lldb::StackFrameSP GetFrameSP() const;
- void
- SetFrameSP (const lldb::StackFrameSP &lldb_object_sp);
+ void SetFrameSP(const lldb::StackFrameSP &lldb_object_sp);
- lldb::ExecutionContextRefSP m_opaque_sp;
+ lldb::ExecutionContextRefSP m_opaque_sp;
};
} // namespace lldb
-#endif // LLDB_SBFrame_h_
+#endif // LLDB_SBFrame_h_
diff --git a/include/lldb/API/SBFunction.h b/include/lldb/API/SBFunction.h
index f76c77c44e3f..23da02102cfb 100644
--- a/include/lldb/API/SBFunction.h
+++ b/include/lldb/API/SBFunction.h
@@ -10,96 +10,72 @@
#ifndef LLDB_SBFunction_h_
#define LLDB_SBFunction_h_
-#include "lldb/API/SBDefines.h"
#include "lldb/API/SBAddress.h"
+#include "lldb/API/SBDefines.h"
#include "lldb/API/SBInstructionList.h"
namespace lldb {
-class LLDB_API SBFunction
-{
+class LLDB_API SBFunction {
public:
+ SBFunction();
- SBFunction ();
+ SBFunction(const lldb::SBFunction &rhs);
- SBFunction (const lldb::SBFunction &rhs);
+ const lldb::SBFunction &operator=(const lldb::SBFunction &rhs);
- const lldb::SBFunction &
- operator = (const lldb::SBFunction &rhs);
+ ~SBFunction();
- ~SBFunction ();
+ bool IsValid() const;
- bool
- IsValid () const;
+ const char *GetName() const;
- const char *
- GetName() const;
+ const char *GetDisplayName() const;
- const char *
- GetDisplayName() const;
-
- const char *
- GetMangledName () const;
+ const char *GetMangledName() const;
- lldb::SBInstructionList
- GetInstructions (lldb::SBTarget target);
+ lldb::SBInstructionList GetInstructions(lldb::SBTarget target);
- lldb::SBInstructionList
- GetInstructions (lldb::SBTarget target, const char *flavor);
+ lldb::SBInstructionList GetInstructions(lldb::SBTarget target,
+ const char *flavor);
- lldb::SBAddress
- GetStartAddress ();
+ lldb::SBAddress GetStartAddress();
- lldb::SBAddress
- GetEndAddress ();
+ lldb::SBAddress GetEndAddress();
- const char *
- GetArgumentName (uint32_t arg_idx);
+ const char *GetArgumentName(uint32_t arg_idx);
- uint32_t
- GetPrologueByteSize ();
+ uint32_t GetPrologueByteSize();
- lldb::SBType
- GetType ();
+ lldb::SBType GetType();
- lldb::SBBlock
- GetBlock ();
-
- lldb::LanguageType
- GetLanguage ();
+ lldb::SBBlock GetBlock();
- bool
- GetIsOptimized ();
+ lldb::LanguageType GetLanguage();
- bool
- operator == (const lldb::SBFunction &rhs) const;
+ bool GetIsOptimized();
- bool
- operator != (const lldb::SBFunction &rhs) const;
+ bool operator==(const lldb::SBFunction &rhs) const;
- bool
- GetDescription (lldb::SBStream &description);
+ bool operator!=(const lldb::SBFunction &rhs) const;
-protected:
+ bool GetDescription(lldb::SBStream &description);
- lldb_private::Function *
- get ();
+protected:
+ lldb_private::Function *get();
- void
- reset (lldb_private::Function *lldb_object_ptr);
+ void reset(lldb_private::Function *lldb_object_ptr);
private:
- friend class SBAddress;
- friend class SBFrame;
- friend class SBSymbolContext;
-
- SBFunction (lldb_private::Function *lldb_object_ptr);
+ friend class SBAddress;
+ friend class SBFrame;
+ friend class SBSymbolContext;
+ SBFunction(lldb_private::Function *lldb_object_ptr);
- lldb_private::Function *m_opaque_ptr;
+ lldb_private::Function *m_opaque_ptr;
};
-
} // namespace lldb
#endif // LLDB_SBFunction_h_
diff --git a/include/lldb/API/SBHostOS.h b/include/lldb/API/SBHostOS.h
index a3675856a136..1671917f865c 100644
--- a/include/lldb/API/SBHostOS.h
+++ b/include/lldb/API/SBHostOS.h
@@ -15,49 +15,31 @@
namespace lldb {
-class LLDB_API SBHostOS
-{
+class LLDB_API SBHostOS {
public:
+ static lldb::SBFileSpec GetProgramFileSpec();
- static lldb::SBFileSpec
- GetProgramFileSpec ();
-
- static lldb::SBFileSpec
- GetLLDBPythonPath ();
+ static lldb::SBFileSpec GetLLDBPythonPath();
- static lldb::SBFileSpec
- GetLLDBPath (lldb::PathType path_type);
+ static lldb::SBFileSpec GetLLDBPath(lldb::PathType path_type);
- static lldb::SBFileSpec
- GetUserHomeDirectory ();
+ static lldb::SBFileSpec GetUserHomeDirectory();
- static void
- ThreadCreated (const char *name);
+ static void ThreadCreated(const char *name);
- static lldb::thread_t
- ThreadCreate (const char *name,
- lldb::thread_func_t thread_function,
- void *thread_arg,
- lldb::SBError *err);
+ static lldb::thread_t ThreadCreate(const char *name,
+ lldb::thread_func_t thread_function,
+ void *thread_arg, lldb::SBError *err);
- static bool
- ThreadCancel (lldb::thread_t thread,
- lldb::SBError *err);
-
- static bool
- ThreadDetach (lldb::thread_t thread,
- lldb::SBError *err);
- static bool
- ThreadJoin (lldb::thread_t thread,
- lldb::thread_result_t *result,
- lldb::SBError *err);
+ static bool ThreadCancel(lldb::thread_t thread, lldb::SBError *err);
+ static bool ThreadDetach(lldb::thread_t thread, lldb::SBError *err);
+ static bool ThreadJoin(lldb::thread_t thread, lldb::thread_result_t *result,
+ lldb::SBError *err);
private:
-
};
-
} // namespace lldb
#endif // LLDB_SBHostOS_h_
diff --git a/include/lldb/API/SBInstruction.h b/include/lldb/API/SBInstruction.h
index cb0b2a32a829..0fc12eb61cba 100644
--- a/include/lldb/API/SBInstruction.h
+++ b/include/lldb/API/SBInstruction.h
@@ -10,93 +10,76 @@
#ifndef LLDB_SBInstruction_h_
#define LLDB_SBInstruction_h_
-#include "lldb/API/SBDefines.h"
#include "lldb/API/SBData.h"
+#include "lldb/API/SBDefines.h"
#include <stdio.h>
-// There's a lot to be fixed here, but need to wait for underlying insn implementation
+// There's a lot to be fixed here, but need to wait for underlying insn
+// implementation
// to be revised & settle down first.
class InstructionImpl;
namespace lldb {
-class LLDB_API SBInstruction
-{
+class LLDB_API SBInstruction {
public:
+ SBInstruction();
+
+ SBInstruction(const SBInstruction &rhs);
+
+ const SBInstruction &operator=(const SBInstruction &rhs);
- SBInstruction ();
+ ~SBInstruction();
- SBInstruction (const SBInstruction &rhs);
-
- const SBInstruction &
- operator = (const SBInstruction &rhs);
+ bool IsValid();
- ~SBInstruction ();
+ SBAddress GetAddress();
- bool
- IsValid();
+ lldb::AddressClass GetAddressClass();
- SBAddress
- GetAddress();
-
- lldb::AddressClass
- GetAddressClass ();
-
- const char *
- GetMnemonic (lldb::SBTarget target);
+ const char *GetMnemonic(lldb::SBTarget target);
- const char *
- GetOperands (lldb::SBTarget target);
-
- const char *
- GetComment (lldb::SBTarget target);
+ const char *GetOperands(lldb::SBTarget target);
- lldb::SBData
- GetData (lldb::SBTarget target);
+ const char *GetComment(lldb::SBTarget target);
- size_t
- GetByteSize ();
+ lldb::SBData GetData(lldb::SBTarget target);
- bool
- DoesBranch ();
+ size_t GetByteSize();
- bool
- HasDelaySlot ();
+ bool DoesBranch();
- void
- Print (FILE *out);
+ bool HasDelaySlot();
- bool
- GetDescription (lldb::SBStream &description);
+ void Print(FILE *out);
- bool
- EmulateWithFrame (lldb::SBFrame &frame, uint32_t evaluate_options);
+ bool GetDescription(lldb::SBStream &description);
- bool
- DumpEmulation (const char * triple); // triple is to specify the architecture, e.g. 'armv6' or 'armv7-apple-ios'
-
- bool
- TestEmulation (lldb::SBStream &output_stream, const char *test_file);
+ bool EmulateWithFrame(lldb::SBFrame &frame, uint32_t evaluate_options);
+
+ bool DumpEmulation(const char *triple); // triple is to specify the
+ // architecture, e.g. 'armv6' or
+ // 'armv7-apple-ios'
+
+ bool TestEmulation(lldb::SBStream &output_stream, const char *test_file);
protected:
- friend class SBInstructionList;
+ friend class SBInstructionList;
- SBInstruction(const lldb::DisassemblerSP &disasm_sp, const lldb::InstructionSP &inst_sp);
+ SBInstruction(const lldb::DisassemblerSP &disasm_sp,
+ const lldb::InstructionSP &inst_sp);
- void
- SetOpaque(const lldb::DisassemblerSP &disasm_sp, const lldb::InstructionSP& inst_sp);
+ void SetOpaque(const lldb::DisassemblerSP &disasm_sp,
+ const lldb::InstructionSP &inst_sp);
- lldb::InstructionSP
- GetOpaque();
+ lldb::InstructionSP GetOpaque();
private:
-
- std::shared_ptr<InstructionImpl> m_opaque_sp;
+ std::shared_ptr<InstructionImpl> m_opaque_sp;
};
-
} // namespace lldb
#endif // LLDB_SBInstruction_h_
diff --git a/include/lldb/API/SBInstructionList.h b/include/lldb/API/SBInstructionList.h
index 8ef163796629..29baef5790eb 100644
--- a/include/lldb/API/SBInstructionList.h
+++ b/include/lldb/API/SBInstructionList.h
@@ -16,55 +16,42 @@
namespace lldb {
-class LLDB_API SBInstructionList
-{
+class LLDB_API SBInstructionList {
public:
+ SBInstructionList();
- SBInstructionList ();
+ SBInstructionList(const SBInstructionList &rhs);
- SBInstructionList (const SBInstructionList &rhs);
-
- const SBInstructionList &
- operator = (const SBInstructionList &rhs);
+ const SBInstructionList &operator=(const SBInstructionList &rhs);
- ~SBInstructionList ();
+ ~SBInstructionList();
- bool
- IsValid () const;
+ bool IsValid() const;
- size_t
- GetSize ();
+ size_t GetSize();
- lldb::SBInstruction
- GetInstructionAtIndex (uint32_t idx);
+ lldb::SBInstruction GetInstructionAtIndex(uint32_t idx);
- void
- Clear ();
+ void Clear();
- void
- AppendInstruction (lldb::SBInstruction inst);
+ void AppendInstruction(lldb::SBInstruction inst);
- void
- Print (FILE *out);
+ void Print(FILE *out);
- bool
- GetDescription (lldb::SBStream &description);
-
- bool
- DumpEmulationForAllInstructions (const char *triple);
+ bool GetDescription(lldb::SBStream &description);
+
+ bool DumpEmulationForAllInstructions(const char *triple);
protected:
- friend class SBFunction;
- friend class SBSymbol;
- friend class SBTarget;
-
- void
- SetDisassembler (const lldb::DisassemblerSP &opaque_sp);
-
-private:
- lldb::DisassemblerSP m_opaque_sp;
-};
+ friend class SBFunction;
+ friend class SBSymbol;
+ friend class SBTarget;
+ void SetDisassembler(const lldb::DisassemblerSP &opaque_sp);
+
+private:
+ lldb::DisassemblerSP m_opaque_sp;
+};
} // namespace lldb
diff --git a/include/lldb/API/SBLanguageRuntime.h b/include/lldb/API/SBLanguageRuntime.h
index 898604c496fa..3912f352491b 100644
--- a/include/lldb/API/SBLanguageRuntime.h
+++ b/include/lldb/API/SBLanguageRuntime.h
@@ -14,14 +14,11 @@
namespace lldb {
-class SBLanguageRuntime
-{
+class SBLanguageRuntime {
public:
- static lldb::LanguageType
- GetLanguageTypeFromString (const char *string);
-
- static const char *
- GetNameForLanguageType (lldb::LanguageType language);
+ static lldb::LanguageType GetLanguageTypeFromString(const char *string);
+
+ static const char *GetNameForLanguageType(lldb::LanguageType language);
};
} // namespace lldb
diff --git a/include/lldb/API/SBLaunchInfo.h b/include/lldb/API/SBLaunchInfo.h
index 38d598aec456..1cece235127f 100644
--- a/include/lldb/API/SBLaunchInfo.h
+++ b/include/lldb/API/SBLaunchInfo.h
@@ -17,179 +17,137 @@ namespace lldb {
class SBPlatform;
class SBTarget;
-class LLDB_API SBLaunchInfo
-{
+class LLDB_API SBLaunchInfo {
public:
- SBLaunchInfo (const char **argv);
-
- ~SBLaunchInfo();
-
- lldb::pid_t
- GetProcessID();
-
- uint32_t
- GetUserID();
-
- uint32_t
- GetGroupID();
-
- bool
- UserIDIsValid ();
-
- bool
- GroupIDIsValid ();
-
- void
- SetUserID (uint32_t uid);
-
- void
- SetGroupID (uint32_t gid);
-
- SBFileSpec
- GetExecutableFile ();
-
- //----------------------------------------------------------------------
- /// Set the executable file that will be used to launch the process and
- /// optionally set it as the first argument in the argument vector.
- ///
- /// This only needs to be specified if clients wish to carefully control
- /// the exact path will be used to launch a binary. If you create a
- /// target with a symlink, that symlink will get resolved in the target
- /// and the resolved path will get used to launch the process. Calling
- /// this function can help you still launch your process using the
- /// path of your choice.
- ///
- /// If this function is not called prior to launching with
- /// SBTarget::Launch(...), the target will use the resolved executable
- /// path that was used to create the target.
- ///
- /// @param[in] exe_file
- /// The override path to use when launching the executable.
- ///
- /// @param[in] add_as_first_arg
- /// If true, then the path will be inserted into the argument vector
- /// prior to launching. Otherwise the argument vector will be left
- /// alone.
- //----------------------------------------------------------------------
- void
- SetExecutableFile (SBFileSpec exe_file, bool add_as_first_arg);
-
-
- //----------------------------------------------------------------------
- /// Get the listener that will be used to receive process events.
- ///
- /// If no listener has been set via a call to
- /// SBLaunchInfo::SetListener(), then an invalid SBListener will be
- /// returned (SBListener::IsValid() will return false). If a listener
- /// has been set, then the valid listener object will be returned.
- //----------------------------------------------------------------------
- SBListener
- GetListener ();
-
- //----------------------------------------------------------------------
- /// Set the listener that will be used to receive process events.
- ///
- /// By default the SBDebugger, which has a listener, that the SBTarget
- /// belongs to will listen for the process events. Calling this function
- /// allows a different listener to be used to listen for process events.
- //----------------------------------------------------------------------
- void
- SetListener (SBListener &listener);
-
- uint32_t
- GetNumArguments ();
-
- const char *
- GetArgumentAtIndex (uint32_t idx);
-
- void
- SetArguments (const char **argv, bool append);
-
- uint32_t
- GetNumEnvironmentEntries ();
-
- const char *
- GetEnvironmentEntryAtIndex (uint32_t idx);
-
- void
- SetEnvironmentEntries (const char **envp, bool append);
-
- void
- Clear ();
-
- const char *
- GetWorkingDirectory () const;
-
- void
- SetWorkingDirectory (const char *working_dir);
-
- uint32_t
- GetLaunchFlags ();
-
- void
- SetLaunchFlags (uint32_t flags);
-
- const char *
- GetProcessPluginName ();
-
- void
- SetProcessPluginName (const char *plugin_name);
-
- const char *
- GetShell ();
-
- void
- SetShell (const char * path);
-
- bool
- GetShellExpandArguments ();
-
- void
- SetShellExpandArguments (bool expand);
-
- uint32_t
- GetResumeCount ();
-
- void
- SetResumeCount (uint32_t c);
-
- bool
- AddCloseFileAction (int fd);
-
- bool
- AddDuplicateFileAction (int fd, int dup_fd);
-
- bool
- AddOpenFileAction (int fd, const char *path, bool read, bool write);
-
- bool
- AddSuppressFileAction (int fd, bool read, bool write);
+ SBLaunchInfo(const char **argv);
- void
- SetLaunchEventData (const char *data);
+ ~SBLaunchInfo();
- const char *
- GetLaunchEventData () const;
+ lldb::pid_t GetProcessID();
- bool
- GetDetachOnError() const;
+ uint32_t GetUserID();
- void
- SetDetachOnError(bool enable);
+ uint32_t GetGroupID();
+
+ bool UserIDIsValid();
+
+ bool GroupIDIsValid();
+
+ void SetUserID(uint32_t uid);
+
+ void SetGroupID(uint32_t gid);
+
+ SBFileSpec GetExecutableFile();
+
+ //----------------------------------------------------------------------
+ /// Set the executable file that will be used to launch the process and
+ /// optionally set it as the first argument in the argument vector.
+ ///
+ /// This only needs to be specified if clients wish to carefully control
+ /// the exact path will be used to launch a binary. If you create a
+ /// target with a symlink, that symlink will get resolved in the target
+ /// and the resolved path will get used to launch the process. Calling
+ /// this function can help you still launch your process using the
+ /// path of your choice.
+ ///
+ /// If this function is not called prior to launching with
+ /// SBTarget::Launch(...), the target will use the resolved executable
+ /// path that was used to create the target.
+ ///
+ /// @param[in] exe_file
+ /// The override path to use when launching the executable.
+ ///
+ /// @param[in] add_as_first_arg
+ /// If true, then the path will be inserted into the argument vector
+ /// prior to launching. Otherwise the argument vector will be left
+ /// alone.
+ //----------------------------------------------------------------------
+ void SetExecutableFile(SBFileSpec exe_file, bool add_as_first_arg);
+
+ //----------------------------------------------------------------------
+ /// Get the listener that will be used to receive process events.
+ ///
+ /// If no listener has been set via a call to
+ /// SBLaunchInfo::SetListener(), then an invalid SBListener will be
+ /// returned (SBListener::IsValid() will return false). If a listener
+ /// has been set, then the valid listener object will be returned.
+ //----------------------------------------------------------------------
+ SBListener GetListener();
+
+ //----------------------------------------------------------------------
+ /// Set the listener that will be used to receive process events.
+ ///
+ /// By default the SBDebugger, which has a listener, that the SBTarget
+ /// belongs to will listen for the process events. Calling this function
+ /// allows a different listener to be used to listen for process events.
+ //----------------------------------------------------------------------
+ void SetListener(SBListener &listener);
+
+ uint32_t GetNumArguments();
+
+ const char *GetArgumentAtIndex(uint32_t idx);
+
+ void SetArguments(const char **argv, bool append);
+
+ uint32_t GetNumEnvironmentEntries();
+
+ const char *GetEnvironmentEntryAtIndex(uint32_t idx);
+
+ void SetEnvironmentEntries(const char **envp, bool append);
+
+ void Clear();
+
+ const char *GetWorkingDirectory() const;
+
+ void SetWorkingDirectory(const char *working_dir);
+
+ uint32_t GetLaunchFlags();
+
+ void SetLaunchFlags(uint32_t flags);
+
+ const char *GetProcessPluginName();
+
+ void SetProcessPluginName(const char *plugin_name);
+
+ const char *GetShell();
+
+ void SetShell(const char *path);
+
+ bool GetShellExpandArguments();
+
+ void SetShellExpandArguments(bool expand);
+
+ uint32_t GetResumeCount();
+
+ void SetResumeCount(uint32_t c);
+
+ bool AddCloseFileAction(int fd);
+
+ bool AddDuplicateFileAction(int fd, int dup_fd);
+
+ bool AddOpenFileAction(int fd, const char *path, bool read, bool write);
+
+ bool AddSuppressFileAction(int fd, bool read, bool write);
+
+ void SetLaunchEventData(const char *data);
+
+ const char *GetLaunchEventData() const;
+
+ bool GetDetachOnError() const;
+
+ void SetDetachOnError(bool enable);
protected:
- friend class SBPlatform;
- friend class SBTarget;
+ friend class SBPlatform;
+ friend class SBTarget;
- lldb_private::ProcessLaunchInfo &
- ref ();
+ lldb_private::ProcessLaunchInfo &ref();
- const lldb_private::ProcessLaunchInfo &
- ref () const;
+ const lldb_private::ProcessLaunchInfo &ref() const;
- ProcessLaunchInfoSP m_opaque_sp;
+ ProcessLaunchInfoSP m_opaque_sp;
};
} // namespace lldb
-#endif // LLDB_SBLaunchInfo_h_
+#endif // LLDB_SBLaunchInfo_h_
diff --git a/include/lldb/API/SBLineEntry.h b/include/lldb/API/SBLineEntry.h
index 8311bbbafc90..3d58ea8278ea 100644
--- a/include/lldb/API/SBLineEntry.h
+++ b/include/lldb/API/SBLineEntry.h
@@ -10,90 +10,68 @@
#ifndef LLDB_SBLineEntry_h_
#define LLDB_SBLineEntry_h_
-#include "lldb/API/SBDefines.h"
#include "lldb/API/SBAddress.h"
+#include "lldb/API/SBDefines.h"
#include "lldb/API/SBFileSpec.h"
namespace lldb {
-class LLDB_API SBLineEntry
-{
+class LLDB_API SBLineEntry {
public:
+ SBLineEntry();
- SBLineEntry ();
+ SBLineEntry(const lldb::SBLineEntry &rhs);
- SBLineEntry (const lldb::SBLineEntry &rhs);
+ ~SBLineEntry();
- ~SBLineEntry ();
+ const lldb::SBLineEntry &operator=(const lldb::SBLineEntry &rhs);
- const lldb::SBLineEntry &
- operator = (const lldb::SBLineEntry &rhs);
+ lldb::SBAddress GetStartAddress() const;
- lldb::SBAddress
- GetStartAddress () const;
+ lldb::SBAddress GetEndAddress() const;
- lldb::SBAddress
- GetEndAddress () const;
+ bool IsValid() const;
- bool
- IsValid () const;
+ lldb::SBFileSpec GetFileSpec() const;
- lldb::SBFileSpec
- GetFileSpec () const;
+ uint32_t GetLine() const;
- uint32_t
- GetLine () const;
+ uint32_t GetColumn() const;
- uint32_t
- GetColumn () const;
+ void SetFileSpec(lldb::SBFileSpec filespec);
- void
- SetFileSpec (lldb::SBFileSpec filespec);
-
- void
- SetLine (uint32_t line);
-
- void
- SetColumn (uint32_t column);
+ void SetLine(uint32_t line);
- bool
- operator == (const lldb::SBLineEntry &rhs) const;
+ void SetColumn(uint32_t column);
- bool
- operator != (const lldb::SBLineEntry &rhs) const;
+ bool operator==(const lldb::SBLineEntry &rhs) const;
- bool
- GetDescription (lldb::SBStream &description);
+ bool operator!=(const lldb::SBLineEntry &rhs) const;
+
+ bool GetDescription(lldb::SBStream &description);
protected:
+ lldb_private::LineEntry *get();
- lldb_private::LineEntry *
- get ();
-
private:
- friend class SBAddress;
- friend class SBCompileUnit;
- friend class SBFrame;
- friend class SBSymbolContext;
+ friend class SBAddress;
+ friend class SBCompileUnit;
+ friend class SBFrame;
+ friend class SBSymbolContext;
- const lldb_private::LineEntry *
- operator->() const;
+ const lldb_private::LineEntry *operator->() const;
- lldb_private::LineEntry &
- ref();
+ lldb_private::LineEntry &ref();
- const lldb_private::LineEntry &
- ref() const;
+ const lldb_private::LineEntry &ref() const;
- SBLineEntry (const lldb_private::LineEntry *lldb_object_ptr);
+ SBLineEntry(const lldb_private::LineEntry *lldb_object_ptr);
- void
- SetLineEntry (const lldb_private::LineEntry &lldb_object_ref);
+ void SetLineEntry(const lldb_private::LineEntry &lldb_object_ref);
- std::unique_ptr<lldb_private::LineEntry> m_opaque_ap;
+ std::unique_ptr<lldb_private::LineEntry> m_opaque_ap;
};
-
} // namespace lldb
#endif // LLDB_SBLineEntry_h_
diff --git a/include/lldb/API/SBListener.h b/include/lldb/API/SBListener.h
index e74d318ea118..05282c215406 100644
--- a/include/lldb/API/SBListener.h
+++ b/include/lldb/API/SBListener.h
@@ -14,121 +14,94 @@
namespace lldb {
-class LLDB_API SBListener
-{
+class LLDB_API SBListener {
public:
- SBListener ();
+ SBListener();
- SBListener (const char *name);
+ SBListener(const char *name);
- SBListener (const SBListener &rhs);
+ SBListener(const SBListener &rhs);
- ~SBListener ();
+ ~SBListener();
- const lldb::SBListener &
- operator = (const lldb::SBListener &rhs);
+ const lldb::SBListener &operator=(const lldb::SBListener &rhs);
- void
- AddEvent (const lldb::SBEvent &event);
+ void AddEvent(const lldb::SBEvent &event);
- void
- Clear ();
+ void Clear();
- bool
- IsValid () const;
+ bool IsValid() const;
- uint32_t
- StartListeningForEventClass (SBDebugger &debugger,
- const char *broadcaster_class,
- uint32_t event_mask);
-
- bool
- StopListeningForEventClass (SBDebugger &debugger,
- const char *broadcaster_class,
- uint32_t event_mask);
-
- uint32_t
- StartListeningForEvents (const lldb::SBBroadcaster& broadcaster,
- uint32_t event_mask);
+ uint32_t StartListeningForEventClass(SBDebugger &debugger,
+ const char *broadcaster_class,
+ uint32_t event_mask);
- bool
- StopListeningForEvents (const lldb::SBBroadcaster& broadcaster,
- uint32_t event_mask);
+ bool StopListeningForEventClass(SBDebugger &debugger,
+ const char *broadcaster_class,
+ uint32_t event_mask);
- // Returns true if an event was received, false if we timed out.
- bool
- WaitForEvent (uint32_t num_seconds,
- lldb::SBEvent &event);
+ uint32_t StartListeningForEvents(const lldb::SBBroadcaster &broadcaster,
+ uint32_t event_mask);
- bool
- WaitForEventForBroadcaster (uint32_t num_seconds,
- const lldb::SBBroadcaster &broadcaster,
- lldb::SBEvent &sb_event);
+ bool StopListeningForEvents(const lldb::SBBroadcaster &broadcaster,
+ uint32_t event_mask);
- bool
- WaitForEventForBroadcasterWithType (uint32_t num_seconds,
- const lldb::SBBroadcaster &broadcaster,
- uint32_t event_type_mask,
- lldb::SBEvent &sb_event);
+ // Returns true if an event was received, false if we timed out.
+ bool WaitForEvent(uint32_t num_seconds, lldb::SBEvent &event);
- bool
- PeekAtNextEvent (lldb::SBEvent &sb_event);
+ bool WaitForEventForBroadcaster(uint32_t num_seconds,
+ const lldb::SBBroadcaster &broadcaster,
+ lldb::SBEvent &sb_event);
- bool
- PeekAtNextEventForBroadcaster (const lldb::SBBroadcaster &broadcaster,
- lldb::SBEvent &sb_event);
+ bool WaitForEventForBroadcasterWithType(
+ uint32_t num_seconds, const lldb::SBBroadcaster &broadcaster,
+ uint32_t event_type_mask, lldb::SBEvent &sb_event);
- bool
- PeekAtNextEventForBroadcasterWithType (const lldb::SBBroadcaster &broadcaster,
- uint32_t event_type_mask,
- lldb::SBEvent &sb_event);
+ bool PeekAtNextEvent(lldb::SBEvent &sb_event);
- bool
- GetNextEvent (lldb::SBEvent &sb_event);
+ bool PeekAtNextEventForBroadcaster(const lldb::SBBroadcaster &broadcaster,
+ lldb::SBEvent &sb_event);
- bool
- GetNextEventForBroadcaster (const lldb::SBBroadcaster &broadcaster,
- lldb::SBEvent &sb_event);
-
- bool
- GetNextEventForBroadcasterWithType (const lldb::SBBroadcaster &broadcaster,
+ bool
+ PeekAtNextEventForBroadcasterWithType(const lldb::SBBroadcaster &broadcaster,
uint32_t event_type_mask,
lldb::SBEvent &sb_event);
- bool
- HandleBroadcastEvent (const lldb::SBEvent &event);
+ bool GetNextEvent(lldb::SBEvent &sb_event);
+
+ bool GetNextEventForBroadcaster(const lldb::SBBroadcaster &broadcaster,
+ lldb::SBEvent &sb_event);
+
+ bool
+ GetNextEventForBroadcasterWithType(const lldb::SBBroadcaster &broadcaster,
+ uint32_t event_type_mask,
+ lldb::SBEvent &sb_event);
+
+ bool HandleBroadcastEvent(const lldb::SBEvent &event);
protected:
- friend class SBAttachInfo;
- friend class SBBroadcaster;
- friend class SBCommandInterpreter;
- friend class SBDebugger;
- friend class SBLaunchInfo;
- friend class SBTarget;
+ friend class SBAttachInfo;
+ friend class SBBroadcaster;
+ friend class SBCommandInterpreter;
+ friend class SBDebugger;
+ friend class SBLaunchInfo;
+ friend class SBTarget;
- SBListener (const lldb::ListenerSP &listener_sp);
+ SBListener(const lldb::ListenerSP &listener_sp);
- lldb::ListenerSP
- GetSP ()
- {
- return m_opaque_sp;
- }
+ lldb::ListenerSP GetSP() { return m_opaque_sp; }
private:
+ lldb_private::Listener *operator->() const;
- lldb_private::Listener *
- operator->() const;
-
- lldb_private::Listener *
- get() const;
+ lldb_private::Listener *get() const;
- void
- reset(lldb::ListenerSP listener_sp);
+ void reset(lldb::ListenerSP listener_sp);
- lldb::ListenerSP m_opaque_sp;
- lldb_private::Listener *m_unused_ptr;
+ lldb::ListenerSP m_opaque_sp;
+ lldb_private::Listener *m_unused_ptr;
};
} // namespace lldb
-#endif // LLDB_SBListener_h_
+#endif // LLDB_SBListener_h_
diff --git a/include/lldb/API/SBMemoryRegionInfo.h b/include/lldb/API/SBMemoryRegionInfo.h
index fadd0760891b..297f877a6341 100644
--- a/include/lldb/API/SBMemoryRegionInfo.h
+++ b/include/lldb/API/SBMemoryRegionInfo.h
@@ -10,108 +10,103 @@
#ifndef LLDB_SBMemoryRegionInfo_h_
#define LLDB_SBMemoryRegionInfo_h_
-#include "lldb/API/SBDefines.h"
#include "lldb/API/SBData.h"
+#include "lldb/API/SBDefines.h"
namespace lldb {
-class LLDB_API SBMemoryRegionInfo
-{
+class LLDB_API SBMemoryRegionInfo {
public:
-
- SBMemoryRegionInfo ();
-
- SBMemoryRegionInfo (const lldb::SBMemoryRegionInfo &rhs);
-
- ~SBMemoryRegionInfo ();
-
- const lldb::SBMemoryRegionInfo &
- operator = (const lldb::SBMemoryRegionInfo &rhs);
-
- void
- Clear();
-
- //------------------------------------------------------------------
- /// Get the base address of this memory range.
- ///
- /// @return
- /// The base address of this memory range.
- //------------------------------------------------------------------
- lldb::addr_t
- GetRegionBase ();
-
- //------------------------------------------------------------------
- /// Get the end address of this memory range.
- ///
- /// @return
- /// The base address of this memory range.
- //------------------------------------------------------------------
- lldb::addr_t
- GetRegionEnd ();
-
- //------------------------------------------------------------------
- /// Check if this memory address is marked readable to the process.
- ///
- /// @return
- /// true if this memory address is marked readable
- //------------------------------------------------------------------
- bool
- IsReadable ();
-
- //------------------------------------------------------------------
- /// Check if this memory address is marked writable to the process.
- ///
- /// @return
- /// true if this memory address is marked writable
- //------------------------------------------------------------------
- bool
- IsWritable ();
-
- //------------------------------------------------------------------
- /// Check if this memory address is marked executable to the process.
- ///
- /// @return
- /// true if this memory address is marked executable
- //------------------------------------------------------------------
- bool
- IsExecutable ();
-
- //------------------------------------------------------------------
- /// Check if this memory address is mapped into the process address
- /// space.
- ///
- /// @return
- /// true if this memory address is in the process address space.
- //------------------------------------------------------------------
- bool
- IsMapped ();
-
- bool
- operator == (const lldb::SBMemoryRegionInfo &rhs) const;
-
- bool
- operator != (const lldb::SBMemoryRegionInfo &rhs) const;
-
- bool
- GetDescription (lldb::SBStream &description);
+ SBMemoryRegionInfo();
+
+ SBMemoryRegionInfo(const lldb::SBMemoryRegionInfo &rhs);
+
+ ~SBMemoryRegionInfo();
+
+ const lldb::SBMemoryRegionInfo &
+ operator=(const lldb::SBMemoryRegionInfo &rhs);
+
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Get the base address of this memory range.
+ ///
+ /// @return
+ /// The base address of this memory range.
+ //------------------------------------------------------------------
+ lldb::addr_t GetRegionBase();
+
+ //------------------------------------------------------------------
+ /// Get the end address of this memory range.
+ ///
+ /// @return
+ /// The base address of this memory range.
+ //------------------------------------------------------------------
+ lldb::addr_t GetRegionEnd();
+
+ //------------------------------------------------------------------
+ /// Check if this memory address is marked readable to the process.
+ ///
+ /// @return
+ /// true if this memory address is marked readable
+ //------------------------------------------------------------------
+ bool IsReadable();
+
+ //------------------------------------------------------------------
+ /// Check if this memory address is marked writable to the process.
+ ///
+ /// @return
+ /// true if this memory address is marked writable
+ //------------------------------------------------------------------
+ bool IsWritable();
+
+ //------------------------------------------------------------------
+ /// Check if this memory address is marked executable to the process.
+ ///
+ /// @return
+ /// true if this memory address is marked executable
+ //------------------------------------------------------------------
+ bool IsExecutable();
+
+ //------------------------------------------------------------------
+ /// Check if this memory address is mapped into the process address
+ /// space.
+ ///
+ /// @return
+ /// true if this memory address is in the process address space.
+ //------------------------------------------------------------------
+ bool IsMapped();
+
+ //------------------------------------------------------------------
+ /// Returns the name of the memory region mapped at the given
+ /// address.
+ ///
+ /// @return
+ /// In case of memory mapped files it is the absolute path of
+ /// the file otherwise it is a name associated with the memory
+ /// region. If no name can be determined the returns nullptr.
+ //------------------------------------------------------------------
+ const char *GetName();
+
+ bool operator==(const lldb::SBMemoryRegionInfo &rhs) const;
+
+ bool operator!=(const lldb::SBMemoryRegionInfo &rhs) const;
+
+ bool GetDescription(lldb::SBStream &description);
private:
+ friend class SBProcess;
+ friend class SBMemoryRegionInfoList;
- friend class SBProcess;
- friend class SBMemoryRegionInfoList;
+ lldb_private::MemoryRegionInfo &ref();
- lldb_private::MemoryRegionInfo &
- ref();
+ const lldb_private::MemoryRegionInfo &ref() const;
- const lldb_private::MemoryRegionInfo &
- ref() const;
+ SBMemoryRegionInfo(const lldb_private::MemoryRegionInfo *lldb_object_ptr);
- SBMemoryRegionInfo (const lldb_private::MemoryRegionInfo *lldb_object_ptr);
-
- lldb::MemoryRegionInfoUP m_opaque_ap;
+ lldb::MemoryRegionInfoUP m_opaque_ap;
};
-
} // namespace lldb
#endif // LLDB_SBMemoryRegionInfo_h_
diff --git a/include/lldb/API/SBMemoryRegionInfoList.h b/include/lldb/API/SBMemoryRegionInfoList.h
index 7723820897d8..883a2224c92d 100644
--- a/include/lldb/API/SBMemoryRegionInfoList.h
+++ b/include/lldb/API/SBMemoryRegionInfoList.h
@@ -16,46 +16,33 @@ class MemoryRegionInfoListImpl;
namespace lldb {
-class LLDB_API SBMemoryRegionInfoList
-{
+class LLDB_API SBMemoryRegionInfoList {
public:
+ SBMemoryRegionInfoList();
- SBMemoryRegionInfoList ();
+ SBMemoryRegionInfoList(const lldb::SBMemoryRegionInfoList &rhs);
- SBMemoryRegionInfoList (const lldb::SBMemoryRegionInfoList &rhs);
+ const SBMemoryRegionInfoList &operator=(const SBMemoryRegionInfoList &rhs);
- const SBMemoryRegionInfoList &
- operator = (const SBMemoryRegionInfoList &rhs);
+ ~SBMemoryRegionInfoList();
- ~SBMemoryRegionInfoList ();
+ uint32_t GetSize() const;
- uint32_t
- GetSize () const;
+ bool GetMemoryRegionAtIndex(uint32_t idx, SBMemoryRegionInfo &region_info);
- bool
- GetMemoryRegionAtIndex (uint32_t idx, SBMemoryRegionInfo &region_info);
+ void Append(lldb::SBMemoryRegionInfo &region);
- void
- Append (lldb::SBMemoryRegionInfo &region);
+ void Append(lldb::SBMemoryRegionInfoList &region_list);
- void
- Append (lldb::SBMemoryRegionInfoList &region_list);
-
- void
- Clear ();
+ void Clear();
protected:
+ const MemoryRegionInfoListImpl *operator->() const;
- const MemoryRegionInfoListImpl *
- operator->() const;
-
- const MemoryRegionInfoListImpl &
- operator*() const;
+ const MemoryRegionInfoListImpl &operator*() const;
private:
-
- std::unique_ptr<MemoryRegionInfoListImpl> m_opaque_ap;
-
+ std::unique_ptr<MemoryRegionInfoListImpl> m_opaque_ap;
};
} // namespace lldb
diff --git a/include/lldb/API/SBModule.h b/include/lldb/API/SBModule.h
index 4030d2b21797..bcc3997a275b 100644
--- a/include/lldb/API/SBModule.h
+++ b/include/lldb/API/SBModule.h
@@ -18,341 +18,298 @@
namespace lldb {
-class LLDB_API SBModule
-{
+class LLDB_API SBModule {
public:
+ SBModule();
+
+ SBModule(const SBModule &rhs);
+
+ SBModule(const SBModuleSpec &module_spec);
+
+ const SBModule &operator=(const SBModule &rhs);
+
+ SBModule(lldb::SBProcess &process, lldb::addr_t header_addr);
+
+ ~SBModule();
+
+ bool IsValid() const;
- SBModule ();
-
- SBModule (const SBModule &rhs);
-
- SBModule (const SBModuleSpec &module_spec);
-
- const SBModule &
- operator = (const SBModule &rhs);
-
- SBModule (lldb::SBProcess &process,
- lldb::addr_t header_addr);
-
- ~SBModule ();
-
- bool
- IsValid () const;
-
- void
- Clear();
-
- //------------------------------------------------------------------
- /// Get const accessor for the module file specification.
- ///
- /// This function returns the file for the module on the host system
- /// that is running LLDB. This can differ from the path on the
- /// platform since we might be doing remote debugging.
- ///
- /// @return
- /// A const reference to the file specification object.
- //------------------------------------------------------------------
- lldb::SBFileSpec
- GetFileSpec () const;
-
- //------------------------------------------------------------------
- /// Get accessor for the module platform file specification.
- ///
- /// Platform file refers to the path of the module as it is known on
- /// the remote system on which it is being debugged. For local
- /// debugging this is always the same as Module::GetFileSpec(). But
- /// remote debugging might mention a file '/usr/lib/liba.dylib'
- /// which might be locally downloaded and cached. In this case the
- /// platform file could be something like:
- /// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib'
- /// The file could also be cached in a local developer kit directory.
- ///
- /// @return
- /// A const reference to the file specification object.
- //------------------------------------------------------------------
- lldb::SBFileSpec
- GetPlatformFileSpec () const;
-
- bool
- SetPlatformFileSpec (const lldb::SBFileSpec &platform_file);
-
- //------------------------------------------------------------------
- /// Get accessor for the remote install path for a module.
- ///
- /// When debugging to a remote platform by connecting to a remote
- /// platform, the install path of the module can be set. If the
- /// install path is set, every time the process is about to launch
- /// the target will install this module on the remote platform prior
- /// to launching.
- ///
- /// @return
- /// A file specification object.
- //------------------------------------------------------------------
- lldb::SBFileSpec
- GetRemoteInstallFileSpec ();
-
- //------------------------------------------------------------------
- /// Set accessor for the remote install path for a module.
- ///
- /// When debugging to a remote platform by connecting to a remote
- /// platform, the install path of the module can be set. If the
- /// install path is set, every time the process is about to launch
- /// the target will install this module on the remote platform prior
- /// to launching.
- ///
- /// If \a file specifies a full path to an install location, the
- /// module will be installed to this path. If the path is relative
- /// (no directory specified, or the path is partial like "usr/lib"
- /// or "./usr/lib", then the install path will be resolved using
- /// the platform's current working directory as the base path.
- ///
- /// @param[in] file
- /// A file specification object.
- //------------------------------------------------------------------
- bool
- SetRemoteInstallFileSpec (lldb::SBFileSpec &file);
-
- lldb::ByteOrder
- GetByteOrder ();
-
- uint32_t
- GetAddressByteSize();
-
- const char *
- GetTriple ();
-
- const uint8_t *
- GetUUIDBytes () const;
-
- const char *
- GetUUIDString () const;
-
- bool
- operator == (const lldb::SBModule &rhs) const;
-
- bool
- operator != (const lldb::SBModule &rhs) const;
-
- lldb::SBSection
- FindSection (const char *sect_name);
-
- lldb::SBAddress
- ResolveFileAddress (lldb::addr_t vm_addr);
-
- lldb::SBSymbolContext
- ResolveSymbolContextForAddress (const lldb::SBAddress& addr,
- uint32_t resolve_scope);
-
- bool
- GetDescription (lldb::SBStream &description);
-
- uint32_t
- GetNumCompileUnits();
-
- lldb::SBCompileUnit
- GetCompileUnitAtIndex (uint32_t);
-
- size_t
- GetNumSymbols ();
-
- lldb::SBSymbol
- GetSymbolAtIndex (size_t idx);
-
- lldb::SBSymbol
- FindSymbol (const char *name,
- lldb::SymbolType type = eSymbolTypeAny);
-
- lldb::SBSymbolContextList
- FindSymbols (const char *name,
- lldb::SymbolType type = eSymbolTypeAny);
-
- size_t
- GetNumSections ();
-
- lldb::SBSection
- GetSectionAtIndex (size_t idx);
- //------------------------------------------------------------------
- /// Find functions by name.
- ///
- /// @param[in] name
- /// The name of the function we are looking for.
- ///
- /// @param[in] name_type_mask
- /// A logical OR of one or more FunctionNameType enum bits that
- /// indicate what kind of names should be used when doing the
- /// lookup. Bits include fully qualified names, base names,
- /// C++ methods, or ObjC selectors.
- /// See FunctionNameType for more details.
- ///
- /// @return
- /// A lldb::SBSymbolContextList that gets filled in with all of
- /// the symbol contexts for all the matches.
- //------------------------------------------------------------------
- lldb::SBSymbolContextList
- FindFunctions (const char *name,
- uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
-
- //------------------------------------------------------------------
- /// Find global and static variables by name.
- ///
- /// @param[in] target
- /// A valid SBTarget instance representing the debuggee.
- ///
- /// @param[in] name
- /// The name of the global or static variable we are looking
- /// for.
- ///
- /// @param[in] max_matches
- /// Allow the number of matches to be limited to \a max_matches.
- ///
- /// @return
- /// A list of matched variables in an SBValueList.
- //------------------------------------------------------------------
- lldb::SBValueList
- FindGlobalVariables (lldb::SBTarget &target,
- const char *name,
- uint32_t max_matches);
-
- //------------------------------------------------------------------
- /// Find the first global (or static) variable by name.
- ///
- /// @param[in] target
- /// A valid SBTarget instance representing the debuggee.
- ///
- /// @param[in] name
- /// The name of the global or static variable we are looking
- /// for.
- ///
- /// @return
- /// An SBValue that gets filled in with the found variable (if any).
- //------------------------------------------------------------------
- lldb::SBValue
- FindFirstGlobalVariable (lldb::SBTarget &target, const char *name);
-
- lldb::SBType
- FindFirstType (const char* name);
-
- lldb::SBTypeList
- FindTypes (const char* type);
-
- //------------------------------------------------------------------
- /// Get a type using its type ID.
- ///
- /// Each symbol file reader will assign different user IDs to their
- /// types, but it is sometimes useful when debugging type issues to
- /// be able to grab a type using its type ID.
- ///
- /// For DWARF debug info, the type ID is the DIE offset.
- ///
- /// @param[in] uid
- /// The type user ID.
- ///
- /// @return
- /// An SBType for the given type ID, or an empty SBType if the
- /// type was not found.
- //------------------------------------------------------------------
- lldb::SBType
- GetTypeByID (lldb::user_id_t uid);
-
- lldb::SBType
- GetBasicType(lldb::BasicType type);
-
- //------------------------------------------------------------------
- /// Get all types matching \a type_mask from debug info in this
- /// module.
- ///
- /// @param[in] type_mask
- /// A bitfield that consists of one or more bits logically OR'ed
- /// together from the lldb::TypeClass enumeration. This allows
- /// you to request only structure types, or only class, struct
- /// and union types. Passing in lldb::eTypeClassAny will return
- /// all types found in the debug information for this module.
- ///
- /// @return
- /// A list of types in this module that match \a type_mask
- //------------------------------------------------------------------
- lldb::SBTypeList
- GetTypes (uint32_t type_mask = lldb::eTypeClassAny);
-
- //------------------------------------------------------------------
- /// Get the module version numbers.
- ///
- /// Many object files have a set of version numbers that describe
- /// the version of the executable or shared library. Typically there
- /// are major, minor and build, but there may be more. This function
- /// will extract the versions from object files if they are available.
- ///
- /// If \a versions is NULL, or if \a num_versions is 0, the return
- /// value will indicate how many version numbers are available in
- /// this object file. Then a subsequent call can be made to this
- /// function with a value of \a versions and \a num_versions that
- /// has enough storage to store some or all version numbers.
- ///
- /// @param[out] versions
- /// A pointer to an array of uint32_t types that is \a num_versions
- /// long. If this value is NULL, the return value will indicate
- /// how many version numbers are required for a subsequent call
- /// to this function so that all versions can be retrieved. If
- /// the value is non-NULL, then at most \a num_versions of the
- /// existing versions numbers will be filled into \a versions.
- /// If there is no version information available, \a versions
- /// will be filled with \a num_versions UINT32_MAX values
- /// and zero will be returned.
- ///
- /// @param[in] num_versions
- /// The maximum number of entries to fill into \a versions. If
- /// this value is zero, then the return value will indicate
- /// how many version numbers there are in total so another call
- /// to this function can be make with adequate storage in
- /// \a versions to get all of the version numbers. If \a
- /// num_versions is less than the actual number of version
- /// numbers in this object file, only \a num_versions will be
- /// filled into \a versions (if \a versions is non-NULL).
- ///
- /// @return
- /// This function always returns the number of version numbers
- /// that this object file has regardless of the number of
- /// version numbers that were copied into \a versions.
- //------------------------------------------------------------------
- uint32_t
- GetVersion (uint32_t *versions,
- uint32_t num_versions);
-
- //------------------------------------------------------------------
- /// Get accessor for the symbol file specification.
- ///
- /// When debugging an object file an additional debug information can
- /// be provided in separate file. Therefore if you debugging something
- /// like '/usr/lib/liba.dylib' then debug information can be located
- /// in folder like '/usr/lib/liba.dylib.dSYM/'.
- ///
- /// @return
- /// A const reference to the file specification object.
- //------------------------------------------------------------------
- lldb::SBFileSpec
- GetSymbolFileSpec() const;
-
- lldb::SBAddress
- GetObjectFileHeaderAddress() const;
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Get const accessor for the module file specification.
+ ///
+ /// This function returns the file for the module on the host system
+ /// that is running LLDB. This can differ from the path on the
+ /// platform since we might be doing remote debugging.
+ ///
+ /// @return
+ /// A const reference to the file specification object.
+ //------------------------------------------------------------------
+ lldb::SBFileSpec GetFileSpec() const;
+
+ //------------------------------------------------------------------
+ /// Get accessor for the module platform file specification.
+ ///
+ /// Platform file refers to the path of the module as it is known on
+ /// the remote system on which it is being debugged. For local
+ /// debugging this is always the same as Module::GetFileSpec(). But
+ /// remote debugging might mention a file '/usr/lib/liba.dylib'
+ /// which might be locally downloaded and cached. In this case the
+ /// platform file could be something like:
+ /// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib'
+ /// The file could also be cached in a local developer kit directory.
+ ///
+ /// @return
+ /// A const reference to the file specification object.
+ //------------------------------------------------------------------
+ lldb::SBFileSpec GetPlatformFileSpec() const;
+
+ bool SetPlatformFileSpec(const lldb::SBFileSpec &platform_file);
+
+ //------------------------------------------------------------------
+ /// Get accessor for the remote install path for a module.
+ ///
+ /// When debugging to a remote platform by connecting to a remote
+ /// platform, the install path of the module can be set. If the
+ /// install path is set, every time the process is about to launch
+ /// the target will install this module on the remote platform prior
+ /// to launching.
+ ///
+ /// @return
+ /// A file specification object.
+ //------------------------------------------------------------------
+ lldb::SBFileSpec GetRemoteInstallFileSpec();
+
+ //------------------------------------------------------------------
+ /// Set accessor for the remote install path for a module.
+ ///
+ /// When debugging to a remote platform by connecting to a remote
+ /// platform, the install path of the module can be set. If the
+ /// install path is set, every time the process is about to launch
+ /// the target will install this module on the remote platform prior
+ /// to launching.
+ ///
+ /// If \a file specifies a full path to an install location, the
+ /// module will be installed to this path. If the path is relative
+ /// (no directory specified, or the path is partial like "usr/lib"
+ /// or "./usr/lib", then the install path will be resolved using
+ /// the platform's current working directory as the base path.
+ ///
+ /// @param[in] file
+ /// A file specification object.
+ //------------------------------------------------------------------
+ bool SetRemoteInstallFileSpec(lldb::SBFileSpec &file);
+
+ lldb::ByteOrder GetByteOrder();
+
+ uint32_t GetAddressByteSize();
+
+ const char *GetTriple();
+
+ const uint8_t *GetUUIDBytes() const;
+
+ const char *GetUUIDString() const;
+
+ bool operator==(const lldb::SBModule &rhs) const;
+
+ bool operator!=(const lldb::SBModule &rhs) const;
+
+ lldb::SBSection FindSection(const char *sect_name);
+
+ lldb::SBAddress ResolveFileAddress(lldb::addr_t vm_addr);
+
+ lldb::SBSymbolContext
+ ResolveSymbolContextForAddress(const lldb::SBAddress &addr,
+ uint32_t resolve_scope);
+
+ bool GetDescription(lldb::SBStream &description);
+
+ uint32_t GetNumCompileUnits();
+
+ lldb::SBCompileUnit GetCompileUnitAtIndex(uint32_t);
+
+ size_t GetNumSymbols();
+
+ lldb::SBSymbol GetSymbolAtIndex(size_t idx);
+
+ lldb::SBSymbol FindSymbol(const char *name,
+ lldb::SymbolType type = eSymbolTypeAny);
+
+ lldb::SBSymbolContextList FindSymbols(const char *name,
+ lldb::SymbolType type = eSymbolTypeAny);
+
+ size_t GetNumSections();
+
+ lldb::SBSection GetSectionAtIndex(size_t idx);
+ //------------------------------------------------------------------
+ /// Find functions by name.
+ ///
+ /// @param[in] name
+ /// The name of the function we are looking for.
+ ///
+ /// @param[in] name_type_mask
+ /// A logical OR of one or more FunctionNameType enum bits that
+ /// indicate what kind of names should be used when doing the
+ /// lookup. Bits include fully qualified names, base names,
+ /// C++ methods, or ObjC selectors.
+ /// See FunctionNameType for more details.
+ ///
+ /// @return
+ /// A lldb::SBSymbolContextList that gets filled in with all of
+ /// the symbol contexts for all the matches.
+ //------------------------------------------------------------------
+ lldb::SBSymbolContextList
+ FindFunctions(const char *name,
+ uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
+
+ //------------------------------------------------------------------
+ /// Find global and static variables by name.
+ ///
+ /// @param[in] target
+ /// A valid SBTarget instance representing the debuggee.
+ ///
+ /// @param[in] name
+ /// The name of the global or static variable we are looking
+ /// for.
+ ///
+ /// @param[in] max_matches
+ /// Allow the number of matches to be limited to \a max_matches.
+ ///
+ /// @return
+ /// A list of matched variables in an SBValueList.
+ //------------------------------------------------------------------
+ lldb::SBValueList FindGlobalVariables(lldb::SBTarget &target,
+ const char *name, uint32_t max_matches);
+
+ //------------------------------------------------------------------
+ /// Find the first global (or static) variable by name.
+ ///
+ /// @param[in] target
+ /// A valid SBTarget instance representing the debuggee.
+ ///
+ /// @param[in] name
+ /// The name of the global or static variable we are looking
+ /// for.
+ ///
+ /// @return
+ /// An SBValue that gets filled in with the found variable (if any).
+ //------------------------------------------------------------------
+ lldb::SBValue FindFirstGlobalVariable(lldb::SBTarget &target,
+ const char *name);
+
+ lldb::SBType FindFirstType(const char *name);
+
+ lldb::SBTypeList FindTypes(const char *type);
+
+ //------------------------------------------------------------------
+ /// Get a type using its type ID.
+ ///
+ /// Each symbol file reader will assign different user IDs to their
+ /// types, but it is sometimes useful when debugging type issues to
+ /// be able to grab a type using its type ID.
+ ///
+ /// For DWARF debug info, the type ID is the DIE offset.
+ ///
+ /// @param[in] uid
+ /// The type user ID.
+ ///
+ /// @return
+ /// An SBType for the given type ID, or an empty SBType if the
+ /// type was not found.
+ //------------------------------------------------------------------
+ lldb::SBType GetTypeByID(lldb::user_id_t uid);
+
+ lldb::SBType GetBasicType(lldb::BasicType type);
+
+ //------------------------------------------------------------------
+ /// Get all types matching \a type_mask from debug info in this
+ /// module.
+ ///
+ /// @param[in] type_mask
+ /// A bitfield that consists of one or more bits logically OR'ed
+ /// together from the lldb::TypeClass enumeration. This allows
+ /// you to request only structure types, or only class, struct
+ /// and union types. Passing in lldb::eTypeClassAny will return
+ /// all types found in the debug information for this module.
+ ///
+ /// @return
+ /// A list of types in this module that match \a type_mask
+ //------------------------------------------------------------------
+ lldb::SBTypeList GetTypes(uint32_t type_mask = lldb::eTypeClassAny);
+
+ //------------------------------------------------------------------
+ /// Get the module version numbers.
+ ///
+ /// Many object files have a set of version numbers that describe
+ /// the version of the executable or shared library. Typically there
+ /// are major, minor and build, but there may be more. This function
+ /// will extract the versions from object files if they are available.
+ ///
+ /// If \a versions is NULL, or if \a num_versions is 0, the return
+ /// value will indicate how many version numbers are available in
+ /// this object file. Then a subsequent call can be made to this
+ /// function with a value of \a versions and \a num_versions that
+ /// has enough storage to store some or all version numbers.
+ ///
+ /// @param[out] versions
+ /// A pointer to an array of uint32_t types that is \a num_versions
+ /// long. If this value is NULL, the return value will indicate
+ /// how many version numbers are required for a subsequent call
+ /// to this function so that all versions can be retrieved. If
+ /// the value is non-NULL, then at most \a num_versions of the
+ /// existing versions numbers will be filled into \a versions.
+ /// If there is no version information available, \a versions
+ /// will be filled with \a num_versions UINT32_MAX values
+ /// and zero will be returned.
+ ///
+ /// @param[in] num_versions
+ /// The maximum number of entries to fill into \a versions. If
+ /// this value is zero, then the return value will indicate
+ /// how many version numbers there are in total so another call
+ /// to this function can be make with adequate storage in
+ /// \a versions to get all of the version numbers. If \a
+ /// num_versions is less than the actual number of version
+ /// numbers in this object file, only \a num_versions will be
+ /// filled into \a versions (if \a versions is non-NULL).
+ ///
+ /// @return
+ /// This function always returns the number of version numbers
+ /// that this object file has regardless of the number of
+ /// version numbers that were copied into \a versions.
+ //------------------------------------------------------------------
+ uint32_t GetVersion(uint32_t *versions, uint32_t num_versions);
+
+ //------------------------------------------------------------------
+ /// Get accessor for the symbol file specification.
+ ///
+ /// When debugging an object file an additional debug information can
+ /// be provided in separate file. Therefore if you debugging something
+ /// like '/usr/lib/liba.dylib' then debug information can be located
+ /// in folder like '/usr/lib/liba.dylib.dSYM/'.
+ ///
+ /// @return
+ /// A const reference to the file specification object.
+ //------------------------------------------------------------------
+ lldb::SBFileSpec GetSymbolFileSpec() const;
+
+ lldb::SBAddress GetObjectFileHeaderAddress() const;
private:
- friend class SBAddress;
- friend class SBFrame;
- friend class SBSection;
- friend class SBSymbolContext;
- friend class SBTarget;
+ friend class SBAddress;
+ friend class SBFrame;
+ friend class SBSection;
+ friend class SBSymbolContext;
+ friend class SBTarget;
- explicit SBModule (const lldb::ModuleSP& module_sp);
+ explicit SBModule(const lldb::ModuleSP &module_sp);
- ModuleSP
- GetSP () const;
-
- void
- SetSP (const ModuleSP &module_sp);
+ ModuleSP GetSP() const;
- lldb::ModuleSP m_opaque_sp;
-};
+ void SetSP(const ModuleSP &module_sp);
+ lldb::ModuleSP m_opaque_sp;
+};
} // namespace lldb
diff --git a/include/lldb/API/SBModuleSpec.h b/include/lldb/API/SBModuleSpec.h
index d533de3c7bce..1a862703a702 100644
--- a/include/lldb/API/SBModuleSpec.h
+++ b/include/lldb/API/SBModuleSpec.h
@@ -15,138 +15,109 @@
namespace lldb {
-class LLDB_API SBModuleSpec
-{
+class LLDB_API SBModuleSpec {
public:
+ SBModuleSpec();
+
+ SBModuleSpec(const SBModuleSpec &rhs);
+
+ ~SBModuleSpec();
+
+ const SBModuleSpec &operator=(const SBModuleSpec &rhs);
+
+ bool IsValid() const;
+
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Get const accessor for the module file.
+ ///
+ /// This function returns the file for the module on the host system
+ /// that is running LLDB. This can differ from the path on the
+ /// platform since we might be doing remote debugging.
+ ///
+ /// @return
+ /// A const reference to the file specification object.
+ //------------------------------------------------------------------
+ lldb::SBFileSpec GetFileSpec();
+
+ void SetFileSpec(const lldb::SBFileSpec &fspec);
+
+ //------------------------------------------------------------------
+ /// Get accessor for the module platform file.
+ ///
+ /// Platform file refers to the path of the module as it is known on
+ /// the remote system on which it is being debugged. For local
+ /// debugging this is always the same as Module::GetFileSpec(). But
+ /// remote debugging might mention a file '/usr/lib/liba.dylib'
+ /// which might be locally downloaded and cached. In this case the
+ /// platform file could be something like:
+ /// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib'
+ /// The file could also be cached in a local developer kit directory.
+ ///
+ /// @return
+ /// A const reference to the file specification object.
+ //------------------------------------------------------------------
+ lldb::SBFileSpec GetPlatformFileSpec();
+
+ void SetPlatformFileSpec(const lldb::SBFileSpec &fspec);
+
+ lldb::SBFileSpec GetSymbolFileSpec();
+
+ void SetSymbolFileSpec(const lldb::SBFileSpec &fspec);
+
+ const char *GetObjectName();
+
+ void SetObjectName(const char *name);
+
+ const char *GetTriple();
+
+ void SetTriple(const char *triple);
+
+ const uint8_t *GetUUIDBytes();
+
+ size_t GetUUIDLength();
+
+ bool SetUUIDBytes(const uint8_t *uuid, size_t uuid_len);
+
+ bool GetDescription(lldb::SBStream &description);
- SBModuleSpec ();
-
- SBModuleSpec (const SBModuleSpec &rhs);
-
- ~SBModuleSpec ();
-
- const SBModuleSpec &
- operator = (const SBModuleSpec &rhs);
-
- bool
- IsValid () const;
-
- void
- Clear();
-
- //------------------------------------------------------------------
- /// Get const accessor for the module file.
- ///
- /// This function returns the file for the module on the host system
- /// that is running LLDB. This can differ from the path on the
- /// platform since we might be doing remote debugging.
- ///
- /// @return
- /// A const reference to the file specification object.
- //------------------------------------------------------------------
- lldb::SBFileSpec
- GetFileSpec ();
-
- void
- SetFileSpec (const lldb::SBFileSpec &fspec);
-
- //------------------------------------------------------------------
- /// Get accessor for the module platform file.
- ///
- /// Platform file refers to the path of the module as it is known on
- /// the remote system on which it is being debugged. For local
- /// debugging this is always the same as Module::GetFileSpec(). But
- /// remote debugging might mention a file '/usr/lib/liba.dylib'
- /// which might be locally downloaded and cached. In this case the
- /// platform file could be something like:
- /// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib'
- /// The file could also be cached in a local developer kit directory.
- ///
- /// @return
- /// A const reference to the file specification object.
- //------------------------------------------------------------------
- lldb::SBFileSpec
- GetPlatformFileSpec ();
-
- void
- SetPlatformFileSpec (const lldb::SBFileSpec &fspec);
-
- lldb::SBFileSpec
- GetSymbolFileSpec ();
-
- void
- SetSymbolFileSpec (const lldb::SBFileSpec &fspec);
-
- const char *
- GetObjectName ();
-
- void
- SetObjectName (const char *name);
-
- const char *
- GetTriple ();
-
- void
- SetTriple (const char *triple);
-
- const uint8_t *
- GetUUIDBytes ();
-
- size_t
- GetUUIDLength ();
-
- bool
- SetUUIDBytes (const uint8_t *uuid, size_t uuid_len);
-
- bool
- GetDescription (lldb::SBStream &description);
-
private:
- friend class SBModuleSpecList;
- friend class SBModule;
- friend class SBTarget;
+ friend class SBModuleSpecList;
+ friend class SBModule;
+ friend class SBTarget;
- std::unique_ptr<lldb_private::ModuleSpec> m_opaque_ap;
+ std::unique_ptr<lldb_private::ModuleSpec> m_opaque_ap;
};
-class SBModuleSpecList
-{
+class SBModuleSpecList {
public:
- SBModuleSpecList();
-
- SBModuleSpecList (const SBModuleSpecList &rhs);
-
- ~SBModuleSpecList();
-
- SBModuleSpecList &
- operator = (const SBModuleSpecList &rhs);
-
- static SBModuleSpecList
- GetModuleSpecifications (const char *path);
-
- void
- Append (const SBModuleSpec &spec);
-
- void
- Append (const SBModuleSpecList &spec_list);
-
- SBModuleSpec
- FindFirstMatchingSpec (const SBModuleSpec &match_spec);
-
- SBModuleSpecList
- FindMatchingSpecs (const SBModuleSpec &match_spec);
-
- size_t
- GetSize();
-
- SBModuleSpec
- GetSpecAtIndex (size_t i);
-
- bool
- GetDescription (lldb::SBStream &description);
-
+ SBModuleSpecList();
+
+ SBModuleSpecList(const SBModuleSpecList &rhs);
+
+ ~SBModuleSpecList();
+
+ SBModuleSpecList &operator=(const SBModuleSpecList &rhs);
+
+ static SBModuleSpecList GetModuleSpecifications(const char *path);
+
+ void Append(const SBModuleSpec &spec);
+
+ void Append(const SBModuleSpecList &spec_list);
+
+ SBModuleSpec FindFirstMatchingSpec(const SBModuleSpec &match_spec);
+
+ SBModuleSpecList FindMatchingSpecs(const SBModuleSpec &match_spec);
+
+ size_t GetSize();
+
+ SBModuleSpec GetSpecAtIndex(size_t i);
+
+ bool GetDescription(lldb::SBStream &description);
+
private:
- std::unique_ptr<lldb_private::ModuleSpecList> m_opaque_ap;
+ std::unique_ptr<lldb_private::ModuleSpecList> m_opaque_ap;
};
} // namespace lldb
diff --git a/include/lldb/API/SBPlatform.h b/include/lldb/API/SBPlatform.h
index 80ad1c06e868..3f7e1acb74b5 100644
--- a/include/lldb/API/SBPlatform.h
+++ b/include/lldb/API/SBPlatform.h
@@ -19,195 +19,147 @@ struct PlatformShellCommand;
namespace lldb {
- class SBLaunchInfo;
-
- class LLDB_API SBPlatformConnectOptions
- {
- public:
- SBPlatformConnectOptions (const char *url);
-
- SBPlatformConnectOptions (const SBPlatformConnectOptions &rhs);
-
- ~SBPlatformConnectOptions ();
-
- void
- operator=(const SBPlatformConnectOptions &rhs);
-
- const char *
- GetURL();
-
- void
- SetURL(const char *url);
-
- bool
- GetRsyncEnabled();
-
- void
- EnableRsync (const char *options,
- const char *remote_path_prefix,
- bool omit_remote_hostname);
-
- void
- DisableRsync ();
-
- const char *
- GetLocalCacheDirectory();
-
- void
- SetLocalCacheDirectory(const char *path);
- protected:
- PlatformConnectOptions *m_opaque_ptr;
- };
-
- class LLDB_API SBPlatformShellCommand
- {
- public:
- SBPlatformShellCommand (const char *shell_command);
-
- SBPlatformShellCommand (const SBPlatformShellCommand &rhs);
-
- ~SBPlatformShellCommand();
-
- void
- Clear();
-
- const char *
- GetCommand();
-
- void
- SetCommand(const char *shell_command);
-
- const char *
- GetWorkingDirectory ();
-
- void
- SetWorkingDirectory (const char *path);
-
- uint32_t
- GetTimeoutSeconds ();
-
- void
- SetTimeoutSeconds (uint32_t sec);
-
- int
- GetSignal ();
-
- int
- GetStatus ();
-
- const char *
- GetOutput ();
-
- protected:
- friend class SBPlatform;
-
- PlatformShellCommand *m_opaque_ptr;
- };
-
- class LLDB_API SBPlatform
- {
- public:
-
- SBPlatform ();
-
- SBPlatform (const char *platform_name);
-
- ~SBPlatform();
-
- bool
- IsValid () const;
-
- void
- Clear ();
-
- const char *
- GetWorkingDirectory();
-
- bool
- SetWorkingDirectory(const char *path);
-
- const char *
- GetName ();
-
- SBError
- ConnectRemote (SBPlatformConnectOptions &connect_options);
-
- void
- DisconnectRemote ();
-
- bool
- IsConnected();
-
- //----------------------------------------------------------------------
- // The following functions will work if the platform is connected
- //----------------------------------------------------------------------
- const char *
- GetTriple();
-
- const char *
- GetHostname ();
-
- const char *
- GetOSBuild ();
-
- const char *
- GetOSDescription ();
-
- uint32_t
- GetOSMajorVersion ();
-
- uint32_t
- GetOSMinorVersion ();
-
- uint32_t
- GetOSUpdateVersion ();
-
- SBError
- Put (SBFileSpec &src, SBFileSpec &dst);
-
- SBError
- Get (SBFileSpec &src, SBFileSpec &dst);
-
- SBError
- Install (SBFileSpec& src, SBFileSpec& dst);
-
- SBError
- Run (SBPlatformShellCommand &shell_command);
-
- SBError
- Launch (SBLaunchInfo &launch_info);
-
- SBError
- Kill (const lldb::pid_t pid);
-
- SBError
- MakeDirectory (const char *path, uint32_t file_permissions = eFilePermissionsDirectoryDefault);
-
- uint32_t
- GetFilePermissions (const char *path);
-
- SBError
- SetFilePermissions (const char *path, uint32_t file_permissions);
-
- SBUnixSignals
- GetUnixSignals() const;
-
- protected:
-
- friend class SBDebugger;
- friend class SBTarget;
-
- lldb::PlatformSP
- GetSP () const;
-
- void
- SetSP (const lldb::PlatformSP& platform_sp);
-
- SBError
- ExecuteConnected (const std::function<lldb_private::Error(const lldb::PlatformSP&)>& func);
-
- lldb::PlatformSP m_opaque_sp;
- };
+class SBLaunchInfo;
+
+class LLDB_API SBPlatformConnectOptions {
+public:
+ SBPlatformConnectOptions(const char *url);
+
+ SBPlatformConnectOptions(const SBPlatformConnectOptions &rhs);
+
+ ~SBPlatformConnectOptions();
+
+ void operator=(const SBPlatformConnectOptions &rhs);
+
+ const char *GetURL();
+
+ void SetURL(const char *url);
+
+ bool GetRsyncEnabled();
+
+ void EnableRsync(const char *options, const char *remote_path_prefix,
+ bool omit_remote_hostname);
+
+ void DisableRsync();
+
+ const char *GetLocalCacheDirectory();
+
+ void SetLocalCacheDirectory(const char *path);
+
+protected:
+ PlatformConnectOptions *m_opaque_ptr;
+};
+
+class LLDB_API SBPlatformShellCommand {
+public:
+ SBPlatformShellCommand(const char *shell_command);
+
+ SBPlatformShellCommand(const SBPlatformShellCommand &rhs);
+
+ ~SBPlatformShellCommand();
+
+ void Clear();
+
+ const char *GetCommand();
+
+ void SetCommand(const char *shell_command);
+
+ const char *GetWorkingDirectory();
+
+ void SetWorkingDirectory(const char *path);
+
+ uint32_t GetTimeoutSeconds();
+
+ void SetTimeoutSeconds(uint32_t sec);
+
+ int GetSignal();
+
+ int GetStatus();
+
+ const char *GetOutput();
+
+protected:
+ friend class SBPlatform;
+
+ PlatformShellCommand *m_opaque_ptr;
+};
+
+class LLDB_API SBPlatform {
+public:
+ SBPlatform();
+
+ SBPlatform(const char *platform_name);
+
+ ~SBPlatform();
+
+ bool IsValid() const;
+
+ void Clear();
+
+ const char *GetWorkingDirectory();
+
+ bool SetWorkingDirectory(const char *path);
+
+ const char *GetName();
+
+ SBError ConnectRemote(SBPlatformConnectOptions &connect_options);
+
+ void DisconnectRemote();
+
+ bool IsConnected();
+
+ //----------------------------------------------------------------------
+ // The following functions will work if the platform is connected
+ //----------------------------------------------------------------------
+ const char *GetTriple();
+
+ const char *GetHostname();
+
+ const char *GetOSBuild();
+
+ const char *GetOSDescription();
+
+ uint32_t GetOSMajorVersion();
+
+ uint32_t GetOSMinorVersion();
+
+ uint32_t GetOSUpdateVersion();
+
+ SBError Put(SBFileSpec &src, SBFileSpec &dst);
+
+ SBError Get(SBFileSpec &src, SBFileSpec &dst);
+
+ SBError Install(SBFileSpec &src, SBFileSpec &dst);
+
+ SBError Run(SBPlatformShellCommand &shell_command);
+
+ SBError Launch(SBLaunchInfo &launch_info);
+
+ SBError Kill(const lldb::pid_t pid);
+
+ SBError
+ MakeDirectory(const char *path,
+ uint32_t file_permissions = eFilePermissionsDirectoryDefault);
+
+ uint32_t GetFilePermissions(const char *path);
+
+ SBError SetFilePermissions(const char *path, uint32_t file_permissions);
+
+ SBUnixSignals GetUnixSignals() const;
+
+protected:
+ friend class SBDebugger;
+ friend class SBTarget;
+
+ lldb::PlatformSP GetSP() const;
+
+ void SetSP(const lldb::PlatformSP &platform_sp);
+
+ SBError ExecuteConnected(
+ const std::function<lldb_private::Error(const lldb::PlatformSP &)> &func);
+
+ lldb::PlatformSP m_opaque_sp;
+};
} // namespace lldb
diff --git a/include/lldb/API/SBProcess.h b/include/lldb/API/SBProcess.h
index a8881ad898c0..fd95790c6686 100644
--- a/include/lldb/API/SBProcess.h
+++ b/include/lldb/API/SBProcess.h
@@ -12,438 +12,368 @@
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBError.h"
-#include "lldb/API/SBTarget.h"
#include "lldb/API/SBQueue.h"
+#include "lldb/API/SBTarget.h"
#include <stdio.h>
namespace lldb {
class SBEvent;
-class LLDB_API SBProcess
-{
+class LLDB_API SBProcess {
public:
- //------------------------------------------------------------------
- /// Broadcaster event bits definitions.
- //------------------------------------------------------------------
- FLAGS_ANONYMOUS_ENUM()
- {
- eBroadcastBitStateChanged = (1 << 0),
- eBroadcastBitInterrupt = (1 << 1),
- eBroadcastBitSTDOUT = (1 << 2),
- eBroadcastBitSTDERR = (1 << 3),
- eBroadcastBitProfileData = (1 << 4)
- };
-
- SBProcess ();
-
- SBProcess (const lldb::SBProcess& rhs);
-
- const lldb::SBProcess&
- operator = (const lldb::SBProcess& rhs);
-
- SBProcess (const lldb::ProcessSP &process_sp);
-
- ~SBProcess();
-
- static const char *
- GetBroadcasterClassName ();
-
- const char *
- GetPluginName ();
-
- // DEPRECATED: use GetPluginName()
- const char *
- GetShortPluginName ();
-
- void
- Clear ();
-
- bool
- IsValid() const;
-
- lldb::SBTarget
- GetTarget() const;
-
- lldb::ByteOrder
- GetByteOrder() const;
-
- size_t
- PutSTDIN (const char *src, size_t src_len);
-
- size_t
- GetSTDOUT (char *dst, size_t dst_len) const;
-
- size_t
- GetSTDERR (char *dst, size_t dst_len) const;
-
- size_t
- GetAsyncProfileData(char *dst, size_t dst_len) const;
-
- void
- ReportEventState (const lldb::SBEvent &event, FILE *out) const;
-
- void
- AppendEventStateReport (const lldb::SBEvent &event, lldb::SBCommandReturnObject &result);
-
- //------------------------------------------------------------------
- /// Remote connection related functions. These will fail if the
- /// process is not in eStateConnected. They are intended for use
- /// when connecting to an externally managed debugserver instance.
- //------------------------------------------------------------------
- bool
- RemoteAttachToProcessWithID (lldb::pid_t pid,
- lldb::SBError& error);
-
- bool
- RemoteLaunch (char const **argv,
- char const **envp,
- const char *stdin_path,
- const char *stdout_path,
- const char *stderr_path,
- const char *working_directory,
- uint32_t launch_flags,
- bool stop_at_entry,
- lldb::SBError& error);
-
- //------------------------------------------------------------------
- // Thread related functions
- //------------------------------------------------------------------
- uint32_t
- GetNumThreads ();
-
- lldb::SBThread
- GetThreadAtIndex (size_t index);
-
- lldb::SBThread
- GetThreadByID (lldb::tid_t sb_thread_id);
-
- lldb::SBThread
- GetThreadByIndexID (uint32_t index_id);
-
- lldb::SBThread
- GetSelectedThread () const;
-
- //------------------------------------------------------------------
- // Function for lazily creating a thread using the current OS
- // plug-in. This function will be removed in the future when there
- // are APIs to create SBThread objects through the interface and add
- // them to the process through the SBProcess API.
- //------------------------------------------------------------------
- lldb::SBThread
- CreateOSPluginThread (lldb::tid_t tid, lldb::addr_t context);
-
- bool
- SetSelectedThread (const lldb::SBThread &thread);
-
- bool
- SetSelectedThreadByID (lldb::tid_t tid);
-
- bool
- SetSelectedThreadByIndexID (uint32_t index_id);
-
- //------------------------------------------------------------------
- // Queue related functions
- //------------------------------------------------------------------
- uint32_t
- GetNumQueues ();
-
- lldb::SBQueue
- GetQueueAtIndex (size_t index);
-
- //------------------------------------------------------------------
- // Stepping related functions
- //------------------------------------------------------------------
-
- lldb::StateType
- GetState ();
-
- int
- GetExitStatus ();
-
- const char *
- GetExitDescription ();
-
- //------------------------------------------------------------------
- /// Gets the process ID
- ///
- /// Returns the process identifier for the process as it is known
- /// on the system on which the process is running. For unix systems
- /// this is typically the same as if you called "getpid()" in the
- /// process.
- ///
- /// @return
- /// Returns LLDB_INVALID_PROCESS_ID if this object does not
- /// contain a valid process object, or if the process has not
- /// been launched. Returns a valid process ID if the process is
- /// valid.
- //------------------------------------------------------------------
- lldb::pid_t
- GetProcessID ();
-
- //------------------------------------------------------------------
- /// Gets the unique ID associated with this process object
- ///
- /// Unique IDs start at 1 and increment up with each new process
- /// instance. Since starting a process on a system might always
- /// create a process with the same process ID, there needs to be a
- /// way to tell two process instances apart.
- ///
- /// @return
- /// Returns a non-zero integer ID if this object contains a
- /// valid process object, zero if this object does not contain
- /// a valid process object.
- //------------------------------------------------------------------
- uint32_t
- GetUniqueID();
-
- uint32_t
- GetAddressByteSize() const;
-
- lldb::SBError
- Destroy ();
-
- lldb::SBError
- Continue ();
-
- lldb::SBError
- Stop ();
-
- lldb::SBError
- Kill ();
-
- lldb::SBError
- Detach ();
-
- lldb::SBError
- Detach (bool keep_stopped);
-
- lldb::SBError
- Signal (int signal);
-
- lldb::SBUnixSignals
- GetUnixSignals();
-
- void
- SendAsyncInterrupt();
-
- uint32_t
- GetStopID(bool include_expression_stops = false);
-
- //------------------------------------------------------------------
- /// Gets the stop event corresponding to stop ID.
- //
- /// Note that it wasn't fully implemented and tracks only the stop
- /// event for the last natural stop ID.
- ///
- /// @param [in] stop_id
- /// The ID of the stop event to return.
- ///
- /// @return
- /// The stop event corresponding to stop ID.
- //------------------------------------------------------------------
- lldb::SBEvent
- GetStopEventForStopID(uint32_t stop_id);
-
- size_t
- ReadMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error);
-
- size_t
- WriteMemory (addr_t addr, const void *buf, size_t size, lldb::SBError &error);
-
- size_t
- ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error);
-
- uint64_t
- ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &error);
-
- lldb::addr_t
- ReadPointerFromMemory (addr_t addr, lldb::SBError &error);
-
- // Events
- static lldb::StateType
- GetStateFromEvent (const lldb::SBEvent &event);
-
- static bool
- GetRestartedFromEvent (const lldb::SBEvent &event);
-
- static size_t
- GetNumRestartedReasonsFromEvent (const lldb::SBEvent &event);
-
- static const char *
- GetRestartedReasonAtIndexFromEvent (const lldb::SBEvent &event, size_t idx);
-
- static lldb::SBProcess
- GetProcessFromEvent (const lldb::SBEvent &event);
-
- static bool
- GetInterruptedFromEvent (const lldb::SBEvent &event);
-
- static bool
- EventIsProcessEvent (const lldb::SBEvent &event);
-
- lldb::SBBroadcaster
- GetBroadcaster () const;
-
- static const char *
- GetBroadcasterClass ();
-
- bool
- GetDescription (lldb::SBStream &description);
-
- uint32_t
- GetNumSupportedHardwareWatchpoints (lldb::SBError &error) const;
-
- //------------------------------------------------------------------
- /// Load a shared library into this process.
- ///
- /// @param[in] remote_image_spec
- /// The path for the shared library on the target what you want
- /// to load.
- ///
- /// @param[out] error
- /// An error object that gets filled in with any errors that
- /// might occur when trying to load the shared library.
- ///
- /// @return
- /// A token that represents the shared library that can be
- /// later used to unload the shared library. A value of
- /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared
- /// library can't be opened.
- //------------------------------------------------------------------
- uint32_t
- LoadImage (lldb::SBFileSpec &remote_image_spec, lldb::SBError &error);
-
- //------------------------------------------------------------------
- /// Load a shared library into this process.
- ///
- /// @param[in] local_image_spec
- /// The file spec that points to the shared library that you
- /// want to load if the library is located on the host. The
- /// library will be copied over to the location specified by
- /// remote_image_spec or into the current working directory with
- /// the same filename if the remote_image_spec isn't specified.
- ///
- /// @param[in] remote_image_spec
- /// If local_image_spec is specified then the location where the
- /// library should be copied over from the host. If
- /// local_image_spec isn't specified, then the path for the
- /// shared library on the target what you want to load.
- ///
- /// @param[out] error
- /// An error object that gets filled in with any errors that
- /// might occur when trying to load the shared library.
- ///
- /// @return
- /// A token that represents the shared library that can be
- /// later used to unload the shared library. A value of
- /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared
- /// library can't be opened.
- //------------------------------------------------------------------
- uint32_t
- LoadImage (const lldb::SBFileSpec &local_image_spec,
- const lldb::SBFileSpec &remote_image_spec,
- lldb::SBError &error);
-
- lldb::SBError
- UnloadImage (uint32_t image_token);
-
- lldb::SBError
- SendEventData (const char *data);
-
- //------------------------------------------------------------------
- /// Return the number of different thread-origin extended backtraces
- /// this process can support.
- ///
- /// When the process is stopped and you have an SBThread, lldb may be
- /// able to show a backtrace of when that thread was originally created,
- /// or the work item was enqueued to it (in the case of a libdispatch
- /// queue).
- ///
- /// @return
- /// The number of thread-origin extended backtrace types that may be
- /// available.
- //------------------------------------------------------------------
- uint32_t
- GetNumExtendedBacktraceTypes ();
-
- //------------------------------------------------------------------
- /// Return the name of one of the thread-origin extended backtrace
- /// methods.
- ///
- /// @param [in] idx
- /// The index of the name to return. They will be returned in
- /// the order that the user will most likely want to see them.
- /// e.g. if the type at index 0 is not available for a thread,
- /// see if the type at index 1 provides an extended backtrace.
- ///
- /// @return
- /// The name at that index.
- //------------------------------------------------------------------
- const char *
- GetExtendedBacktraceTypeAtIndex (uint32_t idx);
-
- lldb::SBThreadCollection
- GetHistoryThreads (addr_t addr);
-
- bool
- IsInstrumentationRuntimePresent(InstrumentationRuntimeType type);
-
- // Save the state of the process in a core file (or mini dump on Windows).
- lldb::SBError
- SaveCore(const char *file_name);
-
- //------------------------------------------------------------------
- /// Query the address load_addr and store the details of the memory
- /// region that contains it in the supplied SBMemoryRegionInfo object.
- /// To iterate over all memory regions use GetMemoryRegionList.
- ///
- /// @param[in] load_addr
- /// The address to be queried.
- ///
- /// @param[out] region_info
- /// A reference to an SBMemoryRegionInfo object that will contain
- /// the details of the memory region containing load_addr.
- ///
- /// @return
- /// An error object describes any errors that occurred while
- /// querying load_addr.
- //------------------------------------------------------------------
- lldb::SBError
- GetMemoryRegionInfo (lldb::addr_t load_addr, lldb::SBMemoryRegionInfo &region_info);
-
- //------------------------------------------------------------------
- /// Return the list of memory regions within the process.
- ///
- /// @return
- /// A list of all witin the process memory regions.
- //------------------------------------------------------------------
- lldb::SBMemoryRegionInfoList
- GetMemoryRegions();
+ //------------------------------------------------------------------
+ /// Broadcaster event bits definitions.
+ //------------------------------------------------------------------
+ FLAGS_ANONYMOUS_ENUM(){eBroadcastBitStateChanged = (1 << 0),
+ eBroadcastBitInterrupt = (1 << 1),
+ eBroadcastBitSTDOUT = (1 << 2),
+ eBroadcastBitSTDERR = (1 << 3),
+ eBroadcastBitProfileData = (1 << 4),
+ eBroadcastBitStructuredData = (1 << 5)};
+
+ SBProcess();
+
+ SBProcess(const lldb::SBProcess &rhs);
+
+ const lldb::SBProcess &operator=(const lldb::SBProcess &rhs);
+
+ SBProcess(const lldb::ProcessSP &process_sp);
+
+ ~SBProcess();
+
+ static const char *GetBroadcasterClassName();
+
+ const char *GetPluginName();
+
+ // DEPRECATED: use GetPluginName()
+ const char *GetShortPluginName();
+
+ void Clear();
+
+ bool IsValid() const;
+
+ lldb::SBTarget GetTarget() const;
+
+ lldb::ByteOrder GetByteOrder() const;
+
+ size_t PutSTDIN(const char *src, size_t src_len);
+
+ size_t GetSTDOUT(char *dst, size_t dst_len) const;
+
+ size_t GetSTDERR(char *dst, size_t dst_len) const;
+
+ size_t GetAsyncProfileData(char *dst, size_t dst_len) const;
+
+ void ReportEventState(const lldb::SBEvent &event, FILE *out) const;
+
+ void AppendEventStateReport(const lldb::SBEvent &event,
+ lldb::SBCommandReturnObject &result);
+
+ //------------------------------------------------------------------
+ /// Remote connection related functions. These will fail if the
+ /// process is not in eStateConnected. They are intended for use
+ /// when connecting to an externally managed debugserver instance.
+ //------------------------------------------------------------------
+ bool RemoteAttachToProcessWithID(lldb::pid_t pid, lldb::SBError &error);
+
+ bool RemoteLaunch(char const **argv, char const **envp,
+ const char *stdin_path, const char *stdout_path,
+ const char *stderr_path, const char *working_directory,
+ uint32_t launch_flags, bool stop_at_entry,
+ lldb::SBError &error);
+
+ //------------------------------------------------------------------
+ // Thread related functions
+ //------------------------------------------------------------------
+ uint32_t GetNumThreads();
+
+ lldb::SBThread GetThreadAtIndex(size_t index);
+
+ lldb::SBThread GetThreadByID(lldb::tid_t sb_thread_id);
+
+ lldb::SBThread GetThreadByIndexID(uint32_t index_id);
+
+ lldb::SBThread GetSelectedThread() const;
+
+ //------------------------------------------------------------------
+ // Function for lazily creating a thread using the current OS
+ // plug-in. This function will be removed in the future when there
+ // are APIs to create SBThread objects through the interface and add
+ // them to the process through the SBProcess API.
+ //------------------------------------------------------------------
+ lldb::SBThread CreateOSPluginThread(lldb::tid_t tid, lldb::addr_t context);
+
+ bool SetSelectedThread(const lldb::SBThread &thread);
+
+ bool SetSelectedThreadByID(lldb::tid_t tid);
+
+ bool SetSelectedThreadByIndexID(uint32_t index_id);
+
+ //------------------------------------------------------------------
+ // Queue related functions
+ //------------------------------------------------------------------
+ uint32_t GetNumQueues();
+
+ lldb::SBQueue GetQueueAtIndex(size_t index);
+
+ //------------------------------------------------------------------
+ // Stepping related functions
+ //------------------------------------------------------------------
+
+ lldb::StateType GetState();
+
+ int GetExitStatus();
+
+ const char *GetExitDescription();
+
+ //------------------------------------------------------------------
+ /// Gets the process ID
+ ///
+ /// Returns the process identifier for the process as it is known
+ /// on the system on which the process is running. For unix systems
+ /// this is typically the same as if you called "getpid()" in the
+ /// process.
+ ///
+ /// @return
+ /// Returns LLDB_INVALID_PROCESS_ID if this object does not
+ /// contain a valid process object, or if the process has not
+ /// been launched. Returns a valid process ID if the process is
+ /// valid.
+ //------------------------------------------------------------------
+ lldb::pid_t GetProcessID();
+
+ //------------------------------------------------------------------
+ /// Gets the unique ID associated with this process object
+ ///
+ /// Unique IDs start at 1 and increment up with each new process
+ /// instance. Since starting a process on a system might always
+ /// create a process with the same process ID, there needs to be a
+ /// way to tell two process instances apart.
+ ///
+ /// @return
+ /// Returns a non-zero integer ID if this object contains a
+ /// valid process object, zero if this object does not contain
+ /// a valid process object.
+ //------------------------------------------------------------------
+ uint32_t GetUniqueID();
+
+ uint32_t GetAddressByteSize() const;
+
+ lldb::SBError Destroy();
+
+ lldb::SBError Continue();
+
+ lldb::SBError Stop();
+
+ lldb::SBError Kill();
+
+ lldb::SBError Detach();
+
+ lldb::SBError Detach(bool keep_stopped);
+
+ lldb::SBError Signal(int signal);
+
+ lldb::SBUnixSignals GetUnixSignals();
+
+ void SendAsyncInterrupt();
+
+ uint32_t GetStopID(bool include_expression_stops = false);
+
+ //------------------------------------------------------------------
+ /// Gets the stop event corresponding to stop ID.
+ //
+ /// Note that it wasn't fully implemented and tracks only the stop
+ /// event for the last natural stop ID.
+ ///
+ /// @param [in] stop_id
+ /// The ID of the stop event to return.
+ ///
+ /// @return
+ /// The stop event corresponding to stop ID.
+ //------------------------------------------------------------------
+ lldb::SBEvent GetStopEventForStopID(uint32_t stop_id);
+
+ size_t ReadMemory(addr_t addr, void *buf, size_t size, lldb::SBError &error);
+
+ size_t WriteMemory(addr_t addr, const void *buf, size_t size,
+ lldb::SBError &error);
+
+ size_t ReadCStringFromMemory(addr_t addr, void *buf, size_t size,
+ lldb::SBError &error);
+
+ uint64_t ReadUnsignedFromMemory(addr_t addr, uint32_t byte_size,
+ lldb::SBError &error);
+
+ lldb::addr_t ReadPointerFromMemory(addr_t addr, lldb::SBError &error);
+
+ // Events
+ static lldb::StateType GetStateFromEvent(const lldb::SBEvent &event);
+
+ static bool GetRestartedFromEvent(const lldb::SBEvent &event);
+
+ static size_t GetNumRestartedReasonsFromEvent(const lldb::SBEvent &event);
+
+ static const char *
+ GetRestartedReasonAtIndexFromEvent(const lldb::SBEvent &event, size_t idx);
+
+ static lldb::SBProcess GetProcessFromEvent(const lldb::SBEvent &event);
+
+ static bool GetInterruptedFromEvent(const lldb::SBEvent &event);
+
+ static lldb::SBStructuredData
+ GetStructuredDataFromEvent(const lldb::SBEvent &event);
+
+ static bool EventIsProcessEvent(const lldb::SBEvent &event);
+
+ static bool EventIsStructuredDataEvent(const lldb::SBEvent &event);
+
+ lldb::SBBroadcaster GetBroadcaster() const;
+
+ static const char *GetBroadcasterClass();
+
+ bool GetDescription(lldb::SBStream &description);
+
+ uint32_t GetNumSupportedHardwareWatchpoints(lldb::SBError &error) const;
+
+ //------------------------------------------------------------------
+ /// Load a shared library into this process.
+ ///
+ /// @param[in] remote_image_spec
+ /// The path for the shared library on the target what you want
+ /// to load.
+ ///
+ /// @param[out] error
+ /// An error object that gets filled in with any errors that
+ /// might occur when trying to load the shared library.
+ ///
+ /// @return
+ /// A token that represents the shared library that can be
+ /// later used to unload the shared library. A value of
+ /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared
+ /// library can't be opened.
+ //------------------------------------------------------------------
+ uint32_t LoadImage(lldb::SBFileSpec &remote_image_spec, lldb::SBError &error);
+
+ //------------------------------------------------------------------
+ /// Load a shared library into this process.
+ ///
+ /// @param[in] local_image_spec
+ /// The file spec that points to the shared library that you
+ /// want to load if the library is located on the host. The
+ /// library will be copied over to the location specified by
+ /// remote_image_spec or into the current working directory with
+ /// the same filename if the remote_image_spec isn't specified.
+ ///
+ /// @param[in] remote_image_spec
+ /// If local_image_spec is specified then the location where the
+ /// library should be copied over from the host. If
+ /// local_image_spec isn't specified, then the path for the
+ /// shared library on the target what you want to load.
+ ///
+ /// @param[out] error
+ /// An error object that gets filled in with any errors that
+ /// might occur when trying to load the shared library.
+ ///
+ /// @return
+ /// A token that represents the shared library that can be
+ /// later used to unload the shared library. A value of
+ /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared
+ /// library can't be opened.
+ //------------------------------------------------------------------
+ uint32_t LoadImage(const lldb::SBFileSpec &local_image_spec,
+ const lldb::SBFileSpec &remote_image_spec,
+ lldb::SBError &error);
+
+ lldb::SBError UnloadImage(uint32_t image_token);
+
+ lldb::SBError SendEventData(const char *data);
+
+ //------------------------------------------------------------------
+ /// Return the number of different thread-origin extended backtraces
+ /// this process can support.
+ ///
+ /// When the process is stopped and you have an SBThread, lldb may be
+ /// able to show a backtrace of when that thread was originally created,
+ /// or the work item was enqueued to it (in the case of a libdispatch
+ /// queue).
+ ///
+ /// @return
+ /// The number of thread-origin extended backtrace types that may be
+ /// available.
+ //------------------------------------------------------------------
+ uint32_t GetNumExtendedBacktraceTypes();
+
+ //------------------------------------------------------------------
+ /// Return the name of one of the thread-origin extended backtrace
+ /// methods.
+ ///
+ /// @param [in] idx
+ /// The index of the name to return. They will be returned in
+ /// the order that the user will most likely want to see them.
+ /// e.g. if the type at index 0 is not available for a thread,
+ /// see if the type at index 1 provides an extended backtrace.
+ ///
+ /// @return
+ /// The name at that index.
+ //------------------------------------------------------------------
+ const char *GetExtendedBacktraceTypeAtIndex(uint32_t idx);
+
+ lldb::SBThreadCollection GetHistoryThreads(addr_t addr);
+
+ bool IsInstrumentationRuntimePresent(InstrumentationRuntimeType type);
+
+ // Save the state of the process in a core file (or mini dump on Windows).
+ lldb::SBError SaveCore(const char *file_name);
+
+ //------------------------------------------------------------------
+ /// Query the address load_addr and store the details of the memory
+ /// region that contains it in the supplied SBMemoryRegionInfo object.
+ /// To iterate over all memory regions use GetMemoryRegionList.
+ ///
+ /// @param[in] load_addr
+ /// The address to be queried.
+ ///
+ /// @param[out] region_info
+ /// A reference to an SBMemoryRegionInfo object that will contain
+ /// the details of the memory region containing load_addr.
+ ///
+ /// @return
+ /// An error object describes any errors that occurred while
+ /// querying load_addr.
+ //------------------------------------------------------------------
+ lldb::SBError GetMemoryRegionInfo(lldb::addr_t load_addr,
+ lldb::SBMemoryRegionInfo &region_info);
+
+ //------------------------------------------------------------------
+ /// Return the list of memory regions within the process.
+ ///
+ /// @return
+ /// A list of all witin the process memory regions.
+ //------------------------------------------------------------------
+ lldb::SBMemoryRegionInfoList GetMemoryRegions();
protected:
- friend class SBAddress;
- friend class SBBreakpoint;
- friend class SBBreakpointLocation;
- friend class SBCommandInterpreter;
- friend class SBDebugger;
- friend class SBExecutionContext;
- friend class SBFunction;
- friend class SBModule;
- friend class SBTarget;
- friend class SBThread;
- friend class SBValue;
- friend class lldb_private::QueueImpl;
-
- lldb::ProcessSP
- GetSP() const;
-
- void
- SetSP (const lldb::ProcessSP &process_sp);
-
- lldb::ProcessWP m_opaque_wp;
+ friend class SBAddress;
+ friend class SBBreakpoint;
+ friend class SBBreakpointLocation;
+ friend class SBCommandInterpreter;
+ friend class SBDebugger;
+ friend class SBExecutionContext;
+ friend class SBFunction;
+ friend class SBModule;
+ friend class SBTarget;
+ friend class SBThread;
+ friend class SBValue;
+ friend class lldb_private::QueueImpl;
+
+ lldb::ProcessSP GetSP() const;
+
+ void SetSP(const lldb::ProcessSP &process_sp);
+
+ lldb::ProcessWP m_opaque_wp;
};
-} // namespace lldb
+} // namespace lldb
-#endif // LLDB_SBProcess_h_
+#endif // LLDB_SBProcess_h_
diff --git a/include/lldb/API/SBQueue.h b/include/lldb/API/SBQueue.h
index 2f453cddd5d1..53612c0a125f 100644
--- a/include/lldb/API/SBQueue.h
+++ b/include/lldb/API/SBQueue.h
@@ -12,78 +12,61 @@
#include <vector>
-#include "lldb/lldb-forward.h"
#include "lldb/API/SBDefines.h"
+#include "lldb/lldb-forward.h"
namespace lldb {
-class LLDB_API SBQueue
-{
+class LLDB_API SBQueue {
public:
- SBQueue ();
+ SBQueue();
+
+ SBQueue(const QueueSP &queue_sp);
- SBQueue (const QueueSP& queue_sp);
-
- SBQueue (const SBQueue& rhs);
+ SBQueue(const SBQueue &rhs);
- const SBQueue &
- operator= (const lldb::SBQueue& rhs);
+ const SBQueue &operator=(const lldb::SBQueue &rhs);
- ~SBQueue();
+ ~SBQueue();
- bool
- IsValid() const;
+ bool IsValid() const;
- void
- Clear ();
+ void Clear();
- lldb::SBProcess
- GetProcess ();
+ lldb::SBProcess GetProcess();
- lldb::queue_id_t
- GetQueueID () const;
+ lldb::queue_id_t GetQueueID() const;
- const char *
- GetName () const;
+ const char *GetName() const;
- uint32_t
- GetIndexID () const;
+ uint32_t GetIndexID() const;
- uint32_t
- GetNumThreads ();
+ uint32_t GetNumThreads();
- lldb::SBThread
- GetThreadAtIndex (uint32_t);
+ lldb::SBThread GetThreadAtIndex(uint32_t);
- uint32_t
- GetNumPendingItems ();
+ uint32_t GetNumPendingItems();
- lldb::SBQueueItem
- GetPendingItemAtIndex (uint32_t);
+ lldb::SBQueueItem GetPendingItemAtIndex(uint32_t);
- uint32_t
- GetNumRunningItems ();
+ uint32_t GetNumRunningItems();
- lldb::QueueKind
- GetKind ();
+ lldb::QueueKind GetKind();
protected:
- friend class SBProcess;
- friend class SBThread;
+ friend class SBProcess;
+ friend class SBThread;
- void
- SetQueue (const lldb::QueueSP& queue_sp);
+ void SetQueue(const lldb::QueueSP &queue_sp);
- void
- FetchThreads ();
+ void FetchThreads();
- void
- FetchItems ();
+ void FetchItems();
private:
- std::shared_ptr<lldb_private::QueueImpl> m_opaque_sp;
+ std::shared_ptr<lldb_private::QueueImpl> m_opaque_sp;
};
} // namespace lldb
-#endif // LLDB_SBQueue_h_
+#endif // LLDB_SBQueue_h_
diff --git a/include/lldb/API/SBQueueItem.h b/include/lldb/API/SBQueueItem.h
index 9426a53b2376..78ca3ba02db1 100644
--- a/include/lldb/API/SBQueueItem.h
+++ b/include/lldb/API/SBQueueItem.h
@@ -10,48 +10,39 @@
#ifndef LLDB_SBQueueItem_h_
#define LLDB_SBQueueItem_h_
-#include "lldb/API/SBDefines.h"
#include "lldb/API/SBAddress.h"
+#include "lldb/API/SBDefines.h"
namespace lldb {
-class LLDB_API SBQueueItem
-{
+class LLDB_API SBQueueItem {
public:
- SBQueueItem ();
+ SBQueueItem();
+
+ SBQueueItem(const lldb::QueueItemSP &queue_item_sp);
- SBQueueItem (const lldb::QueueItemSP& queue_item_sp);
-
- ~SBQueueItem();
+ ~SBQueueItem();
- bool
- IsValid() const;
+ bool IsValid() const;
- void
- Clear ();
+ void Clear();
- lldb::QueueItemKind
- GetKind () const;
+ lldb::QueueItemKind GetKind() const;
- void
- SetKind (lldb::QueueItemKind kind);
+ void SetKind(lldb::QueueItemKind kind);
- lldb::SBAddress
- GetAddress () const;
+ lldb::SBAddress GetAddress() const;
- void
- SetAddress (lldb::SBAddress addr);
+ void SetAddress(lldb::SBAddress addr);
- void
- SetQueueItem (const lldb::QueueItemSP& queue_item_sp);
+ void SetQueueItem(const lldb::QueueItemSP &queue_item_sp);
- SBThread
- GetExtendedBacktraceThread (const char *type);
+ SBThread GetExtendedBacktraceThread(const char *type);
private:
- lldb::QueueItemSP m_queue_item_sp;
+ lldb::QueueItemSP m_queue_item_sp;
};
} // namespace lldb
-#endif // LLDB_SBQueueItem_h_
+#endif // LLDB_SBQueueItem_h_
diff --git a/include/lldb/API/SBSection.h b/include/lldb/API/SBSection.h
index 0a22413b5b9c..ffd8bf7c979b 100644
--- a/include/lldb/API/SBSection.h
+++ b/include/lldb/API/SBSection.h
@@ -10,106 +10,94 @@
#ifndef LLDB_SBSection_h_
#define LLDB_SBSection_h_
-#include "lldb/API/SBDefines.h"
#include "lldb/API/SBData.h"
+#include "lldb/API/SBDefines.h"
namespace lldb {
-class LLDB_API SBSection
-{
+class LLDB_API SBSection {
public:
+ SBSection();
+
+ SBSection(const lldb::SBSection &rhs);
+
+ ~SBSection();
+
+ const lldb::SBSection &operator=(const lldb::SBSection &rhs);
- SBSection ();
+ bool IsValid() const;
- SBSection (const lldb::SBSection &rhs);
+ const char *GetName();
- ~SBSection ();
+ lldb::SBSection GetParent();
- const lldb::SBSection &
- operator = (const lldb::SBSection &rhs);
+ lldb::SBSection FindSubSection(const char *sect_name);
- bool
- IsValid () const;
+ size_t GetNumSubSections();
- const char *
- GetName ();
+ lldb::SBSection GetSubSectionAtIndex(size_t idx);
- lldb::SBSection
- GetParent();
+ lldb::addr_t GetFileAddress();
- lldb::SBSection
- FindSubSection (const char *sect_name);
+ lldb::addr_t GetLoadAddress(lldb::SBTarget &target);
- size_t
- GetNumSubSections ();
+ lldb::addr_t GetByteSize();
- lldb::SBSection
- GetSubSectionAtIndex (size_t idx);
+ uint64_t GetFileOffset();
- lldb::addr_t
- GetFileAddress ();
+ uint64_t GetFileByteSize();
- lldb::addr_t
- GetLoadAddress (lldb::SBTarget &target);
-
- lldb::addr_t
- GetByteSize ();
+ lldb::SBData GetSectionData();
- uint64_t
- GetFileOffset ();
+ lldb::SBData GetSectionData(uint64_t offset, uint64_t size);
- uint64_t
- GetFileByteSize ();
-
- lldb::SBData
- GetSectionData ();
+ SectionType GetSectionType();
- lldb::SBData
- GetSectionData (uint64_t offset,
- uint64_t size);
-
- SectionType
- GetSectionType ();
+ //------------------------------------------------------------------
+ /// Gets the permissions (RWX) of the section of the object file
+ ///
+ /// Returns a mask of bits of enum lldb::Permissions for this section.
+ /// Sections for which permissions are not defined, 0 is returned for
+ /// them. The binary representation of this value corresponds to [XRW]
+ /// i.e. for a section having read and execute permissions, the value
+ /// returned is 6
+ ///
+ /// @return
+ /// Returns an unsigned value for Permissions for the section.
+ //------------------------------------------------------------------
+ uint32_t
+ GetPermissions() const;
- //------------------------------------------------------------------
- /// Return the size of a target's byte represented by this section
- /// in numbers of host bytes. Note that certain architectures have
- /// varying minimum addressable unit (i.e. byte) size for their
- /// CODE or DATA buses.
- ///
- /// @return
- /// The number of host (8-bit) bytes needed to hold a target byte
- //------------------------------------------------------------------
- uint32_t
- GetTargetByteSize ();
+ //------------------------------------------------------------------
+ /// Return the size of a target's byte represented by this section
+ /// in numbers of host bytes. Note that certain architectures have
+ /// varying minimum addressable unit (i.e. byte) size for their
+ /// CODE or DATA buses.
+ ///
+ /// @return
+ /// The number of host (8-bit) bytes needed to hold a target byte
+ //------------------------------------------------------------------
+ uint32_t GetTargetByteSize();
- bool
- operator == (const lldb::SBSection &rhs);
+ bool operator==(const lldb::SBSection &rhs);
- bool
- operator != (const lldb::SBSection &rhs);
+ bool operator!=(const lldb::SBSection &rhs);
- bool
- GetDescription (lldb::SBStream &description);
-
+ bool GetDescription(lldb::SBStream &description);
private:
+ friend class SBAddress;
+ friend class SBModule;
+ friend class SBTarget;
- friend class SBAddress;
- friend class SBModule;
- friend class SBTarget;
-
- SBSection (const lldb::SectionSP &section_sp);
-
- lldb::SectionSP
- GetSP() const;
-
- void
- SetSP(const lldb::SectionSP &section_sp);
-
- lldb::SectionWP m_opaque_wp;
-};
+ SBSection(const lldb::SectionSP &section_sp);
+
+ lldb::SectionSP GetSP() const;
+ void SetSP(const lldb::SectionSP &section_sp);
+
+ lldb::SectionWP m_opaque_wp;
+};
} // namespace lldb
diff --git a/include/lldb/API/SBSourceManager.h b/include/lldb/API/SBSourceManager.h
index 6e7358f16e77..6f1c49504d52 100644
--- a/include/lldb/API/SBSourceManager.h
+++ b/include/lldb/API/SBSourceManager.h
@@ -16,38 +16,35 @@
namespace lldb {
-class LLDB_API SBSourceManager
-{
+class LLDB_API SBSourceManager {
public:
- SBSourceManager (const SBDebugger &debugger);
- SBSourceManager (const SBTarget &target);
- SBSourceManager (const SBSourceManager &rhs);
-
- ~SBSourceManager();
+ SBSourceManager(const SBDebugger &debugger);
+ SBSourceManager(const SBTarget &target);
+ SBSourceManager(const SBSourceManager &rhs);
- const lldb::SBSourceManager &
- operator = (const lldb::SBSourceManager &rhs);
+ ~SBSourceManager();
- size_t
- DisplaySourceLinesWithLineNumbers (const lldb::SBFileSpec &file,
- uint32_t line,
- uint32_t context_before,
- uint32_t context_after,
- const char* current_line_cstr,
- lldb::SBStream &s);
+ const lldb::SBSourceManager &operator=(const lldb::SBSourceManager &rhs);
+ size_t DisplaySourceLinesWithLineNumbers(
+ const lldb::SBFileSpec &file, uint32_t line, uint32_t context_before,
+ uint32_t context_after, const char *current_line_cstr, lldb::SBStream &s);
+
+ size_t DisplaySourceLinesWithLineNumbersAndColumn(
+ const lldb::SBFileSpec &file, uint32_t line, uint32_t column,
+ uint32_t context_before, uint32_t context_after,
+ const char *current_line_cstr, lldb::SBStream &s);
protected:
- friend class SBCommandInterpreter;
- friend class SBDebugger;
+ friend class SBCommandInterpreter;
+ friend class SBDebugger;
- SBSourceManager(lldb_private::SourceManager *source_manager);
+ SBSourceManager(lldb_private::SourceManager *source_manager);
private:
-
- std::unique_ptr<lldb_private::SourceManagerImpl> m_opaque_ap;
+ std::unique_ptr<lldb_private::SourceManagerImpl> m_opaque_ap;
};
} // namespace lldb
-#endif // LLDB_SBSourceManager_h_
+#endif // LLDB_SBSourceManager_h_
diff --git a/include/lldb/API/SBStream.h b/include/lldb/API/SBStream.h
index 717979977d16..68fcae21c08e 100644
--- a/include/lldb/API/SBStream.h
+++ b/include/lldb/API/SBStream.h
@@ -16,100 +16,87 @@
namespace lldb {
-class LLDB_API SBStream
-{
+class LLDB_API SBStream {
public:
+ SBStream();
- SBStream ();
+ SBStream(SBStream &&rhs);
- SBStream (SBStream &&rhs);
+ ~SBStream();
- ~SBStream ();
+ bool IsValid() const;
- bool
- IsValid() const;
+ // If this stream is not redirected to a file, it will maintain a local
+ // cache for the stream data which can be accessed using this accessor.
+ const char *GetData();
- // If this stream is not redirected to a file, it will maintain a local
- // cache for the stream data which can be accessed using this accessor.
- const char *
- GetData ();
+ // If this stream is not redirected to a file, it will maintain a local
+ // cache for the stream output whose length can be accessed using this
+ // accessor.
+ size_t GetSize();
- // If this stream is not redirected to a file, it will maintain a local
- // cache for the stream output whose length can be accessed using this
- // accessor.
- size_t
- GetSize();
+ void Printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
- void
- Printf (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
+ void RedirectToFile(const char *path, bool append);
- void
- RedirectToFile (const char *path, bool append);
+ void RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership);
- void
- RedirectToFileHandle (FILE *fh, bool transfer_fh_ownership);
+ void RedirectToFileDescriptor(int fd, bool transfer_fh_ownership);
- void
- RedirectToFileDescriptor (int fd, bool transfer_fh_ownership);
-
- // If the stream is redirected to a file, forget about the file and if
- // ownership of the file was transferred to this object, close the file.
- // If the stream is backed by a local cache, clear this cache.
- void
- Clear ();
+ // If the stream is redirected to a file, forget about the file and if
+ // ownership of the file was transferred to this object, close the file.
+ // If the stream is backed by a local cache, clear this cache.
+ void Clear();
protected:
- friend class SBAddress;
- friend class SBBlock;
- friend class SBBreakpoint;
- friend class SBBreakpointLocation;
- friend class SBCommandReturnObject;
- friend class SBCompileUnit;
- friend class SBData;
- friend class SBDebugger;
- friend class SBDeclaration;
- friend class SBEvent;
- friend class SBFileSpec;
- friend class SBFileSpecList;
- friend class SBFrame;
- friend class SBFunction;
- friend class SBInstruction;
- friend class SBInstructionList;
- friend class SBLineEntry;
- friend class SBMemoryRegionInfo;
- friend class SBModule;
- friend class SBModuleSpec;
- friend class SBModuleSpecList;
- friend class SBProcess;
- friend class SBSection;
- friend class SBSourceManager;
- friend class SBSymbol;
- friend class SBSymbolContext;
- friend class SBSymbolContextList;
- friend class SBTarget;
- friend class SBThread;
- friend class SBThreadPlan;
- friend class SBType;
- friend class SBTypeEnumMember;
- friend class SBTypeMemberFunction;
- friend class SBTypeMember;
- friend class SBValue;
- friend class SBWatchpoint;
-
- lldb_private::Stream *
- operator->();
-
- lldb_private::Stream *
- get();
-
- lldb_private::Stream &
- ref();
+ friend class SBAddress;
+ friend class SBBlock;
+ friend class SBBreakpoint;
+ friend class SBBreakpointLocation;
+ friend class SBCommandReturnObject;
+ friend class SBCompileUnit;
+ friend class SBData;
+ friend class SBDebugger;
+ friend class SBDeclaration;
+ friend class SBEvent;
+ friend class SBFileSpec;
+ friend class SBFileSpecList;
+ friend class SBFrame;
+ friend class SBFunction;
+ friend class SBInstruction;
+ friend class SBInstructionList;
+ friend class SBLineEntry;
+ friend class SBMemoryRegionInfo;
+ friend class SBModule;
+ friend class SBModuleSpec;
+ friend class SBModuleSpecList;
+ friend class SBProcess;
+ friend class SBSection;
+ friend class SBSourceManager;
+ friend class SBStructuredData;
+ friend class SBSymbol;
+ friend class SBSymbolContext;
+ friend class SBSymbolContextList;
+ friend class SBTarget;
+ friend class SBThread;
+ friend class SBThreadPlan;
+ friend class SBType;
+ friend class SBTypeEnumMember;
+ friend class SBTypeMemberFunction;
+ friend class SBTypeMember;
+ friend class SBValue;
+ friend class SBWatchpoint;
+
+ lldb_private::Stream *operator->();
+
+ lldb_private::Stream *get();
+
+ lldb_private::Stream &ref();
private:
-
- DISALLOW_COPY_AND_ASSIGN (SBStream);
- std::unique_ptr<lldb_private::Stream> m_opaque_ap;
- bool m_is_file;
+ DISALLOW_COPY_AND_ASSIGN(SBStream);
+ std::unique_ptr<lldb_private::Stream> m_opaque_ap;
+ bool m_is_file;
};
} // namespace lldb
diff --git a/include/lldb/API/SBStringList.h b/include/lldb/API/SBStringList.h
index bc8ff935eda3..66b5172a0b3e 100644
--- a/include/lldb/API/SBStringList.h
+++ b/include/lldb/API/SBStringList.h
@@ -14,59 +14,47 @@
namespace lldb {
-class LLDB_API SBStringList
-{
+class LLDB_API SBStringList {
public:
+ SBStringList();
- SBStringList ();
+ SBStringList(const lldb::SBStringList &rhs);
- SBStringList (const lldb::SBStringList &rhs);
-
- const SBStringList &
- operator = (const SBStringList &rhs);
+ const SBStringList &operator=(const SBStringList &rhs);
- ~SBStringList ();
+ ~SBStringList();
- bool
- IsValid() const;
+ bool IsValid() const;
- void
- AppendString (const char *str);
+ void AppendString(const char *str);
- void
- AppendList (const char **strv, int strc);
+ void AppendList(const char **strv, int strc);
- void
- AppendList (const lldb::SBStringList &strings);
+ void AppendList(const lldb::SBStringList &strings);
- uint32_t
- GetSize () const;
+ uint32_t GetSize() const;
- const char *
- GetStringAtIndex (size_t idx);
+ const char *GetStringAtIndex(size_t idx);
- const char *
- GetStringAtIndex (size_t idx) const;
+ const char *GetStringAtIndex(size_t idx) const;
- void
- Clear ();
+ void Clear();
protected:
- friend class SBCommandInterpreter;
- friend class SBDebugger;
+ friend class SBCommandInterpreter;
+ friend class SBDebugger;
+ friend class SBBreakpoint;
- SBStringList (const lldb_private::StringList *lldb_strings);
+ SBStringList(const lldb_private::StringList *lldb_strings);
- const lldb_private::StringList *
- operator->() const;
+ void AppendList(const lldb_private::StringList &strings);
- const lldb_private::StringList &
- operator*() const;
+ const lldb_private::StringList *operator->() const;
-private:
-
- std::unique_ptr<lldb_private::StringList> m_opaque_ap;
+ const lldb_private::StringList &operator*() const;
+private:
+ std::unique_ptr<lldb_private::StringList> m_opaque_ap;
};
} // namespace lldb
diff --git a/include/lldb/API/SBStructuredData.h b/include/lldb/API/SBStructuredData.h
new file mode 100644
index 000000000000..9f0203bb245a
--- /dev/null
+++ b/include/lldb/API/SBStructuredData.h
@@ -0,0 +1,45 @@
+//===-- SBStructuredData.h --------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SBStructuredData_h
+#define SBStructuredData_h
+
+#include "lldb/API/SBDefines.h"
+#include "lldb/API/SBModule.h"
+
+class StructuredDataImpl;
+
+namespace lldb {
+
+class SBStructuredData {
+public:
+ SBStructuredData();
+
+ SBStructuredData(const lldb::SBStructuredData &rhs);
+
+ SBStructuredData(const lldb::EventSP &event_sp);
+
+ ~SBStructuredData();
+
+ lldb::SBStructuredData &operator=(const lldb::SBStructuredData &rhs);
+
+ bool IsValid() const;
+
+ void Clear();
+
+ lldb::SBError GetAsJSON(lldb::SBStream &stream) const;
+
+ lldb::SBError GetDescription(lldb::SBStream &stream) const;
+
+private:
+ std::unique_ptr<StructuredDataImpl> m_impl_up;
+};
+}
+
+#endif /* SBStructuredData_h */
diff --git a/include/lldb/API/SBSymbol.h b/include/lldb/API/SBSymbol.h
index 5acebe975261..d17a4ccffe02 100644
--- a/include/lldb/API/SBSymbol.h
+++ b/include/lldb/API/SBSymbol.h
@@ -10,102 +10,79 @@
#ifndef LLDB_SBSymbol_h_
#define LLDB_SBSymbol_h_
-#include "lldb/API/SBDefines.h"
#include "lldb/API/SBAddress.h"
+#include "lldb/API/SBDefines.h"
#include "lldb/API/SBInstructionList.h"
#include "lldb/API/SBTarget.h"
namespace lldb {
-class LLDB_API SBSymbol
-{
+class LLDB_API SBSymbol {
public:
+ SBSymbol();
+
+ ~SBSymbol();
- SBSymbol ();
+ SBSymbol(const lldb::SBSymbol &rhs);
- ~SBSymbol ();
+ const lldb::SBSymbol &operator=(const lldb::SBSymbol &rhs);
- SBSymbol (const lldb::SBSymbol &rhs);
+ bool IsValid() const;
- const lldb::SBSymbol &
- operator = (const lldb::SBSymbol &rhs);
+ const char *GetName() const;
- bool
- IsValid () const;
+ const char *GetDisplayName() const;
+ const char *GetMangledName() const;
- const char *
- GetName() const;
+ lldb::SBInstructionList GetInstructions(lldb::SBTarget target);
- const char *
- GetDisplayName() const;
-
- const char *
- GetMangledName () const;
+ lldb::SBInstructionList GetInstructions(lldb::SBTarget target,
+ const char *flavor_string);
- lldb::SBInstructionList
- GetInstructions (lldb::SBTarget target);
+ SBAddress GetStartAddress();
- lldb::SBInstructionList
- GetInstructions (lldb::SBTarget target, const char *flavor_string);
+ SBAddress GetEndAddress();
- SBAddress
- GetStartAddress ();
-
- SBAddress
- GetEndAddress ();
-
- uint32_t
- GetPrologueByteSize ();
+ uint32_t GetPrologueByteSize();
- SymbolType
- GetType ();
+ SymbolType GetType();
- bool
- operator == (const lldb::SBSymbol &rhs) const;
+ bool operator==(const lldb::SBSymbol &rhs) const;
- bool
- operator != (const lldb::SBSymbol &rhs) const;
+ bool operator!=(const lldb::SBSymbol &rhs) const;
- bool
- GetDescription (lldb::SBStream &description);
+ bool GetDescription(lldb::SBStream &description);
- //----------------------------------------------------------------------
- // Returns true if the symbol is externally visible in the module that
- // it is defined in
- //----------------------------------------------------------------------
- bool
- IsExternal();
+ //----------------------------------------------------------------------
+ // Returns true if the symbol is externally visible in the module that
+ // it is defined in
+ //----------------------------------------------------------------------
+ bool IsExternal();
- //----------------------------------------------------------------------
- // Returns true if the symbol was synthetically generated from something
- // other than the actual symbol table itself in the object file.
- //----------------------------------------------------------------------
- bool
- IsSynthetic();
+ //----------------------------------------------------------------------
+ // Returns true if the symbol was synthetically generated from something
+ // other than the actual symbol table itself in the object file.
+ //----------------------------------------------------------------------
+ bool IsSynthetic();
protected:
+ lldb_private::Symbol *get();
- lldb_private::Symbol *
- get ();
+ void reset(lldb_private::Symbol *);
- void
- reset (lldb_private::Symbol *);
-
private:
- friend class SBAddress;
- friend class SBFrame;
- friend class SBModule;
- friend class SBSymbolContext;
+ friend class SBAddress;
+ friend class SBFrame;
+ friend class SBModule;
+ friend class SBSymbolContext;
- SBSymbol (lldb_private::Symbol *lldb_object_ptr);
-
- void
- SetSymbol (lldb_private::Symbol *lldb_object_ptr);
+ SBSymbol(lldb_private::Symbol *lldb_object_ptr);
- lldb_private::Symbol *m_opaque_ptr;
-};
+ void SetSymbol(lldb_private::Symbol *lldb_object_ptr);
+ lldb_private::Symbol *m_opaque_ptr;
+};
} // namespace lldb
diff --git a/include/lldb/API/SBSymbolContext.h b/include/lldb/API/SBSymbolContext.h
index 24c2ce9a1d6e..04ee15e8ecb1 100644
--- a/include/lldb/API/SBSymbolContext.h
+++ b/include/lldb/API/SBSymbolContext.h
@@ -10,9 +10,9 @@
#ifndef LLDB_SBSymbolContext_h_
#define LLDB_SBSymbolContext_h_
-#include "lldb/API/SBDefines.h"
#include "lldb/API/SBBlock.h"
#include "lldb/API/SBCompileUnit.h"
+#include "lldb/API/SBDefines.h"
#include "lldb/API/SBFunction.h"
#include "lldb/API/SBLineEntry.h"
#include "lldb/API/SBModule.h"
@@ -20,75 +20,63 @@
namespace lldb {
-class LLDB_API SBSymbolContext
-{
+class LLDB_API SBSymbolContext {
public:
- SBSymbolContext ();
+ SBSymbolContext();
- SBSymbolContext (const lldb::SBSymbolContext& rhs);
+ SBSymbolContext(const lldb::SBSymbolContext &rhs);
- ~SBSymbolContext ();
+ ~SBSymbolContext();
- bool
- IsValid () const;
+ bool IsValid() const;
- const lldb::SBSymbolContext &
- operator = (const lldb::SBSymbolContext &rhs);
+ const lldb::SBSymbolContext &operator=(const lldb::SBSymbolContext &rhs);
- lldb::SBModule GetModule ();
- lldb::SBCompileUnit GetCompileUnit ();
- lldb::SBFunction GetFunction ();
- lldb::SBBlock GetBlock ();
- lldb::SBLineEntry GetLineEntry ();
- lldb::SBSymbol GetSymbol ();
+ lldb::SBModule GetModule();
+ lldb::SBCompileUnit GetCompileUnit();
+ lldb::SBFunction GetFunction();
+ lldb::SBBlock GetBlock();
+ lldb::SBLineEntry GetLineEntry();
+ lldb::SBSymbol GetSymbol();
- void SetModule (lldb::SBModule module);
- void SetCompileUnit (lldb::SBCompileUnit compile_unit);
- void SetFunction (lldb::SBFunction function);
- void SetBlock (lldb::SBBlock block);
- void SetLineEntry (lldb::SBLineEntry line_entry);
- void SetSymbol (lldb::SBSymbol symbol);
+ void SetModule(lldb::SBModule module);
+ void SetCompileUnit(lldb::SBCompileUnit compile_unit);
+ void SetFunction(lldb::SBFunction function);
+ void SetBlock(lldb::SBBlock block);
+ void SetLineEntry(lldb::SBLineEntry line_entry);
+ void SetSymbol(lldb::SBSymbol symbol);
- SBSymbolContext
- GetParentOfInlinedScope (const SBAddress &curr_frame_pc,
- SBAddress &parent_frame_addr) const;
+ SBSymbolContext GetParentOfInlinedScope(const SBAddress &curr_frame_pc,
+ SBAddress &parent_frame_addr) const;
- bool
- GetDescription (lldb::SBStream &description);
+ bool GetDescription(lldb::SBStream &description);
protected:
- friend class SBAddress;
- friend class SBFrame;
- friend class SBModule;
- friend class SBThread;
- friend class SBTarget;
- friend class SBSymbolContextList;
+ friend class SBAddress;
+ friend class SBFrame;
+ friend class SBModule;
+ friend class SBThread;
+ friend class SBTarget;
+ friend class SBSymbolContextList;
- lldb_private::SymbolContext*
- operator->() const;
+ lldb_private::SymbolContext *operator->() const;
- lldb_private::SymbolContext&
- operator*();
+ lldb_private::SymbolContext &operator*();
- lldb_private::SymbolContext&
- ref();
+ lldb_private::SymbolContext &ref();
- const lldb_private::SymbolContext&
- operator*() const;
+ const lldb_private::SymbolContext &operator*() const;
- lldb_private::SymbolContext *
- get() const;
+ lldb_private::SymbolContext *get() const;
- SBSymbolContext (const lldb_private::SymbolContext *sc_ptr);
+ SBSymbolContext(const lldb_private::SymbolContext *sc_ptr);
- void
- SetSymbolContext (const lldb_private::SymbolContext *sc_ptr);
+ void SetSymbolContext(const lldb_private::SymbolContext *sc_ptr);
private:
- std::unique_ptr<lldb_private::SymbolContext> m_opaque_ap;
+ std::unique_ptr<lldb_private::SymbolContext> m_opaque_ap;
};
-
} // namespace lldb
#endif // LLDB_SBSymbolContext_h_
diff --git a/include/lldb/API/SBSymbolContextList.h b/include/lldb/API/SBSymbolContextList.h
index 79dcccdcbf84..e7299dd5330c 100644
--- a/include/lldb/API/SBSymbolContextList.h
+++ b/include/lldb/API/SBSymbolContextList.h
@@ -15,55 +15,43 @@
namespace lldb {
-class LLDB_API SBSymbolContextList
-{
+class LLDB_API SBSymbolContextList {
public:
- SBSymbolContextList ();
+ SBSymbolContextList();
- SBSymbolContextList (const lldb::SBSymbolContextList& rhs);
+ SBSymbolContextList(const lldb::SBSymbolContextList &rhs);
- ~SBSymbolContextList ();
+ ~SBSymbolContextList();
- const lldb::SBSymbolContextList &
- operator = (const lldb::SBSymbolContextList &rhs);
+ const lldb::SBSymbolContextList &
+ operator=(const lldb::SBSymbolContextList &rhs);
- bool
- IsValid () const;
+ bool IsValid() const;
- uint32_t
- GetSize() const;
+ uint32_t GetSize() const;
- lldb::SBSymbolContext
- GetContextAtIndex (uint32_t idx);
-
- bool
- GetDescription (lldb::SBStream &description);
+ lldb::SBSymbolContext GetContextAtIndex(uint32_t idx);
- void
- Append (lldb::SBSymbolContext &sc);
-
- void
- Append (lldb::SBSymbolContextList &sc_list);
-
- void
- Clear();
+ bool GetDescription(lldb::SBStream &description);
-protected:
+ void Append(lldb::SBSymbolContext &sc);
+
+ void Append(lldb::SBSymbolContextList &sc_list);
- friend class SBModule;
- friend class SBTarget;
+ void Clear();
- lldb_private::SymbolContextList*
- operator->() const;
+protected:
+ friend class SBModule;
+ friend class SBTarget;
- lldb_private::SymbolContextList&
- operator*() const;
+ lldb_private::SymbolContextList *operator->() const;
+
+ lldb_private::SymbolContextList &operator*() const;
private:
- std::unique_ptr<lldb_private::SymbolContextList> m_opaque_ap;
+ std::unique_ptr<lldb_private::SymbolContextList> m_opaque_ap;
};
-
} // namespace lldb
#endif // LLDB_SBSymbolContextList_h_
diff --git a/include/lldb/API/SBTarget.h b/include/lldb/API/SBTarget.h
index 0bcabd043c9c..4e8db835ddc0 100644
--- a/include/lldb/API/SBTarget.h
+++ b/include/lldb/API/SBTarget.h
@@ -14,10 +14,11 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/API/SBDefines.h"
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBAttachInfo.h"
+#include "lldb/API/SBBreakpoint.h"
#include "lldb/API/SBBroadcaster.h"
+#include "lldb/API/SBDefines.h"
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBFileSpecList.h"
#include "lldb/API/SBLaunchInfo.h"
@@ -30,831 +31,817 @@ namespace lldb {
class SBPlatform;
-class LLDB_API SBTarget
-{
+class LLDB_API SBTarget {
public:
- //------------------------------------------------------------------
- // Broadcaster bits.
- //------------------------------------------------------------------
- enum
- {
- eBroadcastBitBreakpointChanged = (1 << 0),
- eBroadcastBitModulesLoaded = (1 << 1),
- eBroadcastBitModulesUnloaded = (1 << 2),
- eBroadcastBitWatchpointChanged = (1 << 3),
- eBroadcastBitSymbolsLoaded = (1 << 4)
- };
-
- //------------------------------------------------------------------
- // Constructors
- //------------------------------------------------------------------
- SBTarget ();
-
- SBTarget (const lldb::SBTarget& rhs);
-
- SBTarget (const lldb::TargetSP& target_sp);
-
- //------------------------------------------------------------------
- // Destructor
- //------------------------------------------------------------------
- ~SBTarget();
-
- const lldb::SBTarget&
- operator = (const lldb::SBTarget& rhs);
-
- bool
- IsValid() const;
-
- static bool
- EventIsTargetEvent (const lldb::SBEvent &event);
-
- static lldb::SBTarget
- GetTargetFromEvent (const lldb::SBEvent &event);
-
- static uint32_t
- GetNumModulesFromEvent (const lldb::SBEvent &event);
-
- static lldb::SBModule
- GetModuleAtIndexFromEvent (const uint32_t idx, const lldb::SBEvent &event);
-
- static const char *
- GetBroadcasterClassName ();
-
- lldb::SBProcess
- GetProcess ();
-
- //------------------------------------------------------------------
- /// Return the platform object associated with the target.
- ///
- /// After return, the platform object should be checked for
- /// validity.
- ///
- /// @return
- /// A platform object.
- //------------------------------------------------------------------
- lldb::SBPlatform
- GetPlatform ();
-
- //------------------------------------------------------------------
- /// Install any binaries that need to be installed.
- ///
- /// This function does nothing when debugging on the host system.
- /// When connected to remote platforms, the target's main executable
- /// and any modules that have their remote install path set will be
- /// installed on the remote platform. If the main executable doesn't
- /// have an install location set, it will be installed in the remote
- /// platform's working directory.
- ///
- /// @return
- /// An error describing anything that went wrong during
- /// installation.
- //------------------------------------------------------------------
- SBError
- Install();
-
- //------------------------------------------------------------------
- /// Launch a new process.
- ///
- /// Launch a new process by spawning a new process using the
- /// target object's executable module's file as the file to launch.
- /// Arguments are given in \a argv, and the environment variables
- /// are in \a envp. Standard input and output files can be
- /// optionally re-directed to \a stdin_path, \a stdout_path, and
- /// \a stderr_path.
- ///
- /// @param[in] listener
- /// An optional listener that will receive all process events.
- /// If \a listener is valid then \a listener will listen to all
- /// process events. If not valid, then this target's debugger
- /// (SBTarget::GetDebugger()) will listen to all process events.
- ///
- /// @param[in] argv
- /// The argument array.
- ///
- /// @param[in] envp
- /// The environment array.
- ///
- /// @param[in] launch_flags
- /// Flags to modify the launch (@see lldb::LaunchFlags)
- ///
- /// @param[in] stdin_path
- /// The path to use when re-directing the STDIN of the new
- /// process. If all stdXX_path arguments are nullptr, a pseudo
- /// terminal will be used.
- ///
- /// @param[in] stdout_path
- /// The path to use when re-directing the STDOUT of the new
- /// process. If all stdXX_path arguments are nullptr, a pseudo
- /// terminal will be used.
- ///
- /// @param[in] stderr_path
- /// The path to use when re-directing the STDERR of the new
- /// process. If all stdXX_path arguments are nullptr, a pseudo
- /// terminal will be used.
- ///
- /// @param[in] working_directory
- /// The working directory to have the child process run in
- ///
- /// @param[in] launch_flags
- /// Some launch options specified by logical OR'ing
- /// lldb::LaunchFlags enumeration values together.
- ///
- /// @param[in] stop_at_entry
- /// If false do not stop the inferior at the entry point.
- ///
- /// @param[out] error
- /// An error object. Contains the reason if there is some failure.
- ///
- /// @return
- /// A process object for the newly created process.
- //------------------------------------------------------------------
- lldb::SBProcess
- Launch (SBListener &listener,
- char const **argv,
- char const **envp,
- const char *stdin_path,
- const char *stdout_path,
- const char *stderr_path,
- const char *working_directory,
- uint32_t launch_flags, // See LaunchFlags
- bool stop_at_entry,
- lldb::SBError& error);
-
- SBProcess
- LoadCore (const char *core_file);
-
- //------------------------------------------------------------------
- /// Launch a new process with sensible defaults.
- ///
- /// @param[in] argv
- /// The argument array.
- ///
- /// @param[in] envp
- /// The environment array.
- ///
- /// @param[in] working_directory
- /// The working directory to have the child process run in
- ///
- /// Default: listener
- /// Set to the target's debugger (SBTarget::GetDebugger())
- ///
- /// Default: launch_flags
- /// Empty launch flags
- ///
- /// Default: stdin_path
- /// Default: stdout_path
- /// Default: stderr_path
- /// A pseudo terminal will be used.
- ///
- /// @return
- /// A process object for the newly created process.
- //------------------------------------------------------------------
- SBProcess
- LaunchSimple (const char **argv,
- const char **envp,
- const char *working_directory);
-
- SBProcess
- Launch (SBLaunchInfo &launch_info, SBError& error);
-
- SBProcess
- Attach (SBAttachInfo &attach_info, SBError& error);
-
- //------------------------------------------------------------------
- /// Attach to process with pid.
- ///
- /// @param[in] listener
- /// An optional listener that will receive all process events.
- /// If \a listener is valid then \a listener will listen to all
- /// process events. If not valid, then this target's debugger
- /// (SBTarget::GetDebugger()) will listen to all process events.
- ///
- /// @param[in] pid
- /// The process ID to attach to.
- ///
- /// @param[out] error
- /// An error explaining what went wrong if attach fails.
- ///
- /// @return
- /// A process object for the attached process.
- //------------------------------------------------------------------
- lldb::SBProcess
- AttachToProcessWithID (SBListener &listener,
- lldb::pid_t pid,
- lldb::SBError& error);
+ //------------------------------------------------------------------
+ // Broadcaster bits.
+ //------------------------------------------------------------------
+ enum {
+ eBroadcastBitBreakpointChanged = (1 << 0),
+ eBroadcastBitModulesLoaded = (1 << 1),
+ eBroadcastBitModulesUnloaded = (1 << 2),
+ eBroadcastBitWatchpointChanged = (1 << 3),
+ eBroadcastBitSymbolsLoaded = (1 << 4)
+ };
+
+ //------------------------------------------------------------------
+ // Constructors
+ //------------------------------------------------------------------
+ SBTarget();
+
+ SBTarget(const lldb::SBTarget &rhs);
+
+ SBTarget(const lldb::TargetSP &target_sp);
+
+ //------------------------------------------------------------------
+ // Destructor
+ //------------------------------------------------------------------
+ ~SBTarget();
+
+ const lldb::SBTarget &operator=(const lldb::SBTarget &rhs);
+
+ bool IsValid() const;
+
+ static bool EventIsTargetEvent(const lldb::SBEvent &event);
+
+ static lldb::SBTarget GetTargetFromEvent(const lldb::SBEvent &event);
+
+ static uint32_t GetNumModulesFromEvent(const lldb::SBEvent &event);
+
+ static lldb::SBModule GetModuleAtIndexFromEvent(const uint32_t idx,
+ const lldb::SBEvent &event);
+
+ static const char *GetBroadcasterClassName();
+
+ lldb::SBProcess GetProcess();
+
+ //------------------------------------------------------------------
+ /// Return the platform object associated with the target.
+ ///
+ /// After return, the platform object should be checked for
+ /// validity.
+ ///
+ /// @return
+ /// A platform object.
+ //------------------------------------------------------------------
+ lldb::SBPlatform GetPlatform();
+
+ //------------------------------------------------------------------
+ /// Install any binaries that need to be installed.
+ ///
+ /// This function does nothing when debugging on the host system.
+ /// When connected to remote platforms, the target's main executable
+ /// and any modules that have their remote install path set will be
+ /// installed on the remote platform. If the main executable doesn't
+ /// have an install location set, it will be installed in the remote
+ /// platform's working directory.
+ ///
+ /// @return
+ /// An error describing anything that went wrong during
+ /// installation.
+ //------------------------------------------------------------------
+ SBError Install();
+
+ //------------------------------------------------------------------
+ /// Launch a new process.
+ ///
+ /// Launch a new process by spawning a new process using the
+ /// target object's executable module's file as the file to launch.
+ /// Arguments are given in \a argv, and the environment variables
+ /// are in \a envp. Standard input and output files can be
+ /// optionally re-directed to \a stdin_path, \a stdout_path, and
+ /// \a stderr_path.
+ ///
+ /// @param[in] listener
+ /// An optional listener that will receive all process events.
+ /// If \a listener is valid then \a listener will listen to all
+ /// process events. If not valid, then this target's debugger
+ /// (SBTarget::GetDebugger()) will listen to all process events.
+ ///
+ /// @param[in] argv
+ /// The argument array.
+ ///
+ /// @param[in] envp
+ /// The environment array.
+ ///
+ /// @param[in] launch_flags
+ /// Flags to modify the launch (@see lldb::LaunchFlags)
+ ///
+ /// @param[in] stdin_path
+ /// The path to use when re-directing the STDIN of the new
+ /// process. If all stdXX_path arguments are nullptr, a pseudo
+ /// terminal will be used.
+ ///
+ /// @param[in] stdout_path
+ /// The path to use when re-directing the STDOUT of the new
+ /// process. If all stdXX_path arguments are nullptr, a pseudo
+ /// terminal will be used.
+ ///
+ /// @param[in] stderr_path
+ /// The path to use when re-directing the STDERR of the new
+ /// process. If all stdXX_path arguments are nullptr, a pseudo
+ /// terminal will be used.
+ ///
+ /// @param[in] working_directory
+ /// The working directory to have the child process run in
+ ///
+ /// @param[in] launch_flags
+ /// Some launch options specified by logical OR'ing
+ /// lldb::LaunchFlags enumeration values together.
+ ///
+ /// @param[in] stop_at_entry
+ /// If false do not stop the inferior at the entry point.
+ ///
+ /// @param[out] error
+ /// An error object. Contains the reason if there is some failure.
+ ///
+ /// @return
+ /// A process object for the newly created process.
+ //------------------------------------------------------------------
+ lldb::SBProcess Launch(SBListener &listener, char const **argv,
+ char const **envp, const char *stdin_path,
+ const char *stdout_path, const char *stderr_path,
+ const char *working_directory,
+ uint32_t launch_flags, // See LaunchFlags
+ bool stop_at_entry, lldb::SBError &error);
+
+ SBProcess LoadCore(const char *core_file);
+
+ //------------------------------------------------------------------
+ /// Launch a new process with sensible defaults.
+ ///
+ /// @param[in] argv
+ /// The argument array.
+ ///
+ /// @param[in] envp
+ /// The environment array.
+ ///
+ /// @param[in] working_directory
+ /// The working directory to have the child process run in
+ ///
+ /// Default: listener
+ /// Set to the target's debugger (SBTarget::GetDebugger())
+ ///
+ /// Default: launch_flags
+ /// Empty launch flags
+ ///
+ /// Default: stdin_path
+ /// Default: stdout_path
+ /// Default: stderr_path
+ /// A pseudo terminal will be used.
+ ///
+ /// @return
+ /// A process object for the newly created process.
+ //------------------------------------------------------------------
+ SBProcess LaunchSimple(const char **argv, const char **envp,
+ const char *working_directory);
+
+ SBProcess Launch(SBLaunchInfo &launch_info, SBError &error);
+
+ SBProcess Attach(SBAttachInfo &attach_info, SBError &error);
+
+ //------------------------------------------------------------------
+ /// Attach to process with pid.
+ ///
+ /// @param[in] listener
+ /// An optional listener that will receive all process events.
+ /// If \a listener is valid then \a listener will listen to all
+ /// process events. If not valid, then this target's debugger
+ /// (SBTarget::GetDebugger()) will listen to all process events.
+ ///
+ /// @param[in] pid
+ /// The process ID to attach to.
+ ///
+ /// @param[out] error
+ /// An error explaining what went wrong if attach fails.
+ ///
+ /// @return
+ /// A process object for the attached process.
+ //------------------------------------------------------------------
+ lldb::SBProcess AttachToProcessWithID(SBListener &listener, lldb::pid_t pid,
+ lldb::SBError &error);
#if defined(__APPLE__)
- // We need to keep this around for a build or two since Xcode links
- // to the 32 bit version of this function. We will take it out soon.
- lldb::SBProcess
- AttachToProcessWithID (SBListener &listener,
- ::pid_t pid, // 32 bit int process ID
- lldb::SBError& error); // DEPRECATED
+ // We need to keep this around for a build or two since Xcode links
+ // to the 32 bit version of this function. We will take it out soon.
+ lldb::SBProcess AttachToProcessWithID(SBListener &listener,
+ ::pid_t pid, // 32 bit int process ID
+ lldb::SBError &error); // DEPRECATED
#endif
- //------------------------------------------------------------------
- /// Attach to process with name.
- ///
- /// @param[in] listener
- /// An optional listener that will receive all process events.
- /// If \a listener is valid then \a listener will listen to all
- /// process events. If not valid, then this target's debugger
- /// (SBTarget::GetDebugger()) will listen to all process events.
- ///
- /// @param[in] name
- /// Basename of process to attach to.
- ///
- /// @param[in] wait_for
- /// If true wait for a new instance of 'name' to be launched.
- ///
- /// @param[out] error
- /// An error explaining what went wrong if attach fails.
- ///
- /// @return
- /// A process object for the attached process.
- //------------------------------------------------------------------
- lldb::SBProcess
- AttachToProcessWithName (SBListener &listener,
- const char *name,
- bool wait_for,
- lldb::SBError& error);
-
- //------------------------------------------------------------------
- /// Connect to a remote debug server with url.
- ///
- /// @param[in] listener
- /// An optional listener that will receive all process events.
- /// If \a listener is valid then \a listener will listen to all
- /// process events. If not valid, then this target's debugger
- /// (SBTarget::GetDebugger()) will listen to all process events.
- ///
- /// @param[in] url
- /// The url to connect to, e.g., 'connect://localhost:12345'.
- ///
- /// @param[in] plugin_name
- /// The plugin name to be used; can be nullptr.
- ///
- /// @param[out] error
- /// An error explaining what went wrong if the connect fails.
- ///
- /// @return
- /// A process object for the connected process.
- //------------------------------------------------------------------
- lldb::SBProcess
- ConnectRemote (SBListener &listener,
- const char *url,
- const char *plugin_name,
- SBError& error);
-
- lldb::SBFileSpec
- GetExecutable ();
-
- bool
- AddModule (lldb::SBModule &module);
-
- lldb::SBModule
- AddModule (const char *path,
- const char *triple,
- const char *uuid);
-
- lldb::SBModule
- AddModule (const char *path,
- const char *triple,
- const char *uuid_cstr,
- const char *symfile);
-
- lldb::SBModule
- AddModule (const SBModuleSpec &module_spec);
-
- uint32_t
- GetNumModules () const;
-
- lldb::SBModule
- GetModuleAtIndex (uint32_t idx);
-
- bool
- RemoveModule (lldb::SBModule module);
-
- lldb::SBDebugger
- GetDebugger() const;
-
- lldb::SBModule
- FindModule (const lldb::SBFileSpec &file_spec);
-
- lldb::ByteOrder
- GetByteOrder ();
-
- uint32_t
- GetAddressByteSize();
-
- const char *
- GetTriple ();
-
- //------------------------------------------------------------------
- /// Architecture data byte width accessor
- ///
- /// @return
- /// The size in 8-bit (host) bytes of a minimum addressable
- /// unit from the Architecture's data bus
- //------------------------------------------------------------------
- uint32_t
- GetDataByteSize ();
-
- //------------------------------------------------------------------
- /// Architecture code byte width accessor
- ///
- /// @return
- /// The size in 8-bit (host) bytes of a minimum addressable
- /// unit from the Architecture's code bus
- //------------------------------------------------------------------
- uint32_t
- GetCodeByteSize ();
-
- //------------------------------------------------------------------
- /// Set the base load address for a module section.
- ///
- /// @param[in] section
- /// The section whose base load address will be set within this
- /// target.
- ///
- /// @param[in] section_base_addr
- /// The base address for the section.
- ///
- /// @return
- /// An error to indicate success, fail, and any reason for
- /// failure.
- //------------------------------------------------------------------
- lldb::SBError
- SetSectionLoadAddress (lldb::SBSection section,
- lldb::addr_t section_base_addr);
-
- //------------------------------------------------------------------
- /// Clear the base load address for a module section.
- ///
- /// @param[in] section
- /// The section whose base load address will be cleared within
- /// this target.
- ///
- /// @return
- /// An error to indicate success, fail, and any reason for
- /// failure.
- //------------------------------------------------------------------
- lldb::SBError
- ClearSectionLoadAddress (lldb::SBSection section);
-
- //------------------------------------------------------------------
- /// Slide all file addresses for all module sections so that \a module
- /// appears to loaded at these slide addresses.
- ///
- /// When you need all sections within a module to be loaded at a
- /// rigid slide from the addresses found in the module object file,
- /// this function will allow you to easily and quickly slide all
- /// module sections.
- ///
- /// @param[in] module
- /// The module to load.
- ///
- /// @param[in] sections_offset
- /// An offset that will be applied to all section file addresses
- /// (the virtual addresses found in the object file itself).
- ///
- /// @return
- /// An error to indicate success, fail, and any reason for
- /// failure.
- //------------------------------------------------------------------
- lldb::SBError
- SetModuleLoadAddress (lldb::SBModule module,
- int64_t sections_offset);
-
- //------------------------------------------------------------------
- /// Clear the section base load addresses for all sections in a module.
- ///
- /// @param[in] module
- /// The module to unload.
- ///
- /// @return
- /// An error to indicate success, fail, and any reason for
- /// failure.
- //------------------------------------------------------------------
- lldb::SBError
- ClearModuleLoadAddress (lldb::SBModule module);
-
- //------------------------------------------------------------------
- /// Find functions by name.
- ///
- /// @param[in] name
- /// The name of the function we are looking for.
- ///
- /// @param[in] name_type_mask
- /// A logical OR of one or more FunctionNameType enum bits that
- /// indicate what kind of names should be used when doing the
- /// lookup. Bits include fully qualified names, base names,
- /// C++ methods, or ObjC selectors.
- /// See FunctionNameType for more details.
- ///
- /// @return
- /// A lldb::SBSymbolContextList that gets filled in with all of
- /// the symbol contexts for all the matches.
- //------------------------------------------------------------------
- lldb::SBSymbolContextList
- FindFunctions (const char *name,
- uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
-
- //------------------------------------------------------------------
- /// Find global and static variables by name.
- ///
- /// @param[in] name
- /// The name of the global or static variable we are looking
- /// for.
- ///
- /// @param[in] max_matches
- /// Allow the number of matches to be limited to \a max_matches.
- ///
- /// @return
- /// A list of matched variables in an SBValueList.
- //------------------------------------------------------------------
- lldb::SBValueList
- FindGlobalVariables (const char *name,
- uint32_t max_matches);
-
- //------------------------------------------------------------------
- /// Find the first global (or static) variable by name.
- ///
- /// @param[in] name
- /// The name of the global or static variable we are looking
- /// for.
- ///
- /// @return
- /// An SBValue that gets filled in with the found variable (if any).
- //------------------------------------------------------------------
- lldb::SBValue
- FindFirstGlobalVariable (const char* name);
-
- //------------------------------------------------------------------
- /// Find global and static variables by pattern.
- ///
- /// @param[in] name
- /// The pattern to search for global or static variables
- ///
- /// @param[in] max_matches
- /// Allow the number of matches to be limited to \a max_matches.
- ///
- /// @param[in] matchtype
- /// The match type to use.
- ///
- /// @return
- /// A list of matched variables in an SBValueList.
- //------------------------------------------------------------------
- lldb::SBValueList
- FindGlobalVariables(const char *name,
- uint32_t max_matches,
- MatchType matchtype);
-
- //------------------------------------------------------------------
- /// Find global functions by their name with pattern matching.
- ///
- /// @param[in] name
- /// The pattern to search for global or static variables
- ///
- /// @param[in] max_matches
- /// Allow the number of matches to be limited to \a max_matches.
- ///
- /// @param[in] matchtype
- /// The match type to use.
- ///
- /// @return
- /// A list of matched variables in an SBValueList.
- //------------------------------------------------------------------
- lldb::SBSymbolContextList
- FindGlobalFunctions(const char *name,
- uint32_t max_matches,
- MatchType matchtype);
-
- void
- Clear ();
-
- //------------------------------------------------------------------
- /// Resolve a current file address into a section offset address.
- ///
- /// @param[in] file_addr
- ///
- /// @return
- /// An SBAddress which will be valid if...
- //------------------------------------------------------------------
- lldb::SBAddress
- ResolveFileAddress (lldb::addr_t file_addr);
-
- //------------------------------------------------------------------
- /// Resolve a current load address into a section offset address.
- ///
- /// @param[in] vm_addr
- /// A virtual address from the current process state that is to
- /// be translated into a section offset address.
- ///
- /// @return
- /// An SBAddress which will be valid if \a vm_addr was
- /// successfully resolved into a section offset address, or an
- /// invalid SBAddress if \a vm_addr doesn't resolve to a section
- /// in a module.
- //------------------------------------------------------------------
- lldb::SBAddress
- ResolveLoadAddress (lldb::addr_t vm_addr);
-
- //------------------------------------------------------------------
- /// Resolve a current load address into a section offset address
- /// using the process stop ID to identify a time in the past.
- ///
- /// @param[in] stop_id
- /// Each time a process stops, the process stop ID integer gets
- /// incremented. These stop IDs are used to identify past times
- /// and can be used in history objects as a cheap way to store
- /// the time at which the sample was taken. Specifying
- /// UINT32_MAX will always resolve the address using the
- /// currently loaded sections.
- ///
- /// @param[in] vm_addr
- /// A virtual address from the current process state that is to
- /// be translated into a section offset address.
- ///
- /// @return
- /// An SBAddress which will be valid if \a vm_addr was
- /// successfully resolved into a section offset address, or an
- /// invalid SBAddress if \a vm_addr doesn't resolve to a section
- /// in a module.
- //------------------------------------------------------------------
- lldb::SBAddress
- ResolvePastLoadAddress (uint32_t stop_id, lldb::addr_t vm_addr);
-
- SBSymbolContext
- ResolveSymbolContextForAddress (const SBAddress& addr,
- uint32_t resolve_scope);
-
- //------------------------------------------------------------------
- /// Read target memory. If a target process is running then memory
- /// is read from here. Otherwise the memory is read from the object
- /// files. For a target whose bytes are sized as a multiple of host
- /// bytes, the data read back will preserve the target's byte order.
- ///
- /// @param[in] addr
- /// A target address to read from.
- ///
- /// @param[out] buf
- /// The buffer to read memory into.
- ///
- /// @param[in] size
- /// The maximum number of host bytes to read in the buffer passed
- /// into this call
- ///
- /// @param[out] error
- /// Error information is written here if the memory read fails.
- ///
- /// @return
- /// The amount of data read in host bytes.
- //------------------------------------------------------------------
- size_t
- ReadMemory (const SBAddress addr, void *buf, size_t size, lldb::SBError &error);
-
- lldb::SBBreakpoint
- BreakpointCreateByLocation (const char *file, uint32_t line);
-
- lldb::SBBreakpoint
- BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line);
-
- lldb::SBBreakpoint
- BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line, lldb::addr_t offset);
-
- lldb::SBBreakpoint
- BreakpointCreateByName(const char *symbol_name, const char *module_name = nullptr);
-
- // This version uses name_type_mask = eFunctionNameTypeAuto
- lldb::SBBreakpoint
- BreakpointCreateByName (const char *symbol_name,
- const SBFileSpecList &module_list,
- const SBFileSpecList &comp_unit_list);
-
- lldb::SBBreakpoint
- BreakpointCreateByName (const char *symbol_name,
- uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
- const SBFileSpecList &module_list,
- const SBFileSpecList &comp_unit_list);
-
- lldb::SBBreakpoint
- BreakpointCreateByName (const char *symbol_name,
- uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
- lldb::LanguageType symbol_language,
- const SBFileSpecList &module_list,
- const SBFileSpecList &comp_unit_list);
-
- lldb::SBBreakpoint
- BreakpointCreateByNames (const char *symbol_name[],
- uint32_t num_names,
- uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
- const SBFileSpecList &module_list,
- const SBFileSpecList &comp_unit_list);
-
- lldb::SBBreakpoint
- BreakpointCreateByNames (const char *symbol_name[],
- uint32_t num_names,
- uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
- lldb::LanguageType symbol_language,
- const SBFileSpecList &module_list,
- const SBFileSpecList &comp_unit_list);
-
- lldb::SBBreakpoint
- BreakpointCreateByNames (const char *symbol_name[],
- uint32_t num_names,
- uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
- lldb::LanguageType symbol_language,
- lldb::addr_t offset,
- const SBFileSpecList &module_list,
- const SBFileSpecList &comp_unit_list);
-
- lldb::SBBreakpoint
- BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = nullptr);
-
- lldb::SBBreakpoint
- BreakpointCreateByRegex (const char *symbol_name_regex,
- const SBFileSpecList &module_list,
- const SBFileSpecList &comp_unit_list);
-
- lldb::SBBreakpoint
- BreakpointCreateByRegex (const char *symbol_name_regex,
- lldb::LanguageType symbol_language,
- const SBFileSpecList &module_list,
- const SBFileSpecList &comp_unit_list);
-
- lldb::SBBreakpoint
- BreakpointCreateBySourceRegex(const char *source_regex,
- const SBFileSpec &source_file,
- const char *module_name = nullptr);
-
- lldb::SBBreakpoint
- BreakpointCreateBySourceRegex (const char *source_regex,
- const SBFileSpecList &module_list,
- const SBFileSpecList &source_file);
-
- lldb::SBBreakpoint
- BreakpointCreateBySourceRegex (const char *source_regex,
- const SBFileSpecList &module_list,
- const SBFileSpecList &source_file,
- const SBStringList &func_names);
-
- lldb::SBBreakpoint
- BreakpointCreateForException (lldb::LanguageType language,
- bool catch_bp,
- bool throw_bp);
-
- lldb::SBBreakpoint
- BreakpointCreateByAddress (addr_t address);
-
- lldb::SBBreakpoint
- BreakpointCreateBySBAddress (SBAddress &address);
-
- uint32_t
- GetNumBreakpoints () const;
-
- lldb::SBBreakpoint
- GetBreakpointAtIndex (uint32_t idx) const;
-
- bool
- BreakpointDelete (break_id_t break_id);
-
- lldb::SBBreakpoint
- FindBreakpointByID (break_id_t break_id);
-
- bool
- EnableAllBreakpoints ();
-
- bool
- DisableAllBreakpoints ();
-
- bool
- DeleteAllBreakpoints ();
-
- uint32_t
- GetNumWatchpoints () const;
-
- lldb::SBWatchpoint
- GetWatchpointAtIndex (uint32_t idx) const;
-
- bool
- DeleteWatchpoint (lldb::watch_id_t watch_id);
-
- lldb::SBWatchpoint
- FindWatchpointByID (lldb::watch_id_t watch_id);
-
- lldb::SBWatchpoint
- WatchAddress (lldb::addr_t addr, size_t size, bool read, bool write, SBError& error);
-
- bool
- EnableAllWatchpoints ();
-
- bool
- DisableAllWatchpoints ();
-
- bool
- DeleteAllWatchpoints ();
-
- lldb::SBBroadcaster
- GetBroadcaster () const;
-
- lldb::SBType
- FindFirstType (const char* type);
-
- lldb::SBTypeList
- FindTypes (const char* type);
-
- lldb::SBType
- GetBasicType(lldb::BasicType type);
-
- lldb::SBValue
- CreateValueFromAddress (const char *name, lldb::SBAddress addr, lldb::SBType type);
-
- lldb::SBValue
- CreateValueFromData (const char *name, lldb::SBData data, lldb::SBType type);
-
- lldb::SBValue
- CreateValueFromExpression (const char *name, const char* expr);
-
- SBSourceManager
- GetSourceManager();
-
- lldb::SBInstructionList
- ReadInstructions (lldb::SBAddress base_addr, uint32_t count);
-
- lldb::SBInstructionList
- ReadInstructions (lldb::SBAddress base_addr, uint32_t count, const char *flavor_string);
-
- lldb::SBInstructionList
- GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size);
-
- // The "WithFlavor" is necessary to keep SWIG from getting confused about overloaded arguments when
- // using the buf + size -> Python Object magic.
-
- lldb::SBInstructionList
- GetInstructionsWithFlavor (lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size);
-
- lldb::SBInstructionList
- GetInstructions (lldb::addr_t base_addr, const void *buf, size_t size);
-
- lldb::SBInstructionList
- GetInstructionsWithFlavor (lldb::addr_t base_addr, const char *flavor_string, const void *buf, size_t size);
+ //------------------------------------------------------------------
+ /// Attach to process with name.
+ ///
+ /// @param[in] listener
+ /// An optional listener that will receive all process events.
+ /// If \a listener is valid then \a listener will listen to all
+ /// process events. If not valid, then this target's debugger
+ /// (SBTarget::GetDebugger()) will listen to all process events.
+ ///
+ /// @param[in] name
+ /// Basename of process to attach to.
+ ///
+ /// @param[in] wait_for
+ /// If true wait for a new instance of 'name' to be launched.
+ ///
+ /// @param[out] error
+ /// An error explaining what went wrong if attach fails.
+ ///
+ /// @return
+ /// A process object for the attached process.
+ //------------------------------------------------------------------
+ lldb::SBProcess AttachToProcessWithName(SBListener &listener,
+ const char *name, bool wait_for,
+ lldb::SBError &error);
+
+ //------------------------------------------------------------------
+ /// Connect to a remote debug server with url.
+ ///
+ /// @param[in] listener
+ /// An optional listener that will receive all process events.
+ /// If \a listener is valid then \a listener will listen to all
+ /// process events. If not valid, then this target's debugger
+ /// (SBTarget::GetDebugger()) will listen to all process events.
+ ///
+ /// @param[in] url
+ /// The url to connect to, e.g., 'connect://localhost:12345'.
+ ///
+ /// @param[in] plugin_name
+ /// The plugin name to be used; can be nullptr.
+ ///
+ /// @param[out] error
+ /// An error explaining what went wrong if the connect fails.
+ ///
+ /// @return
+ /// A process object for the connected process.
+ //------------------------------------------------------------------
+ lldb::SBProcess ConnectRemote(SBListener &listener, const char *url,
+ const char *plugin_name, SBError &error);
+
+ lldb::SBFileSpec GetExecutable();
+
+ bool AddModule(lldb::SBModule &module);
+
+ lldb::SBModule AddModule(const char *path, const char *triple,
+ const char *uuid);
+
+ lldb::SBModule AddModule(const char *path, const char *triple,
+ const char *uuid_cstr, const char *symfile);
+
+ lldb::SBModule AddModule(const SBModuleSpec &module_spec);
+
+ uint32_t GetNumModules() const;
+
+ lldb::SBModule GetModuleAtIndex(uint32_t idx);
+
+ bool RemoveModule(lldb::SBModule module);
+
+ lldb::SBDebugger GetDebugger() const;
+
+ lldb::SBModule FindModule(const lldb::SBFileSpec &file_spec);
+
+ lldb::ByteOrder GetByteOrder();
+
+ uint32_t GetAddressByteSize();
+
+ const char *GetTriple();
+
+ //------------------------------------------------------------------
+ /// Architecture data byte width accessor
+ ///
+ /// @return
+ /// The size in 8-bit (host) bytes of a minimum addressable
+ /// unit from the Architecture's data bus
+ //------------------------------------------------------------------
+ uint32_t GetDataByteSize();
+
+ //------------------------------------------------------------------
+ /// Architecture code byte width accessor
+ ///
+ /// @return
+ /// The size in 8-bit (host) bytes of a minimum addressable
+ /// unit from the Architecture's code bus
+ //------------------------------------------------------------------
+ uint32_t GetCodeByteSize();
+
+ //------------------------------------------------------------------
+ /// Set the base load address for a module section.
+ ///
+ /// @param[in] section
+ /// The section whose base load address will be set within this
+ /// target.
+ ///
+ /// @param[in] section_base_addr
+ /// The base address for the section.
+ ///
+ /// @return
+ /// An error to indicate success, fail, and any reason for
+ /// failure.
+ //------------------------------------------------------------------
+ lldb::SBError SetSectionLoadAddress(lldb::SBSection section,
+ lldb::addr_t section_base_addr);
+
+ //------------------------------------------------------------------
+ /// Clear the base load address for a module section.
+ ///
+ /// @param[in] section
+ /// The section whose base load address will be cleared within
+ /// this target.
+ ///
+ /// @return
+ /// An error to indicate success, fail, and any reason for
+ /// failure.
+ //------------------------------------------------------------------
+ lldb::SBError ClearSectionLoadAddress(lldb::SBSection section);
+
+ //------------------------------------------------------------------
+ /// Slide all file addresses for all module sections so that \a module
+ /// appears to loaded at these slide addresses.
+ ///
+ /// When you need all sections within a module to be loaded at a
+ /// rigid slide from the addresses found in the module object file,
+ /// this function will allow you to easily and quickly slide all
+ /// module sections.
+ ///
+ /// @param[in] module
+ /// The module to load.
+ ///
+ /// @param[in] sections_offset
+ /// An offset that will be applied to all section file addresses
+ /// (the virtual addresses found in the object file itself).
+ ///
+ /// @return
+ /// An error to indicate success, fail, and any reason for
+ /// failure.
+ //------------------------------------------------------------------
+ lldb::SBError SetModuleLoadAddress(lldb::SBModule module,
+ int64_t sections_offset);
+
+ //------------------------------------------------------------------
+ /// Clear the section base load addresses for all sections in a module.
+ ///
+ /// @param[in] module
+ /// The module to unload.
+ ///
+ /// @return
+ /// An error to indicate success, fail, and any reason for
+ /// failure.
+ //------------------------------------------------------------------
+ lldb::SBError ClearModuleLoadAddress(lldb::SBModule module);
+
+ //------------------------------------------------------------------
+ /// Find functions by name.
+ ///
+ /// @param[in] name
+ /// The name of the function we are looking for.
+ ///
+ /// @param[in] name_type_mask
+ /// A logical OR of one or more FunctionNameType enum bits that
+ /// indicate what kind of names should be used when doing the
+ /// lookup. Bits include fully qualified names, base names,
+ /// C++ methods, or ObjC selectors.
+ /// See FunctionNameType for more details.
+ ///
+ /// @return
+ /// A lldb::SBSymbolContextList that gets filled in with all of
+ /// the symbol contexts for all the matches.
+ //------------------------------------------------------------------
+ lldb::SBSymbolContextList
+ FindFunctions(const char *name,
+ uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
+
+ //------------------------------------------------------------------
+ /// Find global and static variables by name.
+ ///
+ /// @param[in] name
+ /// The name of the global or static variable we are looking
+ /// for.
+ ///
+ /// @param[in] max_matches
+ /// Allow the number of matches to be limited to \a max_matches.
+ ///
+ /// @return
+ /// A list of matched variables in an SBValueList.
+ //------------------------------------------------------------------
+ lldb::SBValueList FindGlobalVariables(const char *name, uint32_t max_matches);
+
+ //------------------------------------------------------------------
+ /// Find the first global (or static) variable by name.
+ ///
+ /// @param[in] name
+ /// The name of the global or static variable we are looking
+ /// for.
+ ///
+ /// @return
+ /// An SBValue that gets filled in with the found variable (if any).
+ //------------------------------------------------------------------
+ lldb::SBValue FindFirstGlobalVariable(const char *name);
+
+ //------------------------------------------------------------------
+ /// Find global and static variables by pattern.
+ ///
+ /// @param[in] name
+ /// The pattern to search for global or static variables
+ ///
+ /// @param[in] max_matches
+ /// Allow the number of matches to be limited to \a max_matches.
+ ///
+ /// @param[in] matchtype
+ /// The match type to use.
+ ///
+ /// @return
+ /// A list of matched variables in an SBValueList.
+ //------------------------------------------------------------------
+ lldb::SBValueList FindGlobalVariables(const char *name, uint32_t max_matches,
+ MatchType matchtype);
+
+ //------------------------------------------------------------------
+ /// Find global functions by their name with pattern matching.
+ ///
+ /// @param[in] name
+ /// The pattern to search for global or static variables
+ ///
+ /// @param[in] max_matches
+ /// Allow the number of matches to be limited to \a max_matches.
+ ///
+ /// @param[in] matchtype
+ /// The match type to use.
+ ///
+ /// @return
+ /// A list of matched variables in an SBValueList.
+ //------------------------------------------------------------------
+ lldb::SBSymbolContextList FindGlobalFunctions(const char *name,
+ uint32_t max_matches,
+ MatchType matchtype);
+
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Resolve a current file address into a section offset address.
+ ///
+ /// @param[in] file_addr
+ ///
+ /// @return
+ /// An SBAddress which will be valid if...
+ //------------------------------------------------------------------
+ lldb::SBAddress ResolveFileAddress(lldb::addr_t file_addr);
+
+ //------------------------------------------------------------------
+ /// Resolve a current load address into a section offset address.
+ ///
+ /// @param[in] vm_addr
+ /// A virtual address from the current process state that is to
+ /// be translated into a section offset address.
+ ///
+ /// @return
+ /// An SBAddress which will be valid if \a vm_addr was
+ /// successfully resolved into a section offset address, or an
+ /// invalid SBAddress if \a vm_addr doesn't resolve to a section
+ /// in a module.
+ //------------------------------------------------------------------
+ lldb::SBAddress ResolveLoadAddress(lldb::addr_t vm_addr);
+
+ //------------------------------------------------------------------
+ /// Resolve a current load address into a section offset address
+ /// using the process stop ID to identify a time in the past.
+ ///
+ /// @param[in] stop_id
+ /// Each time a process stops, the process stop ID integer gets
+ /// incremented. These stop IDs are used to identify past times
+ /// and can be used in history objects as a cheap way to store
+ /// the time at which the sample was taken. Specifying
+ /// UINT32_MAX will always resolve the address using the
+ /// currently loaded sections.
+ ///
+ /// @param[in] vm_addr
+ /// A virtual address from the current process state that is to
+ /// be translated into a section offset address.
+ ///
+ /// @return
+ /// An SBAddress which will be valid if \a vm_addr was
+ /// successfully resolved into a section offset address, or an
+ /// invalid SBAddress if \a vm_addr doesn't resolve to a section
+ /// in a module.
+ //------------------------------------------------------------------
+ lldb::SBAddress ResolvePastLoadAddress(uint32_t stop_id,
+ lldb::addr_t vm_addr);
+
+ SBSymbolContext ResolveSymbolContextForAddress(const SBAddress &addr,
+ uint32_t resolve_scope);
+
+ //------------------------------------------------------------------
+ /// Read target memory. If a target process is running then memory
+ /// is read from here. Otherwise the memory is read from the object
+ /// files. For a target whose bytes are sized as a multiple of host
+ /// bytes, the data read back will preserve the target's byte order.
+ ///
+ /// @param[in] addr
+ /// A target address to read from.
+ ///
+ /// @param[out] buf
+ /// The buffer to read memory into.
+ ///
+ /// @param[in] size
+ /// The maximum number of host bytes to read in the buffer passed
+ /// into this call
+ ///
+ /// @param[out] error
+ /// Error information is written here if the memory read fails.
+ ///
+ /// @return
+ /// The amount of data read in host bytes.
+ //------------------------------------------------------------------
+ size_t ReadMemory(const SBAddress addr, void *buf, size_t size,
+ lldb::SBError &error);
+
+ lldb::SBBreakpoint BreakpointCreateByLocation(const char *file,
+ uint32_t line);
+
+ lldb::SBBreakpoint
+ BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line);
+
+ lldb::SBBreakpoint
+ BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
+ lldb::addr_t offset);
+
+ lldb::SBBreakpoint
+ BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
+ lldb::addr_t offset, SBFileSpecList &module_list);
+
+ lldb::SBBreakpoint BreakpointCreateByName(const char *symbol_name,
+ const char *module_name = nullptr);
+
+ // This version uses name_type_mask = eFunctionNameTypeAuto
+ lldb::SBBreakpoint
+ BreakpointCreateByName(const char *symbol_name,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list);
+
+ lldb::SBBreakpoint BreakpointCreateByName(
+ const char *symbol_name,
+ uint32_t
+ name_type_mask, // Logical OR one or more FunctionNameType enum bits
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list);
+
+ lldb::SBBreakpoint BreakpointCreateByName(
+ const char *symbol_name,
+ uint32_t
+ name_type_mask, // Logical OR one or more FunctionNameType enum bits
+ lldb::LanguageType symbol_language,
+ const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list);
+
+ lldb::SBBreakpoint BreakpointCreateByNames(
+ const char *symbol_name[], uint32_t num_names,
+ uint32_t
+ name_type_mask, // Logical OR one or more FunctionNameType enum bits
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list);
+
+ lldb::SBBreakpoint BreakpointCreateByNames(
+ const char *symbol_name[], uint32_t num_names,
+ uint32_t
+ name_type_mask, // Logical OR one or more FunctionNameType enum bits
+ lldb::LanguageType symbol_language,
+ const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list);
+
+ lldb::SBBreakpoint BreakpointCreateByNames(
+ const char *symbol_name[], uint32_t num_names,
+ uint32_t
+ name_type_mask, // Logical OR one or more FunctionNameType enum bits
+ lldb::LanguageType symbol_language,
+ lldb::addr_t offset, const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list);
+
+ lldb::SBBreakpoint BreakpointCreateByRegex(const char *symbol_name_regex,
+ const char *module_name = nullptr);
+
+ lldb::SBBreakpoint
+ BreakpointCreateByRegex(const char *symbol_name_regex,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list);
+
+ lldb::SBBreakpoint BreakpointCreateByRegex(
+ const char *symbol_name_regex, lldb::LanguageType symbol_language,
+ const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list);
+
+ lldb::SBBreakpoint
+ BreakpointCreateBySourceRegex(const char *source_regex,
+ const SBFileSpec &source_file,
+ const char *module_name = nullptr);
+
+ lldb::SBBreakpoint
+ BreakpointCreateBySourceRegex(const char *source_regex,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &source_file);
+
+ lldb::SBBreakpoint BreakpointCreateBySourceRegex(
+ const char *source_regex, const SBFileSpecList &module_list,
+ const SBFileSpecList &source_file, const SBStringList &func_names);
+
+ lldb::SBBreakpoint BreakpointCreateForException(lldb::LanguageType language,
+ bool catch_bp, bool throw_bp);
+
+ lldb::SBBreakpoint BreakpointCreateByAddress(addr_t address);
+
+ lldb::SBBreakpoint BreakpointCreateBySBAddress(SBAddress &address);
+
+ //------------------------------------------------------------------
+ /// Read breakpoints from source_file and return the newly created
+ /// breakpoints in bkpt_list.
+ ///
+ /// @param[in] source_file
+ /// The file from which to read the breakpoints.
+ ///
+ /// @param[out] bkpt_list
+ /// A list of the newly created breakpoints.
+ ///
+ /// @return
+ /// An SBError detailing any errors in reading in the breakpoints.
+ //------------------------------------------------------------------
+ lldb::SBError BreakpointsCreateFromFile(SBFileSpec &source_file,
+ SBBreakpointList &new_bps);
+
+ //------------------------------------------------------------------
+ /// Read breakpoints from source_file and return the newly created
+ /// breakpoints in bkpt_list.
+ ///
+ /// @param[in] source_file
+ /// The file from which to read the breakpoints.
+ ///
+ /// @param[in] matching_names
+ /// Only read in breakpoints whose names match one of the names in this
+ /// list.
+ ///
+ /// @param[out] bkpt_list
+ /// A list of the newly created breakpoints.
+ ///
+ /// @return
+ /// An SBError detailing any errors in reading in the breakpoints.
+ //------------------------------------------------------------------
+ lldb::SBError BreakpointsCreateFromFile(SBFileSpec &source_file,
+ SBStringList &matching_names,
+ SBBreakpointList &new_bps);
+
+ //------------------------------------------------------------------
+ /// Write breakpoints to dest_file.
+ ///
+ /// @param[in] dest_file
+ /// The file to which to write the breakpoints.
+ ///
+ /// @return
+ /// An SBError detailing any errors in writing in the breakpoints.
+ //------------------------------------------------------------------
+ lldb::SBError BreakpointsWriteToFile(SBFileSpec &dest_file);
+
+ //------------------------------------------------------------------
+ /// Write breakpoints listed in bkpt_list to dest_file.
+ ///
+ /// @param[in] dest_file
+ /// The file to which to write the breakpoints.
+ ///
+ /// @param[in] bkpt_list
+ /// Only write breakpoints from this list.
+ ///
+ /// @param[in] append
+ /// If \btrue, append the breakpoints in bkpt_list to the others
+ /// serialized in dest_file. If dest_file doesn't exist, then a new
+ /// file will be created and the breakpoints in bkpt_list written to it.
+ ///
+ /// @return
+ /// An SBError detailing any errors in writing in the breakpoints.
+ //------------------------------------------------------------------
+ lldb::SBError BreakpointsWriteToFile(SBFileSpec &dest_file,
+ SBBreakpointList &bkpt_list,
+ bool append = false);
+
+ uint32_t GetNumBreakpoints() const;
+
+ lldb::SBBreakpoint GetBreakpointAtIndex(uint32_t idx) const;
+
+ bool BreakpointDelete(break_id_t break_id);
+
+ lldb::SBBreakpoint FindBreakpointByID(break_id_t break_id);
+
+ // Finds all breakpoints by name, returning the list in bkpt_list. Returns
+ // false if the name is not a valid breakpoint name, true otherwise.
+ bool FindBreakpointsByName(const char *name, SBBreakpointList &bkpt_list);
+
+ bool EnableAllBreakpoints();
+
+ bool DisableAllBreakpoints();
+
+ bool DeleteAllBreakpoints();
+
+ uint32_t GetNumWatchpoints() const;
+
+ lldb::SBWatchpoint GetWatchpointAtIndex(uint32_t idx) const;
+
+ bool DeleteWatchpoint(lldb::watch_id_t watch_id);
+
+ lldb::SBWatchpoint FindWatchpointByID(lldb::watch_id_t watch_id);
+
+ lldb::SBWatchpoint WatchAddress(lldb::addr_t addr, size_t size, bool read,
+ bool write, SBError &error);
+
+ bool EnableAllWatchpoints();
+
+ bool DisableAllWatchpoints();
+
+ bool DeleteAllWatchpoints();
+
+ lldb::SBBroadcaster GetBroadcaster() const;
+
+ lldb::SBType FindFirstType(const char *type);
+
+ lldb::SBTypeList FindTypes(const char *type);
+
+ lldb::SBType GetBasicType(lldb::BasicType type);
+
+ lldb::SBValue CreateValueFromAddress(const char *name, lldb::SBAddress addr,
+ lldb::SBType type);
+
+ lldb::SBValue CreateValueFromData(const char *name, lldb::SBData data,
+ lldb::SBType type);
+
+ lldb::SBValue CreateValueFromExpression(const char *name, const char *expr);
+
+ SBSourceManager GetSourceManager();
+
+ lldb::SBInstructionList ReadInstructions(lldb::SBAddress base_addr,
+ uint32_t count);
+
+ lldb::SBInstructionList ReadInstructions(lldb::SBAddress base_addr,
+ uint32_t count,
+ const char *flavor_string);
+
+ lldb::SBInstructionList GetInstructions(lldb::SBAddress base_addr,
+ const void *buf, size_t size);
+
+ // The "WithFlavor" is necessary to keep SWIG from getting confused about
+ // overloaded arguments when
+ // using the buf + size -> Python Object magic.
+
+ lldb::SBInstructionList GetInstructionsWithFlavor(lldb::SBAddress base_addr,
+ const char *flavor_string,
+ const void *buf,
+ size_t size);
+
+ lldb::SBInstructionList GetInstructions(lldb::addr_t base_addr,
+ const void *buf, size_t size);
+
+ lldb::SBInstructionList GetInstructionsWithFlavor(lldb::addr_t base_addr,
+ const char *flavor_string,
+ const void *buf,
+ size_t size);
+
+ lldb::SBSymbolContextList FindSymbols(const char *name,
+ lldb::SymbolType type = eSymbolTypeAny);
+
+ bool operator==(const lldb::SBTarget &rhs) const;
- lldb::SBSymbolContextList
- FindSymbols (const char *name,
- lldb::SymbolType type = eSymbolTypeAny);
+ bool operator!=(const lldb::SBTarget &rhs) const;
- bool
- operator == (const lldb::SBTarget &rhs) const;
+ bool GetDescription(lldb::SBStream &description,
+ lldb::DescriptionLevel description_level);
- bool
- operator != (const lldb::SBTarget &rhs) const;
+ lldb::SBValue EvaluateExpression(const char *expr);
- bool
- GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level);
+ lldb::SBValue EvaluateExpression(const char *expr,
+ const SBExpressionOptions &options);
- lldb::SBValue
- EvaluateExpression (const char *expr);
+ lldb::addr_t GetStackRedZoneSize();
- lldb::SBValue
- EvaluateExpression (const char *expr, const SBExpressionOptions &options);
+ lldb::SBLaunchInfo GetLaunchInfo() const;
- lldb::addr_t
- GetStackRedZoneSize();
+ void SetLaunchInfo(const lldb::SBLaunchInfo &launch_info);
- lldb::SBLaunchInfo
- GetLaunchInfo () const;
-
- void
- SetLaunchInfo (const lldb::SBLaunchInfo &launch_info);
-
protected:
- friend class SBAddress;
- friend class SBBlock;
- friend class SBDebugger;
- friend class SBExecutionContext;
- friend class SBFunction;
- friend class SBInstruction;
- friend class SBModule;
- friend class SBProcess;
- friend class SBSection;
- friend class SBSourceManager;
- friend class SBSymbol;
- friend class SBValue;
-
- //------------------------------------------------------------------
- // Constructors are private, use static Target::Create function to
- // create an instance of this class.
- //------------------------------------------------------------------
-
- lldb::TargetSP
- GetSP () const;
-
- void
- SetSP (const lldb::TargetSP& target_sp);
+ friend class SBAddress;
+ friend class SBBlock;
+ friend class SBBreakpointList;
+ friend class SBDebugger;
+ friend class SBExecutionContext;
+ friend class SBFunction;
+ friend class SBInstruction;
+ friend class SBModule;
+ friend class SBProcess;
+ friend class SBSection;
+ friend class SBSourceManager;
+ friend class SBSymbol;
+ friend class SBValue;
+
+ //------------------------------------------------------------------
+ // Constructors are private, use static Target::Create function to
+ // create an instance of this class.
+ //------------------------------------------------------------------
+
+ lldb::TargetSP GetSP() const;
+
+ void SetSP(const lldb::TargetSP &target_sp);
private:
- lldb::TargetSP m_opaque_sp;
+ lldb::TargetSP m_opaque_sp;
};
} // namespace lldb
diff --git a/include/lldb/API/SBThread.h b/include/lldb/API/SBThread.h
index c1ce216f9be6..502e5c973ef5 100644
--- a/include/lldb/API/SBThread.h
+++ b/include/lldb/API/SBThread.h
@@ -18,254 +18,203 @@ namespace lldb {
class SBFrame;
-class LLDB_API SBThread
-{
+class LLDB_API SBThread {
public:
- enum
- {
- eBroadcastBitStackChanged = (1 << 0),
- eBroadcastBitThreadSuspended = (1 << 1),
- eBroadcastBitThreadResumed = (1 << 2),
- eBroadcastBitSelectedFrameChanged = (1 << 3),
- eBroadcastBitThreadSelected = (1 << 4)
- };
-
- static const char *
- GetBroadcasterClassName ();
-
- SBThread ();
-
- SBThread (const lldb::SBThread &thread);
-
- SBThread (const lldb::ThreadSP& lldb_object_sp);
-
- ~SBThread();
-
- lldb::SBQueue
- GetQueue () const;
-
- bool
- IsValid() const;
-
- void
- Clear ();
-
- lldb::StopReason
- GetStopReason();
-
- /// Get the number of words associated with the stop reason.
- /// See also GetStopReasonDataAtIndex().
- size_t
- GetStopReasonDataCount();
-
- //--------------------------------------------------------------------------
- /// Get information associated with a stop reason.
- ///
- /// Breakpoint stop reasons will have data that consists of pairs of
- /// breakpoint IDs followed by the breakpoint location IDs (they always come
- /// in pairs).
- ///
- /// Stop Reason Count Data Type
- /// ======================== ===== =========================================
- /// eStopReasonNone 0
- /// eStopReasonTrace 0
- /// eStopReasonBreakpoint N duple: {breakpoint id, location id}
- /// eStopReasonWatchpoint 1 watchpoint id
- /// eStopReasonSignal 1 unix signal number
- /// eStopReasonException N exception data
- /// eStopReasonExec 0
- /// eStopReasonPlanComplete 0
- //--------------------------------------------------------------------------
- uint64_t
- GetStopReasonDataAtIndex(uint32_t idx);
-
- bool
- GetStopReasonExtendedInfoAsJSON (lldb::SBStream &stream);
-
- SBThreadCollection
- GetStopReasonExtendedBacktraces (InstrumentationRuntimeType type);
-
- size_t
- GetStopDescription (char *dst, size_t dst_len);
-
- SBValue
- GetStopReturnValue ();
-
- lldb::tid_t
- GetThreadID () const;
-
- uint32_t
- GetIndexID () const;
-
- const char *
- GetName () const;
-
- const char *
- GetQueueName() const;
-
- lldb::queue_id_t
- GetQueueID() const;
-
- bool
- GetInfoItemByPathAsString ( const char *path, SBStream &strm);
-
- void
- StepOver (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
-
- void
- StepInto (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
-
- void
- StepInto (const char *target_name, lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
-
- void
- StepInto (const char *target_name,
- uint32_t end_line,
- SBError &error,
- lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
-
- void
- StepOut ();
-
- void
- StepOutOfFrame (lldb::SBFrame &frame);
-
- void
- StepInstruction(bool step_over);
-
- SBError
- StepOverUntil (lldb::SBFrame &frame,
- lldb::SBFileSpec &file_spec,
- uint32_t line);
-
- SBError
- StepUsingScriptedThreadPlan (const char *script_class_name);
-
- SBError
- JumpToLine (lldb::SBFileSpec &file_spec, uint32_t line);
-
- void
- RunToAddress (lldb::addr_t addr);
-
- SBError
- ReturnFromFrame (SBFrame &frame, SBValue &return_value);
-
- SBError
- UnwindInnermostExpression();
-
- //--------------------------------------------------------------------------
- /// LLDB currently supports process centric debugging which means when any
- /// thread in a process stops, all other threads are stopped. The Suspend()
- /// call here tells our process to suspend a thread and not let it run when
- /// the other threads in a process are allowed to run. So when
- /// SBProcess::Continue() is called, any threads that aren't suspended will
- /// be allowed to run. If any of the SBThread functions for stepping are
- /// called (StepOver, StepInto, StepOut, StepInstruction, RunToAddress), the
- /// thread will not be allowed to run and these functions will simply return.
- ///
- /// Eventually we plan to add support for thread centric debugging where
- /// each thread is controlled individually and each thread would broadcast
- /// its state, but we haven't implemented this yet.
- ///
- /// Likewise the SBThread::Resume() call will again allow the thread to run
- /// when the process is continued.
- ///
- /// Suspend() and Resume() functions are not currently reference counted, if
- /// anyone has the need for them to be reference counted, please let us
- /// know.
- //--------------------------------------------------------------------------
- bool
- Suspend();
-
- bool
- Resume ();
-
- bool
- IsSuspended();
-
- bool
- IsStopped();
-
- uint32_t
- GetNumFrames ();
-
- lldb::SBFrame
- GetFrameAtIndex (uint32_t idx);
-
- lldb::SBFrame
- GetSelectedFrame ();
-
- lldb::SBFrame
- SetSelectedFrame (uint32_t frame_idx);
-
- static bool
- EventIsThreadEvent (const SBEvent &event);
-
- static SBFrame
- GetStackFrameFromEvent (const SBEvent &event);
-
- static SBThread
- GetThreadFromEvent (const SBEvent &event);
-
- lldb::SBProcess
- GetProcess ();
-
- const lldb::SBThread &
- operator = (const lldb::SBThread &rhs);
-
- bool
- operator == (const lldb::SBThread &rhs) const;
-
- bool
- operator != (const lldb::SBThread &rhs) const;
-
- bool
- GetDescription (lldb::SBStream &description) const;
-
- bool
- GetStatus (lldb::SBStream &status) const;
-
- SBThread
- GetExtendedBacktraceThread (const char *type);
-
- uint32_t
- GetExtendedBacktraceOriginatingIndexID ();
-
- bool
- SafeToCallFunctions ();
+ enum {
+ eBroadcastBitStackChanged = (1 << 0),
+ eBroadcastBitThreadSuspended = (1 << 1),
+ eBroadcastBitThreadResumed = (1 << 2),
+ eBroadcastBitSelectedFrameChanged = (1 << 3),
+ eBroadcastBitThreadSelected = (1 << 4)
+ };
+
+ static const char *GetBroadcasterClassName();
+
+ SBThread();
+
+ SBThread(const lldb::SBThread &thread);
+
+ SBThread(const lldb::ThreadSP &lldb_object_sp);
+
+ ~SBThread();
+
+ lldb::SBQueue GetQueue() const;
+
+ bool IsValid() const;
+
+ void Clear();
+
+ lldb::StopReason GetStopReason();
+
+ /// Get the number of words associated with the stop reason.
+ /// See also GetStopReasonDataAtIndex().
+ size_t GetStopReasonDataCount();
+
+ //--------------------------------------------------------------------------
+ /// Get information associated with a stop reason.
+ ///
+ /// Breakpoint stop reasons will have data that consists of pairs of
+ /// breakpoint IDs followed by the breakpoint location IDs (they always come
+ /// in pairs).
+ ///
+ /// Stop Reason Count Data Type
+ /// ======================== ===== =========================================
+ /// eStopReasonNone 0
+ /// eStopReasonTrace 0
+ /// eStopReasonBreakpoint N duple: {breakpoint id, location id}
+ /// eStopReasonWatchpoint 1 watchpoint id
+ /// eStopReasonSignal 1 unix signal number
+ /// eStopReasonException N exception data
+ /// eStopReasonExec 0
+ /// eStopReasonPlanComplete 0
+ //--------------------------------------------------------------------------
+ uint64_t GetStopReasonDataAtIndex(uint32_t idx);
+
+ bool GetStopReasonExtendedInfoAsJSON(lldb::SBStream &stream);
+
+ SBThreadCollection
+ GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type);
+
+ size_t GetStopDescription(char *dst, size_t dst_len);
+
+ SBValue GetStopReturnValue();
+
+ lldb::tid_t GetThreadID() const;
+
+ uint32_t GetIndexID() const;
+
+ const char *GetName() const;
+
+ const char *GetQueueName() const;
+
+ lldb::queue_id_t GetQueueID() const;
+
+ bool GetInfoItemByPathAsString(const char *path, SBStream &strm);
+
+ void StepOver(lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
+
+ void StepInto(lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
+
+ void StepInto(const char *target_name,
+ lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
+
+ void StepInto(const char *target_name, uint32_t end_line, SBError &error,
+ lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
+
+ void StepOut();
+
+ void StepOutOfFrame(lldb::SBFrame &frame);
+
+ void StepInstruction(bool step_over);
+
+ SBError StepOverUntil(lldb::SBFrame &frame, lldb::SBFileSpec &file_spec,
+ uint32_t line);
+
+ SBError StepUsingScriptedThreadPlan(const char *script_class_name);
+
+ SBError StepUsingScriptedThreadPlan(const char *script_class_name,
+ bool resume_immediately);
+
+ SBError JumpToLine(lldb::SBFileSpec &file_spec, uint32_t line);
+
+ void RunToAddress(lldb::addr_t addr);
+
+ SBError ReturnFromFrame(SBFrame &frame, SBValue &return_value);
+
+ SBError UnwindInnermostExpression();
+
+ //--------------------------------------------------------------------------
+ /// LLDB currently supports process centric debugging which means when any
+ /// thread in a process stops, all other threads are stopped. The Suspend()
+ /// call here tells our process to suspend a thread and not let it run when
+ /// the other threads in a process are allowed to run. So when
+ /// SBProcess::Continue() is called, any threads that aren't suspended will
+ /// be allowed to run. If any of the SBThread functions for stepping are
+ /// called (StepOver, StepInto, StepOut, StepInstruction, RunToAddress), the
+ /// thread will not be allowed to run and these functions will simply return.
+ ///
+ /// Eventually we plan to add support for thread centric debugging where
+ /// each thread is controlled individually and each thread would broadcast
+ /// its state, but we haven't implemented this yet.
+ ///
+ /// Likewise the SBThread::Resume() call will again allow the thread to run
+ /// when the process is continued.
+ ///
+ /// Suspend() and Resume() functions are not currently reference counted, if
+ /// anyone has the need for them to be reference counted, please let us
+ /// know.
+ //--------------------------------------------------------------------------
+ bool Suspend();
+
+ bool Resume();
+
+ bool IsSuspended();
+
+ bool IsStopped();
+
+ uint32_t GetNumFrames();
+
+ lldb::SBFrame GetFrameAtIndex(uint32_t idx);
+
+ lldb::SBFrame GetSelectedFrame();
+
+ lldb::SBFrame SetSelectedFrame(uint32_t frame_idx);
+
+ static bool EventIsThreadEvent(const SBEvent &event);
+
+ static SBFrame GetStackFrameFromEvent(const SBEvent &event);
+
+ static SBThread GetThreadFromEvent(const SBEvent &event);
+
+ lldb::SBProcess GetProcess();
+
+ const lldb::SBThread &operator=(const lldb::SBThread &rhs);
+
+ bool operator==(const lldb::SBThread &rhs) const;
+
+ bool operator!=(const lldb::SBThread &rhs) const;
+
+ bool GetDescription(lldb::SBStream &description) const;
+
+ bool GetDescription(lldb::SBStream &description, bool stop_format) const;
+
+ bool GetStatus(lldb::SBStream &status) const;
+
+ SBThread GetExtendedBacktraceThread(const char *type);
+
+ uint32_t GetExtendedBacktraceOriginatingIndexID();
+
+ bool SafeToCallFunctions();
#ifndef SWIG
- lldb_private::Thread *
- operator->();
+ lldb_private::Thread *operator->();
- lldb_private::Thread *
- get();
+ lldb_private::Thread *get();
#endif
protected:
- friend class SBBreakpoint;
- friend class SBBreakpointLocation;
- friend class SBExecutionContext;
- friend class SBFrame;
- friend class SBProcess;
- friend class SBDebugger;
- friend class SBValue;
- friend class lldb_private::QueueImpl;
- friend class SBQueueItem;
-
- void
- SetThread (const lldb::ThreadSP& lldb_object_sp);
+ friend class SBBreakpoint;
+ friend class SBBreakpointLocation;
+ friend class SBExecutionContext;
+ friend class SBFrame;
+ friend class SBProcess;
+ friend class SBDebugger;
+ friend class SBValue;
+ friend class lldb_private::QueueImpl;
+ friend class SBQueueItem;
+
+ void SetThread(const lldb::ThreadSP &lldb_object_sp);
#ifndef SWIG
- SBError
- ResumeNewPlan (lldb_private::ExecutionContext &exe_ctx, lldb_private::ThreadPlan *new_plan);
+ SBError ResumeNewPlan(lldb_private::ExecutionContext &exe_ctx,
+ lldb_private::ThreadPlan *new_plan);
#endif
private:
- lldb::ExecutionContextRefSP m_opaque_sp;
+ lldb::ExecutionContextRefSP m_opaque_sp;
};
} // namespace lldb
-#endif // LLDB_SBThread_h_
+#endif // LLDB_SBThread_h_
diff --git a/include/lldb/API/SBThreadCollection.h b/include/lldb/API/SBThreadCollection.h
index 79f977454497..715b0826b962 100644
--- a/include/lldb/API/SBThreadCollection.h
+++ b/include/lldb/API/SBThreadCollection.h
@@ -13,57 +13,44 @@
#include "lldb/API/SBDefines.h"
namespace lldb {
-
-class LLDB_API SBThreadCollection
-{
+
+class LLDB_API SBThreadCollection {
public:
-
- SBThreadCollection ();
-
- SBThreadCollection (const SBThreadCollection &rhs);
-
- const SBThreadCollection &
- operator = (const SBThreadCollection &rhs);
-
- ~SBThreadCollection ();
-
- bool
- IsValid () const;
-
- size_t
- GetSize ();
-
- lldb::SBThread
- GetThreadAtIndex (size_t idx);
-
+ SBThreadCollection();
+
+ SBThreadCollection(const SBThreadCollection &rhs);
+
+ const SBThreadCollection &operator=(const SBThreadCollection &rhs);
+
+ ~SBThreadCollection();
+
+ bool IsValid() const;
+
+ size_t GetSize();
+
+ lldb::SBThread GetThreadAtIndex(size_t idx);
+
protected:
-
- // Mimic shared pointer...
- lldb_private::ThreadCollection *
- get() const;
-
- lldb_private::ThreadCollection *
- operator->() const;
-
- lldb::ThreadCollectionSP &
- operator*();
-
- const lldb::ThreadCollectionSP &
- operator*() const;
-
- SBThreadCollection (const lldb::ThreadCollectionSP &threads);
-
- void
- SetOpaque (const lldb::ThreadCollectionSP &threads);
-
+ // Mimic shared pointer...
+ lldb_private::ThreadCollection *get() const;
+
+ lldb_private::ThreadCollection *operator->() const;
+
+ lldb::ThreadCollectionSP &operator*();
+
+ const lldb::ThreadCollectionSP &operator*() const;
+
+ SBThreadCollection(const lldb::ThreadCollectionSP &threads);
+
+ void SetOpaque(const lldb::ThreadCollectionSP &threads);
+
private:
- friend class SBProcess;
- friend class SBThread;
-
- lldb::ThreadCollectionSP m_opaque_sp;
+ friend class SBProcess;
+ friend class SBThread;
+
+ lldb::ThreadCollectionSP m_opaque_sp;
};
-
-
+
} // namespace lldb
#endif // LLDB_SBThreadCollection_h_
diff --git a/include/lldb/API/SBThreadPlan.h b/include/lldb/API/SBThreadPlan.h
index 9cc0d0b89bb5..abc14bf8fe4a 100644
--- a/include/lldb/API/SBThreadPlan.h
+++ b/include/lldb/API/SBThreadPlan.h
@@ -16,114 +16,100 @@
namespace lldb {
-class LLDB_API SBThreadPlan
-{
+class LLDB_API SBThreadPlan {
-friend class lldb_private::ThreadPlan;
+ friend class lldb_private::ThreadPlan;
public:
- SBThreadPlan ();
+ SBThreadPlan();
- SBThreadPlan (const lldb::SBThreadPlan &threadPlan);
-
- SBThreadPlan (const lldb::ThreadPlanSP& lldb_object_sp);
+ SBThreadPlan(const lldb::SBThreadPlan &threadPlan);
- SBThreadPlan (lldb::SBThread &thread, const char *class_name);
+ SBThreadPlan(const lldb::ThreadPlanSP &lldb_object_sp);
- ~SBThreadPlan ();
+ SBThreadPlan(lldb::SBThread &thread, const char *class_name);
- bool
- IsValid() const;
+ ~SBThreadPlan();
- void
- Clear ();
+ bool IsValid() const;
- lldb::StopReason
- GetStopReason();
+ void Clear();
- /// Get the number of words associated with the stop reason.
- /// See also GetStopReasonDataAtIndex().
- size_t
- GetStopReasonDataCount();
+ lldb::StopReason GetStopReason();
- //--------------------------------------------------------------------------
- /// Get information associated with a stop reason.
- ///
- /// Breakpoint stop reasons will have data that consists of pairs of
- /// breakpoint IDs followed by the breakpoint location IDs (they always come
- /// in pairs).
- ///
- /// Stop Reason Count Data Type
- /// ======================== ===== =========================================
- /// eStopReasonNone 0
- /// eStopReasonTrace 0
- /// eStopReasonBreakpoint N duple: {breakpoint id, location id}
- /// eStopReasonWatchpoint 1 watchpoint id
- /// eStopReasonSignal 1 unix signal number
- /// eStopReasonException N exception data
- /// eStopReasonExec 0
- /// eStopReasonPlanComplete 0
- //--------------------------------------------------------------------------
- uint64_t
- GetStopReasonDataAtIndex(uint32_t idx);
+ /// Get the number of words associated with the stop reason.
+ /// See also GetStopReasonDataAtIndex().
+ size_t GetStopReasonDataCount();
- SBThread
- GetThread () const;
+ //--------------------------------------------------------------------------
+ /// Get information associated with a stop reason.
+ ///
+ /// Breakpoint stop reasons will have data that consists of pairs of
+ /// breakpoint IDs followed by the breakpoint location IDs (they always come
+ /// in pairs).
+ ///
+ /// Stop Reason Count Data Type
+ /// ======================== ===== =========================================
+ /// eStopReasonNone 0
+ /// eStopReasonTrace 0
+ /// eStopReasonBreakpoint N duple: {breakpoint id, location id}
+ /// eStopReasonWatchpoint 1 watchpoint id
+ /// eStopReasonSignal 1 unix signal number
+ /// eStopReasonException N exception data
+ /// eStopReasonExec 0
+ /// eStopReasonPlanComplete 0
+ //--------------------------------------------------------------------------
+ uint64_t GetStopReasonDataAtIndex(uint32_t idx);
- const lldb::SBThreadPlan &
- operator = (const lldb::SBThreadPlan &rhs);
+ SBThread GetThread() const;
- bool
- GetDescription (lldb::SBStream &description) const;
+ const lldb::SBThreadPlan &operator=(const lldb::SBThreadPlan &rhs);
- void
- SetPlanComplete (bool success);
+ bool GetDescription(lldb::SBStream &description) const;
- bool
- IsPlanComplete();
+ void SetPlanComplete(bool success);
- bool
- IsValid();
+ bool IsPlanComplete();
- // This section allows an SBThreadPlan to push another of the common types of plans...
- SBThreadPlan
- QueueThreadPlanForStepOverRange (SBAddress &start_address,
- lldb::addr_t range_size);
+ bool IsPlanStale();
- SBThreadPlan
- QueueThreadPlanForStepInRange (SBAddress &start_address,
- lldb::addr_t range_size);
+ bool IsValid();
- SBThreadPlan
- QueueThreadPlanForStepOut (uint32_t frame_idx_to_step_to, bool first_insn = false);
+ // This section allows an SBThreadPlan to push another of the common types of
+ // plans...
+ SBThreadPlan QueueThreadPlanForStepOverRange(SBAddress &start_address,
+ lldb::addr_t range_size);
- SBThreadPlan
- QueueThreadPlanForRunToAddress (SBAddress address);
+ SBThreadPlan QueueThreadPlanForStepInRange(SBAddress &start_address,
+ lldb::addr_t range_size);
+
+ SBThreadPlan QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,
+ bool first_insn = false);
+
+ SBThreadPlan QueueThreadPlanForRunToAddress(SBAddress address);
#ifndef SWIG
- lldb_private::ThreadPlan *
- get();
+ lldb_private::ThreadPlan *get();
#endif
protected:
- friend class SBBreakpoint;
- friend class SBBreakpointLocation;
- friend class SBFrame;
- friend class SBProcess;
- friend class SBDebugger;
- friend class SBValue;
- friend class lldb_private::QueueImpl;
- friend class SBQueueItem;
+ friend class SBBreakpoint;
+ friend class SBBreakpointLocation;
+ friend class SBFrame;
+ friend class SBProcess;
+ friend class SBDebugger;
+ friend class SBValue;
+ friend class lldb_private::QueueImpl;
+ friend class SBQueueItem;
#ifndef SWIG
- void
- SetThreadPlan (const lldb::ThreadPlanSP& lldb_object_sp);
+ void SetThreadPlan(const lldb::ThreadPlanSP &lldb_object_sp);
#endif
private:
- lldb::ThreadPlanSP m_opaque_sp;
+ lldb::ThreadPlanSP m_opaque_sp;
};
} // namespace lldb
-#endif // LLDB_SBThreadPlan_h_
+#endif // LLDB_SBThreadPlan_h_
diff --git a/include/lldb/API/SBType.h b/include/lldb/API/SBType.h
index ed3c2ff23863..0dde0257909f 100644
--- a/include/lldb/API/SBType.h
+++ b/include/lldb/API/SBType.h
@@ -14,328 +14,241 @@
namespace lldb {
-class SBTypeList;
+class SBTypeList;
-class LLDB_API SBTypeMember
-{
+class LLDB_API SBTypeMember {
public:
- SBTypeMember ();
-
- SBTypeMember (const lldb::SBTypeMember& rhs);
-
- ~SBTypeMember();
-
- lldb::SBTypeMember&
- operator = (const lldb::SBTypeMember& rhs);
-
- bool
- IsValid() const;
-
- const char *
- GetName ();
-
- lldb::SBType
- GetType ();
-
- uint64_t
- GetOffsetInBytes();
-
- uint64_t
- GetOffsetInBits();
-
- bool
- IsBitfield();
-
- uint32_t
- GetBitfieldSizeInBits();
-
- bool
- GetDescription (lldb::SBStream &description,
- lldb::DescriptionLevel description_level);
-
+ SBTypeMember();
+
+ SBTypeMember(const lldb::SBTypeMember &rhs);
+
+ ~SBTypeMember();
+
+ lldb::SBTypeMember &operator=(const lldb::SBTypeMember &rhs);
+
+ bool IsValid() const;
+
+ const char *GetName();
+
+ lldb::SBType GetType();
+
+ uint64_t GetOffsetInBytes();
+
+ uint64_t GetOffsetInBits();
+
+ bool IsBitfield();
+
+ uint32_t GetBitfieldSizeInBits();
+
+ bool GetDescription(lldb::SBStream &description,
+ lldb::DescriptionLevel description_level);
+
protected:
- friend class SBType;
+ friend class SBType;
- void
- reset (lldb_private::TypeMemberImpl *);
+ void reset(lldb_private::TypeMemberImpl *);
- lldb_private::TypeMemberImpl &
- ref ();
+ lldb_private::TypeMemberImpl &ref();
- const lldb_private::TypeMemberImpl &
- ref () const;
+ const lldb_private::TypeMemberImpl &ref() const;
- std::unique_ptr<lldb_private::TypeMemberImpl> m_opaque_ap;
+ std::unique_ptr<lldb_private::TypeMemberImpl> m_opaque_ap;
};
-
-class SBTypeMemberFunction
-{
+
+class SBTypeMemberFunction {
public:
- SBTypeMemberFunction ();
-
- SBTypeMemberFunction (const lldb::SBTypeMemberFunction& rhs);
-
- ~SBTypeMemberFunction();
-
- lldb::SBTypeMemberFunction&
- operator = (const lldb::SBTypeMemberFunction& rhs);
-
- bool
- IsValid() const;
-
- const char *
- GetName ();
-
- const char *
- GetDemangledName ();
-
- const char *
- GetMangledName ();
-
- lldb::SBType
- GetType ();
-
- lldb::SBType
- GetReturnType ();
-
- uint32_t
- GetNumberOfArguments ();
-
- lldb::SBType
- GetArgumentTypeAtIndex (uint32_t);
-
- lldb::MemberFunctionKind
- GetKind();
-
- bool
- GetDescription (lldb::SBStream &description,
- lldb::DescriptionLevel description_level);
-
+ SBTypeMemberFunction();
+
+ SBTypeMemberFunction(const lldb::SBTypeMemberFunction &rhs);
+
+ ~SBTypeMemberFunction();
+
+ lldb::SBTypeMemberFunction &operator=(const lldb::SBTypeMemberFunction &rhs);
+
+ bool IsValid() const;
+
+ const char *GetName();
+
+ const char *GetDemangledName();
+
+ const char *GetMangledName();
+
+ lldb::SBType GetType();
+
+ lldb::SBType GetReturnType();
+
+ uint32_t GetNumberOfArguments();
+
+ lldb::SBType GetArgumentTypeAtIndex(uint32_t);
+
+ lldb::MemberFunctionKind GetKind();
+
+ bool GetDescription(lldb::SBStream &description,
+ lldb::DescriptionLevel description_level);
+
protected:
- friend class SBType;
-
- void
- reset (lldb_private::TypeMemberFunctionImpl *);
-
- lldb_private::TypeMemberFunctionImpl &
- ref ();
-
- const lldb_private::TypeMemberFunctionImpl &
- ref () const;
-
- lldb::TypeMemberFunctionImplSP m_opaque_sp;
-};
+ friend class SBType;
+
+ void reset(lldb_private::TypeMemberFunctionImpl *);
+ lldb_private::TypeMemberFunctionImpl &ref();
-class SBType
-{
+ const lldb_private::TypeMemberFunctionImpl &ref() const;
+
+ lldb::TypeMemberFunctionImplSP m_opaque_sp;
+};
+
+class SBType {
public:
+ SBType();
+
+ SBType(const lldb::SBType &rhs);
+
+ ~SBType();
+
+ bool IsValid() const;
+
+ uint64_t GetByteSize();
+
+ bool IsPointerType();
+
+ bool IsReferenceType();
+
+ bool IsFunctionType();
+
+ bool IsPolymorphicClass();
+
+ bool IsArrayType();
+
+ bool IsVectorType();
+
+ bool IsTypedefType();
+
+ bool IsAnonymousType();
+
+ lldb::SBType GetPointerType();
+
+ lldb::SBType GetPointeeType();
+
+ lldb::SBType GetReferenceType();
+
+ lldb::SBType GetTypedefedType();
+
+ lldb::SBType GetDereferencedType();
+
+ lldb::SBType GetUnqualifiedType();
+
+ lldb::SBType GetArrayElementType();
+
+ lldb::SBType GetArrayType(uint64_t size);
+
+ lldb::SBType GetVectorElementType();
+
+ lldb::SBType GetCanonicalType();
+ // Get the "lldb::BasicType" enumeration for a type. If a type is not a basic
+ // type eBasicTypeInvalid will be returned
+ lldb::BasicType GetBasicType();
+
+ // The call below confusing and should really be renamed to "CreateBasicType"
+ lldb::SBType GetBasicType(lldb::BasicType type);
+
+ uint32_t GetNumberOfFields();
+
+ uint32_t GetNumberOfDirectBaseClasses();
+
+ uint32_t GetNumberOfVirtualBaseClasses();
+
+ lldb::SBTypeMember GetFieldAtIndex(uint32_t idx);
+
+ lldb::SBTypeMember GetDirectBaseClassAtIndex(uint32_t idx);
+
+ lldb::SBTypeMember GetVirtualBaseClassAtIndex(uint32_t idx);
+
+ lldb::SBTypeEnumMemberList GetEnumMembers();
+
+ uint32_t GetNumberOfTemplateArguments();
+
+ lldb::SBType GetTemplateArgumentType(uint32_t idx);
+
+ lldb::TemplateArgumentKind GetTemplateArgumentKind(uint32_t idx);
+
+ lldb::SBType GetFunctionReturnType();
+
+ lldb::SBTypeList GetFunctionArgumentTypes();
+
+ uint32_t GetNumberOfMemberFunctions();
+
+ lldb::SBTypeMemberFunction GetMemberFunctionAtIndex(uint32_t idx);
+
+ const char *GetName();
+
+ const char *GetDisplayTypeName();
+
+ lldb::TypeClass GetTypeClass();
+
+ bool IsTypeComplete();
+
+ uint32_t GetTypeFlags();
+
+ bool GetDescription(lldb::SBStream &description,
+ lldb::DescriptionLevel description_level);
+
+ lldb::SBType &operator=(const lldb::SBType &rhs);
+
+ bool operator==(lldb::SBType &rhs);
+
+ bool operator!=(lldb::SBType &rhs);
- SBType();
-
- SBType (const lldb::SBType &rhs);
-
- ~SBType ();
-
- bool
- IsValid() const;
-
- uint64_t
- GetByteSize();
-
- bool
- IsPointerType();
-
- bool
- IsReferenceType();
-
- bool
- IsFunctionType ();
-
- bool
- IsPolymorphicClass ();
-
- bool
- IsArrayType ();
-
- bool
- IsVectorType ();
-
- bool
- IsTypedefType ();
-
- bool
- IsAnonymousType ();
-
- lldb::SBType
- GetPointerType();
-
- lldb::SBType
- GetPointeeType();
-
- lldb::SBType
- GetReferenceType();
-
- lldb::SBType
- GetTypedefedType();
-
- lldb::SBType
- GetDereferencedType();
-
- lldb::SBType
- GetUnqualifiedType();
-
- lldb::SBType
- GetArrayElementType ();
-
- lldb::SBType
- GetVectorElementType ();
-
- lldb::SBType
- GetCanonicalType();
- // Get the "lldb::BasicType" enumeration for a type. If a type is not a basic
- // type eBasicTypeInvalid will be returned
- lldb::BasicType
- GetBasicType();
-
- // The call below confusing and should really be renamed to "CreateBasicType"
- lldb::SBType
- GetBasicType(lldb::BasicType type);
-
- uint32_t
- GetNumberOfFields ();
-
- uint32_t
- GetNumberOfDirectBaseClasses ();
-
- uint32_t
- GetNumberOfVirtualBaseClasses ();
-
- lldb::SBTypeMember
- GetFieldAtIndex (uint32_t idx);
-
- lldb::SBTypeMember
- GetDirectBaseClassAtIndex (uint32_t idx);
-
- lldb::SBTypeMember
- GetVirtualBaseClassAtIndex (uint32_t idx);
-
- lldb::SBTypeEnumMemberList
- GetEnumMembers();
-
- uint32_t
- GetNumberOfTemplateArguments ();
-
- lldb::SBType
- GetTemplateArgumentType (uint32_t idx);
-
- lldb::TemplateArgumentKind
- GetTemplateArgumentKind (uint32_t idx);
-
- lldb::SBType
- GetFunctionReturnType ();
-
- lldb::SBTypeList
- GetFunctionArgumentTypes ();
-
- uint32_t
- GetNumberOfMemberFunctions ();
-
- lldb::SBTypeMemberFunction
- GetMemberFunctionAtIndex (uint32_t idx);
-
- const char*
- GetName();
-
- const char *
- GetDisplayTypeName ();
-
- lldb::TypeClass
- GetTypeClass ();
-
- bool
- IsTypeComplete ();
-
- uint32_t
- GetTypeFlags ();
-
- bool
- GetDescription (lldb::SBStream &description,
- lldb::DescriptionLevel description_level);
-
- lldb::SBType &
- operator = (const lldb::SBType &rhs);
-
- bool
- operator == (lldb::SBType &rhs);
-
- bool
- operator != (lldb::SBType &rhs);
-
protected:
+ lldb_private::TypeImpl &ref();
+
+ const lldb_private::TypeImpl &ref() const;
+
+ lldb::TypeImplSP GetSP();
+
+ void SetSP(const lldb::TypeImplSP &type_impl_sp);
- lldb_private::TypeImpl &
- ref ();
-
- const lldb_private::TypeImpl &
- ref () const;
-
- lldb::TypeImplSP
- GetSP ();
-
- void
- SetSP (const lldb::TypeImplSP &type_impl_sp);
-
- lldb::TypeImplSP m_opaque_sp;
-
- friend class SBFunction;
- friend class SBModule;
- friend class SBTarget;
- friend class SBTypeEnumMember;
- friend class SBTypeEnumMemberList;
- friend class SBTypeNameSpecifier;
- friend class SBTypeMember;
- friend class SBTypeMemberFunction;
- friend class SBTypeList;
- friend class SBValue;
-
- SBType (const lldb_private::CompilerType &);
- SBType (const lldb::TypeSP &);
- SBType (const lldb::TypeImplSP &);
-
+ lldb::TypeImplSP m_opaque_sp;
+
+ friend class SBFunction;
+ friend class SBModule;
+ friend class SBTarget;
+ friend class SBTypeEnumMember;
+ friend class SBTypeEnumMemberList;
+ friend class SBTypeNameSpecifier;
+ friend class SBTypeMember;
+ friend class SBTypeMemberFunction;
+ friend class SBTypeList;
+ friend class SBValue;
+
+ SBType(const lldb_private::CompilerType &);
+ SBType(const lldb::TypeSP &);
+ SBType(const lldb::TypeImplSP &);
};
-
-class SBTypeList
-{
+
+class SBTypeList {
public:
- SBTypeList();
-
- SBTypeList(const lldb::SBTypeList& rhs);
-
- ~SBTypeList();
-
- lldb::SBTypeList&
- operator = (const lldb::SBTypeList& rhs);
-
- bool
- IsValid();
-
- void
- Append (lldb::SBType type);
-
- lldb::SBType
- GetTypeAtIndex (uint32_t index);
-
- uint32_t
- GetSize();
-
-
+ SBTypeList();
+
+ SBTypeList(const lldb::SBTypeList &rhs);
+
+ ~SBTypeList();
+
+ lldb::SBTypeList &operator=(const lldb::SBTypeList &rhs);
+
+ bool IsValid();
+
+ void Append(lldb::SBType type);
+
+ lldb::SBType GetTypeAtIndex(uint32_t index);
+
+ uint32_t GetSize();
+
private:
- std::unique_ptr<lldb_private::TypeListImpl> m_opaque_ap;
- friend class SBModule;
- friend class SBCompileUnit;
+ std::unique_ptr<lldb_private::TypeListImpl> m_opaque_ap;
+ friend class SBModule;
+ friend class SBCompileUnit;
};
-
} // namespace lldb
diff --git a/include/lldb/API/SBTypeCategory.h b/include/lldb/API/SBTypeCategory.h
index 997b3fc2f98d..f44dfc451e44 100644
--- a/include/lldb/API/SBTypeCategory.h
+++ b/include/lldb/API/SBTypeCategory.h
@@ -1,4 +1,5 @@
-//===-- SBTypeCategory.h --------------------------------------------*- C++ -*-===//
+//===-- SBTypeCategory.h --------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -13,165 +14,120 @@
#include "lldb/API/SBDefines.h"
namespace lldb {
-
- class LLDB_API SBTypeCategory
- {
- public:
-
- SBTypeCategory();
-
- SBTypeCategory (const lldb::SBTypeCategory &rhs);
-
- ~SBTypeCategory ();
-
- bool
- IsValid() const;
-
- bool
- GetEnabled ();
-
- void
- SetEnabled (bool);
-
- const char*
- GetName();
-
- lldb::LanguageType
- GetLanguageAtIndex (uint32_t idx);
-
- uint32_t
- GetNumLanguages ();
-
- void
- AddLanguage (lldb::LanguageType language);
-
- bool
- GetDescription (lldb::SBStream &description,
- lldb::DescriptionLevel description_level);
-
- uint32_t
- GetNumFormats ();
-
- uint32_t
- GetNumSummaries ();
-
- uint32_t
- GetNumFilters ();
-
+
+class LLDB_API SBTypeCategory {
+public:
+ SBTypeCategory();
+
+ SBTypeCategory(const lldb::SBTypeCategory &rhs);
+
+ ~SBTypeCategory();
+
+ bool IsValid() const;
+
+ bool GetEnabled();
+
+ void SetEnabled(bool);
+
+ const char *GetName();
+
+ lldb::LanguageType GetLanguageAtIndex(uint32_t idx);
+
+ uint32_t GetNumLanguages();
+
+ void AddLanguage(lldb::LanguageType language);
+
+ bool GetDescription(lldb::SBStream &description,
+ lldb::DescriptionLevel description_level);
+
+ uint32_t GetNumFormats();
+
+ uint32_t GetNumSummaries();
+
+ uint32_t GetNumFilters();
+
#ifndef LLDB_DISABLE_PYTHON
- uint32_t
- GetNumSynthetics ();
+ uint32_t GetNumSynthetics();
#endif
-
- SBTypeNameSpecifier
- GetTypeNameSpecifierForFilterAtIndex (uint32_t);
-
- SBTypeNameSpecifier
- GetTypeNameSpecifierForFormatAtIndex (uint32_t);
-
- SBTypeNameSpecifier
- GetTypeNameSpecifierForSummaryAtIndex (uint32_t);
+
+ SBTypeNameSpecifier GetTypeNameSpecifierForFilterAtIndex(uint32_t);
+
+ SBTypeNameSpecifier GetTypeNameSpecifierForFormatAtIndex(uint32_t);
+
+ SBTypeNameSpecifier GetTypeNameSpecifierForSummaryAtIndex(uint32_t);
#ifndef LLDB_DISABLE_PYTHON
- SBTypeNameSpecifier
- GetTypeNameSpecifierForSyntheticAtIndex (uint32_t);
+ SBTypeNameSpecifier GetTypeNameSpecifierForSyntheticAtIndex(uint32_t);
#endif
-
- SBTypeFilter
- GetFilterForType (SBTypeNameSpecifier);
- SBTypeFormat
- GetFormatForType (SBTypeNameSpecifier);
-
+ SBTypeFilter GetFilterForType(SBTypeNameSpecifier);
+
+ SBTypeFormat GetFormatForType(SBTypeNameSpecifier);
+
#ifndef LLDB_DISABLE_PYTHON
- SBTypeSummary
- GetSummaryForType (SBTypeNameSpecifier);
+ SBTypeSummary GetSummaryForType(SBTypeNameSpecifier);
#endif
#ifndef LLDB_DISABLE_PYTHON
- SBTypeSynthetic
- GetSyntheticForType (SBTypeNameSpecifier);
+ SBTypeSynthetic GetSyntheticForType(SBTypeNameSpecifier);
#endif
-
+
#ifndef LLDB_DISABLE_PYTHON
- SBTypeFilter
- GetFilterAtIndex (uint32_t);
+ SBTypeFilter GetFilterAtIndex(uint32_t);
#endif
-
- SBTypeFormat
- GetFormatAtIndex (uint32_t);
-
+
+ SBTypeFormat GetFormatAtIndex(uint32_t);
+
#ifndef LLDB_DISABLE_PYTHON
- SBTypeSummary
- GetSummaryAtIndex (uint32_t);
+ SBTypeSummary GetSummaryAtIndex(uint32_t);
#endif
-
+
#ifndef LLDB_DISABLE_PYTHON
- SBTypeSynthetic
- GetSyntheticAtIndex (uint32_t);
+ SBTypeSynthetic GetSyntheticAtIndex(uint32_t);
#endif
-
- bool
- AddTypeFormat (SBTypeNameSpecifier,
- SBTypeFormat);
-
- bool
- DeleteTypeFormat (SBTypeNameSpecifier);
-
+
+ bool AddTypeFormat(SBTypeNameSpecifier, SBTypeFormat);
+
+ bool DeleteTypeFormat(SBTypeNameSpecifier);
+
#ifndef LLDB_DISABLE_PYTHON
- bool
- AddTypeSummary (SBTypeNameSpecifier,
- SBTypeSummary);
+ bool AddTypeSummary(SBTypeNameSpecifier, SBTypeSummary);
#endif
-
- bool
- DeleteTypeSummary (SBTypeNameSpecifier);
-
- bool
- AddTypeFilter (SBTypeNameSpecifier,
- SBTypeFilter);
-
- bool
- DeleteTypeFilter (SBTypeNameSpecifier);
-
+
+ bool DeleteTypeSummary(SBTypeNameSpecifier);
+
+ bool AddTypeFilter(SBTypeNameSpecifier, SBTypeFilter);
+
+ bool DeleteTypeFilter(SBTypeNameSpecifier);
+
#ifndef LLDB_DISABLE_PYTHON
- bool
- AddTypeSynthetic (SBTypeNameSpecifier,
- SBTypeSynthetic);
-
- bool
- DeleteTypeSynthetic (SBTypeNameSpecifier);
+ bool AddTypeSynthetic(SBTypeNameSpecifier, SBTypeSynthetic);
+
+ bool DeleteTypeSynthetic(SBTypeNameSpecifier);
#endif
-
- lldb::SBTypeCategory &
- operator = (const lldb::SBTypeCategory &rhs);
-
- bool
- operator == (lldb::SBTypeCategory &rhs);
-
- bool
- operator != (lldb::SBTypeCategory &rhs);
-
- protected:
- friend class SBDebugger;
-
- lldb::TypeCategoryImplSP
- GetSP ();
-
- void
- SetSP (const lldb::TypeCategoryImplSP &typecategory_impl_sp);
-
- TypeCategoryImplSP m_opaque_sp;
-
- SBTypeCategory (const lldb::TypeCategoryImplSP &);
-
- SBTypeCategory (const char*);
-
- bool
- IsDefaultCategory();
-
- };
-
+
+ lldb::SBTypeCategory &operator=(const lldb::SBTypeCategory &rhs);
+
+ bool operator==(lldb::SBTypeCategory &rhs);
+
+ bool operator!=(lldb::SBTypeCategory &rhs);
+
+protected:
+ friend class SBDebugger;
+
+ lldb::TypeCategoryImplSP GetSP();
+
+ void SetSP(const lldb::TypeCategoryImplSP &typecategory_impl_sp);
+
+ TypeCategoryImplSP m_opaque_sp;
+
+ SBTypeCategory(const lldb::TypeCategoryImplSP &);
+
+ SBTypeCategory(const char *);
+
+ bool IsDefaultCategory();
+};
+
} // namespace lldb
#endif // LLDB_SBTypeCategory_h_
diff --git a/include/lldb/API/SBTypeEnumMember.h b/include/lldb/API/SBTypeEnumMember.h
index b141ba0a6bb0..f45c234d2c77 100644
--- a/include/lldb/API/SBTypeEnumMember.h
+++ b/include/lldb/API/SBTypeEnumMember.h
@@ -15,82 +15,64 @@
namespace lldb {
-class LLDB_API SBTypeEnumMember
-{
+class LLDB_API SBTypeEnumMember {
public:
- SBTypeEnumMember ();
+ SBTypeEnumMember();
- SBTypeEnumMember (const SBTypeEnumMember& rhs);
+ SBTypeEnumMember(const SBTypeEnumMember &rhs);
- ~SBTypeEnumMember();
+ ~SBTypeEnumMember();
- SBTypeEnumMember&
- operator = (const SBTypeEnumMember& rhs);
+ SBTypeEnumMember &operator=(const SBTypeEnumMember &rhs);
- bool
- IsValid() const;
+ bool IsValid() const;
- int64_t
- GetValueAsSigned();
+ int64_t GetValueAsSigned();
- uint64_t
- GetValueAsUnsigned();
+ uint64_t GetValueAsUnsigned();
- const char *
- GetName ();
+ const char *GetName();
- lldb::SBType
- GetType ();
+ lldb::SBType GetType();
- bool
- GetDescription (lldb::SBStream &description,
- lldb::DescriptionLevel description_level);
+ bool GetDescription(lldb::SBStream &description,
+ lldb::DescriptionLevel description_level);
protected:
- friend class SBType;
- friend class SBTypeEnumMemberList;
+ friend class SBType;
+ friend class SBTypeEnumMemberList;
- void
- reset (lldb_private::TypeEnumMemberImpl *);
+ void reset(lldb_private::TypeEnumMemberImpl *);
- lldb_private::TypeEnumMemberImpl &
- ref ();
+ lldb_private::TypeEnumMemberImpl &ref();
- const lldb_private::TypeEnumMemberImpl &
- ref () const;
+ const lldb_private::TypeEnumMemberImpl &ref() const;
- lldb::TypeEnumMemberImplSP m_opaque_sp;
+ lldb::TypeEnumMemberImplSP m_opaque_sp;
- SBTypeEnumMember (const lldb::TypeEnumMemberImplSP &);
+ SBTypeEnumMember(const lldb::TypeEnumMemberImplSP &);
};
-class SBTypeEnumMemberList
-{
+class SBTypeEnumMemberList {
public:
- SBTypeEnumMemberList();
+ SBTypeEnumMemberList();
- SBTypeEnumMemberList(const SBTypeEnumMemberList& rhs);
+ SBTypeEnumMemberList(const SBTypeEnumMemberList &rhs);
- ~SBTypeEnumMemberList();
+ ~SBTypeEnumMemberList();
- SBTypeEnumMemberList&
- operator = (const SBTypeEnumMemberList& rhs);
+ SBTypeEnumMemberList &operator=(const SBTypeEnumMemberList &rhs);
- bool
- IsValid();
+ bool IsValid();
- void
- Append (SBTypeEnumMember entry);
+ void Append(SBTypeEnumMember entry);
- SBTypeEnumMember
- GetTypeEnumMemberAtIndex (uint32_t index);
-
- uint32_t
- GetSize();
+ SBTypeEnumMember GetTypeEnumMemberAtIndex(uint32_t index);
+ uint32_t GetSize();
private:
- std::unique_ptr<lldb_private::TypeEnumMemberListImpl> m_opaque_ap;
+ std::unique_ptr<lldb_private::TypeEnumMemberListImpl> m_opaque_ap;
};
} // namespace lldb
diff --git a/include/lldb/API/SBTypeFilter.h b/include/lldb/API/SBTypeFilter.h
index f030b6a99b60..19888ba7cfb6 100644
--- a/include/lldb/API/SBTypeFilter.h
+++ b/include/lldb/API/SBTypeFilter.h
@@ -1,4 +1,5 @@
-//===-- SBTypeFilter.h --------------------------------------------*- C++ -*-===//
+//===-- SBTypeFilter.h --------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -13,80 +14,60 @@
#include "lldb/API/SBDefines.h"
namespace lldb {
-
- class LLDB_API SBTypeFilter
- {
- public:
-
- SBTypeFilter();
-
- SBTypeFilter (uint32_t options); // see lldb::eTypeOption values
-
- SBTypeFilter (const lldb::SBTypeFilter &rhs);
-
- ~SBTypeFilter ();
-
- bool
- IsValid() const;
-
- uint32_t
- GetNumberOfExpressionPaths ();
-
- const char*
- GetExpressionPathAtIndex (uint32_t i);
-
- bool
- ReplaceExpressionPathAtIndex (uint32_t i, const char* item);
-
- void
- AppendExpressionPath (const char* item);
-
- void
- Clear();
-
- uint32_t
- GetOptions();
-
- void
- SetOptions (uint32_t);
-
- bool
- GetDescription (lldb::SBStream &description,
- lldb::DescriptionLevel description_level);
-
- lldb::SBTypeFilter &
- operator = (const lldb::SBTypeFilter &rhs);
-
- bool
- IsEqualTo (lldb::SBTypeFilter &rhs);
-
- bool
- operator == (lldb::SBTypeFilter &rhs);
-
- bool
- operator != (lldb::SBTypeFilter &rhs);
-
- protected:
- friend class SBDebugger;
- friend class SBTypeCategory;
- friend class SBValue;
-
- lldb::TypeFilterImplSP
- GetSP ();
-
- void
- SetSP (const lldb::TypeFilterImplSP &typefilter_impl_sp);
-
- lldb::TypeFilterImplSP m_opaque_sp;
-
- SBTypeFilter (const lldb::TypeFilterImplSP &);
-
- bool
- CopyOnWrite_Impl();
-
- };
-
-
+
+class LLDB_API SBTypeFilter {
+public:
+ SBTypeFilter();
+
+ SBTypeFilter(uint32_t options); // see lldb::eTypeOption values
+
+ SBTypeFilter(const lldb::SBTypeFilter &rhs);
+
+ ~SBTypeFilter();
+
+ bool IsValid() const;
+
+ uint32_t GetNumberOfExpressionPaths();
+
+ const char *GetExpressionPathAtIndex(uint32_t i);
+
+ bool ReplaceExpressionPathAtIndex(uint32_t i, const char *item);
+
+ void AppendExpressionPath(const char *item);
+
+ void Clear();
+
+ uint32_t GetOptions();
+
+ void SetOptions(uint32_t);
+
+ bool GetDescription(lldb::SBStream &description,
+ lldb::DescriptionLevel description_level);
+
+ lldb::SBTypeFilter &operator=(const lldb::SBTypeFilter &rhs);
+
+ bool IsEqualTo(lldb::SBTypeFilter &rhs);
+
+ bool operator==(lldb::SBTypeFilter &rhs);
+
+ bool operator!=(lldb::SBTypeFilter &rhs);
+
+protected:
+ friend class SBDebugger;
+ friend class SBTypeCategory;
+ friend class SBValue;
+
+ lldb::TypeFilterImplSP GetSP();
+
+ void SetSP(const lldb::TypeFilterImplSP &typefilter_impl_sp);
+
+ lldb::TypeFilterImplSP m_opaque_sp;
+
+ SBTypeFilter(const lldb::TypeFilterImplSP &);
+
+ bool CopyOnWrite_Impl();
+};
+
} // namespace lldb
#endif // LLDB_SBTypeFilter_h_
diff --git a/include/lldb/API/SBTypeFormat.h b/include/lldb/API/SBTypeFormat.h
index c24641ac15f5..d0429e97ff9c 100644
--- a/include/lldb/API/SBTypeFormat.h
+++ b/include/lldb/API/SBTypeFormat.h
@@ -1,4 +1,5 @@
-//===-- SBTypeFormat.h --------------------------------------------*- C++ -*-===//
+//===-- SBTypeFormat.h --------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,87 +15,63 @@
namespace lldb {
-class LLDB_API SBTypeFormat
-{
+class LLDB_API SBTypeFormat {
public:
-
- SBTypeFormat();
-
- SBTypeFormat (lldb::Format format,
- uint32_t options = 0); // see lldb::eTypeOption values
-
- SBTypeFormat (const char* type,
- uint32_t options = 0); // see lldb::eTypeOption values
-
- SBTypeFormat (const lldb::SBTypeFormat &rhs);
-
- ~SBTypeFormat ();
-
- bool
- IsValid() const;
-
- lldb::Format
- GetFormat ();
-
- const char*
- GetTypeName ();
-
- uint32_t
- GetOptions();
-
- void
- SetFormat (lldb::Format);
-
- void
- SetTypeName (const char*);
-
- void
- SetOptions (uint32_t);
-
- bool
- GetDescription (lldb::SBStream &description,
- lldb::DescriptionLevel description_level);
-
- lldb::SBTypeFormat &
- operator = (const lldb::SBTypeFormat &rhs);
-
- bool
- IsEqualTo (lldb::SBTypeFormat &rhs);
-
- bool
- operator == (lldb::SBTypeFormat &rhs);
-
- bool
- operator != (lldb::SBTypeFormat &rhs);
-
+ SBTypeFormat();
+
+ SBTypeFormat(lldb::Format format,
+ uint32_t options = 0); // see lldb::eTypeOption values
+
+ SBTypeFormat(const char *type,
+ uint32_t options = 0); // see lldb::eTypeOption values
+
+ SBTypeFormat(const lldb::SBTypeFormat &rhs);
+
+ ~SBTypeFormat();
+
+ bool IsValid() const;
+
+ lldb::Format GetFormat();
+
+ const char *GetTypeName();
+
+ uint32_t GetOptions();
+
+ void SetFormat(lldb::Format);
+
+ void SetTypeName(const char *);
+
+ void SetOptions(uint32_t);
+
+ bool GetDescription(lldb::SBStream &description,
+ lldb::DescriptionLevel description_level);
+
+ lldb::SBTypeFormat &operator=(const lldb::SBTypeFormat &rhs);
+
+ bool IsEqualTo(lldb::SBTypeFormat &rhs);
+
+ bool operator==(lldb::SBTypeFormat &rhs);
+
+ bool operator!=(lldb::SBTypeFormat &rhs);
+
protected:
- friend class SBDebugger;
- friend class SBTypeCategory;
- friend class SBValue;
-
- lldb::TypeFormatImplSP
- GetSP ();
-
- void
- SetSP (const lldb::TypeFormatImplSP &typeformat_impl_sp);
-
- lldb::TypeFormatImplSP m_opaque_sp;
-
- SBTypeFormat (const lldb::TypeFormatImplSP &);
-
- enum class Type
- {
- eTypeKeepSame,
- eTypeFormat,
- eTypeEnum
- };
-
- bool
- CopyOnWrite_Impl(Type);
-
+ friend class SBDebugger;
+ friend class SBTypeCategory;
+ friend class SBValue;
+
+ lldb::TypeFormatImplSP GetSP();
+
+ void SetSP(const lldb::TypeFormatImplSP &typeformat_impl_sp);
+
+ lldb::TypeFormatImplSP m_opaque_sp;
+
+ SBTypeFormat(const lldb::TypeFormatImplSP &);
+
+ enum class Type { eTypeKeepSame, eTypeFormat, eTypeEnum };
+
+ bool CopyOnWrite_Impl(Type);
};
-
} // namespace lldb
#endif // LLDB_SBTypeFormat_h_
diff --git a/include/lldb/API/SBTypeNameSpecifier.h b/include/lldb/API/SBTypeNameSpecifier.h
index 71700a7123d5..2a4f09c2068b 100644
--- a/include/lldb/API/SBTypeNameSpecifier.h
+++ b/include/lldb/API/SBTypeNameSpecifier.h
@@ -1,4 +1,5 @@
-//===-- SBTypeNameSpecifier.h --------------------------------------*- C++ -*-===//
+//===-- SBTypeNameSpecifier.h --------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -13,65 +14,51 @@
#include "lldb/API/SBDefines.h"
namespace lldb {
-
- class LLDB_API SBTypeNameSpecifier
- {
- public:
-
- SBTypeNameSpecifier();
-
- SBTypeNameSpecifier (const char* name,
- bool is_regex = false);
-
- SBTypeNameSpecifier (SBType type);
-
- SBTypeNameSpecifier (const lldb::SBTypeNameSpecifier &rhs);
-
- ~SBTypeNameSpecifier ();
-
- bool
- IsValid() const;
-
- const char*
- GetName();
-
- SBType
- GetType ();
-
- bool
- IsRegex();
-
- bool
- GetDescription (lldb::SBStream &description,
- lldb::DescriptionLevel description_level);
-
- lldb::SBTypeNameSpecifier &
- operator = (const lldb::SBTypeNameSpecifier &rhs);
-
- bool
- IsEqualTo (lldb::SBTypeNameSpecifier &rhs);
-
- bool
- operator == (lldb::SBTypeNameSpecifier &rhs);
-
- bool
- operator != (lldb::SBTypeNameSpecifier &rhs);
-
- protected:
- friend class SBDebugger;
- friend class SBTypeCategory;
-
- lldb::TypeNameSpecifierImplSP
- GetSP ();
-
- void
- SetSP (const lldb::TypeNameSpecifierImplSP &type_namespec_sp);
-
- lldb::TypeNameSpecifierImplSP m_opaque_sp;
-
- SBTypeNameSpecifier (const lldb::TypeNameSpecifierImplSP &);
- };
-
+
+class LLDB_API SBTypeNameSpecifier {
+public:
+ SBTypeNameSpecifier();
+
+ SBTypeNameSpecifier(const char *name, bool is_regex = false);
+
+ SBTypeNameSpecifier(SBType type);
+
+ SBTypeNameSpecifier(const lldb::SBTypeNameSpecifier &rhs);
+
+ ~SBTypeNameSpecifier();
+
+ bool IsValid() const;
+
+ const char *GetName();
+
+ SBType GetType();
+
+ bool IsRegex();
+
+ bool GetDescription(lldb::SBStream &description,
+ lldb::DescriptionLevel description_level);
+
+ lldb::SBTypeNameSpecifier &operator=(const lldb::SBTypeNameSpecifier &rhs);
+
+ bool IsEqualTo(lldb::SBTypeNameSpecifier &rhs);
+
+ bool operator==(lldb::SBTypeNameSpecifier &rhs);
+
+ bool operator!=(lldb::SBTypeNameSpecifier &rhs);
+
+protected:
+ friend class SBDebugger;
+ friend class SBTypeCategory;
+
+ lldb::TypeNameSpecifierImplSP GetSP();
+
+ void SetSP(const lldb::TypeNameSpecifierImplSP &type_namespec_sp);
+
+ lldb::TypeNameSpecifierImplSP m_opaque_sp;
+
+ SBTypeNameSpecifier(const lldb::TypeNameSpecifierImplSP &);
+};
+
} // namespace lldb
#endif // LLDB_SBTypeNameSpecifier_h_
diff --git a/include/lldb/API/SBTypeSummary.h b/include/lldb/API/SBTypeSummary.h
index f4c666180085..c9ccdff834ce 100644
--- a/include/lldb/API/SBTypeSummary.h
+++ b/include/lldb/API/SBTypeSummary.h
@@ -1,4 +1,5 @@
-//===-- SBTypeSummary.h -------------------------------------------*- C++ -*-===//
+//===-- SBTypeSummary.h -------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -13,160 +14,123 @@
#include "lldb/API/SBDefines.h"
namespace lldb {
- class LLDB_API SBTypeSummaryOptions
- {
- public:
- SBTypeSummaryOptions();
-
- SBTypeSummaryOptions (const lldb::SBTypeSummaryOptions &rhs);
-
- SBTypeSummaryOptions (const lldb_private::TypeSummaryOptions *lldb_object_ptr);
-
- ~SBTypeSummaryOptions ();
-
- bool
- IsValid ();
-
- lldb::LanguageType
- GetLanguage ();
-
- lldb::TypeSummaryCapping
- GetCapping ();
-
- void
- SetLanguage (lldb::LanguageType);
-
- void
- SetCapping (lldb::TypeSummaryCapping);
-
- protected:
- friend class SBValue;
-
- lldb_private::TypeSummaryOptions *
- operator->();
-
- const lldb_private::TypeSummaryOptions *
- operator->() const;
-
- lldb_private::TypeSummaryOptions *
- get ();
-
- lldb_private::TypeSummaryOptions &
- ref();
-
- const lldb_private::TypeSummaryOptions &
- ref() const;
-
- void
- SetOptions (const lldb_private::TypeSummaryOptions *lldb_object_ptr);
-
- private:
- std::unique_ptr<lldb_private::TypeSummaryOptions> m_opaque_ap;
- };
-
- class SBTypeSummary
- {
- public:
-
- SBTypeSummary();
-
- // Native function summary formatter callback
- typedef bool (*FormatCallback) (SBValue, SBTypeSummaryOptions, SBStream&);
-
- static SBTypeSummary
- CreateWithSummaryString (const char* data,
- uint32_t options = 0); // see lldb::eTypeOption values
-
- static SBTypeSummary
- CreateWithFunctionName (const char* data,
- uint32_t options = 0); // see lldb::eTypeOption values
-
- static SBTypeSummary
- CreateWithScriptCode (const char* data,
- uint32_t options = 0); // see lldb::eTypeOption values
-
- static SBTypeSummary
- CreateWithCallback (FormatCallback cb,
- uint32_t options = 0,
- const char* description = nullptr);
-
- SBTypeSummary (const lldb::SBTypeSummary &rhs);
-
- ~SBTypeSummary ();
-
- bool
- IsValid() const;
-
- bool
- IsFunctionCode();
-
- bool
- IsFunctionName();
-
- bool
- IsSummaryString();
-
- const char*
- GetData ();
-
- void
- SetSummaryString (const char* data);
-
- void
- SetFunctionName (const char* data);
-
- void
- SetFunctionCode (const char* data);
-
- uint32_t
- GetOptions ();
-
- void
- SetOptions (uint32_t);
-
- bool
- GetDescription (lldb::SBStream &description,
- lldb::DescriptionLevel description_level);
-
- lldb::SBTypeSummary &
- operator = (const lldb::SBTypeSummary &rhs);
-
- bool
- DoesPrintValue (lldb::SBValue value);
-
- bool
- IsEqualTo (lldb::SBTypeSummary &rhs);
-
- bool
- operator == (lldb::SBTypeSummary &rhs);
-
- bool
- operator != (lldb::SBTypeSummary &rhs);
-
- protected:
- friend class SBDebugger;
- friend class SBTypeCategory;
- friend class SBValue;
-
- lldb::TypeSummaryImplSP
- GetSP ();
-
- void
- SetSP (const lldb::TypeSummaryImplSP &typefilter_impl_sp);
-
- lldb::TypeSummaryImplSP m_opaque_sp;
-
- SBTypeSummary (const lldb::TypeSummaryImplSP &);
-
- bool
- CopyOnWrite_Impl();
-
- bool
- ChangeSummaryType (bool want_script);
-
- };
-
-
+class LLDB_API SBTypeSummaryOptions {
+public:
+ SBTypeSummaryOptions();
+
+ SBTypeSummaryOptions(const lldb::SBTypeSummaryOptions &rhs);
+
+ SBTypeSummaryOptions(const lldb_private::TypeSummaryOptions *lldb_object_ptr);
+
+ ~SBTypeSummaryOptions();
+
+ bool IsValid();
+
+ lldb::LanguageType GetLanguage();
+
+ lldb::TypeSummaryCapping GetCapping();
+
+ void SetLanguage(lldb::LanguageType);
+
+ void SetCapping(lldb::TypeSummaryCapping);
+
+protected:
+ friend class SBValue;
+
+ lldb_private::TypeSummaryOptions *operator->();
+
+ const lldb_private::TypeSummaryOptions *operator->() const;
+
+ lldb_private::TypeSummaryOptions *get();
+
+ lldb_private::TypeSummaryOptions &ref();
+
+ const lldb_private::TypeSummaryOptions &ref() const;
+
+ void SetOptions(const lldb_private::TypeSummaryOptions *lldb_object_ptr);
+
+private:
+ std::unique_ptr<lldb_private::TypeSummaryOptions> m_opaque_ap;
+};
+
+class SBTypeSummary {
+public:
+ SBTypeSummary();
+
+ // Native function summary formatter callback
+ typedef bool (*FormatCallback)(SBValue, SBTypeSummaryOptions, SBStream &);
+
+ static SBTypeSummary
+ CreateWithSummaryString(const char *data,
+ uint32_t options = 0); // see lldb::eTypeOption values
+
+ static SBTypeSummary
+ CreateWithFunctionName(const char *data,
+ uint32_t options = 0); // see lldb::eTypeOption values
+
+ static SBTypeSummary
+ CreateWithScriptCode(const char *data,
+ uint32_t options = 0); // see lldb::eTypeOption values
+
+ static SBTypeSummary CreateWithCallback(FormatCallback cb,
+ uint32_t options = 0,
+ const char *description = nullptr);
+
+ SBTypeSummary(const lldb::SBTypeSummary &rhs);
+
+ ~SBTypeSummary();
+
+ bool IsValid() const;
+
+ bool IsFunctionCode();
+
+ bool IsFunctionName();
+
+ bool IsSummaryString();
+
+ const char *GetData();
+
+ void SetSummaryString(const char *data);
+
+ void SetFunctionName(const char *data);
+
+ void SetFunctionCode(const char *data);
+
+ uint32_t GetOptions();
+
+ void SetOptions(uint32_t);
+
+ bool GetDescription(lldb::SBStream &description,
+ lldb::DescriptionLevel description_level);
+
+ lldb::SBTypeSummary &operator=(const lldb::SBTypeSummary &rhs);
+
+ bool DoesPrintValue(lldb::SBValue value);
+
+ bool IsEqualTo(lldb::SBTypeSummary &rhs);
+
+ bool operator==(lldb::SBTypeSummary &rhs);
+
+ bool operator!=(lldb::SBTypeSummary &rhs);
+
+protected:
+ friend class SBDebugger;
+ friend class SBTypeCategory;
+ friend class SBValue;
+
+ lldb::TypeSummaryImplSP GetSP();
+
+ void SetSP(const lldb::TypeSummaryImplSP &typefilter_impl_sp);
+
+ lldb::TypeSummaryImplSP m_opaque_sp;
+
+ SBTypeSummary(const lldb::TypeSummaryImplSP &);
+
+ bool CopyOnWrite_Impl();
+
+ bool ChangeSummaryType(bool want_script);
+};
+
} // namespace lldb
#endif // LLDB_SBTypeSummary_h_
diff --git a/include/lldb/API/SBTypeSynthetic.h b/include/lldb/API/SBTypeSynthetic.h
index 5dd11757ba40..2099df316194 100644
--- a/include/lldb/API/SBTypeSynthetic.h
+++ b/include/lldb/API/SBTypeSynthetic.h
@@ -1,4 +1,5 @@
-//===-- SBTypeSynthetic.h -----------------------------------------*- C++ -*-===//
+//===-- SBTypeSynthetic.h -----------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -15,86 +16,66 @@
#ifndef LLDB_DISABLE_PYTHON
namespace lldb {
-
- class LLDB_API SBTypeSynthetic
- {
- public:
-
- SBTypeSynthetic();
-
- static SBTypeSynthetic
- CreateWithClassName (const char* data,
- uint32_t options = 0); // see lldb::eTypeOption values
-
- static SBTypeSynthetic
- CreateWithScriptCode (const char* data,
- uint32_t options = 0); // see lldb::eTypeOption values
-
- SBTypeSynthetic (const lldb::SBTypeSynthetic &rhs);
-
- ~SBTypeSynthetic ();
-
- bool
- IsValid() const;
-
- bool
- IsClassCode();
-
- bool
- IsClassName();
-
- const char*
- GetData ();
-
- void
- SetClassName (const char* data);
-
- void
- SetClassCode (const char* data);
-
- uint32_t
- GetOptions ();
-
- void
- SetOptions (uint32_t);
-
- bool
- GetDescription (lldb::SBStream &description,
- lldb::DescriptionLevel description_level);
-
- lldb::SBTypeSynthetic &
- operator = (const lldb::SBTypeSynthetic &rhs);
-
- bool
- IsEqualTo (lldb::SBTypeSynthetic &rhs);
-
- bool
- operator == (lldb::SBTypeSynthetic &rhs);
-
- bool
- operator != (lldb::SBTypeSynthetic &rhs);
-
- protected:
- friend class SBDebugger;
- friend class SBTypeCategory;
- friend class SBValue;
-
- lldb::ScriptedSyntheticChildrenSP
- GetSP ();
-
- void
- SetSP (const lldb::ScriptedSyntheticChildrenSP &typefilter_impl_sp);
-
- lldb::ScriptedSyntheticChildrenSP m_opaque_sp;
-
- SBTypeSynthetic (const lldb::ScriptedSyntheticChildrenSP &);
-
- bool
- CopyOnWrite_Impl();
-
- };
-
-
+
+class LLDB_API SBTypeSynthetic {
+public:
+ SBTypeSynthetic();
+
+ static SBTypeSynthetic
+ CreateWithClassName(const char *data,
+ uint32_t options = 0); // see lldb::eTypeOption values
+
+ static SBTypeSynthetic
+ CreateWithScriptCode(const char *data,
+ uint32_t options = 0); // see lldb::eTypeOption values
+
+ SBTypeSynthetic(const lldb::SBTypeSynthetic &rhs);
+
+ ~SBTypeSynthetic();
+
+ bool IsValid() const;
+
+ bool IsClassCode();
+
+ bool IsClassName();
+
+ const char *GetData();
+
+ void SetClassName(const char *data);
+
+ void SetClassCode(const char *data);
+
+ uint32_t GetOptions();
+
+ void SetOptions(uint32_t);
+
+ bool GetDescription(lldb::SBStream &description,
+ lldb::DescriptionLevel description_level);
+
+ lldb::SBTypeSynthetic &operator=(const lldb::SBTypeSynthetic &rhs);
+
+ bool IsEqualTo(lldb::SBTypeSynthetic &rhs);
+
+ bool operator==(lldb::SBTypeSynthetic &rhs);
+
+ bool operator!=(lldb::SBTypeSynthetic &rhs);
+
+protected:
+ friend class SBDebugger;
+ friend class SBTypeCategory;
+ friend class SBValue;
+
+ lldb::ScriptedSyntheticChildrenSP GetSP();
+
+ void SetSP(const lldb::ScriptedSyntheticChildrenSP &typefilter_impl_sp);
+
+ lldb::ScriptedSyntheticChildrenSP m_opaque_sp;
+
+ SBTypeSynthetic(const lldb::ScriptedSyntheticChildrenSP &);
+
+ bool CopyOnWrite_Impl();
+};
+
} // namespace lldb
#endif // LLDB_DISABLE_PYTHON
diff --git a/include/lldb/API/SBUnixSignals.h b/include/lldb/API/SBUnixSignals.h
index ae48b63e1a2f..d44a508fbb42 100644
--- a/include/lldb/API/SBUnixSignals.h
+++ b/include/lldb/API/SBUnixSignals.h
@@ -1,4 +1,5 @@
-//===-- SBUnixSignals.h -----------------------------------------------*- C++ -*-===//
+//===-- SBUnixSignals.h -----------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,72 +17,54 @@ namespace lldb {
class LLDB_API SBUnixSignals {
public:
- SBUnixSignals ();
+ SBUnixSignals();
- SBUnixSignals (const lldb::SBUnixSignals &rhs);
+ SBUnixSignals(const lldb::SBUnixSignals &rhs);
- ~SBUnixSignals();
+ ~SBUnixSignals();
- const SBUnixSignals &
- operator =(const lldb::SBUnixSignals &rhs);
+ const SBUnixSignals &operator=(const lldb::SBUnixSignals &rhs);
- void
- Clear ();
+ void Clear();
- bool
- IsValid () const;
+ bool IsValid() const;
- const char *
- GetSignalAsCString (int32_t signo) const;
+ const char *GetSignalAsCString(int32_t signo) const;
- int32_t
- GetSignalNumberFromName (const char *name) const;
+ int32_t GetSignalNumberFromName(const char *name) const;
- bool
- GetShouldSuppress (int32_t signo) const;
+ bool GetShouldSuppress(int32_t signo) const;
- bool
- SetShouldSuppress (int32_t signo,
- bool value);
+ bool SetShouldSuppress(int32_t signo, bool value);
- bool
- GetShouldStop (int32_t signo) const;
+ bool GetShouldStop(int32_t signo) const;
- bool
- SetShouldStop (int32_t signo,
- bool value);
+ bool SetShouldStop(int32_t signo, bool value);
- bool
- GetShouldNotify (int32_t signo) const;
+ bool GetShouldNotify(int32_t signo) const;
- bool
- SetShouldNotify (int32_t signo, bool value);
+ bool SetShouldNotify(int32_t signo, bool value);
- int32_t
- GetNumSignals () const;
+ int32_t GetNumSignals() const;
- int32_t
- GetSignalAtIndex (int32_t index) const;
+ int32_t GetSignalAtIndex(int32_t index) const;
protected:
- friend class SBProcess;
- friend class SBPlatform;
+ friend class SBProcess;
+ friend class SBPlatform;
- SBUnixSignals(lldb::ProcessSP &process_sp);
+ SBUnixSignals(lldb::ProcessSP &process_sp);
- SBUnixSignals(lldb::PlatformSP &platform_sp);
+ SBUnixSignals(lldb::PlatformSP &platform_sp);
- lldb::UnixSignalsSP
- GetSP() const;
+ lldb::UnixSignalsSP GetSP() const;
- void
- SetSP(const lldb::UnixSignalsSP &signals_sp);
+ void SetSP(const lldb::UnixSignalsSP &signals_sp);
private:
- lldb::UnixSignalsWP m_opaque_wp;
+ lldb::UnixSignalsWP m_opaque_wp;
};
-
} // namespace lldb
#endif // LLDB_SBUnixSignals_h_
diff --git a/include/lldb/API/SBValue.h b/include/lldb/API/SBValue.h
index b9f1e6f5c93f..5ef8915b58f9 100644
--- a/include/lldb/API/SBValue.h
+++ b/include/lldb/API/SBValue.h
@@ -19,498 +19,428 @@ class ValueLocker;
namespace lldb {
-class LLDB_API SBValue
-{
+class LLDB_API SBValue {
public:
- SBValue ();
-
- SBValue (const lldb::SBValue &rhs);
-
- lldb::SBValue &
- operator =(const lldb::SBValue &rhs);
-
- ~SBValue ();
-
- bool
- IsValid();
-
- void
- Clear();
-
- SBError
- GetError();
-
- lldb::user_id_t
- GetID ();
-
- const char *
- GetName();
-
- const char *
- GetTypeName ();
-
- const char *
- GetDisplayTypeName ();
-
- size_t
- GetByteSize ();
-
- bool
- IsInScope ();
-
- lldb::Format
- GetFormat ();
-
- void
- SetFormat (lldb::Format format);
-
- const char *
- GetValue ();
-
- int64_t
- GetValueAsSigned (lldb::SBError& error, int64_t fail_value=0);
-
- uint64_t
- GetValueAsUnsigned (lldb::SBError& error, uint64_t fail_value=0);
-
- int64_t
- GetValueAsSigned(int64_t fail_value=0);
-
- uint64_t
- GetValueAsUnsigned(uint64_t fail_value=0);
-
- ValueType
- GetValueType ();
-
- // If you call this on a newly created ValueObject, it will always return false.
- bool
- GetValueDidChange ();
-
- const char *
- GetSummary ();
-
- const char *
- GetSummary (lldb::SBStream& stream,
- lldb::SBTypeSummaryOptions& options);
-
- const char *
- GetObjectDescription ();
-
- const char *
- GetTypeValidatorResult ();
-
- lldb::SBValue
- GetDynamicValue (lldb::DynamicValueType use_dynamic);
-
- lldb::SBValue
- GetStaticValue ();
-
- lldb::SBValue
- GetNonSyntheticValue ();
-
- lldb::DynamicValueType
- GetPreferDynamicValue ();
-
- void
- SetPreferDynamicValue (lldb::DynamicValueType use_dynamic);
-
- bool
- GetPreferSyntheticValue ();
-
- void
- SetPreferSyntheticValue (bool use_synthetic);
-
- bool
- IsDynamic ();
-
- bool
- IsSynthetic ();
-
- bool
- IsSyntheticChildrenGenerated ();
-
- void
- SetSyntheticChildrenGenerated (bool);
-
- const char *
- GetLocation ();
-
- // Deprecated - use the one that takes SBError&
- bool
- SetValueFromCString (const char *value_str);
-
- bool
- SetValueFromCString (const char *value_str, lldb::SBError& error);
-
- lldb::SBTypeFormat
- GetTypeFormat ();
-
- lldb::SBTypeSummary
- GetTypeSummary ();
-
- lldb::SBTypeFilter
- GetTypeFilter ();
-
+ SBValue();
+
+ SBValue(const lldb::SBValue &rhs);
+
+ lldb::SBValue &operator=(const lldb::SBValue &rhs);
+
+ ~SBValue();
+
+ bool IsValid();
+
+ void Clear();
+
+ SBError GetError();
+
+ lldb::user_id_t GetID();
+
+ const char *GetName();
+
+ const char *GetTypeName();
+
+ const char *GetDisplayTypeName();
+
+ size_t GetByteSize();
+
+ bool IsInScope();
+
+ lldb::Format GetFormat();
+
+ void SetFormat(lldb::Format format);
+
+ const char *GetValue();
+
+ int64_t GetValueAsSigned(lldb::SBError &error, int64_t fail_value = 0);
+
+ uint64_t GetValueAsUnsigned(lldb::SBError &error, uint64_t fail_value = 0);
+
+ int64_t GetValueAsSigned(int64_t fail_value = 0);
+
+ uint64_t GetValueAsUnsigned(uint64_t fail_value = 0);
+
+ ValueType GetValueType();
+
+ // If you call this on a newly created ValueObject, it will always return
+ // false.
+ bool GetValueDidChange();
+
+ const char *GetSummary();
+
+ const char *GetSummary(lldb::SBStream &stream,
+ lldb::SBTypeSummaryOptions &options);
+
+ const char *GetObjectDescription();
+
+ const char *GetTypeValidatorResult();
+
+ lldb::SBValue GetDynamicValue(lldb::DynamicValueType use_dynamic);
+
+ lldb::SBValue GetStaticValue();
+
+ lldb::SBValue GetNonSyntheticValue();
+
+ lldb::DynamicValueType GetPreferDynamicValue();
+
+ void SetPreferDynamicValue(lldb::DynamicValueType use_dynamic);
+
+ bool GetPreferSyntheticValue();
+
+ void SetPreferSyntheticValue(bool use_synthetic);
+
+ bool IsDynamic();
+
+ bool IsSynthetic();
+
+ bool IsSyntheticChildrenGenerated();
+
+ void SetSyntheticChildrenGenerated(bool);
+
+ const char *GetLocation();
+
+ // Deprecated - use the one that takes SBError&
+ bool SetValueFromCString(const char *value_str);
+
+ bool SetValueFromCString(const char *value_str, lldb::SBError &error);
+
+ lldb::SBTypeFormat GetTypeFormat();
+
+ lldb::SBTypeSummary GetTypeSummary();
+
+ lldb::SBTypeFilter GetTypeFilter();
+
#ifndef LLDB_DISABLE_PYTHON
- lldb::SBTypeSynthetic
- GetTypeSynthetic ();
+ lldb::SBTypeSynthetic GetTypeSynthetic();
#endif
- lldb::SBValue
- GetChildAtIndex (uint32_t idx);
-
- lldb::SBValue
- CreateChildAtOffset (const char *name, uint32_t offset, lldb::SBType type);
-
- // Deprecated - use the expression evaluator to perform type casting
- lldb::SBValue
- Cast (lldb::SBType type);
-
- lldb::SBValue
- CreateValueFromExpression (const char *name, const char* expression);
-
- lldb::SBValue
- CreateValueFromExpression (const char *name, const char* expression, SBExpressionOptions &options);
-
- lldb::SBValue
- CreateValueFromAddress (const char* name,
- lldb::addr_t address,
- lldb::SBType type);
-
- // this has no address! GetAddress() and GetLoadAddress() as well as AddressOf()
- // on the return of this call all return invalid
- lldb::SBValue
- CreateValueFromData (const char* name,
- lldb::SBData data,
- lldb::SBType type);
-
- //------------------------------------------------------------------
- /// Get a child value by index from a value.
- ///
- /// Structs, unions, classes, arrays and pointers have child
- /// values that can be access by index.
- ///
- /// Structs and unions access child members using a zero based index
- /// for each child member. For
- ///
- /// Classes reserve the first indexes for base classes that have
- /// members (empty base classes are omitted), and all members of the
- /// current class will then follow the base classes.
- ///
- /// Pointers differ depending on what they point to. If the pointer
- /// points to a simple type, the child at index zero
- /// is the only child value available, unless \a synthetic_allowed
- /// is \b true, in which case the pointer will be used as an array
- /// and can create 'synthetic' child values using positive or
- /// negative indexes. If the pointer points to an aggregate type
- /// (an array, class, union, struct), then the pointee is
- /// transparently skipped and any children are going to be the indexes
- /// of the child values within the aggregate type. For example if
- /// we have a 'Point' type and we have a SBValue that contains a
- /// pointer to a 'Point' type, then the child at index zero will be
- /// the 'x' member, and the child at index 1 will be the 'y' member
- /// (the child at index zero won't be a 'Point' instance).
- ///
- /// If you actually need an SBValue that represents the type pointed
- /// to by a SBValue for which GetType().IsPointeeType() returns true,
- /// regardless of the pointee type, you can do that with SBValue::Dereference.
- ///
- /// Arrays have a preset number of children that can be accessed by
- /// index and will returns invalid child values for indexes that are
- /// out of bounds unless the \a synthetic_allowed is \b true. In this
- /// case the array can create 'synthetic' child values for indexes
- /// that aren't in the array bounds using positive or negative
- /// indexes.
- ///
- /// @param[in] idx
- /// The index of the child value to get
- ///
- /// @param[in] use_dynamic
- /// An enumeration that specifies whether to get dynamic values,
- /// and also if the target can be run to figure out the dynamic
- /// type of the child value.
- ///
- /// @param[in] can_create_synthetic
- /// If \b true, then allow child values to be created by index
- /// for pointers and arrays for indexes that normally wouldn't
- /// be allowed.
- ///
- /// @return
- /// A new SBValue object that represents the child member value.
- //------------------------------------------------------------------
- lldb::SBValue
- GetChildAtIndex (uint32_t idx,
- lldb::DynamicValueType use_dynamic,
- bool can_create_synthetic);
-
- // Matches children of this object only and will match base classes and
- // member names if this is a clang typed object.
- uint32_t
- GetIndexOfChildWithName (const char *name);
-
- // Matches child members of this object and child members of any base
- // classes.
- lldb::SBValue
- GetChildMemberWithName (const char *name);
-
- // Matches child members of this object and child members of any base
- // classes.
- lldb::SBValue
- GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic);
-
- // Expands nested expressions like .a->b[0].c[1]->d
- lldb::SBValue
- GetValueForExpressionPath(const char* expr_path);
-
- lldb::SBValue
- AddressOf();
-
- lldb::addr_t
- GetLoadAddress();
-
- lldb::SBAddress
- GetAddress();
-
- //------------------------------------------------------------------
- /// Get an SBData wrapping what this SBValue points to.
- ///
- /// This method will dereference the current SBValue, if its
- /// data type is a T* or T[], and extract item_count elements
- /// of type T from it, copying their contents in an SBData.
- ///
- /// @param[in] item_idx
- /// The index of the first item to retrieve. For an array
- /// this is equivalent to array[item_idx], for a pointer
- /// to *(pointer + item_idx). In either case, the measurement
- /// unit for item_idx is the sizeof(T) rather than the byte
- ///
- /// @param[in] item_count
- /// How many items should be copied into the output. By default
- /// only one item is copied, but more can be asked for.
- ///
- /// @return
- /// An SBData with the contents of the copied items, on success.
- /// An empty SBData otherwise.
- //------------------------------------------------------------------
- lldb::SBData
- GetPointeeData (uint32_t item_idx = 0,
- uint32_t item_count = 1);
-
- //------------------------------------------------------------------
- /// Get an SBData wrapping the contents of this SBValue.
- ///
- /// This method will read the contents of this object in memory
- /// and copy them into an SBData for future use.
- ///
- /// @return
- /// An SBData with the contents of this SBValue, on success.
- /// An empty SBData otherwise.
- //------------------------------------------------------------------
- lldb::SBData
- GetData ();
-
- bool
- SetData (lldb::SBData &data, lldb::SBError& error);
-
- lldb::SBDeclaration
- GetDeclaration ();
-
- //------------------------------------------------------------------
- /// Find out if a SBValue might have children.
- ///
- /// This call is much more efficient than GetNumChildren() as it
- /// doesn't need to complete the underlying type. This is designed
- /// to be used in a UI environment in order to detect if the
- /// disclosure triangle should be displayed or not.
- ///
- /// This function returns true for class, union, structure,
- /// pointers, references, arrays and more. Again, it does so without
- /// doing any expensive type completion.
- ///
- /// @return
- /// Returns \b true if the SBValue might have children, or \b
- /// false otherwise.
- //------------------------------------------------------------------
- bool
- MightHaveChildren ();
-
- bool
- IsRuntimeSupportValue ();
-
- uint32_t
- GetNumChildren ();
-
- uint32_t
- GetNumChildren (uint32_t max);
-
- void *
- GetOpaqueType();
-
- lldb::SBTarget
- GetTarget();
-
- lldb::SBProcess
- GetProcess();
-
- lldb::SBThread
- GetThread();
-
- lldb::SBFrame
- GetFrame();
-
- lldb::SBValue
- Dereference ();
-
- // Deprecated - please use GetType().IsPointerType() instead.
- bool
- TypeIsPointerType ();
-
- lldb::SBType
- GetType();
-
- lldb::SBValue
- Persist ();
-
- bool
- GetDescription (lldb::SBStream &description);
-
- bool
- GetExpressionPath (lldb::SBStream &description);
-
- bool
- GetExpressionPath (lldb::SBStream &description,
- bool qualify_cxx_base_classes);
-
- SBValue (const lldb::ValueObjectSP &value_sp);
-
- //------------------------------------------------------------------
- /// Watch this value if it resides in memory.
- ///
- /// Sets a watchpoint on the value.
- ///
- /// @param[in] resolve_location
- /// Resolve the location of this value once and watch its address.
- /// This value must currently be set to \b true as watching all
- /// locations of a variable or a variable path is not yet supported,
- /// though we plan to support it in the future.
- ///
- /// @param[in] read
- /// Stop when this value is accessed.
- ///
- /// @param[in] write
- /// Stop when this value is modified
- ///
- /// @param[out] error
- /// An error object. Contains the reason if there is some failure.
- ///
- /// @return
- /// An SBWatchpoint object. This object might not be valid upon
- /// return due to a value not being contained in memory, too
- /// large, or watchpoint resources are not available or all in
- /// use.
- //------------------------------------------------------------------
- lldb::SBWatchpoint
- Watch (bool resolve_location, bool read, bool write, SBError &error);
-
- // Backward compatibility fix in the interim.
- lldb::SBWatchpoint
- Watch (bool resolve_location, bool read, bool write);
-
- //------------------------------------------------------------------
- /// Watch this value that this value points to in memory
- ///
- /// Sets a watchpoint on the value.
- ///
- /// @param[in] resolve_location
- /// Resolve the location of this value once and watch its address.
- /// This value must currently be set to \b true as watching all
- /// locations of a variable or a variable path is not yet supported,
- /// though we plan to support it in the future.
- ///
- /// @param[in] read
- /// Stop when this value is accessed.
- ///
- /// @param[in] write
- /// Stop when this value is modified
- ///
- /// @param[out] error
- /// An error object. Contains the reason if there is some failure.
- ///
- /// @return
- /// An SBWatchpoint object. This object might not be valid upon
- /// return due to a value not being contained in memory, too
- /// large, or watchpoint resources are not available or all in
- /// use.
- //------------------------------------------------------------------
- lldb::SBWatchpoint
- WatchPointee (bool resolve_location, bool read, bool write, SBError &error);
-
- //------------------------------------------------------------------
- /// Same as the protected version of GetSP that takes a locker, except that we make the
- /// locker locally in the function. Since the Target API mutex is recursive, and the
- /// StopLocker is a read lock, you can call this function even if you are already
- /// holding the two above-mentioned locks.
- ///
- /// @return
- /// A ValueObjectSP of the best kind (static, dynamic or synthetic) we
- /// can cons up, in accordance with the SBValue's settings.
- //------------------------------------------------------------------
- lldb::ValueObjectSP
- GetSP () const;
+ lldb::SBValue GetChildAtIndex(uint32_t idx);
+
+ lldb::SBValue CreateChildAtOffset(const char *name, uint32_t offset,
+ lldb::SBType type);
+
+ // Deprecated - use the expression evaluator to perform type casting
+ lldb::SBValue Cast(lldb::SBType type);
+
+ lldb::SBValue CreateValueFromExpression(const char *name,
+ const char *expression);
+
+ lldb::SBValue CreateValueFromExpression(const char *name,
+ const char *expression,
+ SBExpressionOptions &options);
+
+ lldb::SBValue CreateValueFromAddress(const char *name, lldb::addr_t address,
+ lldb::SBType type);
+
+ // this has no address! GetAddress() and GetLoadAddress() as well as
+ // AddressOf()
+ // on the return of this call all return invalid
+ lldb::SBValue CreateValueFromData(const char *name, lldb::SBData data,
+ lldb::SBType type);
+
+ //------------------------------------------------------------------
+ /// Get a child value by index from a value.
+ ///
+ /// Structs, unions, classes, arrays and pointers have child
+ /// values that can be access by index.
+ ///
+ /// Structs and unions access child members using a zero based index
+ /// for each child member. For
+ ///
+ /// Classes reserve the first indexes for base classes that have
+ /// members (empty base classes are omitted), and all members of the
+ /// current class will then follow the base classes.
+ ///
+ /// Pointers differ depending on what they point to. If the pointer
+ /// points to a simple type, the child at index zero
+ /// is the only child value available, unless \a synthetic_allowed
+ /// is \b true, in which case the pointer will be used as an array
+ /// and can create 'synthetic' child values using positive or
+ /// negative indexes. If the pointer points to an aggregate type
+ /// (an array, class, union, struct), then the pointee is
+ /// transparently skipped and any children are going to be the indexes
+ /// of the child values within the aggregate type. For example if
+ /// we have a 'Point' type and we have a SBValue that contains a
+ /// pointer to a 'Point' type, then the child at index zero will be
+ /// the 'x' member, and the child at index 1 will be the 'y' member
+ /// (the child at index zero won't be a 'Point' instance).
+ ///
+ /// If you actually need an SBValue that represents the type pointed
+ /// to by a SBValue for which GetType().IsPointeeType() returns true,
+ /// regardless of the pointee type, you can do that with SBValue::Dereference.
+ ///
+ /// Arrays have a preset number of children that can be accessed by
+ /// index and will returns invalid child values for indexes that are
+ /// out of bounds unless the \a synthetic_allowed is \b true. In this
+ /// case the array can create 'synthetic' child values for indexes
+ /// that aren't in the array bounds using positive or negative
+ /// indexes.
+ ///
+ /// @param[in] idx
+ /// The index of the child value to get
+ ///
+ /// @param[in] use_dynamic
+ /// An enumeration that specifies whether to get dynamic values,
+ /// and also if the target can be run to figure out the dynamic
+ /// type of the child value.
+ ///
+ /// @param[in] can_create_synthetic
+ /// If \b true, then allow child values to be created by index
+ /// for pointers and arrays for indexes that normally wouldn't
+ /// be allowed.
+ ///
+ /// @return
+ /// A new SBValue object that represents the child member value.
+ //------------------------------------------------------------------
+ lldb::SBValue GetChildAtIndex(uint32_t idx,
+ lldb::DynamicValueType use_dynamic,
+ bool can_create_synthetic);
+
+ // Matches children of this object only and will match base classes and
+ // member names if this is a clang typed object.
+ uint32_t GetIndexOfChildWithName(const char *name);
+
+ // Matches child members of this object and child members of any base
+ // classes.
+ lldb::SBValue GetChildMemberWithName(const char *name);
+
+ // Matches child members of this object and child members of any base
+ // classes.
+ lldb::SBValue GetChildMemberWithName(const char *name,
+ lldb::DynamicValueType use_dynamic);
+
+ // Expands nested expressions like .a->b[0].c[1]->d
+ lldb::SBValue GetValueForExpressionPath(const char *expr_path);
+
+ lldb::SBValue AddressOf();
+
+ lldb::addr_t GetLoadAddress();
+
+ lldb::SBAddress GetAddress();
+
+ //------------------------------------------------------------------
+ /// Get an SBData wrapping what this SBValue points to.
+ ///
+ /// This method will dereference the current SBValue, if its
+ /// data type is a T* or T[], and extract item_count elements
+ /// of type T from it, copying their contents in an SBData.
+ ///
+ /// @param[in] item_idx
+ /// The index of the first item to retrieve. For an array
+ /// this is equivalent to array[item_idx], for a pointer
+ /// to *(pointer + item_idx). In either case, the measurement
+ /// unit for item_idx is the sizeof(T) rather than the byte
+ ///
+ /// @param[in] item_count
+ /// How many items should be copied into the output. By default
+ /// only one item is copied, but more can be asked for.
+ ///
+ /// @return
+ /// An SBData with the contents of the copied items, on success.
+ /// An empty SBData otherwise.
+ //------------------------------------------------------------------
+ lldb::SBData GetPointeeData(uint32_t item_idx = 0, uint32_t item_count = 1);
+
+ //------------------------------------------------------------------
+ /// Get an SBData wrapping the contents of this SBValue.
+ ///
+ /// This method will read the contents of this object in memory
+ /// and copy them into an SBData for future use.
+ ///
+ /// @return
+ /// An SBData with the contents of this SBValue, on success.
+ /// An empty SBData otherwise.
+ //------------------------------------------------------------------
+ lldb::SBData GetData();
+
+ bool SetData(lldb::SBData &data, lldb::SBError &error);
+
+ lldb::SBDeclaration GetDeclaration();
+
+ //------------------------------------------------------------------
+ /// Find out if a SBValue might have children.
+ ///
+ /// This call is much more efficient than GetNumChildren() as it
+ /// doesn't need to complete the underlying type. This is designed
+ /// to be used in a UI environment in order to detect if the
+ /// disclosure triangle should be displayed or not.
+ ///
+ /// This function returns true for class, union, structure,
+ /// pointers, references, arrays and more. Again, it does so without
+ /// doing any expensive type completion.
+ ///
+ /// @return
+ /// Returns \b true if the SBValue might have children, or \b
+ /// false otherwise.
+ //------------------------------------------------------------------
+ bool MightHaveChildren();
+
+ bool IsRuntimeSupportValue();
+
+ uint32_t GetNumChildren();
+
+ uint32_t GetNumChildren(uint32_t max);
+
+ void *GetOpaqueType();
+
+ lldb::SBTarget GetTarget();
+
+ lldb::SBProcess GetProcess();
+
+ lldb::SBThread GetThread();
+
+ lldb::SBFrame GetFrame();
+
+ lldb::SBValue Dereference();
+
+ // Deprecated - please use GetType().IsPointerType() instead.
+ bool TypeIsPointerType();
+
+ lldb::SBType GetType();
+
+ lldb::SBValue Persist();
+
+ bool GetDescription(lldb::SBStream &description);
+
+ bool GetExpressionPath(lldb::SBStream &description);
+
+ bool GetExpressionPath(lldb::SBStream &description,
+ bool qualify_cxx_base_classes);
+
+ SBValue(const lldb::ValueObjectSP &value_sp);
+
+ //------------------------------------------------------------------
+ /// Watch this value if it resides in memory.
+ ///
+ /// Sets a watchpoint on the value.
+ ///
+ /// @param[in] resolve_location
+ /// Resolve the location of this value once and watch its address.
+ /// This value must currently be set to \b true as watching all
+ /// locations of a variable or a variable path is not yet supported,
+ /// though we plan to support it in the future.
+ ///
+ /// @param[in] read
+ /// Stop when this value is accessed.
+ ///
+ /// @param[in] write
+ /// Stop when this value is modified
+ ///
+ /// @param[out] error
+ /// An error object. Contains the reason if there is some failure.
+ ///
+ /// @return
+ /// An SBWatchpoint object. This object might not be valid upon
+ /// return due to a value not being contained in memory, too
+ /// large, or watchpoint resources are not available or all in
+ /// use.
+ //------------------------------------------------------------------
+ lldb::SBWatchpoint Watch(bool resolve_location, bool read, bool write,
+ SBError &error);
+
+ // Backward compatibility fix in the interim.
+ lldb::SBWatchpoint Watch(bool resolve_location, bool read, bool write);
+
+ //------------------------------------------------------------------
+ /// Watch this value that this value points to in memory
+ ///
+ /// Sets a watchpoint on the value.
+ ///
+ /// @param[in] resolve_location
+ /// Resolve the location of this value once and watch its address.
+ /// This value must currently be set to \b true as watching all
+ /// locations of a variable or a variable path is not yet supported,
+ /// though we plan to support it in the future.
+ ///
+ /// @param[in] read
+ /// Stop when this value is accessed.
+ ///
+ /// @param[in] write
+ /// Stop when this value is modified
+ ///
+ /// @param[out] error
+ /// An error object. Contains the reason if there is some failure.
+ ///
+ /// @return
+ /// An SBWatchpoint object. This object might not be valid upon
+ /// return due to a value not being contained in memory, too
+ /// large, or watchpoint resources are not available or all in
+ /// use.
+ //------------------------------------------------------------------
+ lldb::SBWatchpoint WatchPointee(bool resolve_location, bool read, bool write,
+ SBError &error);
+
+ //------------------------------------------------------------------
+ /// Same as the protected version of GetSP that takes a locker, except that we
+ /// make the
+ /// locker locally in the function. Since the Target API mutex is recursive,
+ /// and the
+ /// StopLocker is a read lock, you can call this function even if you are
+ /// already
+ /// holding the two above-mentioned locks.
+ ///
+ /// @return
+ /// A ValueObjectSP of the best kind (static, dynamic or synthetic) we
+ /// can cons up, in accordance with the SBValue's settings.
+ //------------------------------------------------------------------
+ lldb::ValueObjectSP GetSP() const;
protected:
- friend class SBBlock;
- friend class SBFrame;
- friend class SBTarget;
- friend class SBThread;
- friend class SBValueList;
-
- //------------------------------------------------------------------
- /// Get the appropriate ValueObjectSP from this SBValue, consulting the
- /// use_dynamic and use_synthetic options passed in to SetSP when the
- /// SBValue's contents were set. Since this often requires examining memory,
- /// and maybe even running code, it needs to acquire the Target API and Process StopLock.
- /// Those are held in an opaque class ValueLocker which is currently local to SBValue.cpp.
- /// So you don't have to get these yourself just default construct a ValueLocker, and pass it into this.
- /// If we need to make a ValueLocker and use it in some other .cpp file, we'll have to move it to
- /// ValueObject.h/cpp or somewhere else convenient. We haven't needed to so far.
- ///
- /// @param[in] value_locker
- /// An object that will hold the Target API, and Process RunLocks, and
- /// auto-destroy them when it goes out of scope. Currently this is only useful in
- /// SBValue.cpp.
- ///
- /// @return
- /// A ValueObjectSP of the best kind (static, dynamic or synthetic) we
- /// can cons up, in accordance with the SBValue's settings.
- //------------------------------------------------------------------
- lldb::ValueObjectSP
- GetSP (ValueLocker &value_locker) const;
-
- // these calls do the right thing WRT adjusting their settings according to the target's preferences
- void
- SetSP (const lldb::ValueObjectSP &sp);
-
- void
- SetSP (const lldb::ValueObjectSP &sp, bool use_synthetic);
-
- void
- SetSP (const lldb::ValueObjectSP &sp, lldb::DynamicValueType use_dynamic);
-
- void
- SetSP (const lldb::ValueObjectSP &sp, lldb::DynamicValueType use_dynamic, bool use_synthetic);
-
- void
- SetSP (const lldb::ValueObjectSP &sp, lldb::DynamicValueType use_dynamic, bool use_synthetic, const char *name);
-
+ friend class SBBlock;
+ friend class SBFrame;
+ friend class SBTarget;
+ friend class SBThread;
+ friend class SBValueList;
+
+ //------------------------------------------------------------------
+ /// Get the appropriate ValueObjectSP from this SBValue, consulting the
+ /// use_dynamic and use_synthetic options passed in to SetSP when the
+ /// SBValue's contents were set. Since this often requires examining memory,
+ /// and maybe even running code, it needs to acquire the Target API and
+ /// Process StopLock.
+ /// Those are held in an opaque class ValueLocker which is currently local to
+ /// SBValue.cpp.
+ /// So you don't have to get these yourself just default construct a
+ /// ValueLocker, and pass it into this.
+ /// If we need to make a ValueLocker and use it in some other .cpp file, we'll
+ /// have to move it to
+ /// ValueObject.h/cpp or somewhere else convenient. We haven't needed to so
+ /// far.
+ ///
+ /// @param[in] value_locker
+ /// An object that will hold the Target API, and Process RunLocks, and
+ /// auto-destroy them when it goes out of scope. Currently this is only
+ /// useful in
+ /// SBValue.cpp.
+ ///
+ /// @return
+ /// A ValueObjectSP of the best kind (static, dynamic or synthetic) we
+ /// can cons up, in accordance with the SBValue's settings.
+ //------------------------------------------------------------------
+ lldb::ValueObjectSP GetSP(ValueLocker &value_locker) const;
+
+ // these calls do the right thing WRT adjusting their settings according to
+ // the target's preferences
+ void SetSP(const lldb::ValueObjectSP &sp);
+
+ void SetSP(const lldb::ValueObjectSP &sp, bool use_synthetic);
+
+ void SetSP(const lldb::ValueObjectSP &sp, lldb::DynamicValueType use_dynamic);
+
+ void SetSP(const lldb::ValueObjectSP &sp, lldb::DynamicValueType use_dynamic,
+ bool use_synthetic);
+
+ void SetSP(const lldb::ValueObjectSP &sp, lldb::DynamicValueType use_dynamic,
+ bool use_synthetic, const char *name);
+
private:
- typedef std::shared_ptr<ValueImpl> ValueImplSP;
- ValueImplSP m_opaque_sp;
-
- void
- SetSP (ValueImplSP impl_sp);
+ typedef std::shared_ptr<ValueImpl> ValueImplSP;
+ ValueImplSP m_opaque_sp;
+
+ void SetSP(ValueImplSP impl_sp);
};
} // namespace lldb
-#endif // LLDB_SBValue_h_
+#endif // LLDB_SBValue_h_
diff --git a/include/lldb/API/SBValueList.h b/include/lldb/API/SBValueList.h
index 563ca3d7e1bf..495b0140cad0 100644
--- a/include/lldb/API/SBValueList.h
+++ b/include/lldb/API/SBValueList.h
@@ -16,81 +16,59 @@ class ValueListImpl;
namespace lldb {
-class LLDB_API SBValueList
-{
+class LLDB_API SBValueList {
public:
+ SBValueList();
- SBValueList ();
+ SBValueList(const lldb::SBValueList &rhs);
- SBValueList (const lldb::SBValueList &rhs);
+ ~SBValueList();
- ~SBValueList();
+ bool IsValid() const;
- bool
- IsValid() const;
-
- void
- Clear();
+ void Clear();
- void
- Append (const lldb::SBValue &val_obj);
+ void Append(const lldb::SBValue &val_obj);
- void
- Append (const lldb::SBValueList& value_list);
+ void Append(const lldb::SBValueList &value_list);
- uint32_t
- GetSize() const;
+ uint32_t GetSize() const;
- lldb::SBValue
- GetValueAtIndex (uint32_t idx) const;
-
- lldb::SBValue
- GetFirstValueByName (const char* name) const;
+ lldb::SBValue GetValueAtIndex(uint32_t idx) const;
- lldb::SBValue
- FindValueObjectByUID (lldb::user_id_t uid);
+ lldb::SBValue GetFirstValueByName(const char *name) const;
- const lldb::SBValueList &
- operator = (const lldb::SBValueList &rhs);
+ lldb::SBValue FindValueObjectByUID(lldb::user_id_t uid);
+
+ const lldb::SBValueList &operator=(const lldb::SBValueList &rhs);
protected:
-
- // only useful for visualizing the pointer or comparing two SBValueLists
- // to see if they are backed by the same underlying Impl.
- void *
- opaque_ptr ();
+ // only useful for visualizing the pointer or comparing two SBValueLists
+ // to see if they are backed by the same underlying Impl.
+ void *opaque_ptr();
private:
- friend class SBFrame;
-
- SBValueList (const ValueListImpl *lldb_object_ptr);
-
- void
- Append (lldb::ValueObjectSP& val_obj_sp);
-
- void
- CreateIfNeeded ();
-
- ValueListImpl *
- operator -> ();
-
- ValueListImpl &
- operator* ();
-
- const ValueListImpl *
- operator -> () const;
-
- const ValueListImpl &
- operator* () const;
-
-
- ValueListImpl &
- ref ();
-
- std::unique_ptr<ValueListImpl> m_opaque_ap;
-};
+ friend class SBFrame;
+
+ SBValueList(const ValueListImpl *lldb_object_ptr);
+
+ void Append(lldb::ValueObjectSP &val_obj_sp);
+
+ void CreateIfNeeded();
+
+ ValueListImpl *operator->();
+ ValueListImpl &operator*();
+
+ const ValueListImpl *operator->() const;
+
+ const ValueListImpl &operator*() const;
+
+ ValueListImpl &ref();
+
+ std::unique_ptr<ValueListImpl> m_opaque_ap;
+};
} // namespace lldb
-#endif // LLDB_SBValueList_h_
+#endif // LLDB_SBValueList_h_
diff --git a/include/lldb/API/SBVariablesOptions.h b/include/lldb/API/SBVariablesOptions.h
index 527310f5dfc7..756da6439e3b 100644
--- a/include/lldb/API/SBVariablesOptions.h
+++ b/include/lldb/API/SBVariablesOptions.h
@@ -1,4 +1,5 @@
-//===-- SBVariablesOptions.h ------------------------------------------*- C++ -*-===//
+//===-- SBVariablesOptions.h ------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,83 +17,61 @@ class VariablesOptionsImpl;
namespace lldb {
-class LLDB_API SBVariablesOptions
-{
+class LLDB_API SBVariablesOptions {
public:
- SBVariablesOptions ();
-
- SBVariablesOptions (const SBVariablesOptions& options);
-
- SBVariablesOptions&
- operator = (const SBVariablesOptions& options);
-
- ~SBVariablesOptions ();
-
- bool
- IsValid () const;
-
- bool
- GetIncludeArguments () const;
-
- void
- SetIncludeArguments (bool);
-
- bool
- GetIncludeLocals () const;
-
- void
- SetIncludeLocals (bool);
-
- bool
- GetIncludeStatics () const;
-
- void
- SetIncludeStatics (bool);
-
- bool
- GetInScopeOnly () const;
-
- void
- SetInScopeOnly (bool);
-
- bool
- GetIncludeRuntimeSupportValues () const;
-
- void
- SetIncludeRuntimeSupportValues (bool);
-
- lldb::DynamicValueType
- GetUseDynamic () const;
-
- void
- SetUseDynamic (lldb::DynamicValueType);
-
+ SBVariablesOptions();
+
+ SBVariablesOptions(const SBVariablesOptions &options);
+
+ SBVariablesOptions &operator=(const SBVariablesOptions &options);
+
+ ~SBVariablesOptions();
+
+ bool IsValid() const;
+
+ bool GetIncludeArguments() const;
+
+ void SetIncludeArguments(bool);
+
+ bool GetIncludeLocals() const;
+
+ void SetIncludeLocals(bool);
+
+ bool GetIncludeStatics() const;
+
+ void SetIncludeStatics(bool);
+
+ bool GetInScopeOnly() const;
+
+ void SetInScopeOnly(bool);
+
+ bool GetIncludeRuntimeSupportValues() const;
+
+ void SetIncludeRuntimeSupportValues(bool);
+
+ lldb::DynamicValueType GetUseDynamic() const;
+
+ void SetUseDynamic(lldb::DynamicValueType);
+
protected:
- VariablesOptionsImpl *
- operator->();
-
- const VariablesOptionsImpl *
- operator->() const;
-
- VariablesOptionsImpl *
- get ();
-
- VariablesOptionsImpl &
- ref();
-
- const VariablesOptionsImpl &
- ref() const;
-
- SBVariablesOptions (VariablesOptionsImpl *lldb_object_ptr);
-
- void
- SetOptions (VariablesOptionsImpl *lldb_object_ptr);
-
+ VariablesOptionsImpl *operator->();
+
+ const VariablesOptionsImpl *operator->() const;
+
+ VariablesOptionsImpl *get();
+
+ VariablesOptionsImpl &ref();
+
+ const VariablesOptionsImpl &ref() const;
+
+ SBVariablesOptions(VariablesOptionsImpl *lldb_object_ptr);
+
+ void SetOptions(VariablesOptionsImpl *lldb_object_ptr);
+
private:
-
- std::unique_ptr<VariablesOptionsImpl> m_opaque_ap;
+ std::unique_ptr<VariablesOptionsImpl> m_opaque_ap;
};
} // namespace lldb
-#endif // LLDB_SBValue_h_
+#endif // LLDB_SBValue_h_
diff --git a/include/lldb/API/SBWatchpoint.h b/include/lldb/API/SBWatchpoint.h
index 5d0d48ee12f2..284ec12392a3 100644
--- a/include/lldb/API/SBWatchpoint.h
+++ b/include/lldb/API/SBWatchpoint.h
@@ -14,91 +14,67 @@
namespace lldb {
-class LLDB_API SBWatchpoint
-{
+class LLDB_API SBWatchpoint {
public:
+ SBWatchpoint();
- SBWatchpoint ();
+ SBWatchpoint(const lldb::SBWatchpoint &rhs);
- SBWatchpoint (const lldb::SBWatchpoint &rhs);
+ SBWatchpoint(const lldb::WatchpointSP &wp_sp);
- SBWatchpoint (const lldb::WatchpointSP &wp_sp);
+ ~SBWatchpoint();
- ~SBWatchpoint ();
+ const lldb::SBWatchpoint &operator=(const lldb::SBWatchpoint &rhs);
- const lldb::SBWatchpoint &
- operator = (const lldb::SBWatchpoint &rhs);
+ bool IsValid() const;
- bool
- IsValid() const;
+ SBError GetError();
- SBError
- GetError();
+ watch_id_t GetID();
- watch_id_t
- GetID ();
+ /// With -1 representing an invalid hardware index.
+ int32_t GetHardwareIndex();
- /// With -1 representing an invalid hardware index.
- int32_t
- GetHardwareIndex ();
+ lldb::addr_t GetWatchAddress();
- lldb::addr_t
- GetWatchAddress ();
+ size_t GetWatchSize();
- size_t
- GetWatchSize();
+ void SetEnabled(bool enabled);
- void
- SetEnabled(bool enabled);
+ bool IsEnabled();
- bool
- IsEnabled ();
+ uint32_t GetHitCount();
- uint32_t
- GetHitCount ();
+ uint32_t GetIgnoreCount();
- uint32_t
- GetIgnoreCount ();
+ void SetIgnoreCount(uint32_t n);
- void
- SetIgnoreCount (uint32_t n);
+ const char *GetCondition();
- const char *
- GetCondition ();
+ void SetCondition(const char *condition);
- void
- SetCondition (const char *condition);
-
- bool
- GetDescription (lldb::SBStream &description, DescriptionLevel level);
+ bool GetDescription(lldb::SBStream &description, DescriptionLevel level);
- void
- Clear ();
+ void Clear();
- lldb::WatchpointSP
- GetSP () const;
+ lldb::WatchpointSP GetSP() const;
- void
- SetSP (const lldb::WatchpointSP &sp);
+ void SetSP(const lldb::WatchpointSP &sp);
- static bool
- EventIsWatchpointEvent (const lldb::SBEvent &event);
-
- static lldb::WatchpointEventType
- GetWatchpointEventTypeFromEvent (const lldb::SBEvent& event);
+ static bool EventIsWatchpointEvent(const lldb::SBEvent &event);
- static lldb::SBWatchpoint
- GetWatchpointFromEvent (const lldb::SBEvent& event);
+ static lldb::WatchpointEventType
+ GetWatchpointEventTypeFromEvent(const lldb::SBEvent &event);
-private:
- friend class SBTarget;
- friend class SBValue;
+ static lldb::SBWatchpoint GetWatchpointFromEvent(const lldb::SBEvent &event);
-
- lldb::WatchpointSP m_opaque_sp;
+private:
+ friend class SBTarget;
+ friend class SBValue;
+ lldb::WatchpointSP m_opaque_sp;
};
} // namespace lldb
-#endif // LLDB_SBWatchpoint_h_
+#endif // LLDB_SBWatchpoint_h_
diff --git a/include/lldb/API/SystemInitializerFull.h b/include/lldb/API/SystemInitializerFull.h
index 9e37611a6598..9cfc6896da61 100644
--- a/include/lldb/API/SystemInitializerFull.h
+++ b/include/lldb/API/SystemInitializerFull.h
@@ -12,8 +12,7 @@
#include "lldb/Initialization/SystemInitializerCommon.h"
-namespace lldb_private
-{
+namespace lldb_private {
//------------------------------------------------------------------
/// Initializes lldb.
///
@@ -22,17 +21,16 @@ namespace lldb_private
/// not intended to be used externally, but is instead used
/// internally by SBDebugger to initialize the system.
//------------------------------------------------------------------
-class SystemInitializerFull : public SystemInitializerCommon
-{
- public:
- SystemInitializerFull();
- ~SystemInitializerFull() override;
+class SystemInitializerFull : public SystemInitializerCommon {
+public:
+ SystemInitializerFull();
+ ~SystemInitializerFull() override;
- void Initialize() override;
- void Terminate() override;
+ void Initialize() override;
+ void Terminate() override;
- private:
- void InitializeSWIG();
+private:
+ void InitializeSWIG();
};
} // namespace lldb_private
diff --git a/include/lldb/Breakpoint/Breakpoint.h b/include/lldb/Breakpoint/Breakpoint.h
index 7fdf06da3936..9af6e586de39 100644
--- a/include/lldb/Breakpoint/Breakpoint.h
+++ b/include/lldb/Breakpoint/Breakpoint.h
@@ -20,13 +20,14 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/BreakpointID.h"
+#include "lldb/Breakpoint/BreakpointLocationCollection.h"
#include "lldb/Breakpoint/BreakpointLocationList.h"
#include "lldb/Breakpoint/BreakpointOptions.h"
-#include "lldb/Breakpoint/BreakpointLocationCollection.h"
#include "lldb/Breakpoint/Stoppoint.h"
-#include "lldb/Core/SearchFilter.h"
#include "lldb/Core/Event.h"
+#include "lldb/Core/SearchFilter.h"
#include "lldb/Core/StringList.h"
+#include "lldb/Core/StructuredData.h"
namespace lldb_private {
@@ -37,27 +38,35 @@ namespace lldb_private {
//----------------------------------------------------------------------
/// General Outline:
-/// A breakpoint has four main parts, a filter, a resolver, the list of breakpoint
-/// locations that have been determined for the filter/resolver pair, and finally
+/// A breakpoint has four main parts, a filter, a resolver, the list of
+/// breakpoint
+/// locations that have been determined for the filter/resolver pair, and
+/// finally
/// a set of options for the breakpoint.
///
/// \b Filter:
/// This is an object derived from SearchFilter. It manages the search
-/// for breakpoint location matches through the symbols in the module list of the target
-/// that owns it. It also filters out locations based on whatever logic it wants.
+/// for breakpoint location matches through the symbols in the module list of
+/// the target
+/// that owns it. It also filters out locations based on whatever logic it
+/// wants.
///
/// \b Resolver:
/// This is an object derived from BreakpointResolver. It provides a
-/// callback to the filter that will find breakpoint locations. How it does this is
+/// callback to the filter that will find breakpoint locations. How it does
+/// this is
/// determined by what kind of resolver it is.
///
-/// The Breakpoint class also provides constructors for the common breakpoint cases
+/// The Breakpoint class also provides constructors for the common breakpoint
+/// cases
/// which make the appropriate filter and resolver for you.
///
/// \b Location List:
/// This stores the breakpoint locations that have been determined
-/// to date. For a given breakpoint, there will be only one location with a given
-/// address. Adding a location at an already taken address will just return the location
+/// to date. For a given breakpoint, there will be only one location with a
+/// given
+/// address. Adding a location at an already taken address will just return the
+/// location
/// already at that address. Locations can be looked up by ID, or by address.
///
/// \b Options:
@@ -66,734 +75,687 @@ namespace lldb_private {
/// \b Ignore Count
/// \b Callback
/// \b Condition
-/// Note, these options can be set on the breakpoint, and they can also be set on the
-/// individual locations. The options set on the breakpoint take precedence over the
+/// Note, these options can be set on the breakpoint, and they can also be set
+/// on the
+/// individual locations. The options set on the breakpoint take precedence
+/// over the
/// options set on the individual location.
-/// So for instance disabling the breakpoint will cause NONE of the locations to get hit.
-/// But if the breakpoint is enabled, then the location's enabled state will be checked
+/// So for instance disabling the breakpoint will cause NONE of the locations to
+/// get hit.
+/// But if the breakpoint is enabled, then the location's enabled state will be
+/// checked
/// to determine whether to insert that breakpoint location.
-/// Similarly, if the breakpoint condition says "stop", we won't check the location's condition.
-/// But if the breakpoint condition says "continue", then we will check the location for whether
+/// Similarly, if the breakpoint condition says "stop", we won't check the
+/// location's condition.
+/// But if the breakpoint condition says "continue", then we will check the
+/// location for whether
/// to actually stop or not.
-/// One subtle point worth observing here is that you don't actually stop at a Breakpoint, you
-/// always stop at one of its locations. So the "should stop" tests are done by the location,
+/// One subtle point worth observing here is that you don't actually stop at a
+/// Breakpoint, you
+/// always stop at one of its locations. So the "should stop" tests are done by
+/// the location,
/// not by the breakpoint.
//----------------------------------------------------------------------
-class Breakpoint:
- public std::enable_shared_from_this<Breakpoint>,
- public Stoppoint
-{
+class Breakpoint : public std::enable_shared_from_this<Breakpoint>,
+ public Stoppoint {
public:
- static const ConstString &
- GetEventIdentifier ();
-
- //------------------------------------------------------------------
- /// An enum specifying the match style for breakpoint settings. At
- /// present only used for function name style breakpoints.
- //------------------------------------------------------------------
- typedef enum
- {
- Exact,
- Regexp,
- Glob
- } MatchType;
-
- class BreakpointEventData :
- public EventData
- {
- public:
- BreakpointEventData (lldb::BreakpointEventType sub_type,
- const lldb::BreakpointSP &new_breakpoint_sp);
-
- ~BreakpointEventData() override;
-
- static const ConstString &
- GetFlavorString ();
-
- const ConstString &
- GetFlavor() const override;
-
- lldb::BreakpointEventType
- GetBreakpointEventType () const;
-
- lldb::BreakpointSP &
- GetBreakpoint ();
-
- BreakpointLocationCollection &
- GetBreakpointLocationCollection()
- {
- return m_locations;
- }
-
- void
- Dump(Stream *s) const override;
-
- static lldb::BreakpointEventType
- GetBreakpointEventTypeFromEvent (const lldb::EventSP &event_sp);
-
- static lldb::BreakpointSP
- GetBreakpointFromEvent (const lldb::EventSP &event_sp);
-
- static lldb::BreakpointLocationSP
- GetBreakpointLocationAtIndexFromEvent (const lldb::EventSP &event_sp, uint32_t loc_idx);
-
- static size_t
- GetNumBreakpointLocationsFromEvent (const lldb::EventSP &event_sp);
-
- static const BreakpointEventData *
- GetEventDataFromEvent (const Event *event_sp);
-
- private:
- lldb::BreakpointEventType m_breakpoint_event;
- lldb::BreakpointSP m_new_breakpoint_sp;
- BreakpointLocationCollection m_locations;
-
- DISALLOW_COPY_AND_ASSIGN (BreakpointEventData);
- };
-
- class BreakpointPrecondition
- {
- public:
- virtual ~BreakpointPrecondition() = default;
-
- virtual bool
- EvaluatePrecondition(StoppointCallbackContext &context);
-
- virtual Error
- ConfigurePrecondition(Args &options);
-
- virtual void
- GetDescription(Stream &stream, lldb::DescriptionLevel level);
- };
-
- typedef std::shared_ptr<BreakpointPrecondition> BreakpointPreconditionSP;
-
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// The destructor is not virtual since there should be no reason to subclass
- /// breakpoints. The varieties of breakpoints are specified instead by
- /// providing different resolvers & filters.
- //------------------------------------------------------------------
- ~Breakpoint() override;
-
- //------------------------------------------------------------------
- // Methods
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Tell whether this breakpoint is an "internal" breakpoint.
- /// @return
- /// Returns \b true if this is an internal breakpoint, \b false otherwise.
- //------------------------------------------------------------------
- bool
- IsInternal () const;
-
- //------------------------------------------------------------------
- /// Standard "Dump" method. At present it does nothing.
- //------------------------------------------------------------------
- void
- Dump(Stream *s) override;
-
- //------------------------------------------------------------------
- // The next set of methods provide ways to tell the breakpoint to update
- // it's location list - usually done when modules appear or disappear.
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Tell this breakpoint to clear all its breakpoint sites. Done
- /// when the process holding the breakpoint sites is destroyed.
- //------------------------------------------------------------------
- void
- ClearAllBreakpointSites ();
-
- //------------------------------------------------------------------
- /// Tell this breakpoint to scan it's target's module list and resolve any
- /// new locations that match the breakpoint's specifications.
- //------------------------------------------------------------------
- void
- ResolveBreakpoint ();
-
- //------------------------------------------------------------------
- /// Tell this breakpoint to scan a given module list and resolve any
- /// new locations that match the breakpoint's specifications.
- ///
- /// @param[in] module_list
- /// The list of modules to look in for new locations.
- ///
- /// @param[in] send_event
- /// If \b true, send a breakpoint location added event for non-internal breakpoints.
- //------------------------------------------------------------------
- void
- ResolveBreakpointInModules (ModuleList &module_list, bool send_event = true);
-
- //------------------------------------------------------------------
- /// Tell this breakpoint to scan a given module list and resolve any
- /// new locations that match the breakpoint's specifications.
- ///
- /// @param[in] changed_modules
- /// The list of modules to look in for new locations.
- ///
- /// @param[in] new_locations
- /// Fills new_locations with the new locations that were made.
- //------------------------------------------------------------------
- void
- ResolveBreakpointInModules (ModuleList &module_list, BreakpointLocationCollection &new_locations);
-
- //------------------------------------------------------------------
- /// Like ResolveBreakpointInModules, but allows for "unload" events, in
- /// which case we will remove any locations that are in modules that got
- /// unloaded.
- ///
- /// @param[in] changedModules
- /// The list of modules to look in for new locations.
- /// @param[in] load_event
- /// If \b true then the modules were loaded, if \b false, unloaded.
- /// @param[in] delete_locations
- /// If \b true then the modules were unloaded delete any locations in the changed modules.
- //------------------------------------------------------------------
- void
- ModulesChanged (ModuleList &changed_modules,
- bool load_event,
- bool delete_locations = false);
-
- //------------------------------------------------------------------
- /// Tells the breakpoint the old module \a old_module_sp has been
- /// replaced by new_module_sp (usually because the underlying file has been
- /// rebuilt, and the old version is gone.)
- ///
- /// @param[in] old_module_sp
- /// The old module that is going away.
- /// @param[in] new_module_sp
- /// The new module that is replacing it.
- //------------------------------------------------------------------
- void
- ModuleReplaced (lldb::ModuleSP old_module_sp, lldb::ModuleSP new_module_sp);
-
- //------------------------------------------------------------------
- // The next set of methods provide access to the breakpoint locations
- // for this breakpoint.
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Add a location to the breakpoint's location list. This is only meant
- /// to be called by the breakpoint's resolver. FIXME: how do I ensure that?
- ///
- /// @param[in] addr
- /// The Address specifying the new location.
- /// @param[out] new_location
- /// Set to \b true if a new location was created, to \b false if there
- /// already was a location at this Address.
- /// @return
- /// Returns a pointer to the new location.
- //------------------------------------------------------------------
- lldb::BreakpointLocationSP
- AddLocation(const Address &addr,
- bool *new_location = nullptr);
-
- //------------------------------------------------------------------
- /// Find a breakpoint location by Address.
- ///
- /// @param[in] addr
- /// The Address specifying the location.
- /// @return
- /// Returns a shared pointer to the location at \a addr. The pointer
- /// in the shared pointer will be nullptr if there is no location at that address.
- //------------------------------------------------------------------
- lldb::BreakpointLocationSP
- FindLocationByAddress (const Address &addr);
-
- //------------------------------------------------------------------
- /// Find a breakpoint location ID by Address.
- ///
- /// @param[in] addr
- /// The Address specifying the location.
- /// @return
- /// Returns the UID of the location at \a addr, or \b LLDB_INVALID_ID if
- /// there is no breakpoint location at that address.
- //------------------------------------------------------------------
- lldb::break_id_t
- FindLocationIDByAddress (const Address &addr);
-
- //------------------------------------------------------------------
- /// Find a breakpoint location for a given breakpoint location ID.
- ///
- /// @param[in] bp_loc_id
- /// The ID specifying the location.
- /// @return
- /// Returns a shared pointer to the location with ID \a bp_loc_id. The pointer
- /// in the shared pointer will be nullptr if there is no location with that ID.
- //------------------------------------------------------------------
- lldb::BreakpointLocationSP
- FindLocationByID (lldb::break_id_t bp_loc_id);
-
- //------------------------------------------------------------------
- /// Get breakpoint locations by index.
- ///
- /// @param[in] index
- /// The location index.
- ///
- /// @return
- /// Returns a shared pointer to the location with index \a
- /// index. The shared pointer might contain nullptr if \a index is
- /// greater than then number of actual locations.
- //------------------------------------------------------------------
- lldb::BreakpointLocationSP
- GetLocationAtIndex (size_t index);
-
- //------------------------------------------------------------------
- /// Removes all invalid breakpoint locations.
- ///
- /// Removes all breakpoint locations with architectures that aren't
- /// compatible with \a arch. Also remove any breakpoint locations
- /// with whose locations have address where the section has been
- /// deleted (module and object files no longer exist).
- ///
- /// This is typically used after the process calls exec, or anytime
- /// the architecture of the target changes.
- ///
- /// @param[in] arch
- /// If valid, check the module in each breakpoint to make sure
- /// they are compatible, otherwise, ignore architecture.
- //------------------------------------------------------------------
- void
- RemoveInvalidLocations (const ArchSpec &arch);
-
- //------------------------------------------------------------------
- // The next section deals with various breakpoint options.
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// If \a enable is \b true, enable the breakpoint, if \b false disable it.
- //------------------------------------------------------------------
- void
- SetEnabled(bool enable) override;
-
- //------------------------------------------------------------------
- /// Check the Enable/Disable state.
- /// @return
- /// \b true if the breakpoint is enabled, \b false if disabled.
- //------------------------------------------------------------------
- bool
- IsEnabled() override;
-
- //------------------------------------------------------------------
- /// Set the breakpoint to ignore the next \a count breakpoint hits.
- /// @param[in] count
- /// The number of breakpoint hits to ignore.
- //------------------------------------------------------------------
- void
- SetIgnoreCount (uint32_t count);
-
- //------------------------------------------------------------------
- /// Return the current ignore count/
- /// @return
- /// The number of breakpoint hits to be ignored.
- //------------------------------------------------------------------
- uint32_t
- GetIgnoreCount () const;
-
- //------------------------------------------------------------------
- /// Return the current hit count for all locations.
- /// @return
- /// The current hit count for all locations.
- //------------------------------------------------------------------
- uint32_t
- GetHitCount () const;
-
- //------------------------------------------------------------------
- /// If \a one_shot is \b true, breakpoint will be deleted on first hit.
- //------------------------------------------------------------------
- void
- SetOneShot (bool one_shot);
-
- //------------------------------------------------------------------
- /// Check the OneShot state.
- /// @return
- /// \b true if the breakpoint is one shot, \b false otherwise.
- //------------------------------------------------------------------
- bool
- IsOneShot () const;
-
- //------------------------------------------------------------------
- /// Set the valid thread to be checked when the breakpoint is hit.
- /// @param[in] thread_id
- /// If this thread hits the breakpoint, we stop, otherwise not.
- //------------------------------------------------------------------
- void
- SetThreadID (lldb::tid_t thread_id);
-
- //------------------------------------------------------------------
- /// Return the current stop thread value.
- /// @return
- /// The thread id for which the breakpoint hit will stop, LLDB_INVALID_THREAD_ID for all threads.
- //------------------------------------------------------------------
- lldb::tid_t
- GetThreadID () const;
-
- void
- SetThreadIndex (uint32_t index);
-
- uint32_t
- GetThreadIndex() const;
-
- void
- SetThreadName (const char *thread_name);
-
- const char *
- GetThreadName () const;
-
- void
- SetQueueName (const char *queue_name);
-
- const char *
- GetQueueName () const;
-
- //------------------------------------------------------------------
- /// Set the callback action invoked when the breakpoint is hit.
- ///
- /// @param[in] callback
- /// The method that will get called when the breakpoint is hit.
- /// @param[in] baton
- /// A void * pointer that will get passed back to the callback function.
- /// @param[in] is_synchronous
- /// If \b true the callback will be run on the private event thread
- /// before the stop event gets reported. If false, the callback will get
- /// handled on the public event thread after the stop has been posted.
- ///
- /// @return
- /// \b true if the process should stop when you hit the breakpoint.
- /// \b false if it should continue.
- //------------------------------------------------------------------
- void
- SetCallback (BreakpointHitCallback callback,
- void *baton,
- bool is_synchronous = false);
-
- void
- SetCallback (BreakpointHitCallback callback,
- const lldb::BatonSP &callback_baton_sp,
- bool is_synchronous = false);
-
- void
- ClearCallback ();
-
- //------------------------------------------------------------------
- /// Set the breakpoint's condition.
- ///
- /// @param[in] condition
- /// The condition expression to evaluate when the breakpoint is hit.
- /// Pass in nullptr to clear the condition.
- //------------------------------------------------------------------
- void SetCondition (const char *condition);
-
- //------------------------------------------------------------------
- /// Return a pointer to the text of the condition expression.
- ///
- /// @return
- /// A pointer to the condition expression text, or nullptr if no
- // condition has been set.
- //------------------------------------------------------------------
- const char *GetConditionText () const;
-
- //------------------------------------------------------------------
- // The next section are various utility functions.
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Return the number of breakpoint locations that have resolved to
- /// actual breakpoint sites.
- ///
- /// @return
- /// The number locations resolved breakpoint sites.
- //------------------------------------------------------------------
- size_t
- GetNumResolvedLocations() const;
-
- //------------------------------------------------------------------
- /// Return the number of breakpoint locations.
- ///
- /// @return
- /// The number breakpoint locations.
- //------------------------------------------------------------------
- size_t
- GetNumLocations() const;
-
- //------------------------------------------------------------------
- /// Put a description of this breakpoint into the stream \a s.
- ///
- /// @param[in] s
- /// Stream into which to dump the description.
- ///
- /// @param[in] level
- /// The description level that indicates the detail level to
- /// provide.
- ///
- /// @see lldb::DescriptionLevel
- //------------------------------------------------------------------
- void
- GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_locations = false);
-
- //------------------------------------------------------------------
- /// Set the "kind" description for a breakpoint. If the breakpoint is hit
- /// the stop info will show this "kind" description instead of the breakpoint
- /// number. Mostly useful for internal breakpoints, where the breakpoint number
- /// doesn't have meaning to the user.
- ///
- /// @param[in] kind
- /// New "kind" description.
- //------------------------------------------------------------------
- void
- SetBreakpointKind (const char *kind)
- {
- m_kind_description.assign (kind);
- }
-
- //------------------------------------------------------------------
- /// Return the "kind" description for a breakpoint.
- ///
- /// @return
- /// The breakpoint kind, or nullptr if none is set.
- //------------------------------------------------------------------
- const char *GetBreakpointKind () const
- {
- return m_kind_description.c_str();
- }
+ static const ConstString &GetEventIdentifier();
- //------------------------------------------------------------------
- /// Accessor for the breakpoint Target.
- /// @return
- /// This breakpoint's Target.
- //------------------------------------------------------------------
- Target &
- GetTarget ()
- {
- return m_target;
- }
+ //------------------------------------------------------------------
+ /// An enum specifying the match style for breakpoint settings. At
+ /// present only used for function name style breakpoints.
+ //------------------------------------------------------------------
+ typedef enum { Exact, Regexp, Glob } MatchType;
- const Target &
- GetTarget () const
- {
- return m_target;
- }
+private:
+ enum class OptionNames : uint32_t { Names = 0, Hardware, LastOptionName };
- const lldb::TargetSP
- GetTargetSP ();
-
- void
- GetResolverDescription (Stream *s);
-
- //------------------------------------------------------------------
- /// Find breakpoint locations which match the (filename, line_number) description.
- /// The breakpoint location collection is to be filled with the matching locations.
- /// It should be initialized with 0 size by the API client.
- ///
- /// @return
- /// True if there is a match
- ///
- /// The locations which match the filename and line_number in loc_coll. If its
- /// size is 0 and true is returned, it means the breakpoint fully matches the
- /// description.
- //------------------------------------------------------------------
- bool GetMatchingFileLine(const ConstString &filename, uint32_t line_number,
- BreakpointLocationCollection &loc_coll);
-
- void
- GetFilterDescription (Stream *s);
-
- //------------------------------------------------------------------
- /// Returns the BreakpointOptions structure set at the breakpoint level.
- ///
- /// Meant to be used by the BreakpointLocation class.
- ///
- /// @return
- /// A pointer to this breakpoint's BreakpointOptions.
- //------------------------------------------------------------------
- BreakpointOptions *
- GetOptions ();
-
- //------------------------------------------------------------------
- /// Invoke the callback action when the breakpoint is hit.
- ///
- /// Meant to be used by the BreakpointLocation class.
- ///
- /// @param[in] context
- /// Described the breakpoint event.
- ///
- /// @param[in] bp_loc_id
- /// Which breakpoint location hit this breakpoint.
- ///
- /// @return
- /// \b true if the target should stop at this breakpoint and \b false not.
- //------------------------------------------------------------------
- bool
- InvokeCallback (StoppointCallbackContext *context,
- lldb::break_id_t bp_loc_id);
-
- bool
- IsHardware() const
- {
- return m_hardware;
- }
+ static const char
+ *g_option_names[static_cast<uint32_t>(OptionNames::LastOptionName)];
- lldb::BreakpointResolverSP
- GetResolver()
- {
- return m_resolver_sp;
- }
+ static const char *GetKey(OptionNames enum_value) {
+ return g_option_names[static_cast<uint32_t>(enum_value)];
+ }
- lldb::SearchFilterSP
- GetSearchFilter()
- {
- return m_filter_sp;
- }
+public:
+ class BreakpointEventData : public EventData {
+ public:
+ BreakpointEventData(lldb::BreakpointEventType sub_type,
+ const lldb::BreakpointSP &new_breakpoint_sp);
- bool
- AddName (const char *new_name, Error &error);
+ ~BreakpointEventData() override;
- void
- RemoveName (const char *name_to_remove)
- {
- if (name_to_remove)
- m_name_list.erase(name_to_remove);
- }
-
- bool
- MatchesName (const char *name)
- {
- return m_name_list.find(name) != m_name_list.end();
- }
+ static const ConstString &GetFlavorString();
- void
- GetNames (std::vector<std::string> &names)
- {
- names.clear();
- for (auto name : m_name_list)
- {
- names.push_back(name);
- }
- }
+ const ConstString &GetFlavor() const override;
- //------------------------------------------------------------------
- /// Set a pre-condition filter that overrides all user provided filters/callbacks etc.
- ///
- /// Used to define fancy breakpoints that can do dynamic hit detection without taking up the condition slot -
- /// which really belongs to the user anyway...
- ///
- /// The Precondition should not continue the target, it should return true if the condition says to stop and
- /// false otherwise.
- ///
- //------------------------------------------------------------------
- void
- SetPrecondition(BreakpointPreconditionSP precondition_sp)
- {
- m_precondition_sp = precondition_sp;
- }
+ lldb::BreakpointEventType GetBreakpointEventType() const;
- bool
- EvaluatePrecondition (StoppointCallbackContext &context);
+ lldb::BreakpointSP &GetBreakpoint();
- BreakpointPreconditionSP
- GetPrecondition()
- {
- return m_precondition_sp;
+ BreakpointLocationCollection &GetBreakpointLocationCollection() {
+ return m_locations;
}
-protected:
- friend class Target;
- //------------------------------------------------------------------
- // Protected Methods
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Constructors and Destructors
- /// Only the Target can make a breakpoint, and it owns the breakpoint lifespans.
- /// The constructor takes a filter and a resolver. Up in Target there are convenience
- /// variants that make breakpoints for some common cases.
- ///
- /// @param[in] target
- /// The target in which the breakpoint will be set.
- ///
- /// @param[in] filter_sp
- /// Shared pointer to the search filter that restricts the search domain of the breakpoint.
- ///
- /// @param[in] resolver_sp
- /// Shared pointer to the resolver object that will determine breakpoint matches.
- ///
- /// @param hardware
- /// If true, request a hardware breakpoint to be used to implement the breakpoint locations.
- ///
- /// @param resolve_indirect_symbols
- /// If true, and the address of a given breakpoint location in this breakpoint is set on an
- /// indirect symbol (i.e. Symbol::IsIndirect returns true) then the actual breakpoint site will
- /// be set on the target of the indirect symbol.
- //------------------------------------------------------------------
- // This is the generic constructor
- Breakpoint(Target &target,
- lldb::SearchFilterSP &filter_sp,
- lldb::BreakpointResolverSP &resolver_sp,
- bool hardware,
- bool resolve_indirect_symbols = true);
-
- friend class BreakpointLocation; // To call the following two when determining whether to stop.
-
- void
- DecrementIgnoreCount();
-
- // BreakpointLocation::IgnoreCountShouldStop & Breakpoint::IgnoreCountShouldStop can only be called once per stop,
- // and BreakpointLocation::IgnoreCountShouldStop should be tested first, and if it returns false we should
- // continue, otherwise we should test Breakpoint::IgnoreCountShouldStop.
-
- bool
- IgnoreCountShouldStop ();
-
- void
- IncrementHitCount()
- {
- m_hit_count++;
+ void Dump(Stream *s) const override;
+
+ static lldb::BreakpointEventType
+ GetBreakpointEventTypeFromEvent(const lldb::EventSP &event_sp);
+
+ static lldb::BreakpointSP
+ GetBreakpointFromEvent(const lldb::EventSP &event_sp);
+
+ static lldb::BreakpointLocationSP
+ GetBreakpointLocationAtIndexFromEvent(const lldb::EventSP &event_sp,
+ uint32_t loc_idx);
+
+ static size_t
+ GetNumBreakpointLocationsFromEvent(const lldb::EventSP &event_sp);
+
+ static const BreakpointEventData *
+ GetEventDataFromEvent(const Event *event_sp);
+
+ private:
+ lldb::BreakpointEventType m_breakpoint_event;
+ lldb::BreakpointSP m_new_breakpoint_sp;
+ BreakpointLocationCollection m_locations;
+
+ DISALLOW_COPY_AND_ASSIGN(BreakpointEventData);
+ };
+
+ class BreakpointPrecondition {
+ public:
+ virtual ~BreakpointPrecondition() = default;
+
+ virtual bool EvaluatePrecondition(StoppointCallbackContext &context);
+
+ virtual Error ConfigurePrecondition(Args &options);
+
+ virtual void GetDescription(Stream &stream, lldb::DescriptionLevel level);
+ };
+
+ typedef std::shared_ptr<BreakpointPrecondition> BreakpointPreconditionSP;
+
+ // Saving & restoring breakpoints:
+ static lldb::BreakpointSP CreateFromStructuredData(
+ Target &target, StructuredData::ObjectSP &data_object_sp, Error &error);
+
+ static bool
+ SerializedBreakpointMatchesNames(StructuredData::ObjectSP &bkpt_object_sp,
+ std::vector<std::string> &names);
+
+ virtual StructuredData::ObjectSP SerializeToStructuredData();
+
+ static const char *GetSerializationKey() { return "Breakpoint"; }
+ //------------------------------------------------------------------
+ /// Destructor.
+ ///
+ /// The destructor is not virtual since there should be no reason to subclass
+ /// breakpoints. The varieties of breakpoints are specified instead by
+ /// providing different resolvers & filters.
+ //------------------------------------------------------------------
+ ~Breakpoint() override;
+
+ //------------------------------------------------------------------
+ // Methods
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Tell whether this breakpoint is an "internal" breakpoint.
+ /// @return
+ /// Returns \b true if this is an internal breakpoint, \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsInternal() const;
+
+ //------------------------------------------------------------------
+ /// Standard "Dump" method. At present it does nothing.
+ //------------------------------------------------------------------
+ void Dump(Stream *s) override;
+
+ //------------------------------------------------------------------
+ // The next set of methods provide ways to tell the breakpoint to update
+ // it's location list - usually done when modules appear or disappear.
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Tell this breakpoint to clear all its breakpoint sites. Done
+ /// when the process holding the breakpoint sites is destroyed.
+ //------------------------------------------------------------------
+ void ClearAllBreakpointSites();
+
+ //------------------------------------------------------------------
+ /// Tell this breakpoint to scan it's target's module list and resolve any
+ /// new locations that match the breakpoint's specifications.
+ //------------------------------------------------------------------
+ void ResolveBreakpoint();
+
+ //------------------------------------------------------------------
+ /// Tell this breakpoint to scan a given module list and resolve any
+ /// new locations that match the breakpoint's specifications.
+ ///
+ /// @param[in] module_list
+ /// The list of modules to look in for new locations.
+ ///
+ /// @param[in] send_event
+ /// If \b true, send a breakpoint location added event for non-internal
+ /// breakpoints.
+ //------------------------------------------------------------------
+ void ResolveBreakpointInModules(ModuleList &module_list,
+ bool send_event = true);
+
+ //------------------------------------------------------------------
+ /// Tell this breakpoint to scan a given module list and resolve any
+ /// new locations that match the breakpoint's specifications.
+ ///
+ /// @param[in] changed_modules
+ /// The list of modules to look in for new locations.
+ ///
+ /// @param[in] new_locations
+ /// Fills new_locations with the new locations that were made.
+ //------------------------------------------------------------------
+ void ResolveBreakpointInModules(ModuleList &module_list,
+ BreakpointLocationCollection &new_locations);
+
+ //------------------------------------------------------------------
+ /// Like ResolveBreakpointInModules, but allows for "unload" events, in
+ /// which case we will remove any locations that are in modules that got
+ /// unloaded.
+ ///
+ /// @param[in] changedModules
+ /// The list of modules to look in for new locations.
+ /// @param[in] load_event
+ /// If \b true then the modules were loaded, if \b false, unloaded.
+ /// @param[in] delete_locations
+ /// If \b true then the modules were unloaded delete any locations in the
+ /// changed modules.
+ //------------------------------------------------------------------
+ void ModulesChanged(ModuleList &changed_modules, bool load_event,
+ bool delete_locations = false);
+
+ //------------------------------------------------------------------
+ /// Tells the breakpoint the old module \a old_module_sp has been
+ /// replaced by new_module_sp (usually because the underlying file has been
+ /// rebuilt, and the old version is gone.)
+ ///
+ /// @param[in] old_module_sp
+ /// The old module that is going away.
+ /// @param[in] new_module_sp
+ /// The new module that is replacing it.
+ //------------------------------------------------------------------
+ void ModuleReplaced(lldb::ModuleSP old_module_sp,
+ lldb::ModuleSP new_module_sp);
+
+ //------------------------------------------------------------------
+ // The next set of methods provide access to the breakpoint locations
+ // for this breakpoint.
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Add a location to the breakpoint's location list. This is only meant
+ /// to be called by the breakpoint's resolver. FIXME: how do I ensure that?
+ ///
+ /// @param[in] addr
+ /// The Address specifying the new location.
+ /// @param[out] new_location
+ /// Set to \b true if a new location was created, to \b false if there
+ /// already was a location at this Address.
+ /// @return
+ /// Returns a pointer to the new location.
+ //------------------------------------------------------------------
+ lldb::BreakpointLocationSP AddLocation(const Address &addr,
+ bool *new_location = nullptr);
+
+ //------------------------------------------------------------------
+ /// Find a breakpoint location by Address.
+ ///
+ /// @param[in] addr
+ /// The Address specifying the location.
+ /// @return
+ /// Returns a shared pointer to the location at \a addr. The pointer
+ /// in the shared pointer will be nullptr if there is no location at that
+ /// address.
+ //------------------------------------------------------------------
+ lldb::BreakpointLocationSP FindLocationByAddress(const Address &addr);
+
+ //------------------------------------------------------------------
+ /// Find a breakpoint location ID by Address.
+ ///
+ /// @param[in] addr
+ /// The Address specifying the location.
+ /// @return
+ /// Returns the UID of the location at \a addr, or \b LLDB_INVALID_ID if
+ /// there is no breakpoint location at that address.
+ //------------------------------------------------------------------
+ lldb::break_id_t FindLocationIDByAddress(const Address &addr);
+
+ //------------------------------------------------------------------
+ /// Find a breakpoint location for a given breakpoint location ID.
+ ///
+ /// @param[in] bp_loc_id
+ /// The ID specifying the location.
+ /// @return
+ /// Returns a shared pointer to the location with ID \a bp_loc_id. The
+ /// pointer
+ /// in the shared pointer will be nullptr if there is no location with that
+ /// ID.
+ //------------------------------------------------------------------
+ lldb::BreakpointLocationSP FindLocationByID(lldb::break_id_t bp_loc_id);
+
+ //------------------------------------------------------------------
+ /// Get breakpoint locations by index.
+ ///
+ /// @param[in] index
+ /// The location index.
+ ///
+ /// @return
+ /// Returns a shared pointer to the location with index \a
+ /// index. The shared pointer might contain nullptr if \a index is
+ /// greater than then number of actual locations.
+ //------------------------------------------------------------------
+ lldb::BreakpointLocationSP GetLocationAtIndex(size_t index);
+
+ //------------------------------------------------------------------
+ /// Removes all invalid breakpoint locations.
+ ///
+ /// Removes all breakpoint locations with architectures that aren't
+ /// compatible with \a arch. Also remove any breakpoint locations
+ /// with whose locations have address where the section has been
+ /// deleted (module and object files no longer exist).
+ ///
+ /// This is typically used after the process calls exec, or anytime
+ /// the architecture of the target changes.
+ ///
+ /// @param[in] arch
+ /// If valid, check the module in each breakpoint to make sure
+ /// they are compatible, otherwise, ignore architecture.
+ //------------------------------------------------------------------
+ void RemoveInvalidLocations(const ArchSpec &arch);
+
+ //------------------------------------------------------------------
+ // The next section deals with various breakpoint options.
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// If \a enable is \b true, enable the breakpoint, if \b false disable it.
+ //------------------------------------------------------------------
+ void SetEnabled(bool enable) override;
+
+ //------------------------------------------------------------------
+ /// Check the Enable/Disable state.
+ /// @return
+ /// \b true if the breakpoint is enabled, \b false if disabled.
+ //------------------------------------------------------------------
+ bool IsEnabled() override;
+
+ //------------------------------------------------------------------
+ /// Set the breakpoint to ignore the next \a count breakpoint hits.
+ /// @param[in] count
+ /// The number of breakpoint hits to ignore.
+ //------------------------------------------------------------------
+ void SetIgnoreCount(uint32_t count);
+
+ //------------------------------------------------------------------
+ /// Return the current ignore count/
+ /// @return
+ /// The number of breakpoint hits to be ignored.
+ //------------------------------------------------------------------
+ uint32_t GetIgnoreCount() const;
+
+ //------------------------------------------------------------------
+ /// Return the current hit count for all locations.
+ /// @return
+ /// The current hit count for all locations.
+ //------------------------------------------------------------------
+ uint32_t GetHitCount() const;
+
+ //------------------------------------------------------------------
+ /// If \a one_shot is \b true, breakpoint will be deleted on first hit.
+ //------------------------------------------------------------------
+ void SetOneShot(bool one_shot);
+
+ //------------------------------------------------------------------
+ /// Check the OneShot state.
+ /// @return
+ /// \b true if the breakpoint is one shot, \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsOneShot() const;
+
+ //------------------------------------------------------------------
+ /// Set the valid thread to be checked when the breakpoint is hit.
+ /// @param[in] thread_id
+ /// If this thread hits the breakpoint, we stop, otherwise not.
+ //------------------------------------------------------------------
+ void SetThreadID(lldb::tid_t thread_id);
+
+ //------------------------------------------------------------------
+ /// Return the current stop thread value.
+ /// @return
+ /// The thread id for which the breakpoint hit will stop,
+ /// LLDB_INVALID_THREAD_ID for all threads.
+ //------------------------------------------------------------------
+ lldb::tid_t GetThreadID() const;
+
+ void SetThreadIndex(uint32_t index);
+
+ uint32_t GetThreadIndex() const;
+
+ void SetThreadName(const char *thread_name);
+
+ const char *GetThreadName() const;
+
+ void SetQueueName(const char *queue_name);
+
+ const char *GetQueueName() const;
+
+ //------------------------------------------------------------------
+ /// Set the callback action invoked when the breakpoint is hit.
+ ///
+ /// @param[in] callback
+ /// The method that will get called when the breakpoint is hit.
+ /// @param[in] baton
+ /// A void * pointer that will get passed back to the callback function.
+ /// @param[in] is_synchronous
+ /// If \b true the callback will be run on the private event thread
+ /// before the stop event gets reported. If false, the callback will get
+ /// handled on the public event thread after the stop has been posted.
+ ///
+ /// @return
+ /// \b true if the process should stop when you hit the breakpoint.
+ /// \b false if it should continue.
+ //------------------------------------------------------------------
+ void SetCallback(BreakpointHitCallback callback, void *baton,
+ bool is_synchronous = false);
+
+ void SetCallback(BreakpointHitCallback callback,
+ const lldb::BatonSP &callback_baton_sp,
+ bool is_synchronous = false);
+
+ void ClearCallback();
+
+ //------------------------------------------------------------------
+ /// Set the breakpoint's condition.
+ ///
+ /// @param[in] condition
+ /// The condition expression to evaluate when the breakpoint is hit.
+ /// Pass in nullptr to clear the condition.
+ //------------------------------------------------------------------
+ void SetCondition(const char *condition);
+
+ //------------------------------------------------------------------
+ /// Return a pointer to the text of the condition expression.
+ ///
+ /// @return
+ /// A pointer to the condition expression text, or nullptr if no
+ // condition has been set.
+ //------------------------------------------------------------------
+ const char *GetConditionText() const;
+
+ //------------------------------------------------------------------
+ // The next section are various utility functions.
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Return the number of breakpoint locations that have resolved to
+ /// actual breakpoint sites.
+ ///
+ /// @return
+ /// The number locations resolved breakpoint sites.
+ //------------------------------------------------------------------
+ size_t GetNumResolvedLocations() const;
+
+ //------------------------------------------------------------------
+ /// Return the number of breakpoint locations.
+ ///
+ /// @return
+ /// The number breakpoint locations.
+ //------------------------------------------------------------------
+ size_t GetNumLocations() const;
+
+ //------------------------------------------------------------------
+ /// Put a description of this breakpoint into the stream \a s.
+ ///
+ /// @param[in] s
+ /// Stream into which to dump the description.
+ ///
+ /// @param[in] level
+ /// The description level that indicates the detail level to
+ /// provide.
+ ///
+ /// @see lldb::DescriptionLevel
+ //------------------------------------------------------------------
+ void GetDescription(Stream *s, lldb::DescriptionLevel level,
+ bool show_locations = false);
+
+ //------------------------------------------------------------------
+ /// Set the "kind" description for a breakpoint. If the breakpoint is hit
+ /// the stop info will show this "kind" description instead of the breakpoint
+ /// number. Mostly useful for internal breakpoints, where the breakpoint
+ /// number
+ /// doesn't have meaning to the user.
+ ///
+ /// @param[in] kind
+ /// New "kind" description.
+ //------------------------------------------------------------------
+ void SetBreakpointKind(const char *kind) { m_kind_description.assign(kind); }
+
+ //------------------------------------------------------------------
+ /// Return the "kind" description for a breakpoint.
+ ///
+ /// @return
+ /// The breakpoint kind, or nullptr if none is set.
+ //------------------------------------------------------------------
+ const char *GetBreakpointKind() const { return m_kind_description.c_str(); }
+
+ //------------------------------------------------------------------
+ /// Accessor for the breakpoint Target.
+ /// @return
+ /// This breakpoint's Target.
+ //------------------------------------------------------------------
+ Target &GetTarget() { return m_target; }
+
+ const Target &GetTarget() const { return m_target; }
+
+ const lldb::TargetSP GetTargetSP();
+
+ void GetResolverDescription(Stream *s);
+
+ //------------------------------------------------------------------
+ /// Find breakpoint locations which match the (filename, line_number)
+ /// description.
+ /// The breakpoint location collection is to be filled with the matching
+ /// locations.
+ /// It should be initialized with 0 size by the API client.
+ ///
+ /// @return
+ /// True if there is a match
+ ///
+ /// The locations which match the filename and line_number in loc_coll.
+ /// If its
+ /// size is 0 and true is returned, it means the breakpoint fully matches
+ /// the
+ /// description.
+ //------------------------------------------------------------------
+ bool GetMatchingFileLine(const ConstString &filename, uint32_t line_number,
+ BreakpointLocationCollection &loc_coll);
+
+ void GetFilterDescription(Stream *s);
+
+ //------------------------------------------------------------------
+ /// Returns the BreakpointOptions structure set at the breakpoint level.
+ ///
+ /// Meant to be used by the BreakpointLocation class.
+ ///
+ /// @return
+ /// A pointer to this breakpoint's BreakpointOptions.
+ //------------------------------------------------------------------
+ BreakpointOptions *GetOptions();
+
+ //------------------------------------------------------------------
+ /// Invoke the callback action when the breakpoint is hit.
+ ///
+ /// Meant to be used by the BreakpointLocation class.
+ ///
+ /// @param[in] context
+ /// Described the breakpoint event.
+ ///
+ /// @param[in] bp_loc_id
+ /// Which breakpoint location hit this breakpoint.
+ ///
+ /// @return
+ /// \b true if the target should stop at this breakpoint and \b false not.
+ //------------------------------------------------------------------
+ bool InvokeCallback(StoppointCallbackContext *context,
+ lldb::break_id_t bp_loc_id);
+
+ bool IsHardware() const { return m_hardware; }
+
+ lldb::BreakpointResolverSP GetResolver() { return m_resolver_sp; }
+
+ lldb::SearchFilterSP GetSearchFilter() { return m_filter_sp; }
+
+ bool AddName(const char *new_name, Error &error);
+
+ void RemoveName(const char *name_to_remove) {
+ if (name_to_remove)
+ m_name_list.erase(name_to_remove);
+ }
+
+ bool MatchesName(const char *name) {
+ return m_name_list.find(name) != m_name_list.end();
+ }
+
+ void GetNames(std::vector<std::string> &names) {
+ names.clear();
+ for (auto name : m_name_list) {
+ names.push_back(name);
}
+ }
+
+ //------------------------------------------------------------------
+ /// Set a pre-condition filter that overrides all user provided
+ /// filters/callbacks etc.
+ ///
+ /// Used to define fancy breakpoints that can do dynamic hit detection without
+ /// taking up the condition slot -
+ /// which really belongs to the user anyway...
+ ///
+ /// The Precondition should not continue the target, it should return true if
+ /// the condition says to stop and
+ /// false otherwise.
+ ///
+ //------------------------------------------------------------------
+ void SetPrecondition(BreakpointPreconditionSP precondition_sp) {
+ m_precondition_sp = precondition_sp;
+ }
+
+ bool EvaluatePrecondition(StoppointCallbackContext &context);
+
+ BreakpointPreconditionSP GetPrecondition() { return m_precondition_sp; }
- void
- DecrementHitCount()
- {
- assert (m_hit_count > 0);
- m_hit_count--;
- }
+protected:
+ friend class Target;
+ //------------------------------------------------------------------
+ // Protected Methods
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Constructors and Destructors
+ /// Only the Target can make a breakpoint, and it owns the breakpoint
+ /// lifespans.
+ /// The constructor takes a filter and a resolver. Up in Target there are
+ /// convenience
+ /// variants that make breakpoints for some common cases.
+ ///
+ /// @param[in] target
+ /// The target in which the breakpoint will be set.
+ ///
+ /// @param[in] filter_sp
+ /// Shared pointer to the search filter that restricts the search domain of
+ /// the breakpoint.
+ ///
+ /// @param[in] resolver_sp
+ /// Shared pointer to the resolver object that will determine breakpoint
+ /// matches.
+ ///
+ /// @param hardware
+ /// If true, request a hardware breakpoint to be used to implement the
+ /// breakpoint locations.
+ ///
+ /// @param resolve_indirect_symbols
+ /// If true, and the address of a given breakpoint location in this
+ /// breakpoint is set on an
+ /// indirect symbol (i.e. Symbol::IsIndirect returns true) then the actual
+ /// breakpoint site will
+ /// be set on the target of the indirect symbol.
+ //------------------------------------------------------------------
+ // This is the generic constructor
+ Breakpoint(Target &target, lldb::SearchFilterSP &filter_sp,
+ lldb::BreakpointResolverSP &resolver_sp, bool hardware,
+ bool resolve_indirect_symbols = true);
+
+ friend class BreakpointLocation; // To call the following two when determining
+ // whether to stop.
+
+ void DecrementIgnoreCount();
+
+ // BreakpointLocation::IgnoreCountShouldStop &
+ // Breakpoint::IgnoreCountShouldStop can only be called once per stop,
+ // and BreakpointLocation::IgnoreCountShouldStop should be tested first, and
+ // if it returns false we should
+ // continue, otherwise we should test Breakpoint::IgnoreCountShouldStop.
+
+ bool IgnoreCountShouldStop();
+
+ void IncrementHitCount() { m_hit_count++; }
+
+ void DecrementHitCount() {
+ assert(m_hit_count > 0);
+ m_hit_count--;
+ }
private:
- // This one should only be used by Target to copy breakpoints from target to target - primarily from the dummy
- // target to prime new targets.
- Breakpoint (Target &new_target,
- Breakpoint &bp_to_copy_from);
-
- //------------------------------------------------------------------
- // For Breakpoint only
- //------------------------------------------------------------------
- bool m_being_created;
- bool m_hardware; // If this breakpoint is required to use a hardware breakpoint
- Target &m_target; // The target that holds this breakpoint.
- std::unordered_set<std::string> m_name_list; // If not empty, this is the name of this breakpoint (many breakpoints can share the same name.)
- lldb::SearchFilterSP m_filter_sp; // The filter that constrains the breakpoint's domain.
- lldb::BreakpointResolverSP m_resolver_sp; // The resolver that defines this breakpoint.
- BreakpointPreconditionSP m_precondition_sp; // The precondition is a breakpoint-level hit filter that can be used
- // to skip certain breakpoint hits. For instance, exception breakpoints
- // use this to limit the stop to certain exception classes, while leaving
- // the condition & callback free for user specification.
- BreakpointOptions m_options; // Settable breakpoint options
- BreakpointLocationList m_locations; // The list of locations currently found for this breakpoint.
- std::string m_kind_description;
- bool m_resolve_indirect_symbols;
- uint32_t m_hit_count; // Number of times this breakpoint/watchpoint has been hit. This is kept
- // separately from the locations hit counts, since locations can go away when
- // their backing library gets unloaded, and we would lose hit counts.
-
- void
- SendBreakpointChangedEvent (lldb::BreakpointEventType eventKind);
-
- void
- SendBreakpointChangedEvent (BreakpointEventData *data);
-
- DISALLOW_COPY_AND_ASSIGN(Breakpoint);
+ // This one should only be used by Target to copy breakpoints from target to
+ // target - primarily from the dummy
+ // target to prime new targets.
+ Breakpoint(Target &new_target, Breakpoint &bp_to_copy_from);
+
+ //------------------------------------------------------------------
+ // For Breakpoint only
+ //------------------------------------------------------------------
+ bool m_being_created;
+ bool
+ m_hardware; // If this breakpoint is required to use a hardware breakpoint
+ Target &m_target; // The target that holds this breakpoint.
+ std::unordered_set<std::string> m_name_list; // If not empty, this is the name
+ // of this breakpoint (many
+ // breakpoints can share the same
+ // name.)
+ lldb::SearchFilterSP
+ m_filter_sp; // The filter that constrains the breakpoint's domain.
+ lldb::BreakpointResolverSP
+ m_resolver_sp; // The resolver that defines this breakpoint.
+ BreakpointPreconditionSP m_precondition_sp; // The precondition is a
+ // breakpoint-level hit filter
+ // that can be used
+ // to skip certain breakpoint hits. For instance, exception breakpoints
+ // use this to limit the stop to certain exception classes, while leaving
+ // the condition & callback free for user specification.
+ std::unique_ptr<BreakpointOptions>
+ m_options_up; // Settable breakpoint options
+ BreakpointLocationList
+ m_locations; // The list of locations currently found for this breakpoint.
+ std::string m_kind_description;
+ bool m_resolve_indirect_symbols;
+ uint32_t m_hit_count; // Number of times this breakpoint/watchpoint has been
+ // hit. This is kept
+ // separately from the locations hit counts, since locations can go away when
+ // their backing library gets unloaded, and we would lose hit counts.
+
+ void SendBreakpointChangedEvent(lldb::BreakpointEventType eventKind);
+
+ void SendBreakpointChangedEvent(BreakpointEventData *data);
+
+ DISALLOW_COPY_AND_ASSIGN(Breakpoint);
};
} // namespace lldb_private
diff --git a/include/lldb/Breakpoint/BreakpointID.h b/include/lldb/Breakpoint/BreakpointID.h
index 5ca09634ee09..aa4add4cd665 100644
--- a/include/lldb/Breakpoint/BreakpointID.h
+++ b/include/lldb/Breakpoint/BreakpointID.h
@@ -17,116 +17,95 @@
#include "lldb/lldb-private.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
+
namespace lldb_private {
//----------------------------------------------------------------------
// class BreakpointID
//----------------------------------------------------------------------
-class BreakpointID
-{
+class BreakpointID {
public:
-
- BreakpointID (lldb::break_id_t bp_id = LLDB_INVALID_BREAK_ID,
- lldb::break_id_t loc_id = LLDB_INVALID_BREAK_ID);
-
- virtual
- ~BreakpointID ();
-
- lldb::break_id_t
- GetBreakpointID ()
- {
- return m_break_id;
- }
-
- lldb::break_id_t
- GetLocationID ()
- {
- return m_location_id;
- }
-
- void
- SetID (lldb::break_id_t bp_id, lldb::break_id_t loc_id)
- {
- m_break_id = bp_id;
- m_location_id = loc_id;
- }
-
- void
- SetBreakpointID (lldb::break_id_t bp_id)
- {
- m_break_id = bp_id;
- }
-
- void
- SetBreakpointLocationID (lldb::break_id_t loc_id)
- {
- m_location_id = loc_id;
- }
-
- void
- GetDescription (Stream *s, lldb::DescriptionLevel level);
-
- static bool
- IsRangeIdentifier (const char *str);
-
- static bool
- IsValidIDExpression (const char *str);
-
- static const char *g_range_specifiers[];
-
- //------------------------------------------------------------------
- /// Takes an input string containing the description of a breakpoint or breakpoint and location
- /// and returns the breakpoint ID and the breakpoint location id.
- ///
- /// @param[in] input
- /// A string containing JUST the breakpoint description.
- /// @param[out] break_id
- /// This is the break id.
- /// @param[out] break_loc_id
- /// This is breakpoint location id, or LLDB_INVALID_BREAK_ID is no location was specified.
- /// @return
- /// \b true if the call was able to extract a breakpoint location from the string. \b false otherwise.
- //------------------------------------------------------------------
- static bool
- ParseCanonicalReference (const char *input, lldb::break_id_t *break_id, lldb::break_id_t *break_loc_id);
-
-
- //------------------------------------------------------------------
- /// Takes an input string and checks to see whether it is a breakpoint name.
- /// If it is a mal-formed breakpoint name, error will be set to an appropriate
- /// error string.
- ///
- /// @param[in] input
- /// A string containing JUST the breakpoint description.
- /// @param[out] error
- /// If the name is a well-formed breakpoint name, set to success, otherwise set to an error.
- /// @return
- /// \b true if the name is a breakpoint name (as opposed to an ID or range) false otherwise.
- //------------------------------------------------------------------
- static bool
- StringIsBreakpointName (const char *name, Error &error);
-
- //------------------------------------------------------------------
- /// Takes a breakpoint ID and the breakpoint location id and returns
- /// a string containing the canonical description for the breakpoint
- /// or breakpoint location.
- ///
- /// @param[out] break_id
- /// This is the break id.
- ///
- /// @param[out] break_loc_id
- /// This is breakpoint location id, or LLDB_INVALID_BREAK_ID is no
- /// location is to be specified.
- //------------------------------------------------------------------
- static void
- GetCanonicalReference (Stream *s, lldb::break_id_t break_id, lldb::break_id_t break_loc_id);
+ BreakpointID(lldb::break_id_t bp_id = LLDB_INVALID_BREAK_ID,
+ lldb::break_id_t loc_id = LLDB_INVALID_BREAK_ID);
+
+ virtual ~BreakpointID();
+
+ lldb::break_id_t GetBreakpointID() const { return m_break_id; }
+
+ lldb::break_id_t GetLocationID() const { return m_location_id; }
+
+ void SetID(lldb::break_id_t bp_id, lldb::break_id_t loc_id) {
+ m_break_id = bp_id;
+ m_location_id = loc_id;
+ }
+
+ void SetBreakpointID(lldb::break_id_t bp_id) { m_break_id = bp_id; }
+
+ void SetBreakpointLocationID(lldb::break_id_t loc_id) {
+ m_location_id = loc_id;
+ }
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level);
+
+ static bool IsRangeIdentifier(llvm::StringRef str);
+ static bool IsValidIDExpression(llvm::StringRef str);
+ static llvm::ArrayRef<llvm::StringRef> GetRangeSpecifiers();
+
+ //------------------------------------------------------------------
+ /// Takes an input string containing the description of a breakpoint or
+ /// breakpoint and location and returns the a BreakpointID filled out with
+ /// the proper id and location.
+ ///
+ /// @param[in] input
+ /// A string containing JUST the breakpoint description.
+ /// @return
+ /// If \p input was not a valid breakpoint ID string, returns
+ /// \b llvm::None. Otherwise returns a BreakpointID with members filled
+ /// out accordingly.
+ //------------------------------------------------------------------
+ static llvm::Optional<BreakpointID>
+ ParseCanonicalReference(llvm::StringRef input);
+
+ //------------------------------------------------------------------
+ /// Takes an input string and checks to see whether it is a breakpoint name.
+ /// If it is a mal-formed breakpoint name, error will be set to an appropriate
+ /// error string.
+ ///
+ /// @param[in] input
+ /// A string containing JUST the breakpoint description.
+ /// @param[out] error
+ /// If the name is a well-formed breakpoint name, set to success,
+ /// otherwise set to an error.
+ /// @return
+ /// \b true if the name is a breakpoint name (as opposed to an ID or
+ /// range) false otherwise.
+ //------------------------------------------------------------------
+ static bool StringIsBreakpointName(llvm::StringRef str, Error &error);
+
+ //------------------------------------------------------------------
+ /// Takes a breakpoint ID and the breakpoint location id and returns
+ /// a string containing the canonical description for the breakpoint
+ /// or breakpoint location.
+ ///
+ /// @param[out] break_id
+ /// This is the break id.
+ ///
+ /// @param[out] break_loc_id
+ /// This is breakpoint location id, or LLDB_INVALID_BREAK_ID is no
+ /// location is to be specified.
+ //------------------------------------------------------------------
+ static void GetCanonicalReference(Stream *s, lldb::break_id_t break_id,
+ lldb::break_id_t break_loc_id);
protected:
- lldb::break_id_t m_break_id;
- lldb::break_id_t m_location_id;
+ lldb::break_id_t m_break_id;
+ lldb::break_id_t m_location_id;
};
} // namespace lldb_private
-#endif // liblldb_BreakpointID_h_
+#endif // liblldb_BreakpointID_h_
diff --git a/include/lldb/Breakpoint/BreakpointIDList.h b/include/lldb/Breakpoint/BreakpointIDList.h
index c42787066617..34cfbfe3268d 100644
--- a/include/lldb/Breakpoint/BreakpointIDList.h
+++ b/include/lldb/Breakpoint/BreakpointIDList.h
@@ -12,13 +12,14 @@
// C Includes
// C++ Includes
+#include <utility>
#include <vector>
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Breakpoint/BreakpointID.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -26,57 +27,53 @@ namespace lldb_private {
// class BreakpointIDList
//----------------------------------------------------------------------
-
-class BreakpointIDList
-{
+class BreakpointIDList {
public:
- typedef std::vector<BreakpointID> BreakpointIDArray;
+ // TODO: Convert this class to StringRef.
+ typedef std::vector<BreakpointID> BreakpointIDArray;
- BreakpointIDList ();
+ BreakpointIDList();
- virtual
- ~BreakpointIDList ();
+ virtual ~BreakpointIDList();
- size_t
- GetSize();
+ size_t GetSize() const;
- BreakpointID &
- GetBreakpointIDAtIndex (size_t index);
+ const BreakpointID &GetBreakpointIDAtIndex(size_t index) const;
- bool
- RemoveBreakpointIDAtIndex (size_t index);
+ bool RemoveBreakpointIDAtIndex(size_t index);
- void
- Clear();
+ void Clear();
- bool
- AddBreakpointID (BreakpointID bp_id);
+ bool AddBreakpointID(BreakpointID bp_id);
- bool
- AddBreakpointID (const char *bp_id);
+ bool AddBreakpointID(const char *bp_id);
- bool
- FindBreakpointID (BreakpointID &bp_id, size_t *position);
+ // TODO: This should take a const BreakpointID.
+ bool FindBreakpointID(BreakpointID &bp_id, size_t *position) const;
- bool
- FindBreakpointID (const char *bp_id, size_t *position);
+ bool FindBreakpointID(const char *bp_id, size_t *position) const;
- void
- InsertStringArray (const char **string_array, size_t array_size, CommandReturnObject &result);
+ void InsertStringArray(const char **string_array, size_t array_size,
+ CommandReturnObject &result);
- static bool
- StringContainsIDRangeExpression (const char *in_string, size_t *range_start_len, size_t *range_end_pos);
+ // Returns a pair consisting of the beginning and end of a breakpoint
+ // ID range expression. If the input string is not a valid specification,
+ // returns an empty pair.
+ static std::pair<llvm::StringRef, llvm::StringRef>
+ SplitIDRangeExpression(llvm::StringRef in_string);
- static void
- FindAndReplaceIDRanges (Args &old_args, Target *target, bool allow_locations, CommandReturnObject &result, Args &new_args);
+ static void FindAndReplaceIDRanges(Args &old_args, Target *target,
+ bool allow_locations,
+ CommandReturnObject &result,
+ Args &new_args);
private:
- BreakpointIDArray m_breakpoint_ids;
- BreakpointID m_invalid_id;
+ BreakpointIDArray m_breakpoint_ids;
+ BreakpointID m_invalid_id;
- DISALLOW_COPY_AND_ASSIGN(BreakpointIDList);
+ DISALLOW_COPY_AND_ASSIGN(BreakpointIDList);
};
} // namespace lldb_private
-#endif // liblldb_BreakpointIDList_h_
+#endif // liblldb_BreakpointIDList_h_
diff --git a/include/lldb/Breakpoint/BreakpointList.h b/include/lldb/Breakpoint/BreakpointList.h
index 5ddde7d837c4..2865288acc59 100644
--- a/include/lldb/Breakpoint/BreakpointList.h
+++ b/include/lldb/Breakpoint/BreakpointList.h
@@ -31,204 +31,192 @@ namespace lldb_private {
/// Allows adding and removing breakpoints and find by ID and index.
//----------------------------------------------------------------------
-class BreakpointList
-{
+class BreakpointList {
public:
- BreakpointList (bool is_internal);
-
- ~BreakpointList();
-
- //------------------------------------------------------------------
- /// Add the breakpoint \a bp_sp to the list.
- ///
- /// @param[in] bp_sp
- /// Shared pointer to the breakpoint that will get added to the list.
- ///
- /// @result
- /// Returns breakpoint id.
- //------------------------------------------------------------------
- lldb::break_id_t
- Add (lldb::BreakpointSP& bp_sp, bool notify);
-
- //------------------------------------------------------------------
- /// Standard "Dump" method. At present it does nothing.
- //------------------------------------------------------------------
- void
- Dump (Stream *s) const;
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint with id \a breakID.
- ///
- /// @param[in] breakID
- /// The breakpoint ID to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a NULL pointer if the
- /// breakpoint doesn't exist.
- //------------------------------------------------------------------
- lldb::BreakpointSP
- FindBreakpointByID (lldb::break_id_t breakID);
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint with id \a breakID. Const version.
- ///
- /// @param[in] breakID
- /// The breakpoint ID to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a NULL pointer if the
- /// breakpoint doesn't exist.
- //------------------------------------------------------------------
- const lldb::BreakpointSP
- FindBreakpointByID (lldb::break_id_t breakID) const;
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint with index \a i.
- ///
- /// @param[in] i
- /// The breakpoint index to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a NULL pointer if the
- /// breakpoint doesn't exist.
- //------------------------------------------------------------------
- lldb::BreakpointSP
- GetBreakpointAtIndex (size_t i);
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint with index \a i, const version
- ///
- /// @param[in] i
- /// The breakpoint index to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a NULL pointer if the
- /// breakpoint doesn't exist.
- //------------------------------------------------------------------
- const lldb::BreakpointSP
- GetBreakpointAtIndex (size_t i) const;
-
- //------------------------------------------------------------------
- /// Returns the number of elements in this breakpoint list.
- ///
- /// @result
- /// The number of elements.
- //------------------------------------------------------------------
- size_t
- GetSize() const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_breakpoints.size();
- }
-
- //------------------------------------------------------------------
- /// Removes the breakpoint given by \b breakID from this list.
- ///
- /// @param[in] breakID
- /// The breakpoint index to remove.
- ///
- /// @result
- /// \b true if the breakpoint \a breakID was in the list.
- //------------------------------------------------------------------
- bool
- Remove (lldb::break_id_t breakID, bool notify);
-
-
- //------------------------------------------------------------------
- /// Removes all invalid breakpoint locations.
- ///
- /// Removes all breakpoint locations in the list with architectures
- /// that aren't compatible with \a arch. Also remove any breakpoint
- /// locations with whose locations have address where the section
- /// has been deleted (module and object files no longer exist).
- ///
- /// This is typically used after the process calls exec, or anytime
- /// the architecture of the target changes.
- ///
- /// @param[in] arch
- /// If valid, check the module in each breakpoint to make sure
- /// they are compatible, otherwise, ignore architecture.
- //------------------------------------------------------------------
- void
- RemoveInvalidLocations (const ArchSpec &arch);
-
- void
- SetEnabledAll (bool enabled);
-
- //------------------------------------------------------------------
- /// Removes all the breakpoints from this list.
- //------------------------------------------------------------------
- void
- RemoveAll (bool notify);
-
- //------------------------------------------------------------------
- /// Tell all the breakpoints to update themselves due to a change in the
- /// modules in \a module_list. \a added says whether the module was loaded
- /// or unloaded.
- ///
- /// @param[in] module_list
- /// The module list that has changed.
- ///
- /// @param[in] load
- /// \b true if the modules are loaded, \b false if unloaded.
- ///
- /// @param[in] delete_locations
- /// If \a load is \b false, then delete breakpoint locations when
- /// when updating breakpoints.
- //------------------------------------------------------------------
- void
- UpdateBreakpoints (ModuleList &module_list,
- bool load,
- bool delete_locations);
-
- void
- UpdateBreakpointsWhenModuleIsReplaced (lldb::ModuleSP old_module_sp, lldb::ModuleSP new_module_sp);
-
- void
- ClearAllBreakpointSites ();
-
- //------------------------------------------------------------------
- /// Sets the passed in Locker to hold the Breakpoint List mutex.
- ///
- /// @param[in] locker
- /// The locker object that is set.
- //------------------------------------------------------------------
- void
- GetListMutex(std::unique_lock<std::recursive_mutex> &lock);
+ BreakpointList(bool is_internal);
+
+ ~BreakpointList();
+
+ //------------------------------------------------------------------
+ /// Add the breakpoint \a bp_sp to the list.
+ ///
+ /// @param[in] bp_sp
+ /// Shared pointer to the breakpoint that will get added to the list.
+ ///
+ /// @result
+ /// Returns breakpoint id.
+ //------------------------------------------------------------------
+ lldb::break_id_t Add(lldb::BreakpointSP &bp_sp, bool notify);
+
+ //------------------------------------------------------------------
+ /// Standard "Dump" method. At present it does nothing.
+ //------------------------------------------------------------------
+ void Dump(Stream *s) const;
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint with id \a breakID.
+ ///
+ /// @param[in] breakID
+ /// The breakpoint ID to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a NULL pointer if the
+ /// breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ lldb::BreakpointSP FindBreakpointByID(lldb::break_id_t breakID);
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint with id \a breakID. Const
+ /// version.
+ ///
+ /// @param[in] breakID
+ /// The breakpoint ID to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a NULL pointer if the
+ /// breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ const lldb::BreakpointSP FindBreakpointByID(lldb::break_id_t breakID) const;
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint with index \a i.
+ ///
+ /// @param[in] i
+ /// The breakpoint index to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a NULL pointer if the
+ /// breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ lldb::BreakpointSP GetBreakpointAtIndex(size_t i);
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint with index \a i, const version
+ ///
+ /// @param[in] i
+ /// The breakpoint index to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a NULL pointer if the
+ /// breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ const lldb::BreakpointSP GetBreakpointAtIndex(size_t i) const;
+
+ //------------------------------------------------------------------
+ /// Find all the breakpoints with a given name
+ ///
+ /// @param[in] name
+ /// The breakpoint name for which to search.
+ ///
+ /// @result
+ /// \bfalse if the input name was not a legal breakpoint name.
+ //------------------------------------------------------------------
+ bool FindBreakpointsByName(const char *name, BreakpointList &matching_bps);
+
+ //------------------------------------------------------------------
+ /// Returns the number of elements in this breakpoint list.
+ ///
+ /// @result
+ /// The number of elements.
+ //------------------------------------------------------------------
+ size_t GetSize() const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_breakpoints.size();
+ }
+
+ //------------------------------------------------------------------
+ /// Removes the breakpoint given by \b breakID from this list.
+ ///
+ /// @param[in] breakID
+ /// The breakpoint index to remove.
+ ///
+ /// @result
+ /// \b true if the breakpoint \a breakID was in the list.
+ //------------------------------------------------------------------
+ bool Remove(lldb::break_id_t breakID, bool notify);
+
+ //------------------------------------------------------------------
+ /// Removes all invalid breakpoint locations.
+ ///
+ /// Removes all breakpoint locations in the list with architectures
+ /// that aren't compatible with \a arch. Also remove any breakpoint
+ /// locations with whose locations have address where the section
+ /// has been deleted (module and object files no longer exist).
+ ///
+ /// This is typically used after the process calls exec, or anytime
+ /// the architecture of the target changes.
+ ///
+ /// @param[in] arch
+ /// If valid, check the module in each breakpoint to make sure
+ /// they are compatible, otherwise, ignore architecture.
+ //------------------------------------------------------------------
+ void RemoveInvalidLocations(const ArchSpec &arch);
+
+ void SetEnabledAll(bool enabled);
+
+ //------------------------------------------------------------------
+ /// Removes all the breakpoints from this list.
+ //------------------------------------------------------------------
+ void RemoveAll(bool notify);
+
+ //------------------------------------------------------------------
+ /// Tell all the breakpoints to update themselves due to a change in the
+ /// modules in \a module_list. \a added says whether the module was loaded
+ /// or unloaded.
+ ///
+ /// @param[in] module_list
+ /// The module list that has changed.
+ ///
+ /// @param[in] load
+ /// \b true if the modules are loaded, \b false if unloaded.
+ ///
+ /// @param[in] delete_locations
+ /// If \a load is \b false, then delete breakpoint locations when
+ /// when updating breakpoints.
+ //------------------------------------------------------------------
+ void UpdateBreakpoints(ModuleList &module_list, bool load,
+ bool delete_locations);
+
+ void UpdateBreakpointsWhenModuleIsReplaced(lldb::ModuleSP old_module_sp,
+ lldb::ModuleSP new_module_sp);
+
+ void ClearAllBreakpointSites();
+
+ //------------------------------------------------------------------
+ /// Sets the passed in Locker to hold the Breakpoint List mutex.
+ ///
+ /// @param[in] locker
+ /// The locker object that is set.
+ //------------------------------------------------------------------
+ void GetListMutex(std::unique_lock<std::recursive_mutex> &lock);
protected:
- typedef std::list<lldb::BreakpointSP> bp_collection;
+ typedef std::list<lldb::BreakpointSP> bp_collection;
- bp_collection::iterator
- GetBreakpointIDIterator(lldb::break_id_t breakID);
+ bp_collection::iterator GetBreakpointIDIterator(lldb::break_id_t breakID);
- bp_collection::const_iterator
- GetBreakpointIDConstIterator(lldb::break_id_t breakID) const;
+ bp_collection::const_iterator
+ GetBreakpointIDConstIterator(lldb::break_id_t breakID) const;
- std::recursive_mutex &
- GetMutex() const
- {
- return m_mutex;
- }
+ std::recursive_mutex &GetMutex() const { return m_mutex; }
- mutable std::recursive_mutex m_mutex;
- bp_collection m_breakpoints; // The breakpoint list, currently a list.
- lldb::break_id_t m_next_break_id;
- bool m_is_internal;
+ mutable std::recursive_mutex m_mutex;
+ bp_collection m_breakpoints; // The breakpoint list, currently a list.
+ lldb::break_id_t m_next_break_id;
+ bool m_is_internal;
public:
- typedef LockingAdaptedIterable<bp_collection, lldb::BreakpointSP, list_adapter, std::recursive_mutex>
- BreakpointIterable;
- BreakpointIterable
- Breakpoints()
- {
- return BreakpointIterable(m_breakpoints, GetMutex());
- }
+ typedef LockingAdaptedIterable<bp_collection, lldb::BreakpointSP,
+ list_adapter, std::recursive_mutex>
+ BreakpointIterable;
+ BreakpointIterable Breakpoints() {
+ return BreakpointIterable(m_breakpoints, GetMutex());
+ }
private:
- DISALLOW_COPY_AND_ASSIGN (BreakpointList);
+ DISALLOW_COPY_AND_ASSIGN(BreakpointList);
};
} // namespace lldb_private
-#endif // liblldb_BreakpointList_h_
+#endif // liblldb_BreakpointList_h_
diff --git a/include/lldb/Breakpoint/BreakpointLocation.h b/include/lldb/Breakpoint/BreakpointLocation.h
index 42eca73dbb22..43aef9fc6a27 100644
--- a/include/lldb/Breakpoint/BreakpointLocation.h
+++ b/include/lldb/Breakpoint/BreakpointLocation.h
@@ -17,16 +17,18 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Breakpoint/StoppointLocation.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/UserID.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class BreakpointLocation BreakpointLocation.h "lldb/Breakpoint/BreakpointLocation.h"
-/// @brief Class that manages one unique (by address) instance of a logical breakpoint.
+/// @class BreakpointLocation BreakpointLocation.h
+/// "lldb/Breakpoint/BreakpointLocation.h"
+/// @brief Class that manages one unique (by address) instance of a logical
+/// breakpoint.
//----------------------------------------------------------------------
//----------------------------------------------------------------------
@@ -42,438 +44,384 @@ namespace lldb_private {
/// would be useful if you've set options on the locations.
//----------------------------------------------------------------------
-class BreakpointLocation :
- public std::enable_shared_from_this<BreakpointLocation>,
- public StoppointLocation
-{
+class BreakpointLocation
+ : public std::enable_shared_from_this<BreakpointLocation>,
+ public StoppointLocation {
public:
- ~BreakpointLocation() override;
-
- //------------------------------------------------------------------
- /// Gets the load address for this breakpoint location
- /// @return
- /// Returns breakpoint location load address, \b
- /// LLDB_INVALID_ADDRESS if not yet set.
- //------------------------------------------------------------------
- lldb::addr_t
- GetLoadAddress() const override;
-
- //------------------------------------------------------------------
- /// Gets the Address for this breakpoint location
- /// @return
- /// Returns breakpoint location Address.
- //------------------------------------------------------------------
- Address &
- GetAddress ();
- //------------------------------------------------------------------
- /// Gets the Breakpoint that created this breakpoint location
- /// @return
- /// Returns the owning breakpoint.
- //------------------------------------------------------------------
- Breakpoint &
- GetBreakpoint ();
-
- Target &
- GetTarget();
-
- //------------------------------------------------------------------
- /// Determines whether we should stop due to a hit at this
- /// breakpoint location.
- ///
- /// Side Effects: This may evaluate the breakpoint condition, and
- /// run the callback. So this command may do a considerable amount
- /// of work.
- ///
- /// @return
- /// \b true if this breakpoint location thinks we should stop,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool
- ShouldStop(StoppointCallbackContext *context) override;
-
- //------------------------------------------------------------------
- // The next section deals with various breakpoint options.
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// If \a enable is \b true, enable the breakpoint, if \b false
- /// disable it.
- //------------------------------------------------------------------
- void
- SetEnabled(bool enabled);
-
- //------------------------------------------------------------------
- /// Check the Enable/Disable state.
- ///
- /// @return
- /// \b true if the breakpoint is enabled, \b false if disabled.
- //------------------------------------------------------------------
- bool
- IsEnabled () const;
-
- //------------------------------------------------------------------
- /// Return the current Ignore Count.
- ///
- /// @return
- /// The number of breakpoint hits to be ignored.
- //------------------------------------------------------------------
- uint32_t
- GetIgnoreCount ();
-
- //------------------------------------------------------------------
- /// Set the breakpoint to ignore the next \a count breakpoint hits.
- ///
- /// @param[in] count
- /// The number of breakpoint hits to ignore.
- //------------------------------------------------------------------
- void
- SetIgnoreCount (uint32_t n);
-
- //------------------------------------------------------------------
- /// Set the callback action invoked when the breakpoint is hit.
- ///
- /// The callback will return a bool indicating whether the target
- /// should stop at this breakpoint or not.
- ///
- /// @param[in] callback
- /// The method that will get called when the breakpoint is hit.
- ///
- /// @param[in] callback_baton_sp
- /// A shared pointer to a Baton that provides the void * needed
- /// for the callback.
- ///
- /// @see lldb_private::Baton
- //------------------------------------------------------------------
- void
- SetCallback (BreakpointHitCallback callback,
- const lldb::BatonSP &callback_baton_sp,
- bool is_synchronous);
-
- void
- SetCallback (BreakpointHitCallback callback,
- void *baton,
- bool is_synchronous);
-
- void
- ClearCallback ();
-
- //------------------------------------------------------------------
- /// Set the breakpoint location's condition.
- ///
- /// @param[in] condition
- /// The condition expression to evaluate when the breakpoint is hit.
- //------------------------------------------------------------------
- void
- SetCondition (const char *condition);
-
- //------------------------------------------------------------------
- /// Return a pointer to the text of the condition expression.
- ///
- /// @return
- /// A pointer to the condition expression text, or nullptr if no
- // condition has been set.
- //------------------------------------------------------------------
- const char *
- GetConditionText(size_t *hash = nullptr) const;
-
- bool
- ConditionSaysStop (ExecutionContext &exe_ctx, Error &error);
-
- //------------------------------------------------------------------
- /// Set the valid thread to be checked when the breakpoint is hit.
- ///
- /// @param[in] thread_id
- /// If this thread hits the breakpoint, we stop, otherwise not.
- //------------------------------------------------------------------
- void
- SetThreadID (lldb::tid_t thread_id);
-
- lldb::tid_t
- GetThreadID ();
-
- void
- SetThreadIndex (uint32_t index);
-
- uint32_t
- GetThreadIndex() const;
-
- void
- SetThreadName (const char *thread_name);
-
- const char *
- GetThreadName () const;
-
- void
- SetQueueName (const char *queue_name);
-
- const char *
- GetQueueName () const;
-
- //------------------------------------------------------------------
- // The next section deals with this location's breakpoint sites.
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Try to resolve the breakpoint site for this location.
- ///
- /// @return
- /// \b true if we were successful at setting a breakpoint site,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool
- ResolveBreakpointSite ();
-
- //------------------------------------------------------------------
- /// Clear this breakpoint location's breakpoint site - for instance
- /// when disabling the breakpoint.
- ///
- /// @return
- /// \b true if there was a breakpoint site to be cleared, \b false
- /// otherwise.
- //------------------------------------------------------------------
- bool
- ClearBreakpointSite ();
-
- //------------------------------------------------------------------
- /// Return whether this breakpoint location has a breakpoint site.
- /// @return
- /// \b true if there was a breakpoint site for this breakpoint
- /// location, \b false otherwise.
- //------------------------------------------------------------------
- bool
- IsResolved () const;
-
- lldb::BreakpointSiteSP
- GetBreakpointSite() const;
-
- //------------------------------------------------------------------
- // The next section are generic report functions.
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Print a description of this breakpoint location to the stream
- /// \a s.
- ///
- /// @param[in] s
- /// The stream to which to print the description.
- ///
- /// @param[in] level
- /// The description level that indicates the detail level to
- /// provide.
- ///
- /// @see lldb::DescriptionLevel
- //------------------------------------------------------------------
- void
- GetDescription (Stream *s, lldb::DescriptionLevel level);
-
- //------------------------------------------------------------------
- /// Standard "Dump" method. At present it does nothing.
- //------------------------------------------------------------------
- void
- Dump(Stream *s) const override;
-
- //------------------------------------------------------------------
- /// Use this to set location specific breakpoint options.
- ///
- /// It will create a copy of the containing breakpoint's options if
- /// that hasn't been done already
- ///
- /// @return
- /// A pointer to the breakpoint options.
- //------------------------------------------------------------------
- BreakpointOptions *
- GetLocationOptions ();
-
- //------------------------------------------------------------------
- /// Use this to access breakpoint options from this breakpoint location.
- /// This will point to the owning breakpoint's options unless options have
- /// been set specifically on this location.
- ///
- /// @return
- /// A pointer to the containing breakpoint's options if this
- /// location doesn't have its own copy.
- //------------------------------------------------------------------
- const BreakpointOptions *
- GetOptionsNoCreate () const;
-
- bool
- ValidForThisThread (Thread *thread);
-
- //------------------------------------------------------------------
- /// Invoke the callback action when the breakpoint is hit.
- ///
- /// Meant to be used by the BreakpointLocation class.
- ///
- /// @param[in] context
- /// Described the breakpoint event.
- ///
- /// @param[in] bp_loc_id
- /// Which breakpoint location hit this breakpoint.
- ///
- /// @return
- /// \b true if the target should stop at this breakpoint and \b
- /// false not.
- //------------------------------------------------------------------
- bool
- InvokeCallback (StoppointCallbackContext *context);
-
- //------------------------------------------------------------------
- /// Returns whether we should resolve Indirect functions in setting the breakpoint site
- /// for this location.
- ///
- /// @return
- /// \b true if the breakpoint SITE for this location should be set on the
- /// resolved location for Indirect functions.
- //------------------------------------------------------------------
- bool
- ShouldResolveIndirectFunctions ()
- {
- return m_should_resolve_indirect_functions;
- }
-
- //------------------------------------------------------------------
- /// Returns whether the address set in the breakpoint site for this location was found by resolving
- /// an indirect symbol.
- ///
- /// @return
- /// \b true or \b false as given in the description above.
- //------------------------------------------------------------------
- bool
- IsIndirect ()
- {
- return m_is_indirect;
- }
-
- void
- SetIsIndirect (bool is_indirect)
- {
- m_is_indirect = is_indirect;
- }
-
- //------------------------------------------------------------------
- /// Returns whether the address set in the breakpoint location was re-routed to the target of a
- /// re-exported symbol.
- ///
- /// @return
- /// \b true or \b false as given in the description above.
- //------------------------------------------------------------------
- bool
- IsReExported ()
- {
- return m_is_reexported;
- }
-
- void
- SetIsReExported (bool is_reexported)
- {
- m_is_reexported = is_reexported;
- }
-
- //------------------------------------------------------------------
- /// Returns whether the two breakpoint locations might represent "equivalent locations".
- /// This is used when modules changed to determine if a Location in the old module might
- /// be the "same as" the input location.
- ///
- /// @param[in] location
- /// The location to compare against.
- ///
- /// @return
- /// \b true or \b false as given in the description above.
- //------------------------------------------------------------------
- bool EquivalentToLocation(BreakpointLocation &location);
-
+ ~BreakpointLocation() override;
+
+ //------------------------------------------------------------------
+ /// Gets the load address for this breakpoint location
+ /// @return
+ /// Returns breakpoint location load address, \b
+ /// LLDB_INVALID_ADDRESS if not yet set.
+ //------------------------------------------------------------------
+ lldb::addr_t GetLoadAddress() const override;
+
+ //------------------------------------------------------------------
+ /// Gets the Address for this breakpoint location
+ /// @return
+ /// Returns breakpoint location Address.
+ //------------------------------------------------------------------
+ Address &GetAddress();
+ //------------------------------------------------------------------
+ /// Gets the Breakpoint that created this breakpoint location
+ /// @return
+ /// Returns the owning breakpoint.
+ //------------------------------------------------------------------
+ Breakpoint &GetBreakpoint();
+
+ Target &GetTarget();
+
+ //------------------------------------------------------------------
+ /// Determines whether we should stop due to a hit at this
+ /// breakpoint location.
+ ///
+ /// Side Effects: This may evaluate the breakpoint condition, and
+ /// run the callback. So this command may do a considerable amount
+ /// of work.
+ ///
+ /// @return
+ /// \b true if this breakpoint location thinks we should stop,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool ShouldStop(StoppointCallbackContext *context) override;
+
+ //------------------------------------------------------------------
+ // The next section deals with various breakpoint options.
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// If \a enable is \b true, enable the breakpoint, if \b false
+ /// disable it.
+ //------------------------------------------------------------------
+ void SetEnabled(bool enabled);
+
+ //------------------------------------------------------------------
+ /// Check the Enable/Disable state.
+ ///
+ /// @return
+ /// \b true if the breakpoint is enabled, \b false if disabled.
+ //------------------------------------------------------------------
+ bool IsEnabled() const;
+
+ //------------------------------------------------------------------
+ /// Return the current Ignore Count.
+ ///
+ /// @return
+ /// The number of breakpoint hits to be ignored.
+ //------------------------------------------------------------------
+ uint32_t GetIgnoreCount();
+
+ //------------------------------------------------------------------
+ /// Set the breakpoint to ignore the next \a count breakpoint hits.
+ ///
+ /// @param[in] count
+ /// The number of breakpoint hits to ignore.
+ //------------------------------------------------------------------
+ void SetIgnoreCount(uint32_t n);
+
+ //------------------------------------------------------------------
+ /// Set the callback action invoked when the breakpoint is hit.
+ ///
+ /// The callback will return a bool indicating whether the target
+ /// should stop at this breakpoint or not.
+ ///
+ /// @param[in] callback
+ /// The method that will get called when the breakpoint is hit.
+ ///
+ /// @param[in] callback_baton_sp
+ /// A shared pointer to a Baton that provides the void * needed
+ /// for the callback.
+ ///
+ /// @see lldb_private::Baton
+ //------------------------------------------------------------------
+ void SetCallback(BreakpointHitCallback callback,
+ const lldb::BatonSP &callback_baton_sp, bool is_synchronous);
+
+ void SetCallback(BreakpointHitCallback callback, void *baton,
+ bool is_synchronous);
+
+ void ClearCallback();
+
+ //------------------------------------------------------------------
+ /// Set the breakpoint location's condition.
+ ///
+ /// @param[in] condition
+ /// The condition expression to evaluate when the breakpoint is hit.
+ //------------------------------------------------------------------
+ void SetCondition(const char *condition);
+
+ //------------------------------------------------------------------
+ /// Return a pointer to the text of the condition expression.
+ ///
+ /// @return
+ /// A pointer to the condition expression text, or nullptr if no
+ // condition has been set.
+ //------------------------------------------------------------------
+ const char *GetConditionText(size_t *hash = nullptr) const;
+
+ bool ConditionSaysStop(ExecutionContext &exe_ctx, Error &error);
+
+ //------------------------------------------------------------------
+ /// Set the valid thread to be checked when the breakpoint is hit.
+ ///
+ /// @param[in] thread_id
+ /// If this thread hits the breakpoint, we stop, otherwise not.
+ //------------------------------------------------------------------
+ void SetThreadID(lldb::tid_t thread_id);
+
+ lldb::tid_t GetThreadID();
+
+ void SetThreadIndex(uint32_t index);
+
+ uint32_t GetThreadIndex() const;
+
+ void SetThreadName(const char *thread_name);
+
+ const char *GetThreadName() const;
+
+ void SetQueueName(const char *queue_name);
+
+ const char *GetQueueName() const;
+
+ //------------------------------------------------------------------
+ // The next section deals with this location's breakpoint sites.
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Try to resolve the breakpoint site for this location.
+ ///
+ /// @return
+ /// \b true if we were successful at setting a breakpoint site,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool ResolveBreakpointSite();
+
+ //------------------------------------------------------------------
+ /// Clear this breakpoint location's breakpoint site - for instance
+ /// when disabling the breakpoint.
+ ///
+ /// @return
+ /// \b true if there was a breakpoint site to be cleared, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ bool ClearBreakpointSite();
+
+ //------------------------------------------------------------------
+ /// Return whether this breakpoint location has a breakpoint site.
+ /// @return
+ /// \b true if there was a breakpoint site for this breakpoint
+ /// location, \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsResolved() const;
+
+ lldb::BreakpointSiteSP GetBreakpointSite() const;
+
+ //------------------------------------------------------------------
+ // The next section are generic report functions.
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Print a description of this breakpoint location to the stream
+ /// \a s.
+ ///
+ /// @param[in] s
+ /// The stream to which to print the description.
+ ///
+ /// @param[in] level
+ /// The description level that indicates the detail level to
+ /// provide.
+ ///
+ /// @see lldb::DescriptionLevel
+ //------------------------------------------------------------------
+ void GetDescription(Stream *s, lldb::DescriptionLevel level);
+
+ //------------------------------------------------------------------
+ /// Standard "Dump" method. At present it does nothing.
+ //------------------------------------------------------------------
+ void Dump(Stream *s) const override;
+
+ //------------------------------------------------------------------
+ /// Use this to set location specific breakpoint options.
+ ///
+ /// It will create a copy of the containing breakpoint's options if
+ /// that hasn't been done already
+ ///
+ /// @return
+ /// A pointer to the breakpoint options.
+ //------------------------------------------------------------------
+ BreakpointOptions *GetLocationOptions();
+
+ //------------------------------------------------------------------
+ /// Use this to access breakpoint options from this breakpoint location.
+ /// This will point to the owning breakpoint's options unless options have
+ /// been set specifically on this location.
+ ///
+ /// @return
+ /// A pointer to the containing breakpoint's options if this
+ /// location doesn't have its own copy.
+ //------------------------------------------------------------------
+ const BreakpointOptions *GetOptionsNoCreate() const;
+
+ bool ValidForThisThread(Thread *thread);
+
+ //------------------------------------------------------------------
+ /// Invoke the callback action when the breakpoint is hit.
+ ///
+ /// Meant to be used by the BreakpointLocation class.
+ ///
+ /// @param[in] context
+ /// Described the breakpoint event.
+ ///
+ /// @param[in] bp_loc_id
+ /// Which breakpoint location hit this breakpoint.
+ ///
+ /// @return
+ /// \b true if the target should stop at this breakpoint and \b
+ /// false not.
+ //------------------------------------------------------------------
+ bool InvokeCallback(StoppointCallbackContext *context);
+
+ //------------------------------------------------------------------
+ /// Returns whether we should resolve Indirect functions in setting the
+ /// breakpoint site
+ /// for this location.
+ ///
+ /// @return
+ /// \b true if the breakpoint SITE for this location should be set on the
+ /// resolved location for Indirect functions.
+ //------------------------------------------------------------------
+ bool ShouldResolveIndirectFunctions() {
+ return m_should_resolve_indirect_functions;
+ }
+
+ //------------------------------------------------------------------
+ /// Returns whether the address set in the breakpoint site for this location
+ /// was found by resolving
+ /// an indirect symbol.
+ ///
+ /// @return
+ /// \b true or \b false as given in the description above.
+ //------------------------------------------------------------------
+ bool IsIndirect() { return m_is_indirect; }
+
+ void SetIsIndirect(bool is_indirect) { m_is_indirect = is_indirect; }
+
+ //------------------------------------------------------------------
+ /// Returns whether the address set in the breakpoint location was re-routed
+ /// to the target of a
+ /// re-exported symbol.
+ ///
+ /// @return
+ /// \b true or \b false as given in the description above.
+ //------------------------------------------------------------------
+ bool IsReExported() { return m_is_reexported; }
+
+ void SetIsReExported(bool is_reexported) { m_is_reexported = is_reexported; }
+
+ //------------------------------------------------------------------
+ /// Returns whether the two breakpoint locations might represent "equivalent
+ /// locations".
+ /// This is used when modules changed to determine if a Location in the old
+ /// module might
+ /// be the "same as" the input location.
+ ///
+ /// @param[in] location
+ /// The location to compare against.
+ ///
+ /// @return
+ /// \b true or \b false as given in the description above.
+ //------------------------------------------------------------------
+ bool EquivalentToLocation(BreakpointLocation &location);
+
protected:
- friend class BreakpointSite;
- friend class BreakpointLocationList;
- friend class Process;
- friend class StopInfoBreakpoint;
-
- //------------------------------------------------------------------
- /// Set the breakpoint site for this location to \a bp_site_sp.
- ///
- /// @param[in] bp_site_sp
- /// The breakpoint site we are setting for this location.
- ///
- /// @return
- /// \b true if we were successful at setting the breakpoint site,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool
- SetBreakpointSite (lldb::BreakpointSiteSP& bp_site_sp);
-
- void
- DecrementIgnoreCount();
-
- bool
- IgnoreCountShouldStop();
-
+ friend class BreakpointSite;
+ friend class BreakpointLocationList;
+ friend class Process;
+ friend class StopInfoBreakpoint;
+
+ //------------------------------------------------------------------
+ /// Set the breakpoint site for this location to \a bp_site_sp.
+ ///
+ /// @param[in] bp_site_sp
+ /// The breakpoint site we are setting for this location.
+ ///
+ /// @return
+ /// \b true if we were successful at setting the breakpoint site,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool SetBreakpointSite(lldb::BreakpointSiteSP &bp_site_sp);
+
+ void DecrementIgnoreCount();
+
+ bool IgnoreCountShouldStop();
+
private:
- void
- SwapLocation (lldb::BreakpointLocationSP swap_from);
-
- void
- BumpHitCount();
-
- void
- UndoBumpHitCount();
-
- //------------------------------------------------------------------
- // Constructors and Destructors
- //
- // Only the Breakpoint can make breakpoint locations, and it owns
- // them.
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Constructor.
- ///
- /// @param[in] owner
- /// A back pointer to the breakpoint that owns this location.
- ///
- /// @param[in] addr
- /// The Address defining this location.
- ///
- /// @param[in] tid
- /// The thread for which this breakpoint location is valid, or
- /// LLDB_INVALID_THREAD_ID if it is valid for all threads.
- ///
- /// @param[in] hardware
- /// \b true if a hardware breakpoint is requested.
- //------------------------------------------------------------------
-
- BreakpointLocation (lldb::break_id_t bid,
- Breakpoint &owner,
- const Address &addr,
- lldb::tid_t tid,
- bool hardware,
- bool check_for_resolver = true);
-
- //------------------------------------------------------------------
- // Data members:
- //------------------------------------------------------------------
- bool m_being_created;
- bool m_should_resolve_indirect_functions;
- bool m_is_reexported;
- bool m_is_indirect;
- Address m_address; ///< The address defining this location.
- Breakpoint &m_owner; ///< The breakpoint that produced this object.
- std::unique_ptr<BreakpointOptions> m_options_ap; ///< Breakpoint options pointer, nullptr if we're using our breakpoint's options.
- lldb::BreakpointSiteSP m_bp_site_sp; ///< Our breakpoint site (it may be shared by more than one location.)
- lldb::UserExpressionSP m_user_expression_sp; ///< The compiled expression to use in testing our condition.
- std::mutex m_condition_mutex; ///< Guards parsing and evaluation of the condition, which could be evaluated by
- /// multiple processes.
- size_t m_condition_hash; ///< For testing whether the condition source code changed.
-
- void
- SetShouldResolveIndirectFunctions (bool do_resolve)
- {
- m_should_resolve_indirect_functions = do_resolve;
- }
-
- void
- SendBreakpointLocationChangedEvent (lldb::BreakpointEventType eventKind);
-
- DISALLOW_COPY_AND_ASSIGN (BreakpointLocation);
+ void SwapLocation(lldb::BreakpointLocationSP swap_from);
+
+ void BumpHitCount();
+
+ void UndoBumpHitCount();
+
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //
+ // Only the Breakpoint can make breakpoint locations, and it owns
+ // them.
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Constructor.
+ ///
+ /// @param[in] owner
+ /// A back pointer to the breakpoint that owns this location.
+ ///
+ /// @param[in] addr
+ /// The Address defining this location.
+ ///
+ /// @param[in] tid
+ /// The thread for which this breakpoint location is valid, or
+ /// LLDB_INVALID_THREAD_ID if it is valid for all threads.
+ ///
+ /// @param[in] hardware
+ /// \b true if a hardware breakpoint is requested.
+ //------------------------------------------------------------------
+
+ BreakpointLocation(lldb::break_id_t bid, Breakpoint &owner,
+ const Address &addr, lldb::tid_t tid, bool hardware,
+ bool check_for_resolver = true);
+
+ //------------------------------------------------------------------
+ // Data members:
+ //------------------------------------------------------------------
+ bool m_being_created;
+ bool m_should_resolve_indirect_functions;
+ bool m_is_reexported;
+ bool m_is_indirect;
+ Address m_address; ///< The address defining this location.
+ Breakpoint &m_owner; ///< The breakpoint that produced this object.
+ std::unique_ptr<BreakpointOptions> m_options_ap; ///< Breakpoint options
+ ///pointer, nullptr if we're
+ ///using our breakpoint's
+ ///options.
+ lldb::BreakpointSiteSP m_bp_site_sp; ///< Our breakpoint site (it may be
+ ///shared by more than one location.)
+ lldb::UserExpressionSP m_user_expression_sp; ///< The compiled expression to
+ ///use in testing our condition.
+ std::mutex m_condition_mutex; ///< Guards parsing and evaluation of the
+ ///condition, which could be evaluated by
+ /// multiple processes.
+ size_t m_condition_hash; ///< For testing whether the condition source code
+ ///changed.
+
+ void SetShouldResolveIndirectFunctions(bool do_resolve) {
+ m_should_resolve_indirect_functions = do_resolve;
+ }
+
+ void SendBreakpointLocationChangedEvent(lldb::BreakpointEventType eventKind);
+
+ DISALLOW_COPY_AND_ASSIGN(BreakpointLocation);
};
} // namespace lldb_private
diff --git a/include/lldb/Breakpoint/BreakpointLocationCollection.h b/include/lldb/Breakpoint/BreakpointLocationCollection.h
index 1a016544fa4c..4b2d9d4b344d 100644
--- a/include/lldb/Breakpoint/BreakpointLocationCollection.h
+++ b/include/lldb/Breakpoint/BreakpointLocationCollection.h
@@ -12,210 +12,202 @@
// C Includes
// C++ Includes
-#include <vector>
#include <mutex>
+#include <vector>
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Utility/Iterable.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class BreakpointLocationCollection
-{
+class BreakpointLocationCollection {
public:
- BreakpointLocationCollection();
-
- ~BreakpointLocationCollection();
-
- //------------------------------------------------------------------
- /// Add the breakpoint \a bp_loc_sp to the list.
- ///
- /// @param[in] bp_sp
- /// Shared pointer to the breakpoint location that will get added
- /// to the list.
- ///
- /// @result
- /// Returns breakpoint location id.
- //------------------------------------------------------------------
- void
- Add (const lldb::BreakpointLocationSP& bp_loc_sp);
-
- //------------------------------------------------------------------
- /// Removes the breakpoint location given by \b breakID from this
- /// list.
- ///
- /// @param[in] break_id
- /// The breakpoint index to remove.
- ///
- /// @param[in] break_loc_id
- /// The breakpoint location index in break_id to remove.
- ///
- /// @result
- /// \b true if the breakpoint was in the list.
- //------------------------------------------------------------------
- bool
- Remove (lldb::break_id_t break_id, lldb::break_id_t break_loc_id);
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint location with id \a
- /// breakID.
- ///
- /// @param[in] break_id
- /// The breakpoint ID to seek for.
- ///
- /// @param[in] break_loc_id
- /// The breakpoint location ID in \a break_id to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a NULL
- /// pointer if the breakpoint doesn't exist.
- //------------------------------------------------------------------
- lldb::BreakpointLocationSP
- FindByIDPair (lldb::break_id_t break_id, lldb::break_id_t break_loc_id);
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint location with id \a
- /// breakID, const version.
- ///
- /// @param[in] breakID
- /// The breakpoint location ID to seek for.
- ///
- /// @param[in] break_loc_id
- /// The breakpoint location ID in \a break_id to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a NULL
- /// pointer if the breakpoint doesn't exist.
- //------------------------------------------------------------------
- const lldb::BreakpointLocationSP
- FindByIDPair (lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const;
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint location with index
- /// \a i.
- ///
- /// @param[in] i
- /// The breakpoint location index to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a NULL
- /// pointer if the breakpoint doesn't exist.
- //------------------------------------------------------------------
- lldb::BreakpointLocationSP
- GetByIndex (size_t i);
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint location with index
- /// \a i, const version.
- ///
- /// @param[in] i
- /// The breakpoint location index to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a NULL
- /// pointer if the breakpoint doesn't exist.
- //------------------------------------------------------------------
- const lldb::BreakpointLocationSP
- GetByIndex (size_t i) const;
-
- //------------------------------------------------------------------
- /// Returns the number of elements in this breakpoint location list.
- ///
- /// @result
- /// The number of elements.
- //------------------------------------------------------------------
- size_t
- GetSize() const { return m_break_loc_collection.size(); }
-
- //------------------------------------------------------------------
- /// Enquires of all the breakpoint locations in this list whether
- /// we should stop at a hit at \a breakID.
- ///
- /// @param[in] context
- /// This contains the information about this stop.
- ///
- /// @param[in] breakID
- /// This break ID that we hit.
- ///
- /// @return
- /// \b true if we should stop, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ShouldStop (StoppointCallbackContext *context);
-
- //------------------------------------------------------------------
- /// Print a description of the breakpoint locations in this list
- /// to the stream \a s.
- ///
- /// @param[in] s
- /// The stream to which to print the description.
- ///
- /// @param[in] level
- /// The description level that indicates the detail level to
- /// provide.
- ///
- /// @see lldb::DescriptionLevel
- //------------------------------------------------------------------
- void GetDescription (Stream *s, lldb::DescriptionLevel level);
-
- //------------------------------------------------------------------
- /// Check whether this collection of breakpoint locations have any
- /// thread specifiers, and if yes, is \a thread_id contained in any
- /// of these specifiers.
- ///
- /// @param[in] thread
- /// The thread against which to test.
- ///
- /// return
- /// \b true if the collection contains at least one location that
- /// would be valid for this thread, false otherwise.
- //------------------------------------------------------------------
- bool ValidForThisThread (Thread *thread);
-
- //------------------------------------------------------------------
- /// Tell whether ALL the breakpoints in the location collection are internal.
- ///
- /// @result
- /// \b true if all breakpoint locations are owned by internal breakpoints,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool IsInternal() const;
-
+ BreakpointLocationCollection();
+
+ ~BreakpointLocationCollection();
+
+ //------------------------------------------------------------------
+ /// Add the breakpoint \a bp_loc_sp to the list.
+ ///
+ /// @param[in] bp_sp
+ /// Shared pointer to the breakpoint location that will get added
+ /// to the list.
+ ///
+ /// @result
+ /// Returns breakpoint location id.
+ //------------------------------------------------------------------
+ void Add(const lldb::BreakpointLocationSP &bp_loc_sp);
+
+ //------------------------------------------------------------------
+ /// Removes the breakpoint location given by \b breakID from this
+ /// list.
+ ///
+ /// @param[in] break_id
+ /// The breakpoint index to remove.
+ ///
+ /// @param[in] break_loc_id
+ /// The breakpoint location index in break_id to remove.
+ ///
+ /// @result
+ /// \b true if the breakpoint was in the list.
+ //------------------------------------------------------------------
+ bool Remove(lldb::break_id_t break_id, lldb::break_id_t break_loc_id);
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint location with id \a
+ /// breakID.
+ ///
+ /// @param[in] break_id
+ /// The breakpoint ID to seek for.
+ ///
+ /// @param[in] break_loc_id
+ /// The breakpoint location ID in \a break_id to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a NULL
+ /// pointer if the breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ lldb::BreakpointLocationSP FindByIDPair(lldb::break_id_t break_id,
+ lldb::break_id_t break_loc_id);
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint location with id \a
+ /// breakID, const version.
+ ///
+ /// @param[in] breakID
+ /// The breakpoint location ID to seek for.
+ ///
+ /// @param[in] break_loc_id
+ /// The breakpoint location ID in \a break_id to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a NULL
+ /// pointer if the breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ const lldb::BreakpointLocationSP
+ FindByIDPair(lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const;
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint location with index
+ /// \a i.
+ ///
+ /// @param[in] i
+ /// The breakpoint location index to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a NULL
+ /// pointer if the breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ lldb::BreakpointLocationSP GetByIndex(size_t i);
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint location with index
+ /// \a i, const version.
+ ///
+ /// @param[in] i
+ /// The breakpoint location index to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a NULL
+ /// pointer if the breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ const lldb::BreakpointLocationSP GetByIndex(size_t i) const;
+
+ //------------------------------------------------------------------
+ /// Returns the number of elements in this breakpoint location list.
+ ///
+ /// @result
+ /// The number of elements.
+ //------------------------------------------------------------------
+ size_t GetSize() const { return m_break_loc_collection.size(); }
+
+ //------------------------------------------------------------------
+ /// Enquires of all the breakpoint locations in this list whether
+ /// we should stop at a hit at \a breakID.
+ ///
+ /// @param[in] context
+ /// This contains the information about this stop.
+ ///
+ /// @param[in] breakID
+ /// This break ID that we hit.
+ ///
+ /// @return
+ /// \b true if we should stop, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ShouldStop(StoppointCallbackContext *context);
+
+ //------------------------------------------------------------------
+ /// Print a description of the breakpoint locations in this list
+ /// to the stream \a s.
+ ///
+ /// @param[in] s
+ /// The stream to which to print the description.
+ ///
+ /// @param[in] level
+ /// The description level that indicates the detail level to
+ /// provide.
+ ///
+ /// @see lldb::DescriptionLevel
+ //------------------------------------------------------------------
+ void GetDescription(Stream *s, lldb::DescriptionLevel level);
+
+ //------------------------------------------------------------------
+ /// Check whether this collection of breakpoint locations have any
+ /// thread specifiers, and if yes, is \a thread_id contained in any
+ /// of these specifiers.
+ ///
+ /// @param[in] thread
+ /// The thread against which to test.
+ ///
+ /// return
+ /// \b true if the collection contains at least one location that
+ /// would be valid for this thread, false otherwise.
+ //------------------------------------------------------------------
+ bool ValidForThisThread(Thread *thread);
+
+ //------------------------------------------------------------------
+ /// Tell whether ALL the breakpoints in the location collection are internal.
+ ///
+ /// @result
+ /// \b true if all breakpoint locations are owned by internal breakpoints,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsInternal() const;
protected:
- //------------------------------------------------------------------
- // Classes that inherit from BreakpointLocationCollection can see
- // and modify these
- //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ // Classes that inherit from BreakpointLocationCollection can see
+ // and modify these
+ //------------------------------------------------------------------
private:
- //------------------------------------------------------------------
- // For BreakpointLocationCollection only
- //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ // For BreakpointLocationCollection only
+ //------------------------------------------------------------------
- typedef std::vector<lldb::BreakpointLocationSP> collection;
+ typedef std::vector<lldb::BreakpointLocationSP> collection;
- collection::iterator
- GetIDPairIterator(lldb::break_id_t break_id, lldb::break_id_t break_loc_id);
+ collection::iterator GetIDPairIterator(lldb::break_id_t break_id,
+ lldb::break_id_t break_loc_id);
- collection::const_iterator
- GetIDPairConstIterator(lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const;
+ collection::const_iterator
+ GetIDPairConstIterator(lldb::break_id_t break_id,
+ lldb::break_id_t break_loc_id) const;
- collection m_break_loc_collection;
- mutable std::mutex m_collection_mutex;
+ collection m_break_loc_collection;
+ mutable std::mutex m_collection_mutex;
public:
- typedef AdaptedIterable<collection, lldb::BreakpointLocationSP, vector_adapter> BreakpointLocationCollectionIterable;
- BreakpointLocationCollectionIterable
- BreakpointLocations()
- {
- return BreakpointLocationCollectionIterable(m_break_loc_collection);
- }
-
+ typedef AdaptedIterable<collection, lldb::BreakpointLocationSP,
+ vector_adapter>
+ BreakpointLocationCollectionIterable;
+ BreakpointLocationCollectionIterable BreakpointLocations() {
+ return BreakpointLocationCollectionIterable(m_break_loc_collection);
+ }
};
} // namespace lldb_private
-#endif // liblldb_BreakpointLocationCollection_h_
+#endif // liblldb_BreakpointLocationCollection_h_
diff --git a/include/lldb/Breakpoint/BreakpointLocationList.h b/include/lldb/Breakpoint/BreakpointLocationList.h
index 1fbfa43a40f4..46eb2612bbe8 100644
--- a/include/lldb/Breakpoint/BreakpointLocationList.h
+++ b/include/lldb/Breakpoint/BreakpointLocationList.h
@@ -18,270 +18,248 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/Address.h"
#include "lldb/Utility/Iterable.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class BreakpointLocationList BreakpointLocationList.h "lldb/Breakpoint/BreakpointLocationList.h"
-/// @brief This class is used by Breakpoint to manage a list of breakpoint locations,
+/// @class BreakpointLocationList BreakpointLocationList.h
+/// "lldb/Breakpoint/BreakpointLocationList.h"
+/// @brief This class is used by Breakpoint to manage a list of breakpoint
+/// locations,
// each breakpoint location in the list
/// has a unique ID, and is unique by Address as well.
//----------------------------------------------------------------------
-class BreakpointLocationList
-{
-// Only Breakpoints can make the location list, or add elements to it.
-// This is not just some random collection of locations. Rather, the act of adding the location
-// to this list sets its ID, and implicitly all the locations have the same breakpoint ID as
-// well. If you need a generic container for breakpoint locations, use BreakpointLocationCollection.
-friend class Breakpoint;
+class BreakpointLocationList {
+ // Only Breakpoints can make the location list, or add elements to it.
+ // This is not just some random collection of locations. Rather, the act of
+ // adding the location
+ // to this list sets its ID, and implicitly all the locations have the same
+ // breakpoint ID as
+ // well. If you need a generic container for breakpoint locations, use
+ // BreakpointLocationCollection.
+ friend class Breakpoint;
public:
- virtual
- ~BreakpointLocationList();
-
- //------------------------------------------------------------------
- /// Standard "Dump" method. At present it does nothing.
- //------------------------------------------------------------------
- void
- Dump (Stream *s) const;
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint location at address
- /// \a addr - const version.
- ///
- /// @param[in] addr
- /// The address to look for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a nullptr
- /// pointer if the breakpoint doesn't exist.
- //------------------------------------------------------------------
- const lldb::BreakpointLocationSP
- FindByAddress (const Address &addr) const;
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint location with id
- /// \a breakID, const version.
- ///
- /// @param[in] breakID
- /// The breakpoint location ID to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a nullptr
- /// pointer if the breakpoint doesn't exist.
- //------------------------------------------------------------------
- lldb::BreakpointLocationSP
- FindByID (lldb::break_id_t breakID) const;
-
- //------------------------------------------------------------------
- /// Returns the breakpoint location id to the breakpoint location
- /// at address \a addr.
- ///
- /// @param[in] addr
- /// The address to match.
- ///
- /// @result
- /// The ID of the breakpoint location, or LLDB_INVALID_BREAK_ID.
- //------------------------------------------------------------------
- lldb::break_id_t
- FindIDByAddress (const Address &addr);
-
- //------------------------------------------------------------------
- /// Returns a breakpoint location list of the breakpoint locations
- /// in the module \a module. This list is allocated, and owned by
- /// the caller.
- ///
- /// @param[in] module
- /// The module to seek in.
- ///
- /// @param[in]
- /// A breakpoint collection that gets any breakpoint locations
- /// that match \a module appended to.
- ///
- /// @result
- /// The number of matches
- //------------------------------------------------------------------
- size_t
- FindInModule (Module *module,
- BreakpointLocationCollection& bp_loc_list);
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint location with
- /// index \a i.
- ///
- /// @param[in] i
- /// The breakpoint location index to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a nullptr
- /// pointer if the breakpoint doesn't exist.
- //------------------------------------------------------------------
- lldb::BreakpointLocationSP
- GetByIndex (size_t i);
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint location with index
- /// \a i, const version.
- ///
- /// @param[in] i
- /// The breakpoint location index to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a nullptr
- /// pointer if the breakpoint doesn't exist.
- //------------------------------------------------------------------
- const lldb::BreakpointLocationSP
- GetByIndex (size_t i) const;
-
- //------------------------------------------------------------------
- /// Removes all the locations in this list from their breakpoint site
- /// owners list.
- //------------------------------------------------------------------
- void
- ClearAllBreakpointSites ();
-
- //------------------------------------------------------------------
- /// Tells all the breakpoint locations in this list to attempt to
- /// resolve any possible breakpoint sites.
- //------------------------------------------------------------------
- void
- ResolveAllBreakpointSites ();
-
- //------------------------------------------------------------------
- /// Returns the number of breakpoint locations in this list with
- /// resolved breakpoints.
- ///
- /// @result
- /// Number of qualifying breakpoint locations.
- //------------------------------------------------------------------
- size_t
- GetNumResolvedLocations() const;
-
- //------------------------------------------------------------------
- /// Returns the number hit count of all locations in this list.
- ///
- /// @result
- /// Hit count of all locations in this list.
- //------------------------------------------------------------------
- uint32_t
- GetHitCount () const;
-
- //------------------------------------------------------------------
- /// Enquires of the breakpoint location in this list with ID \a
- /// breakID whether we should stop.
- ///
- /// @param[in] context
- /// This contains the information about this stop.
- ///
- /// @param[in] breakID
- /// This break ID that we hit.
- ///
- /// @return
- /// \b true if we should stop, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ShouldStop (StoppointCallbackContext *context,
- lldb::break_id_t breakID);
-
- //------------------------------------------------------------------
- /// Returns the number of elements in this breakpoint location list.
- ///
- /// @result
- /// The number of elements.
- //------------------------------------------------------------------
- size_t
- GetSize() const
- {
- return m_locations.size();
- }
-
- //------------------------------------------------------------------
- /// Print a description of the breakpoint locations in this list to
- /// the stream \a s.
- ///
- /// @param[in] s
- /// The stream to which to print the description.
- ///
- /// @param[in] level
- /// The description level that indicates the detail level to
- /// provide.
- ///
- /// @see lldb::DescriptionLevel
- //------------------------------------------------------------------
- void
- GetDescription (Stream *s,
- lldb::DescriptionLevel level);
+ virtual ~BreakpointLocationList();
+
+ //------------------------------------------------------------------
+ /// Standard "Dump" method. At present it does nothing.
+ //------------------------------------------------------------------
+ void Dump(Stream *s) const;
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint location at address
+ /// \a addr - const version.
+ ///
+ /// @param[in] addr
+ /// The address to look for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a nullptr
+ /// pointer if the breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ const lldb::BreakpointLocationSP FindByAddress(const Address &addr) const;
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint location with id
+ /// \a breakID, const version.
+ ///
+ /// @param[in] breakID
+ /// The breakpoint location ID to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a nullptr
+ /// pointer if the breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ lldb::BreakpointLocationSP FindByID(lldb::break_id_t breakID) const;
+
+ //------------------------------------------------------------------
+ /// Returns the breakpoint location id to the breakpoint location
+ /// at address \a addr.
+ ///
+ /// @param[in] addr
+ /// The address to match.
+ ///
+ /// @result
+ /// The ID of the breakpoint location, or LLDB_INVALID_BREAK_ID.
+ //------------------------------------------------------------------
+ lldb::break_id_t FindIDByAddress(const Address &addr);
+
+ //------------------------------------------------------------------
+ /// Returns a breakpoint location list of the breakpoint locations
+ /// in the module \a module. This list is allocated, and owned by
+ /// the caller.
+ ///
+ /// @param[in] module
+ /// The module to seek in.
+ ///
+ /// @param[in]
+ /// A breakpoint collection that gets any breakpoint locations
+ /// that match \a module appended to.
+ ///
+ /// @result
+ /// The number of matches
+ //------------------------------------------------------------------
+ size_t FindInModule(Module *module,
+ BreakpointLocationCollection &bp_loc_list);
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint location with
+ /// index \a i.
+ ///
+ /// @param[in] i
+ /// The breakpoint location index to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a nullptr
+ /// pointer if the breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ lldb::BreakpointLocationSP GetByIndex(size_t i);
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint location with index
+ /// \a i, const version.
+ ///
+ /// @param[in] i
+ /// The breakpoint location index to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a nullptr
+ /// pointer if the breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ const lldb::BreakpointLocationSP GetByIndex(size_t i) const;
+
+ //------------------------------------------------------------------
+ /// Removes all the locations in this list from their breakpoint site
+ /// owners list.
+ //------------------------------------------------------------------
+ void ClearAllBreakpointSites();
+
+ //------------------------------------------------------------------
+ /// Tells all the breakpoint locations in this list to attempt to
+ /// resolve any possible breakpoint sites.
+ //------------------------------------------------------------------
+ void ResolveAllBreakpointSites();
+
+ //------------------------------------------------------------------
+ /// Returns the number of breakpoint locations in this list with
+ /// resolved breakpoints.
+ ///
+ /// @result
+ /// Number of qualifying breakpoint locations.
+ //------------------------------------------------------------------
+ size_t GetNumResolvedLocations() const;
+
+ //------------------------------------------------------------------
+ /// Returns the number hit count of all locations in this list.
+ ///
+ /// @result
+ /// Hit count of all locations in this list.
+ //------------------------------------------------------------------
+ uint32_t GetHitCount() const;
+
+ //------------------------------------------------------------------
+ /// Enquires of the breakpoint location in this list with ID \a
+ /// breakID whether we should stop.
+ ///
+ /// @param[in] context
+ /// This contains the information about this stop.
+ ///
+ /// @param[in] breakID
+ /// This break ID that we hit.
+ ///
+ /// @return
+ /// \b true if we should stop, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ShouldStop(StoppointCallbackContext *context, lldb::break_id_t breakID);
+
+ //------------------------------------------------------------------
+ /// Returns the number of elements in this breakpoint location list.
+ ///
+ /// @result
+ /// The number of elements.
+ //------------------------------------------------------------------
+ size_t GetSize() const { return m_locations.size(); }
+
+ //------------------------------------------------------------------
+ /// Print a description of the breakpoint locations in this list to
+ /// the stream \a s.
+ ///
+ /// @param[in] s
+ /// The stream to which to print the description.
+ ///
+ /// @param[in] level
+ /// The description level that indicates the detail level to
+ /// provide.
+ ///
+ /// @see lldb::DescriptionLevel
+ //------------------------------------------------------------------
+ void GetDescription(Stream *s, lldb::DescriptionLevel level);
protected:
- //------------------------------------------------------------------
- /// This is the standard constructor.
- ///
- /// It creates an empty breakpoint location list. It is protected
- /// here because only Breakpoints are allowed to create the
- /// breakpoint location list.
- //------------------------------------------------------------------
- BreakpointLocationList(Breakpoint &owner);
-
- //------------------------------------------------------------------
- /// Add the breakpoint \a bp_loc_sp to the list.
- ///
- /// @param[in] bp_sp
- /// Shared pointer to the breakpoint location that will get
- /// added to the list.
- ///
- /// @result
- /// Returns breakpoint location id.
- //------------------------------------------------------------------
- lldb::BreakpointLocationSP
- Create (const Address &addr, bool resolve_indirect_symbols);
-
- void
- StartRecordingNewLocations(BreakpointLocationCollection &new_locations);
-
- void
- StopRecordingNewLocations();
-
- lldb::BreakpointLocationSP
- AddLocation(const Address &addr,
- bool resolve_indirect_symbols,
- bool *new_location = nullptr);
-
- void
- SwapLocation (lldb::BreakpointLocationSP to_location_sp, lldb::BreakpointLocationSP from_location_sp);
-
- bool
- RemoveLocation (const lldb::BreakpointLocationSP &bp_loc_sp);
-
- void
- RemoveInvalidLocations (const ArchSpec &arch);
-
- void
- Compact();
-
- typedef std::vector<lldb::BreakpointLocationSP> collection;
- typedef std::map<lldb_private::Address,
- lldb::BreakpointLocationSP,
- Address::ModulePointerAndOffsetLessThanFunctionObject> addr_map;
-
- Breakpoint &m_owner;
- collection m_locations; // Vector of locations, sorted by ID
- addr_map m_address_to_location;
- mutable std::recursive_mutex m_mutex;
- lldb::break_id_t m_next_id;
- BreakpointLocationCollection *m_new_location_recorder;
+ //------------------------------------------------------------------
+ /// This is the standard constructor.
+ ///
+ /// It creates an empty breakpoint location list. It is protected
+ /// here because only Breakpoints are allowed to create the
+ /// breakpoint location list.
+ //------------------------------------------------------------------
+ BreakpointLocationList(Breakpoint &owner);
+
+ //------------------------------------------------------------------
+ /// Add the breakpoint \a bp_loc_sp to the list.
+ ///
+ /// @param[in] bp_sp
+ /// Shared pointer to the breakpoint location that will get
+ /// added to the list.
+ ///
+ /// @result
+ /// Returns breakpoint location id.
+ //------------------------------------------------------------------
+ lldb::BreakpointLocationSP Create(const Address &addr,
+ bool resolve_indirect_symbols);
+
+ void StartRecordingNewLocations(BreakpointLocationCollection &new_locations);
+
+ void StopRecordingNewLocations();
+
+ lldb::BreakpointLocationSP AddLocation(const Address &addr,
+ bool resolve_indirect_symbols,
+ bool *new_location = nullptr);
+
+ void SwapLocation(lldb::BreakpointLocationSP to_location_sp,
+ lldb::BreakpointLocationSP from_location_sp);
+
+ bool RemoveLocation(const lldb::BreakpointLocationSP &bp_loc_sp);
+
+ void RemoveInvalidLocations(const ArchSpec &arch);
+
+ void Compact();
+
+ typedef std::vector<lldb::BreakpointLocationSP> collection;
+ typedef std::map<lldb_private::Address, lldb::BreakpointLocationSP,
+ Address::ModulePointerAndOffsetLessThanFunctionObject>
+ addr_map;
+
+ Breakpoint &m_owner;
+ collection m_locations; // Vector of locations, sorted by ID
+ addr_map m_address_to_location;
+ mutable std::recursive_mutex m_mutex;
+ lldb::break_id_t m_next_id;
+ BreakpointLocationCollection *m_new_location_recorder;
public:
- typedef AdaptedIterable<collection, lldb::BreakpointLocationSP, vector_adapter> BreakpointLocationIterable;
+ typedef AdaptedIterable<collection, lldb::BreakpointLocationSP,
+ vector_adapter>
+ BreakpointLocationIterable;
- BreakpointLocationIterable
- BreakpointLocations()
- {
- return BreakpointLocationIterable(m_locations);
- }
+ BreakpointLocationIterable BreakpointLocations() {
+ return BreakpointLocationIterable(m_locations);
+ }
};
} // namespace lldb_private
diff --git a/include/lldb/Breakpoint/BreakpointOptions.h b/include/lldb/Breakpoint/BreakpointOptions.h
index e7882147a4da..e053af352ff2 100644
--- a/include/lldb/Breakpoint/BreakpointOptions.h
+++ b/include/lldb/Breakpoint/BreakpointOptions.h
@@ -17,341 +17,389 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/Baton.h"
#include "lldb/Core/StringList.h"
+#include "lldb/Core/StructuredData.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class BreakpointOptions BreakpointOptions.h "lldb/Breakpoint/BreakpointOptions.h"
-/// @brief Class that manages the options on a breakpoint or breakpoint location.
+/// @class BreakpointOptions BreakpointOptions.h
+/// "lldb/Breakpoint/BreakpointOptions.h"
+/// @brief Class that manages the options on a breakpoint or breakpoint
+/// location.
//----------------------------------------------------------------------
-class BreakpointOptions
-{
+class BreakpointOptions {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- //------------------------------------------------------------------
- /// Default constructor. The breakpoint is enabled, and has no condition,
- /// callback, ignore count, etc...
- //------------------------------------------------------------------
- BreakpointOptions();
- BreakpointOptions(const BreakpointOptions& rhs);
-
- static BreakpointOptions *
- CopyOptionsNoCallback (BreakpointOptions &rhs);
- //------------------------------------------------------------------
- /// This constructor allows you to specify all the breakpoint options.
- ///
- /// @param[in] condition
- /// The expression which if it evaluates to \b true if we are to stop
- ///
- /// @param[in] callback
- /// This is the plugin for some code that gets run, returns \b true if we are to stop.
- ///
- /// @param[in] baton
- /// Client data that will get passed to the callback.
- ///
- /// @param[in] enabled
- /// Is this breakpoint enabled.
- ///
- /// @param[in] ignore
- /// How many breakpoint hits we should ignore before stopping.
- ///
- /// @param[in] thread_id
- /// Only stop if \a thread_id hits the breakpoint.
- //------------------------------------------------------------------
- BreakpointOptions(void *condition,
- BreakpointHitCallback callback,
- void *baton,
- bool enabled = true,
- int32_t ignore = 0,
- lldb::tid_t thread_id = LLDB_INVALID_THREAD_ID,
- bool one_shot = false);
-
- virtual ~BreakpointOptions();
-
- //------------------------------------------------------------------
- // Operators
- //------------------------------------------------------------------
- const BreakpointOptions&
- operator=(const BreakpointOptions& rhs);
-
- //------------------------------------------------------------------
- // Callbacks
- //
- // Breakpoint callbacks come in two forms, synchronous and asynchronous. Synchronous callbacks will get
- // run before any of the thread plans are consulted, and if they return false the target will continue
- // "under the radar" of the thread plans. There are a couple of restrictions to synchronous callbacks:
- // 1) They should NOT resume the target themselves. Just return false if you want the target to restart.
- // 2) Breakpoints with synchronous callbacks can't have conditions (or rather, they can have them, but they
- // won't do anything. Ditto with ignore counts, etc... You are supposed to control that all through the
- // callback.
- // Asynchronous callbacks get run as part of the "ShouldStop" logic in the thread plan. The logic there is:
- // a) If the breakpoint is thread specific and not for this thread, continue w/o running the callback.
- // NB. This is actually enforced underneath the breakpoint system, the Process plugin is expected to
- // call BreakpointSite::IsValidForThread, and set the thread's StopInfo to "no reason". That way,
- // thread displays won't show stops for breakpoints not for that thread...
- // b) If the ignore count says we shouldn't stop, then ditto.
- // c) If the condition says we shouldn't stop, then ditto.
- // d) Otherwise, the callback will get run, and if it returns true we will stop, and if false we won't.
- // The asynchronous callback can run the target itself, but at present that should be the last action the
- // callback does. We will relax this condition at some point, but it will take a bit of plumbing to get
- // that to work.
- //
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Adds a callback to the breakpoint option set.
- ///
- /// @param[in] callback
- /// The function to be called when the breakpoint gets hit.
- ///
- /// @param[in] baton_sp
- /// A baton which will get passed back to the callback when it is invoked.
- ///
- /// @param[in] synchronous
- /// Whether this is a synchronous or asynchronous callback. See discussion above.
- //------------------------------------------------------------------
- void SetCallback (BreakpointHitCallback callback, const lldb::BatonSP &baton_sp, bool synchronous = false);
-
- //------------------------------------------------------------------
- /// Remove the callback from this option set.
- //------------------------------------------------------------------
- void ClearCallback ();
-
- // The rest of these functions are meant to be used only within the breakpoint handling mechanism.
-
- //------------------------------------------------------------------
- /// Use this function to invoke the callback for a specific stop.
- ///
- /// @param[in] context
- /// The context in which the callback is to be invoked. This includes the stop event, the
- /// execution context of the stop (since you might hit the same breakpoint on multiple threads) and
- /// whether we are currently executing synchronous or asynchronous callbacks.
- ///
- /// @param[in] break_id
- /// The breakpoint ID that owns this option set.
- ///
- /// @param[in] break_loc_id
- /// The breakpoint location ID that owns this option set.
- ///
- /// @return
- /// The callback return value.
- //------------------------------------------------------------------
- bool InvokeCallback (StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
-
- //------------------------------------------------------------------
- /// Used in InvokeCallback to tell whether it is the right time to run this kind of callback.
- ///
- /// @return
- /// The synchronicity of our callback.
- //------------------------------------------------------------------
- bool IsCallbackSynchronous () const
- {
- return m_callback_is_synchronous;
- }
-
- //------------------------------------------------------------------
- /// Fetch the baton from the callback.
- ///
- /// @return
- /// The baton.
- //------------------------------------------------------------------
- Baton *GetBaton ();
-
- //------------------------------------------------------------------
- /// Fetch a const version of the baton from the callback.
- ///
- /// @return
- /// The baton.
- //------------------------------------------------------------------
- const Baton *GetBaton () const;
-
- //------------------------------------------------------------------
- // Condition
- //------------------------------------------------------------------
- //------------------------------------------------------------------
- /// Set the breakpoint option's condition.
- ///
- /// @param[in] condition
- /// The condition expression to evaluate when the breakpoint is hit.
- //------------------------------------------------------------------
- void SetCondition (const char *condition);
-
- //------------------------------------------------------------------
- /// Return a pointer to the text of the condition expression.
- ///
- /// @return
- /// A pointer to the condition expression text, or nullptr if no
- // condition has been set.
- //------------------------------------------------------------------
- const char *GetConditionText(size_t *hash = nullptr) const;
-
- //------------------------------------------------------------------
- // Enabled/Ignore Count
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Check the Enable/Disable state.
- /// @return
- /// \b true if the breakpoint is enabled, \b false if disabled.
- //------------------------------------------------------------------
- bool
- IsEnabled () const
- {
- return m_enabled;
- }
+ struct CommandData {
+ CommandData()
+ : user_source(), script_source(),
+ interpreter(lldb::eScriptLanguageNone), stop_on_error(true) {}
- //------------------------------------------------------------------
- /// If \a enable is \b true, enable the breakpoint, if \b false disable it.
- //------------------------------------------------------------------
- void
- SetEnabled (bool enabled)
- {
- m_enabled = enabled;
- }
+ CommandData(const StringList &user_source, lldb::ScriptLanguage interp)
+ : user_source(user_source), script_source(), interpreter(interp),
+ stop_on_error(true) {}
- //------------------------------------------------------------------
- /// Check the One-shot state.
- /// @return
- /// \b true if the breakpoint is one-shot, \b false otherwise.
- //------------------------------------------------------------------
- bool
- IsOneShot () const
- {
- return m_one_shot;
- }
+ ~CommandData() = default;
- //------------------------------------------------------------------
- /// If \a enable is \b true, enable the breakpoint, if \b false disable it.
- //------------------------------------------------------------------
- void
- SetOneShot (bool one_shot)
- {
- m_one_shot = one_shot;
- }
+ static const char *GetSerializationKey() { return "BKPTCMDData"; }
- //------------------------------------------------------------------
- /// Set the breakpoint to ignore the next \a count breakpoint hits.
- /// @param[in] count
- /// The number of breakpoint hits to ignore.
- //------------------------------------------------------------------
+ StructuredData::ObjectSP SerializeToStructuredData();
- void
- SetIgnoreCount (uint32_t n)
- {
- m_ignore_count = n;
- }
+ static std::unique_ptr<CommandData>
+ CreateFromStructuredData(const StructuredData::Dictionary &options_dict,
+ Error &error);
- //------------------------------------------------------------------
- /// Return the current Ignore Count.
- /// @return
- /// The number of breakpoint hits to be ignored.
- //------------------------------------------------------------------
- uint32_t
- GetIgnoreCount () const
- {
- return m_ignore_count;
- }
+ StringList user_source;
+ std::string script_source;
+ enum lldb::ScriptLanguage
+ interpreter; // eScriptLanguageNone means command interpreter.
+ bool stop_on_error;
- //------------------------------------------------------------------
- /// Return the current thread spec for this option. This will return nullptr if the no thread
- /// specifications have been set for this Option yet.
- /// @return
- /// The thread specification pointer for this option, or nullptr if none has
- /// been set yet.
- //------------------------------------------------------------------
- const ThreadSpec *
- GetThreadSpecNoCreate () const;
-
- //------------------------------------------------------------------
- /// Returns a pointer to the ThreadSpec for this option, creating it.
- /// if it hasn't been created already. This API is used for setting the
- /// ThreadSpec items for this option.
- //------------------------------------------------------------------
- ThreadSpec *
- GetThreadSpec ();
-
- void
- SetThreadID(lldb::tid_t thread_id);
-
- void
- GetDescription (Stream *s, lldb::DescriptionLevel level) const;
-
- //------------------------------------------------------------------
- /// Returns true if the breakpoint option has a callback set.
- //------------------------------------------------------------------
- bool
- HasCallback() const;
-
- //------------------------------------------------------------------
- /// This is the default empty callback.
- /// @return
- /// The thread id for which the breakpoint hit will stop,
- /// LLDB_INVALID_THREAD_ID for all threads.
- //------------------------------------------------------------------
- static bool
- NullCallback (void *baton,
- StoppointCallbackContext *context,
- lldb::user_id_t break_id,
- lldb::user_id_t break_loc_id);
-
- struct CommandData
- {
- CommandData () :
- user_source(),
- script_source(),
- stop_on_error(true)
- {
- }
-
- ~CommandData() = default;
-
- StringList user_source;
- std::string script_source;
- bool stop_on_error;
+ private:
+ enum class OptionNames : uint32_t {
+ UserSource = 0,
+ Interpreter,
+ StopOnError,
+ LastOptionName
};
- class CommandBaton : public Baton
- {
- public:
- CommandBaton (CommandData *data) :
- Baton (data)
- {
- }
-
- ~CommandBaton() override
- {
- delete ((CommandData *)m_data);
- m_data = nullptr;
- }
-
- void
- GetDescription (Stream *s, lldb::DescriptionLevel level) const override;
- };
+ static const char
+ *g_option_names[static_cast<uint32_t>(OptionNames::LastOptionName)];
+
+ static const char *GetKey(OptionNames enum_value) {
+ return g_option_names[static_cast<uint32_t>(enum_value)];
+ }
+ };
+
+ class CommandBaton : public TypedBaton<CommandData> {
+ public:
+ explicit CommandBaton(std::unique_ptr<CommandData> Data)
+ : TypedBaton(std::move(Data)) {}
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) const override;
+ };
+
+ typedef std::shared_ptr<CommandBaton> CommandBatonSP;
+
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ /// Default constructor. The breakpoint is enabled, and has no condition,
+ /// callback, ignore count, etc...
+ //------------------------------------------------------------------
+ BreakpointOptions();
+ BreakpointOptions(const BreakpointOptions &rhs);
+
+ static BreakpointOptions *CopyOptionsNoCallback(BreakpointOptions &rhs);
+
+ //------------------------------------------------------------------
+ /// This constructor allows you to specify all the breakpoint options
+ /// except the callback. That one is more complicated, and better
+ /// to do by hand.
+ ///
+ /// @param[in] condition
+ /// The expression which if it evaluates to \b true if we are to stop
+ ///
+ /// @param[in] enabled
+ /// Is this breakpoint enabled.
+ ///
+ /// @param[in] ignore
+ /// How many breakpoint hits we should ignore before stopping.
+ ///
+ //------------------------------------------------------------------
+ BreakpointOptions(const char *condition, bool enabled = true,
+ int32_t ignore = 0, bool one_shot = false);
+
+ virtual ~BreakpointOptions();
+
+ static std::unique_ptr<BreakpointOptions>
+ CreateFromStructuredData(Target &target,
+ const StructuredData::Dictionary &data_dict,
+ Error &error);
+
+ virtual StructuredData::ObjectSP SerializeToStructuredData();
+
+ static const char *GetSerializationKey() { return "BKPTOptions"; }
+
+ //------------------------------------------------------------------
+ // Operators
+ //------------------------------------------------------------------
+ const BreakpointOptions &operator=(const BreakpointOptions &rhs);
+
+ //------------------------------------------------------------------
+ // Callbacks
+ //
+ // Breakpoint callbacks come in two forms, synchronous and asynchronous.
+ // Synchronous callbacks will get
+ // run before any of the thread plans are consulted, and if they return false
+ // the target will continue
+ // "under the radar" of the thread plans. There are a couple of restrictions
+ // to synchronous callbacks:
+ // 1) They should NOT resume the target themselves. Just return false if you
+ // want the target to restart.
+ // 2) Breakpoints with synchronous callbacks can't have conditions (or rather,
+ // they can have them, but they
+ // won't do anything. Ditto with ignore counts, etc... You are supposed
+ // to control that all through the
+ // callback.
+ // Asynchronous callbacks get run as part of the "ShouldStop" logic in the
+ // thread plan. The logic there is:
+ // a) If the breakpoint is thread specific and not for this thread, continue
+ // w/o running the callback.
+ // NB. This is actually enforced underneath the breakpoint system, the
+ // Process plugin is expected to
+ // call BreakpointSite::IsValidForThread, and set the thread's StopInfo
+ // to "no reason". That way,
+ // thread displays won't show stops for breakpoints not for that
+ // thread...
+ // b) If the ignore count says we shouldn't stop, then ditto.
+ // c) If the condition says we shouldn't stop, then ditto.
+ // d) Otherwise, the callback will get run, and if it returns true we will
+ // stop, and if false we won't.
+ // The asynchronous callback can run the target itself, but at present that
+ // should be the last action the
+ // callback does. We will relax this condition at some point, but it will
+ // take a bit of plumbing to get
+ // that to work.
+ //
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Adds a callback to the breakpoint option set.
+ ///
+ /// @param[in] callback
+ /// The function to be called when the breakpoint gets hit.
+ ///
+ /// @param[in] baton_sp
+ /// A baton which will get passed back to the callback when it is invoked.
+ ///
+ /// @param[in] synchronous
+ /// Whether this is a synchronous or asynchronous callback. See discussion
+ /// above.
+ //------------------------------------------------------------------
+ void SetCallback(BreakpointHitCallback callback,
+ const lldb::BatonSP &baton_sp, bool synchronous = false);
+
+ void SetCallback(BreakpointHitCallback callback,
+ const BreakpointOptions::CommandBatonSP &command_baton_sp,
+ bool synchronous = false);
+
+ //------------------------------------------------------------------
+ /// Returns the command line commands for the callback on this breakpoint.
+ ///
+ /// @param[out] command_list
+ /// The commands will be appended to this list.
+ ///
+ /// @return
+ /// \btrue if the command callback is a command-line callback,
+ /// \bfalse otherwise.
+ //------------------------------------------------------------------
+ bool GetCommandLineCallbacks(StringList &command_list);
+
+ //------------------------------------------------------------------
+ /// Remove the callback from this option set.
+ //------------------------------------------------------------------
+ void ClearCallback();
+
+ // The rest of these functions are meant to be used only within the breakpoint
+ // handling mechanism.
+
+ //------------------------------------------------------------------
+ /// Use this function to invoke the callback for a specific stop.
+ ///
+ /// @param[in] context
+ /// The context in which the callback is to be invoked. This includes the
+ /// stop event, the
+ /// execution context of the stop (since you might hit the same breakpoint
+ /// on multiple threads) and
+ /// whether we are currently executing synchronous or asynchronous
+ /// callbacks.
+ ///
+ /// @param[in] break_id
+ /// The breakpoint ID that owns this option set.
+ ///
+ /// @param[in] break_loc_id
+ /// The breakpoint location ID that owns this option set.
+ ///
+ /// @return
+ /// The callback return value.
+ //------------------------------------------------------------------
+ bool InvokeCallback(StoppointCallbackContext *context,
+ lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
+
+ //------------------------------------------------------------------
+ /// Used in InvokeCallback to tell whether it is the right time to run this
+ /// kind of callback.
+ ///
+ /// @return
+ /// The synchronicity of our callback.
+ //------------------------------------------------------------------
+ bool IsCallbackSynchronous() const { return m_callback_is_synchronous; }
+
+ //------------------------------------------------------------------
+ /// Fetch the baton from the callback.
+ ///
+ /// @return
+ /// The baton.
+ //------------------------------------------------------------------
+ Baton *GetBaton();
+
+ //------------------------------------------------------------------
+ /// Fetch a const version of the baton from the callback.
+ ///
+ /// @return
+ /// The baton.
+ //------------------------------------------------------------------
+ const Baton *GetBaton() const;
+
+ //------------------------------------------------------------------
+ // Condition
+ //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ /// Set the breakpoint option's condition.
+ ///
+ /// @param[in] condition
+ /// The condition expression to evaluate when the breakpoint is hit.
+ //------------------------------------------------------------------
+ void SetCondition(const char *condition);
+
+ //------------------------------------------------------------------
+ /// Return a pointer to the text of the condition expression.
+ ///
+ /// @return
+ /// A pointer to the condition expression text, or nullptr if no
+ // condition has been set.
+ //------------------------------------------------------------------
+ const char *GetConditionText(size_t *hash = nullptr) const;
+
+ //------------------------------------------------------------------
+ // Enabled/Ignore Count
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Check the Enable/Disable state.
+ /// @return
+ /// \b true if the breakpoint is enabled, \b false if disabled.
+ //------------------------------------------------------------------
+ bool IsEnabled() const { return m_enabled; }
+
+ //------------------------------------------------------------------
+ /// If \a enable is \b true, enable the breakpoint, if \b false disable it.
+ //------------------------------------------------------------------
+ void SetEnabled(bool enabled) { m_enabled = enabled; }
+
+ //------------------------------------------------------------------
+ /// Check the One-shot state.
+ /// @return
+ /// \b true if the breakpoint is one-shot, \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsOneShot() const { return m_one_shot; }
+
+ //------------------------------------------------------------------
+ /// If \a enable is \b true, enable the breakpoint, if \b false disable it.
+ //------------------------------------------------------------------
+ void SetOneShot(bool one_shot) { m_one_shot = one_shot; }
+
+ //------------------------------------------------------------------
+ /// Set the breakpoint to ignore the next \a count breakpoint hits.
+ /// @param[in] count
+ /// The number of breakpoint hits to ignore.
+ //------------------------------------------------------------------
+
+ void SetIgnoreCount(uint32_t n) { m_ignore_count = n; }
+
+ //------------------------------------------------------------------
+ /// Return the current Ignore Count.
+ /// @return
+ /// The number of breakpoint hits to be ignored.
+ //------------------------------------------------------------------
+ uint32_t GetIgnoreCount() const { return m_ignore_count; }
+
+ //------------------------------------------------------------------
+ /// Return the current thread spec for this option. This will return nullptr
+ /// if the no thread
+ /// specifications have been set for this Option yet.
+ /// @return
+ /// The thread specification pointer for this option, or nullptr if none
+ /// has
+ /// been set yet.
+ //------------------------------------------------------------------
+ const ThreadSpec *GetThreadSpecNoCreate() const;
+
+ //------------------------------------------------------------------
+ /// Returns a pointer to the ThreadSpec for this option, creating it.
+ /// if it hasn't been created already. This API is used for setting the
+ /// ThreadSpec items for this option.
+ //------------------------------------------------------------------
+ ThreadSpec *GetThreadSpec();
+
+ void SetThreadID(lldb::tid_t thread_id);
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) const;
+
+ //------------------------------------------------------------------
+ /// Returns true if the breakpoint option has a callback set.
+ //------------------------------------------------------------------
+ bool HasCallback() const;
+
+ //------------------------------------------------------------------
+ /// This is the default empty callback.
+ //------------------------------------------------------------------
+ static bool NullCallback(void *baton, StoppointCallbackContext *context,
+ lldb::user_id_t break_id,
+ lldb::user_id_t break_loc_id);
+
+ //------------------------------------------------------------------
+ /// Set a callback based on BreakpointOptions::CommandData.
+ /// @param[in] cmd_data
+ /// A UP holding the new'ed CommandData object.
+ /// The breakpoint will take ownership of pointer held by this object.
+ //------------------------------------------------------------------
+ void SetCommandDataCallback(std::unique_ptr<CommandData> &cmd_data);
protected:
- //------------------------------------------------------------------
- // Classes that inherit from BreakpointOptions can see and modify these
- //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ // Classes that inherit from BreakpointOptions can see and modify these
+ //------------------------------------------------------------------
+ enum class OptionNames {
+ ConditionText = 0,
+ IgnoreCount,
+ EnabledState,
+ OneShotState,
+ LastOptionName
+ };
+ static const char *g_option_names[(size_t)OptionNames::LastOptionName];
+
+ static const char *GetKey(OptionNames enum_value) {
+ return g_option_names[(size_t)enum_value];
+ }
+
+ static bool BreakpointOptionsCallbackFunction(
+ void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id,
+ lldb::user_id_t break_loc_id);
+
+ void SetThreadSpec(std::unique_ptr<ThreadSpec> &thread_spec_up);
private:
- //------------------------------------------------------------------
- // For BreakpointOptions only
- //------------------------------------------------------------------
- BreakpointHitCallback m_callback; // This is the callback function pointer
- lldb::BatonSP m_callback_baton_sp; // This is the client data for the callback
- bool m_callback_is_synchronous;
- bool m_enabled;
- bool m_one_shot;
- uint32_t m_ignore_count; // Number of times to ignore this breakpoint
- std::unique_ptr<ThreadSpec> m_thread_spec_ap; // Thread for which this breakpoint will take
- std::string m_condition_text; // The condition to test.
- size_t m_condition_text_hash; // Its hash, so that locations know when the condition is updated.
+ //------------------------------------------------------------------
+ // For BreakpointOptions only
+ //------------------------------------------------------------------
+ BreakpointHitCallback m_callback; // This is the callback function pointer
+ lldb::BatonSP m_callback_baton_sp; // This is the client data for the callback
+ bool m_baton_is_command_baton;
+ bool m_callback_is_synchronous;
+ bool m_enabled;
+ bool m_one_shot;
+ uint32_t m_ignore_count; // Number of times to ignore this breakpoint
+ std::unique_ptr<ThreadSpec>
+ m_thread_spec_ap; // Thread for which this breakpoint will take
+ std::string m_condition_text; // The condition to test.
+ size_t m_condition_text_hash; // Its hash, so that locations know when the
+ // condition is updated.
};
} // namespace lldb_private
diff --git a/include/lldb/Breakpoint/BreakpointResolver.h b/include/lldb/Breakpoint/BreakpointResolver.h
index b117e668a1bd..e19a2135fbd2 100644
--- a/include/lldb/Breakpoint/BreakpointResolver.h
+++ b/include/lldb/Breakpoint/BreakpointResolver.h
@@ -14,20 +14,22 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
-#include "lldb/Core/Address.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointResolver.h"
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Core/Address.h"
+#include "lldb/Core/ConstString.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/SearchFilter.h"
-#include "lldb/Core/ConstString.h"
+#include "lldb/Host/FileSpec.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class BreakpointResolver BreakpointResolver.h "lldb/Breakpoint/BreakpointResolver.h"
-/// @brief This class works with SearchFilter to resolve logical breakpoints to their
+/// @class BreakpointResolver BreakpointResolver.h
+/// "lldb/Breakpoint/BreakpointResolver.h"
+/// @brief This class works with SearchFilter to resolve logical breakpoints to
+/// their
/// of concrete breakpoint locations.
//----------------------------------------------------------------------
@@ -35,150 +37,220 @@ namespace lldb_private {
/// General Outline:
/// The BreakpointResolver is a Searcher. In that protocol,
/// the SearchFilter asks the question "At what depth of the symbol context
-/// descent do you want your callback to get called?" of the filter. The resolver
-/// answers this question (in the GetDepth method) and provides the resolution callback.
-/// Each Breakpoint has a BreakpointResolver, and it calls either ResolveBreakpoint
-/// or ResolveBreakpointInModules to tell it to look for new breakpoint locations.
+/// descent do you want your callback to get called?" of the filter. The
+/// resolver
+/// answers this question (in the GetDepth method) and provides the resolution
+/// callback.
+/// Each Breakpoint has a BreakpointResolver, and it calls either
+/// ResolveBreakpoint
+/// or ResolveBreakpointInModules to tell it to look for new breakpoint
+/// locations.
//----------------------------------------------------------------------
-class BreakpointResolver :
- public Searcher
-{
-friend class Breakpoint;
+class BreakpointResolver : public Searcher {
+ friend class Breakpoint;
public:
- //------------------------------------------------------------------
- /// The breakpoint resolver need to have a breakpoint for "ResolveBreakpoint
- /// to make sense. It can be constructed without a breakpoint, but you have to
- /// call SetBreakpoint before ResolveBreakpoint.
- ///
- /// @param[in] bkpt
- /// The breakpoint that owns this resolver.
- /// @param[in] resolverType
- /// The concrete breakpoint resolver type for this breakpoint.
- ///
- /// @result
- /// Returns breakpoint location id.
- //------------------------------------------------------------------
- BreakpointResolver (Breakpoint *bkpt, unsigned char resolverType, lldb::addr_t offset = 0);
-
- //------------------------------------------------------------------
- /// The Destructor is virtual, all significant breakpoint resolvers derive
- /// from this class.
- //------------------------------------------------------------------
- ~BreakpointResolver() override;
-
- //------------------------------------------------------------------
- /// This sets the breakpoint for this resolver.
- ///
- /// @param[in] bkpt
- /// The breakpoint that owns this resolver.
- //------------------------------------------------------------------
- void
- SetBreakpoint (Breakpoint *bkpt);
-
- //------------------------------------------------------------------
- /// This updates the offset for this breakpoint. All the locations currently
- /// set for this breakpoint will have their offset adjusted when this is called.
- ///
- /// @param[in] offset
- /// The offset to add to all locations.
- //------------------------------------------------------------------
- void
- SetOffset (lldb::addr_t offset);
-
- //------------------------------------------------------------------
- /// This updates the offset for this breakpoint. All the locations currently
- /// set for this breakpoint will have their offset adjusted when this is called.
- ///
- /// @param[in] offset
- /// The offset to add to all locations.
- //------------------------------------------------------------------
- lldb::addr_t
- GetOffset () const
- {
- return m_offset;
- }
-
- //------------------------------------------------------------------
- /// In response to this method the resolver scans all the modules in the breakpoint's
- /// target, and adds any new locations it finds.
- ///
- /// @param[in] filter
- /// The filter that will manage the search for this resolver.
- //------------------------------------------------------------------
- virtual void
- ResolveBreakpoint (SearchFilter &filter);
-
- //------------------------------------------------------------------
- /// In response to this method the resolver scans the modules in the module list
- /// \a modules, and adds any new locations it finds.
- ///
- /// @param[in] filter
- /// The filter that will manage the search for this resolver.
- //------------------------------------------------------------------
- virtual void
- ResolveBreakpointInModules (SearchFilter &filter,
- ModuleList &modules);
-
- //------------------------------------------------------------------
- /// Prints a canonical description for the breakpoint to the stream \a s.
- ///
- /// @param[in] s
- /// Stream to which the output is copied.
- //------------------------------------------------------------------
- void
- GetDescription(Stream *s) override = 0;
-
- //------------------------------------------------------------------
- /// Standard "Dump" method. At present it does nothing.
- //------------------------------------------------------------------
- virtual void
- Dump (Stream *s) const = 0;
-
- //------------------------------------------------------------------
- /// An enumeration for keeping track of the concrete subclass that
- /// is actually instantiated. Values of this enumeration are kept in the
- /// BreakpointResolver's SubclassID field. They are used for concrete type
- /// identification.
- enum ResolverTy {
- FileLineResolver, // This is an instance of BreakpointResolverFileLine
- AddressResolver, // This is an instance of BreakpointResolverAddress
- NameResolver, // This is an instance of BreakpointResolverName
- FileRegexResolver,
- ExceptionResolver,
- LastKnownResolverType = ExceptionResolver
- };
-
- //------------------------------------------------------------------
- /// getResolverID - Return an ID for the concrete type of this object. This
- /// is used to implement the LLVM classof checks. This should not be used
- /// for any other purpose, as the values may change as LLDB evolves.
- unsigned getResolverID() const {
- return SubclassID;
- }
-
- virtual lldb::BreakpointResolverSP
- CopyForBreakpoint (Breakpoint &breakpoint) = 0;
+ //------------------------------------------------------------------
+ /// The breakpoint resolver need to have a breakpoint for "ResolveBreakpoint
+ /// to make sense. It can be constructed without a breakpoint, but you have
+ /// to
+ /// call SetBreakpoint before ResolveBreakpoint.
+ ///
+ /// @param[in] bkpt
+ /// The breakpoint that owns this resolver.
+ /// @param[in] resolverType
+ /// The concrete breakpoint resolver type for this breakpoint.
+ ///
+ /// @result
+ /// Returns breakpoint location id.
+ //------------------------------------------------------------------
+ BreakpointResolver(Breakpoint *bkpt, unsigned char resolverType,
+ lldb::addr_t offset = 0);
+
+ //------------------------------------------------------------------
+ /// The Destructor is virtual, all significant breakpoint resolvers derive
+ /// from this class.
+ //------------------------------------------------------------------
+ ~BreakpointResolver() override;
+
+ //------------------------------------------------------------------
+ /// This sets the breakpoint for this resolver.
+ ///
+ /// @param[in] bkpt
+ /// The breakpoint that owns this resolver.
+ //------------------------------------------------------------------
+ void SetBreakpoint(Breakpoint *bkpt);
+
+ //------------------------------------------------------------------
+ /// This updates the offset for this breakpoint. All the locations currently
+ /// set for this breakpoint will have their offset adjusted when this is
+ /// called.
+ ///
+ /// @param[in] offset
+ /// The offset to add to all locations.
+ //------------------------------------------------------------------
+ void SetOffset(lldb::addr_t offset);
+
+ //------------------------------------------------------------------
+ /// This updates the offset for this breakpoint. All the locations currently
+ /// set for this breakpoint will have their offset adjusted when this is
+ /// called.
+ ///
+ /// @param[in] offset
+ /// The offset to add to all locations.
+ //------------------------------------------------------------------
+ lldb::addr_t GetOffset() const { return m_offset; }
+
+ //------------------------------------------------------------------
+ /// In response to this method the resolver scans all the modules in the
+ /// breakpoint's
+ /// target, and adds any new locations it finds.
+ ///
+ /// @param[in] filter
+ /// The filter that will manage the search for this resolver.
+ //------------------------------------------------------------------
+ virtual void ResolveBreakpoint(SearchFilter &filter);
+
+ //------------------------------------------------------------------
+ /// In response to this method the resolver scans the modules in the module
+ /// list
+ /// \a modules, and adds any new locations it finds.
+ ///
+ /// @param[in] filter
+ /// The filter that will manage the search for this resolver.
+ //------------------------------------------------------------------
+ virtual void ResolveBreakpointInModules(SearchFilter &filter,
+ ModuleList &modules);
+
+ //------------------------------------------------------------------
+ /// Prints a canonical description for the breakpoint to the stream \a s.
+ ///
+ /// @param[in] s
+ /// Stream to which the output is copied.
+ //------------------------------------------------------------------
+ void GetDescription(Stream *s) override = 0;
+
+ //------------------------------------------------------------------
+ /// Standard "Dump" method. At present it does nothing.
+ //------------------------------------------------------------------
+ virtual void Dump(Stream *s) const = 0;
+
+ /// This section handles serializing and deserializing from StructuredData
+ /// objects.
+
+ static lldb::BreakpointResolverSP
+ CreateFromStructuredData(const StructuredData::Dictionary &resolver_dict,
+ Error &error);
+
+ virtual StructuredData::ObjectSP SerializeToStructuredData() {
+ return StructuredData::ObjectSP();
+ }
+
+ static const char *GetSerializationKey() { return "BKPTResolver"; }
+
+ static const char *GetSerializationSubclassKey() { return "Type"; }
+
+ static const char *GetSerializationSubclassOptionsKey() { return "Options"; }
+
+ StructuredData::DictionarySP
+ WrapOptionsDict(StructuredData::DictionarySP options_dict_sp);
+
+ //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ /// An enumeration for keeping track of the concrete subclass that
+ /// is actually instantiated. Values of this enumeration are kept in the
+ /// BreakpointResolver's SubclassID field. They are used for concrete type
+ /// identification.
+ enum ResolverTy {
+ FileLineResolver = 0, // This is an instance of BreakpointResolverFileLine
+ AddressResolver, // This is an instance of BreakpointResolverAddress
+ NameResolver, // This is an instance of BreakpointResolverName
+ FileRegexResolver,
+ ExceptionResolver,
+ LastKnownResolverType = ExceptionResolver,
+ UnknownResolver
+ };
+
+ // Translate the Ty to name for serialization,
+ // the "+2" is one for size vrs. index, and one for UnknownResolver.
+ static const char *g_ty_to_name[LastKnownResolverType + 2];
+
+ //------------------------------------------------------------------
+ /// getResolverID - Return an ID for the concrete type of this object. This
+ /// is used to implement the LLVM classof checks. This should not be used
+ /// for any other purpose, as the values may change as LLDB evolves.
+ unsigned getResolverID() const { return SubclassID; }
+
+ enum ResolverTy GetResolverTy() {
+ if (SubclassID > ResolverTy::LastKnownResolverType)
+ return ResolverTy::UnknownResolver;
+ else
+ return (enum ResolverTy)SubclassID;
+ }
+
+ const char *GetResolverName() { return ResolverTyToName(GetResolverTy()); }
+
+ static const char *ResolverTyToName(enum ResolverTy);
+
+ static ResolverTy NameToResolverTy(const char *name);
+
+ virtual lldb::BreakpointResolverSP
+ CopyForBreakpoint(Breakpoint &breakpoint) = 0;
protected:
- //------------------------------------------------------------------
- /// SetSCMatchesByLine - Takes a symbol context list of matches which supposedly represent the same file and
- /// line number in a CU, and find the nearest actual line number that matches, and then filter down the
- /// matching addresses to unique entries, and skip the prologue if asked to do so, and then set
- /// breakpoint locations in this breakpoint for all the resultant addresses.
- void SetSCMatchesByLine (SearchFilter &filter, SymbolContextList &sc_list, bool skip_prologue, const char *log_ident);
-
- lldb::BreakpointLocationSP
- AddLocation(Address loc_addr, bool *new_location = NULL);
-
- Breakpoint *m_breakpoint; // This is the breakpoint we add locations to.
- lldb::addr_t m_offset; // A random offset the user asked us to add to any breakpoints we set.
+ // Used for serializing resolver options:
+ // The options in this enum and the strings in the
+ // g_option_names must be kept in sync.
+ enum class OptionNames : uint32_t {
+ AddressOffset = 0,
+ ExactMatch,
+ FileName,
+ Inlines,
+ LanguageName,
+ LineNumber,
+ ModuleName,
+ NameMaskArray,
+ Offset,
+ RegexString,
+ SectionName,
+ SkipPrologue,
+ SymbolNameArray,
+ LastOptionName
+ };
+ static const char
+ *g_option_names[static_cast<uint32_t>(OptionNames::LastOptionName)];
+
+public:
+ static const char *GetKey(OptionNames enum_value) {
+ return g_option_names[static_cast<uint32_t>(enum_value)];
+ }
+
+protected:
+ //------------------------------------------------------------------
+ /// SetSCMatchesByLine - Takes a symbol context list of matches which
+ /// supposedly represent the same file and
+ /// line number in a CU, and find the nearest actual line number that matches,
+ /// and then filter down the
+ /// matching addresses to unique entries, and skip the prologue if asked to do
+ /// so, and then set
+ /// breakpoint locations in this breakpoint for all the resultant addresses.
+ void SetSCMatchesByLine(SearchFilter &filter, SymbolContextList &sc_list,
+ bool skip_prologue, llvm::StringRef log_ident);
+ void SetSCMatchesByLine(SearchFilter &, SymbolContextList &, bool,
+ const char *) = delete;
+
+ lldb::BreakpointLocationSP AddLocation(Address loc_addr,
+ bool *new_location = NULL);
+
+ Breakpoint *m_breakpoint; // This is the breakpoint we add locations to.
+ lldb::addr_t m_offset; // A random offset the user asked us to add to any
+ // breakpoints we set.
private:
- // Subclass identifier (for llvm isa/dyn_cast)
- const unsigned char SubclassID;
- DISALLOW_COPY_AND_ASSIGN(BreakpointResolver);
+ // Subclass identifier (for llvm isa/dyn_cast)
+ const unsigned char SubclassID;
+ DISALLOW_COPY_AND_ASSIGN(BreakpointResolver);
};
} // namespace lldb_private
diff --git a/include/lldb/Breakpoint/BreakpointResolverAddress.h b/include/lldb/Breakpoint/BreakpointResolverAddress.h
index 8ec1e39e52ab..6d2d505811f9 100644
--- a/include/lldb/Breakpoint/BreakpointResolverAddress.h
+++ b/include/lldb/Breakpoint/BreakpointResolverAddress.h
@@ -20,63 +20,64 @@
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class BreakpointResolverAddress BreakpointResolverAddress.h "lldb/Breakpoint/BreakpointResolverAddress.h"
-/// @brief This class sets breakpoints on a given Address. This breakpoint only takes
+/// @class BreakpointResolverAddress BreakpointResolverAddress.h
+/// "lldb/Breakpoint/BreakpointResolverAddress.h"
+/// @brief This class sets breakpoints on a given Address. This breakpoint only
+/// takes
/// once, and then it won't attempt to reset itself.
//----------------------------------------------------------------------
-class BreakpointResolverAddress:
- public BreakpointResolver
-{
+class BreakpointResolverAddress : public BreakpointResolver {
public:
- BreakpointResolverAddress (Breakpoint *bkpt,
- const Address &addr);
+ BreakpointResolverAddress(Breakpoint *bkpt, const Address &addr);
- BreakpointResolverAddress (Breakpoint *bkpt,
- const Address &addr,
- const FileSpec &module_spec);
+ BreakpointResolverAddress(Breakpoint *bkpt, const Address &addr,
+ const FileSpec &module_spec);
- ~BreakpointResolverAddress() override;
+ ~BreakpointResolverAddress() override;
- void
- ResolveBreakpoint (SearchFilter &filter) override;
+ static BreakpointResolver *
+ CreateFromStructuredData(Breakpoint *bkpt,
+ const StructuredData::Dictionary &options_dict,
+ Error &error);
- void
- ResolveBreakpointInModules (SearchFilter &filter,
- ModuleList &modules) override;
+ StructuredData::ObjectSP SerializeToStructuredData() override;
- Searcher::CallbackReturn
- SearchCallback (SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool containing) override;
+ void ResolveBreakpoint(SearchFilter &filter) override;
- Searcher::Depth
- GetDepth () override;
+ void ResolveBreakpointInModules(SearchFilter &filter,
+ ModuleList &modules) override;
- void
- GetDescription (Stream *s) override;
+ Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
+ SymbolContext &context, Address *addr,
+ bool containing) override;
- void
- Dump (Stream *s) const override;
+ Searcher::Depth GetDepth() override;
- /// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool classof(const BreakpointResolverAddress *) { return true; }
- static inline bool classof(const BreakpointResolver *V) {
- return V->getResolverID() == BreakpointResolver::AddressResolver;
- }
+ void GetDescription(Stream *s) override;
- lldb::BreakpointResolverSP
- CopyForBreakpoint (Breakpoint &breakpoint) override;
+ void Dump(Stream *s) const override;
+
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const BreakpointResolverAddress *) { return true; }
+ static inline bool classof(const BreakpointResolver *V) {
+ return V->getResolverID() == BreakpointResolver::AddressResolver;
+ }
+
+ lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override;
protected:
- Address m_addr; // The address - may be Section Offset or may be just an offset
- lldb::addr_t m_resolved_addr; // The current value of the resolved load address for this breakpoint,
- FileSpec m_module_filespec; // If this filespec is Valid, and m_addr is an offset, then it will be converted
- // to a Section+Offset address in this module, whenever that module gets around to
- // being loaded.
+ Address
+ m_addr; // The address - may be Section Offset or may be just an offset
+ lldb::addr_t m_resolved_addr; // The current value of the resolved load
+ // address for this breakpoint,
+ FileSpec m_module_filespec; // If this filespec is Valid, and m_addr is an
+ // offset, then it will be converted
+ // to a Section+Offset address in this module, whenever that module gets
+ // around to
+ // being loaded.
private:
- DISALLOW_COPY_AND_ASSIGN(BreakpointResolverAddress);
+ DISALLOW_COPY_AND_ASSIGN(BreakpointResolverAddress);
};
} // namespace lldb_private
diff --git a/include/lldb/Breakpoint/BreakpointResolverFileLine.h b/include/lldb/Breakpoint/BreakpointResolverFileLine.h
index cea192b5edbf..f1fdf60e74ec 100644
--- a/include/lldb/Breakpoint/BreakpointResolverFileLine.h
+++ b/include/lldb/Breakpoint/BreakpointResolverFileLine.h
@@ -19,59 +19,60 @@
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class BreakpointResolverFileLine BreakpointResolverFileLine.h "lldb/Breakpoint/BreakpointResolverFileLine.h"
-/// @brief This class sets breakpoints by file and line. Optionally, it will look for inlined
+/// @class BreakpointResolverFileLine BreakpointResolverFileLine.h
+/// "lldb/Breakpoint/BreakpointResolverFileLine.h"
+/// @brief This class sets breakpoints by file and line. Optionally, it will
+/// look for inlined
/// instances of the file and line specification.
//----------------------------------------------------------------------
-class BreakpointResolverFileLine :
- public BreakpointResolver
-{
+class BreakpointResolverFileLine : public BreakpointResolver {
public:
- BreakpointResolverFileLine (Breakpoint *bkpt,
- const FileSpec &resolver,
- uint32_t line_no,
- lldb::addr_t m_offset,
- bool check_inlines,
- bool skip_prologue,
- bool exact_match);
+ BreakpointResolverFileLine(Breakpoint *bkpt, const FileSpec &resolver,
+ uint32_t line_no, lldb::addr_t m_offset,
+ bool check_inlines, bool skip_prologue,
+ bool exact_match);
- ~BreakpointResolverFileLine() override;
+ static BreakpointResolver *
+ CreateFromStructuredData(Breakpoint *bkpt,
+ const StructuredData::Dictionary &data_dict,
+ Error &error);
- Searcher::CallbackReturn
- SearchCallback (SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool containing) override;
+ StructuredData::ObjectSP SerializeToStructuredData() override;
- Searcher::Depth
- GetDepth () override;
+ ~BreakpointResolverFileLine() override;
- void
- GetDescription (Stream *s) override;
+ Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
+ SymbolContext &context, Address *addr,
+ bool containing) override;
- void
- Dump (Stream *s) const override;
+ Searcher::Depth GetDepth() override;
- /// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool classof(const BreakpointResolverFileLine *) { return true; }
- static inline bool classof(const BreakpointResolver *V) {
- return V->getResolverID() == BreakpointResolver::FileLineResolver;
- }
+ void GetDescription(Stream *s) override;
- lldb::BreakpointResolverSP
- CopyForBreakpoint (Breakpoint &breakpoint) override;
+ void Dump(Stream *s) const override;
+
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const BreakpointResolverFileLine *) {
+ return true;
+ }
+ static inline bool classof(const BreakpointResolver *V) {
+ return V->getResolverID() == BreakpointResolver::FileLineResolver;
+ }
+
+ lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override;
protected:
- friend class Breakpoint;
- FileSpec m_file_spec; // This is the file spec we are looking for.
- uint32_t m_line_number; // This is the line number that we are looking for.
- bool m_inlines; // This determines whether the resolver looks for inlined functions or not.
- bool m_skip_prologue;
- bool m_exact_match;
+ friend class Breakpoint;
+ FileSpec m_file_spec; // This is the file spec we are looking for.
+ uint32_t m_line_number; // This is the line number that we are looking for.
+ bool m_inlines; // This determines whether the resolver looks for inlined
+ // functions or not.
+ bool m_skip_prologue;
+ bool m_exact_match;
private:
- DISALLOW_COPY_AND_ASSIGN(BreakpointResolverFileLine);
+ DISALLOW_COPY_AND_ASSIGN(BreakpointResolverFileLine);
};
} // namespace lldb_private
diff --git a/include/lldb/Breakpoint/BreakpointResolverFileRegex.h b/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
index ce67c2dc98ec..0429e264774e 100644
--- a/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
+++ b/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
@@ -1,4 +1,5 @@
-//===-- BreakpointResolverFileRegex.h ----------------------------*- C++ -*-===//
+//===-- BreakpointResolverFileRegex.h ----------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -21,57 +22,62 @@
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class BreakpointResolverFileRegex BreakpointResolverFileRegex.h "lldb/Breakpoint/BreakpointResolverFileRegex.h"
-/// @brief This class sets breakpoints by file and line. Optionally, it will look for inlined
+/// @class BreakpointResolverFileRegex BreakpointResolverFileRegex.h
+/// "lldb/Breakpoint/BreakpointResolverFileRegex.h"
+/// @brief This class sets breakpoints by file and line. Optionally, it will
+/// look for inlined
/// instances of the file and line specification.
//----------------------------------------------------------------------
-class BreakpointResolverFileRegex :
- public BreakpointResolver
-{
+class BreakpointResolverFileRegex : public BreakpointResolver {
public:
- BreakpointResolverFileRegex (Breakpoint *bkpt,
- RegularExpression &regex,
- const std::unordered_set<std::string> &func_name_set,
- bool exact_match);
+ BreakpointResolverFileRegex(
+ Breakpoint *bkpt, RegularExpression &regex,
+ const std::unordered_set<std::string> &func_name_set, bool exact_match);
- ~BreakpointResolverFileRegex() override;
+ static BreakpointResolver *
+ CreateFromStructuredData(Breakpoint *bkpt,
+ const StructuredData::Dictionary &options_dict,
+ Error &error);
- Searcher::CallbackReturn
- SearchCallback (SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool containing) override;
+ StructuredData::ObjectSP SerializeToStructuredData() override;
- Searcher::Depth
- GetDepth () override;
+ ~BreakpointResolverFileRegex() override;
- void
- GetDescription (Stream *s) override;
+ Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
+ SymbolContext &context, Address *addr,
+ bool containing) override;
- void
- Dump (Stream *s) const override;
-
- void
- AddFunctionName(const char *func_name);
+ Searcher::Depth GetDepth() override;
- /// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool classof(const BreakpointResolverFileRegex *) { return true; }
- static inline bool classof(const BreakpointResolver *V) {
- return V->getResolverID() == BreakpointResolver::FileRegexResolver;
- }
+ void GetDescription(Stream *s) override;
- lldb::BreakpointResolverSP
- CopyForBreakpoint (Breakpoint &breakpoint) override;
+ void Dump(Stream *s) const override;
+
+ void AddFunctionName(const char *func_name);
+
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const BreakpointResolverFileRegex *) {
+ return true;
+ }
+ static inline bool classof(const BreakpointResolver *V) {
+ return V->getResolverID() == BreakpointResolver::FileRegexResolver;
+ }
+
+ lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override;
protected:
- friend class Breakpoint;
- RegularExpression m_regex; // This is the line expression that we are looking for.
- bool m_exact_match; // If true, then if the source we match is in a comment, we won't set a location there.
- std::unordered_set<std::string> m_function_names; // Limit the search to functions in the comp_unit passed in.
+ friend class Breakpoint;
+ RegularExpression
+ m_regex; // This is the line expression that we are looking for.
+ bool m_exact_match; // If true, then if the source we match is in a comment,
+ // we won't set a location there.
+ std::unordered_set<std::string> m_function_names; // Limit the search to
+ // functions in the
+ // comp_unit passed in.
private:
- DISALLOW_COPY_AND_ASSIGN(BreakpointResolverFileRegex);
+ DISALLOW_COPY_AND_ASSIGN(BreakpointResolverFileRegex);
};
} // namespace lldb_private
diff --git a/include/lldb/Breakpoint/BreakpointResolverName.h b/include/lldb/Breakpoint/BreakpointResolverName.h
index a11359dd0094..4223125d9268 100644
--- a/include/lldb/Breakpoint/BreakpointResolverName.h
+++ b/include/lldb/Breakpoint/BreakpointResolverName.h
@@ -12,8 +12,8 @@
// C Includes
// C++ Includes
-#include <vector>
#include <string>
+#include <vector>
// Other libraries and framework includes
// Project includes
@@ -23,93 +23,75 @@
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class BreakpointResolverName BreakpointResolverName.h "lldb/Breakpoint/BreakpointResolverName.h"
-/// @brief This class sets breakpoints on a given function name, either by exact match
+/// @class BreakpointResolverName BreakpointResolverName.h
+/// "lldb/Breakpoint/BreakpointResolverName.h"
+/// @brief This class sets breakpoints on a given function name, either by exact
+/// match
/// or by regular expression.
//----------------------------------------------------------------------
-class BreakpointResolverName:
- public BreakpointResolver
-{
+class BreakpointResolverName : public BreakpointResolver {
public:
+ BreakpointResolverName(Breakpoint *bkpt, const char *name,
+ uint32_t name_type_mask, lldb::LanguageType language,
+ Breakpoint::MatchType type, lldb::addr_t offset,
+ bool skip_prologue);
+
+ // This one takes an array of names. It is always MatchType = Exact.
+ BreakpointResolverName(Breakpoint *bkpt, const char *names[],
+ size_t num_names, uint32_t name_type_mask,
+ lldb::LanguageType language, lldb::addr_t offset,
+ bool skip_prologue);
+
+ // This one takes a C++ array of names. It is always MatchType = Exact.
+ BreakpointResolverName(Breakpoint *bkpt, std::vector<std::string> names,
+ uint32_t name_type_mask, lldb::LanguageType language,
+ lldb::addr_t offset, bool skip_prologue);
+
+ // Creates a function breakpoint by regular expression. Takes over control of
+ // the lifespan of func_regex.
+ BreakpointResolverName(Breakpoint *bkpt, RegularExpression &func_regex,
+ lldb::LanguageType language, lldb::addr_t offset,
+ bool skip_prologue);
+
+ static BreakpointResolver *
+ CreateFromStructuredData(Breakpoint *bkpt,
+ const StructuredData::Dictionary &data_dict,
+ Error &error);
+
+ StructuredData::ObjectSP SerializeToStructuredData() override;
+
+ ~BreakpointResolverName() override;
+
+ Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
+ SymbolContext &context, Address *addr,
+ bool containing) override;
+
+ Searcher::Depth GetDepth() override;
+
+ void GetDescription(Stream *s) override;
+
+ void Dump(Stream *s) const override;
+
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const BreakpointResolverName *) { return true; }
+ static inline bool classof(const BreakpointResolver *V) {
+ return V->getResolverID() == BreakpointResolver::NameResolver;
+ }
- BreakpointResolverName (Breakpoint *bkpt,
- const char *name,
- uint32_t name_type_mask,
- lldb::LanguageType language,
- Breakpoint::MatchType type,
- lldb::addr_t offset,
- bool skip_prologue);
-
- // This one takes an array of names. It is always MatchType = Exact.
- BreakpointResolverName (Breakpoint *bkpt,
- const char *names[],
- size_t num_names,
- uint32_t name_type_mask,
- lldb::LanguageType language,
- lldb::addr_t offset,
- bool skip_prologue);
-
- // This one takes a C++ array of names. It is always MatchType = Exact.
- BreakpointResolverName (Breakpoint *bkpt,
- std::vector<std::string> names,
- uint32_t name_type_mask,
- lldb::LanguageType language,
- lldb::addr_t offset,
- bool skip_prologue);
-
- // Creates a function breakpoint by regular expression. Takes over control of the lifespan of func_regex.
- BreakpointResolverName (Breakpoint *bkpt,
- RegularExpression &func_regex,
- lldb::LanguageType language,
- lldb::addr_t offset,
- bool skip_prologue);
-
- BreakpointResolverName (Breakpoint *bkpt,
- const char *class_name,
- const char *method,
- Breakpoint::MatchType type,
- lldb::addr_t offset,
- bool skip_prologue);
-
- ~BreakpointResolverName() override;
-
- Searcher::CallbackReturn
- SearchCallback (SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool containing) override;
-
- Searcher::Depth
- GetDepth () override;
-
- void
- GetDescription (Stream *s) override;
-
- void
- Dump (Stream *s) const override;
-
- /// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool classof(const BreakpointResolverName *) { return true; }
- static inline bool classof(const BreakpointResolver *V) {
- return V->getResolverID() == BreakpointResolver::NameResolver;
- }
-
- lldb::BreakpointResolverSP
- CopyForBreakpoint (Breakpoint &breakpoint) override;
+ lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override;
protected:
- BreakpointResolverName(const BreakpointResolverName &rhs);
+ BreakpointResolverName(const BreakpointResolverName &rhs);
- std::vector<Module::LookupInfo> m_lookups;
- ConstString m_class_name;
- RegularExpression m_regex;
- Breakpoint::MatchType m_match_type;
- lldb::LanguageType m_language;
- bool m_skip_prologue;
+ std::vector<Module::LookupInfo> m_lookups;
+ ConstString m_class_name;
+ RegularExpression m_regex;
+ Breakpoint::MatchType m_match_type;
+ lldb::LanguageType m_language;
+ bool m_skip_prologue;
- void
- AddNameLookup (const ConstString &name, uint32_t name_type_mask);
+ void AddNameLookup(const ConstString &name, uint32_t name_type_mask);
};
} // namespace lldb_private
diff --git a/include/lldb/Breakpoint/BreakpointSite.h b/include/lldb/Breakpoint/BreakpointSite.h
index 27a23527d9fa..b334c6e1a276 100644
--- a/include/lldb/Breakpoint/BreakpointSite.h
+++ b/include/lldb/Breakpoint/BreakpointSite.h
@@ -19,10 +19,10 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-forward.h"
-#include "lldb/Core/UserID.h"
-#include "lldb/Breakpoint/StoppointLocation.h"
#include "lldb/Breakpoint/BreakpointLocationCollection.h"
+#include "lldb/Breakpoint/StoppointLocation.h"
+#include "lldb/Core/UserID.h"
+#include "lldb/lldb-forward.h"
namespace lldb_private {
@@ -39,277 +39,247 @@ namespace lldb_private {
/// site. Breakpoint sites are owned by the process.
//----------------------------------------------------------------------
-class BreakpointSite :
- public std::enable_shared_from_this<BreakpointSite>,
- public StoppointLocation
-{
+class BreakpointSite : public std::enable_shared_from_this<BreakpointSite>,
+ public StoppointLocation {
public:
-
- enum Type
- {
- eSoftware, // Breakpoint opcode has been written to memory and m_saved_opcode
- // and m_trap_opcode contain the saved and written opcode.
- eHardware, // Breakpoint site is set as a hardware breakpoint
- eExternal // Breakpoint site is managed by an external debug nub or
- // debug interface where memory reads transparently will not
- // display any breakpoint opcodes.
- };
-
- ~BreakpointSite() override;
-
- //----------------------------------------------------------------------
- // This section manages the breakpoint traps
- //----------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Returns the Opcode Bytes for this breakpoint
- //------------------------------------------------------------------
- uint8_t *
- GetTrapOpcodeBytes ();
-
- //------------------------------------------------------------------
- /// Returns the Opcode Bytes for this breakpoint - const version
- //------------------------------------------------------------------
- const uint8_t *
- GetTrapOpcodeBytes () const;
-
- //------------------------------------------------------------------
- /// Get the size of the trap opcode for this address
- //------------------------------------------------------------------
- size_t
- GetTrapOpcodeMaxByteSize () const;
-
- //------------------------------------------------------------------
- /// Sets the trap opcode
- //------------------------------------------------------------------
- bool
- SetTrapOpcode (const uint8_t *trap_opcode,
- uint32_t trap_opcode_size);
-
- //------------------------------------------------------------------
- /// Gets the original instruction bytes that were overwritten by the trap
- //------------------------------------------------------------------
- uint8_t *
- GetSavedOpcodeBytes ();
-
- //------------------------------------------------------------------
- /// Gets the original instruction bytes that were overwritten by the trap const version
- //------------------------------------------------------------------
- const uint8_t *
- GetSavedOpcodeBytes () const;
-
- //------------------------------------------------------------------
- /// Says whether \a addr and size \a size intersects with the address \a intersect_addr
- //------------------------------------------------------------------
- bool
- IntersectsRange (lldb::addr_t addr,
- size_t size,
- lldb::addr_t *intersect_addr,
- size_t *intersect_size,
- size_t *opcode_offset) const;
-
- //------------------------------------------------------------------
- /// Tells whether the current breakpoint site is enabled or not
- ///
- /// This is a low-level enable bit for the breakpoint sites. If a
- /// breakpoint site has no enabled owners, it should just get
- /// removed. This enable/disable is for the low-level target code
- /// to enable and disable breakpoint sites when single stepping,
- /// etc.
- //------------------------------------------------------------------
- bool
- IsEnabled () const;
-
- //------------------------------------------------------------------
- /// Sets whether the current breakpoint site is enabled or not
- ///
- /// @param[in] enabled
- /// \b true if the breakpoint is enabled, \b false otherwise.
- //------------------------------------------------------------------
- void
- SetEnabled (bool enabled);
-
- //------------------------------------------------------------------
- /// Enquires of the breakpoint locations that produced this breakpoint site whether
- /// we should stop at this location.
- ///
- /// @param[in] context
- /// This contains the information about this stop.
- ///
- /// @return
- /// \b true if we should stop, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ShouldStop(StoppointCallbackContext *context) override;
-
- //------------------------------------------------------------------
- /// Standard Dump method
- ///
- /// @param[in] context
- /// The stream to dump this output.
- //------------------------------------------------------------------
- void
- Dump(Stream *s) const override;
-
- //------------------------------------------------------------------
- /// The "Owners" are the breakpoint locations that share this
- /// breakpoint site. The method adds the \a owner to this breakpoint
- /// site's owner list.
- ///
- /// @param[in] context
- /// \a owner is the Breakpoint Location to add.
- //------------------------------------------------------------------
- void
- AddOwner (const lldb::BreakpointLocationSP &owner);
-
- //------------------------------------------------------------------
- /// This method returns the number of breakpoint locations currently
- /// located at this breakpoint site.
- ///
- /// @return
- /// The number of owners.
- //------------------------------------------------------------------
- size_t
- GetNumberOfOwners ();
-
- //------------------------------------------------------------------
- /// This method returns the breakpoint location at index \a index
- /// located at this breakpoint site. The owners are listed ordinally
- /// from 0 to GetNumberOfOwners() - 1 so you can use this method to iterate
- /// over the owners
- ///
- /// @param[in] index
- /// The index in the list of owners for which you wish the owner location.
- /// @return
- /// A shared pointer to the breakpoint location at that index.
- //------------------------------------------------------------------
- lldb::BreakpointLocationSP
- GetOwnerAtIndex (size_t idx);
-
- //------------------------------------------------------------------
- /// This method copies the breakpoint site's owners into a new collection.
- /// It does this while the owners mutex is locked.
- ///
- /// @param[out] out_collection
- /// The BreakpointLocationCollection into which to put the owners
- /// of this breakpoint site.
- ///
- /// @return
- /// The number of elements copied into out_collection.
- //------------------------------------------------------------------
- size_t
- CopyOwnersList (BreakpointLocationCollection &out_collection);
-
- //------------------------------------------------------------------
- /// Check whether the owners of this breakpoint site have any
- /// thread specifiers, and if yes, is \a thread contained in any
- /// of these specifiers.
- ///
- /// @param[in] thread
- /// The thread against which to test.
- ///
- /// return
- /// \b true if the collection contains at least one location that
- /// would be valid for this thread, false otherwise.
- //------------------------------------------------------------------
- bool
- ValidForThisThread (Thread *thread);
-
- //------------------------------------------------------------------
- /// Print a description of this breakpoint site to the stream \a s.
- /// GetDescription tells you about the breakpoint site's owners.
- /// Use BreakpointSite::Dump(Stream *) to get information about the
- /// breakpoint site itself.
- ///
- /// @param[in] s
- /// The stream to which to print the description.
- ///
- /// @param[in] level
- /// The description level that indicates the detail level to
- /// provide.
- ///
- /// @see lldb::DescriptionLevel
- //------------------------------------------------------------------
- void
- GetDescription (Stream *s,
- lldb::DescriptionLevel level);
-
- //------------------------------------------------------------------
- /// Tell whether a breakpoint has a location at this site.
- ///
- /// @param[in] bp_id
- /// The breakpoint id to query.
- ///
- /// @result
- /// \b true if bp_id has a location that is at this site,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool
- IsBreakpointAtThisSite (lldb::break_id_t bp_id);
-
- //------------------------------------------------------------------
- /// Tell whether ALL the breakpoints in the location collection are internal.
- ///
- /// @result
- /// \b true if all breakpoint locations are owned by internal breakpoints,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool
- IsInternal () const;
-
- BreakpointSite::Type
- GetType () const
- {
- return m_type;
- }
-
- void
- SetType (BreakpointSite::Type type)
- {
- m_type = type;
- }
+ enum Type {
+ eSoftware, // Breakpoint opcode has been written to memory and
+ // m_saved_opcode
+ // and m_trap_opcode contain the saved and written opcode.
+ eHardware, // Breakpoint site is set as a hardware breakpoint
+ eExternal // Breakpoint site is managed by an external debug nub or
+ // debug interface where memory reads transparently will not
+ // display any breakpoint opcodes.
+ };
+
+ ~BreakpointSite() override;
+
+ //----------------------------------------------------------------------
+ // This section manages the breakpoint traps
+ //----------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Returns the Opcode Bytes for this breakpoint
+ //------------------------------------------------------------------
+ uint8_t *GetTrapOpcodeBytes();
+
+ //------------------------------------------------------------------
+ /// Returns the Opcode Bytes for this breakpoint - const version
+ //------------------------------------------------------------------
+ const uint8_t *GetTrapOpcodeBytes() const;
+
+ //------------------------------------------------------------------
+ /// Get the size of the trap opcode for this address
+ //------------------------------------------------------------------
+ size_t GetTrapOpcodeMaxByteSize() const;
+
+ //------------------------------------------------------------------
+ /// Sets the trap opcode
+ //------------------------------------------------------------------
+ bool SetTrapOpcode(const uint8_t *trap_opcode, uint32_t trap_opcode_size);
+
+ //------------------------------------------------------------------
+ /// Gets the original instruction bytes that were overwritten by the trap
+ //------------------------------------------------------------------
+ uint8_t *GetSavedOpcodeBytes();
+
+ //------------------------------------------------------------------
+ /// Gets the original instruction bytes that were overwritten by the trap
+ /// const version
+ //------------------------------------------------------------------
+ const uint8_t *GetSavedOpcodeBytes() const;
+
+ //------------------------------------------------------------------
+ /// Says whether \a addr and size \a size intersects with the address \a
+ /// intersect_addr
+ //------------------------------------------------------------------
+ bool IntersectsRange(lldb::addr_t addr, size_t size,
+ lldb::addr_t *intersect_addr, size_t *intersect_size,
+ size_t *opcode_offset) const;
+
+ //------------------------------------------------------------------
+ /// Tells whether the current breakpoint site is enabled or not
+ ///
+ /// This is a low-level enable bit for the breakpoint sites. If a
+ /// breakpoint site has no enabled owners, it should just get
+ /// removed. This enable/disable is for the low-level target code
+ /// to enable and disable breakpoint sites when single stepping,
+ /// etc.
+ //------------------------------------------------------------------
+ bool IsEnabled() const;
+
+ //------------------------------------------------------------------
+ /// Sets whether the current breakpoint site is enabled or not
+ ///
+ /// @param[in] enabled
+ /// \b true if the breakpoint is enabled, \b false otherwise.
+ //------------------------------------------------------------------
+ void SetEnabled(bool enabled);
+
+ //------------------------------------------------------------------
+ /// Enquires of the breakpoint locations that produced this breakpoint site
+ /// whether
+ /// we should stop at this location.
+ ///
+ /// @param[in] context
+ /// This contains the information about this stop.
+ ///
+ /// @return
+ /// \b true if we should stop, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ShouldStop(StoppointCallbackContext *context) override;
+
+ //------------------------------------------------------------------
+ /// Standard Dump method
+ ///
+ /// @param[in] context
+ /// The stream to dump this output.
+ //------------------------------------------------------------------
+ void Dump(Stream *s) const override;
+
+ //------------------------------------------------------------------
+ /// The "Owners" are the breakpoint locations that share this
+ /// breakpoint site. The method adds the \a owner to this breakpoint
+ /// site's owner list.
+ ///
+ /// @param[in] context
+ /// \a owner is the Breakpoint Location to add.
+ //------------------------------------------------------------------
+ void AddOwner(const lldb::BreakpointLocationSP &owner);
+
+ //------------------------------------------------------------------
+ /// This method returns the number of breakpoint locations currently
+ /// located at this breakpoint site.
+ ///
+ /// @return
+ /// The number of owners.
+ //------------------------------------------------------------------
+ size_t GetNumberOfOwners();
+
+ //------------------------------------------------------------------
+ /// This method returns the breakpoint location at index \a index
+ /// located at this breakpoint site. The owners are listed ordinally
+ /// from 0 to GetNumberOfOwners() - 1 so you can use this method to iterate
+ /// over the owners
+ ///
+ /// @param[in] index
+ /// The index in the list of owners for which you wish the owner location.
+ /// @return
+ /// A shared pointer to the breakpoint location at that index.
+ //------------------------------------------------------------------
+ lldb::BreakpointLocationSP GetOwnerAtIndex(size_t idx);
+
+ //------------------------------------------------------------------
+ /// This method copies the breakpoint site's owners into a new collection.
+ /// It does this while the owners mutex is locked.
+ ///
+ /// @param[out] out_collection
+ /// The BreakpointLocationCollection into which to put the owners
+ /// of this breakpoint site.
+ ///
+ /// @return
+ /// The number of elements copied into out_collection.
+ //------------------------------------------------------------------
+ size_t CopyOwnersList(BreakpointLocationCollection &out_collection);
+
+ //------------------------------------------------------------------
+ /// Check whether the owners of this breakpoint site have any
+ /// thread specifiers, and if yes, is \a thread contained in any
+ /// of these specifiers.
+ ///
+ /// @param[in] thread
+ /// The thread against which to test.
+ ///
+ /// return
+ /// \b true if the collection contains at least one location that
+ /// would be valid for this thread, false otherwise.
+ //------------------------------------------------------------------
+ bool ValidForThisThread(Thread *thread);
+
+ //------------------------------------------------------------------
+ /// Print a description of this breakpoint site to the stream \a s.
+ /// GetDescription tells you about the breakpoint site's owners.
+ /// Use BreakpointSite::Dump(Stream *) to get information about the
+ /// breakpoint site itself.
+ ///
+ /// @param[in] s
+ /// The stream to which to print the description.
+ ///
+ /// @param[in] level
+ /// The description level that indicates the detail level to
+ /// provide.
+ ///
+ /// @see lldb::DescriptionLevel
+ //------------------------------------------------------------------
+ void GetDescription(Stream *s, lldb::DescriptionLevel level);
+
+ //------------------------------------------------------------------
+ /// Tell whether a breakpoint has a location at this site.
+ ///
+ /// @param[in] bp_id
+ /// The breakpoint id to query.
+ ///
+ /// @result
+ /// \b true if bp_id has a location that is at this site,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsBreakpointAtThisSite(lldb::break_id_t bp_id);
+
+ //------------------------------------------------------------------
+ /// Tell whether ALL the breakpoints in the location collection are internal.
+ ///
+ /// @result
+ /// \b true if all breakpoint locations are owned by internal breakpoints,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsInternal() const;
+
+ BreakpointSite::Type GetType() const { return m_type; }
+
+ void SetType(BreakpointSite::Type type) { m_type = type; }
private:
- friend class Process;
- friend class BreakpointLocation;
- // The StopInfoBreakpoint knows when it is processing a hit for a thread for a site, so let it be the
- // one to manage setting the location hit count once and only once.
- friend class StopInfoBreakpoint;
-
- void
- BumpHitCounts();
-
- //------------------------------------------------------------------
- /// The method removes the owner at \a break_loc_id from this breakpoint list.
- ///
- /// @param[in] context
- /// \a break_loc_id is the Breakpoint Location to remove.
- //------------------------------------------------------------------
- size_t
- RemoveOwner (lldb::break_id_t break_id,
- lldb::break_id_t break_loc_id);
-
- BreakpointSite::Type m_type;///< The type of this breakpoint site.
- uint8_t m_saved_opcode[8]; ///< The saved opcode bytes if this breakpoint site uses trap opcodes.
- uint8_t m_trap_opcode[8]; ///< The opcode that was used to create the breakpoint if it is a software breakpoint site.
- bool m_enabled; ///< Boolean indicating if this breakpoint site enabled or not.
-
- // Consider adding an optimization where if there is only one
- // owner, we don't store a list. The usual case will be only one owner...
- BreakpointLocationCollection m_owners; ///< This has the BreakpointLocations that share this breakpoint site.
- std::recursive_mutex m_owners_mutex; ///< This mutex protects the owners collection.
-
- static lldb::break_id_t
- GetNextID();
-
- // Only the Process can create breakpoint sites in
- // Process::CreateBreakpointSite (lldb::BreakpointLocationSP &, bool).
- BreakpointSite (BreakpointSiteList *list,
- const lldb::BreakpointLocationSP& owner,
- lldb::addr_t m_addr,
- bool use_hardware);
-
- DISALLOW_COPY_AND_ASSIGN(BreakpointSite);
+ friend class Process;
+ friend class BreakpointLocation;
+ // The StopInfoBreakpoint knows when it is processing a hit for a thread for a
+ // site, so let it be the
+ // one to manage setting the location hit count once and only once.
+ friend class StopInfoBreakpoint;
+
+ void BumpHitCounts();
+
+ //------------------------------------------------------------------
+ /// The method removes the owner at \a break_loc_id from this breakpoint list.
+ ///
+ /// @param[in] context
+ /// \a break_loc_id is the Breakpoint Location to remove.
+ //------------------------------------------------------------------
+ size_t RemoveOwner(lldb::break_id_t break_id, lldb::break_id_t break_loc_id);
+
+ BreakpointSite::Type m_type; ///< The type of this breakpoint site.
+ uint8_t m_saved_opcode[8]; ///< The saved opcode bytes if this breakpoint site
+ ///uses trap opcodes.
+ uint8_t m_trap_opcode[8]; ///< The opcode that was used to create the
+ ///breakpoint if it is a software breakpoint site.
+ bool
+ m_enabled; ///< Boolean indicating if this breakpoint site enabled or not.
+
+ // Consider adding an optimization where if there is only one
+ // owner, we don't store a list. The usual case will be only one owner...
+ BreakpointLocationCollection m_owners; ///< This has the BreakpointLocations
+ ///that share this breakpoint site.
+ std::recursive_mutex
+ m_owners_mutex; ///< This mutex protects the owners collection.
+
+ static lldb::break_id_t GetNextID();
+
+ // Only the Process can create breakpoint sites in
+ // Process::CreateBreakpointSite (lldb::BreakpointLocationSP &, bool).
+ BreakpointSite(BreakpointSiteList *list,
+ const lldb::BreakpointLocationSP &owner, lldb::addr_t m_addr,
+ bool use_hardware);
+
+ DISALLOW_COPY_AND_ASSIGN(BreakpointSite);
};
} // namespace lldb_private
diff --git a/include/lldb/Breakpoint/BreakpointSiteList.h b/include/lldb/Breakpoint/BreakpointSiteList.h
index e681aa3599f7..1431fe799675 100644
--- a/include/lldb/Breakpoint/BreakpointSiteList.h
+++ b/include/lldb/Breakpoint/BreakpointSiteList.h
@@ -23,197 +23,185 @@
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class BreakpointSiteList BreakpointSiteList.h "lldb/Breakpoint/BreakpointSiteList.h"
+/// @class BreakpointSiteList BreakpointSiteList.h
+/// "lldb/Breakpoint/BreakpointSiteList.h"
/// @brief Class that manages lists of BreakpointSite shared pointers.
//----------------------------------------------------------------------
-class BreakpointSiteList
-{
-// At present Process directly accesses the map of BreakpointSites so it can
-// do quick lookups into the map (using GetMap).
-// FIXME: Find a better interface for this.
-friend class Process;
+class BreakpointSiteList {
+ // At present Process directly accesses the map of BreakpointSites so it can
+ // do quick lookups into the map (using GetMap).
+ // FIXME: Find a better interface for this.
+ friend class Process;
public:
- //------------------------------------------------------------------
- /// Default constructor makes an empty list.
- //------------------------------------------------------------------
- BreakpointSiteList();
-
- //------------------------------------------------------------------
- /// Destructor, currently does nothing.
- //------------------------------------------------------------------
- ~BreakpointSiteList();
-
- //------------------------------------------------------------------
- /// Add a BreakpointSite to the list.
- ///
- /// @param[in] bp_site_sp
- /// A shared pointer to a breakpoint site being added to the list.
- ///
- /// @return
- /// The ID of the BreakpointSite in the list.
- //------------------------------------------------------------------
- lldb::break_id_t
- Add (const lldb::BreakpointSiteSP& bp_site_sp);
-
- //------------------------------------------------------------------
- /// Standard Dump routine, doesn't do anything at present.
- /// @param[in] s
- /// Stream into which to dump the description.
- //------------------------------------------------------------------
- void
- Dump (Stream *s) const;
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint site at address
- /// \a addr.
- ///
- /// @param[in] addr
- /// The address to look for.
- ///
- /// @result
- /// A shared pointer to the breakpoint site. May contain a NULL
- /// pointer if no breakpoint site exists with a matching address.
- //------------------------------------------------------------------
- lldb::BreakpointSiteSP
- FindByAddress (lldb::addr_t addr);
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint site with id \a breakID.
- ///
- /// @param[in] breakID
- /// The breakpoint site ID to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint site. May contain a NULL pointer if the
- /// breakpoint doesn't exist.
- //------------------------------------------------------------------
- lldb::BreakpointSiteSP
- FindByID (lldb::break_id_t breakID);
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint site with id \a breakID - const version.
- ///
- /// @param[in] breakID
- /// The breakpoint site ID to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint site. May contain a NULL pointer if the
- /// breakpoint doesn't exist.
- //------------------------------------------------------------------
- const lldb::BreakpointSiteSP
- FindByID (lldb::break_id_t breakID) const;
-
- //------------------------------------------------------------------
- /// Returns the breakpoint site id to the breakpoint site at address \a addr.
- ///
- /// @param[in] addr
- /// The address to match.
- ///
- /// @result
- /// The ID of the breakpoint site, or LLDB_INVALID_BREAK_ID.
- //------------------------------------------------------------------
- lldb::break_id_t
- FindIDByAddress (lldb::addr_t addr);
-
- //------------------------------------------------------------------
- /// Returns whether the breakpoint site \a bp_site_id has \a bp_id
- // as one of its owners.
- ///
- /// @param[in] bp_site_id
- /// The breakpoint site id to query.
- ///
- /// @param[in] bp_id
- /// The breakpoint id to look for in \a bp_site_id.
- ///
- /// @result
- /// True if \a bp_site_id exists in the site list AND \a bp_id is one of the
- /// owners of that site.
- //------------------------------------------------------------------
- bool
- BreakpointSiteContainsBreakpoint (lldb::break_id_t bp_site_id, lldb::break_id_t bp_id);
-
- void
- ForEach (std::function <void(BreakpointSite *)> const &callback);
-
- //------------------------------------------------------------------
- /// Removes the breakpoint site given by \b breakID from this list.
- ///
- /// @param[in] breakID
- /// The breakpoint site index to remove.
- ///
- /// @result
- /// \b true if the breakpoint site \a breakID was in the list.
- //------------------------------------------------------------------
- bool
- Remove (lldb::break_id_t breakID);
-
- //------------------------------------------------------------------
- /// Removes the breakpoint site at address \a addr from this list.
- ///
- /// @param[in] addr
- /// The address from which to remove a breakpoint site.
- ///
- /// @result
- /// \b true if \a addr had a breakpoint site to remove from the list.
- //------------------------------------------------------------------
- bool
- RemoveByAddress (lldb::addr_t addr);
-
- bool
- FindInRange (lldb::addr_t lower_bound, lldb::addr_t upper_bound, BreakpointSiteList &bp_site_list) const;
-
- typedef void (*BreakpointSiteSPMapFunc) (lldb::BreakpointSiteSP &bp, void *baton);
-
- //------------------------------------------------------------------
- /// Enquires of the breakpoint site on in this list with ID \a breakID whether
- /// we should stop for the breakpoint or not.
- ///
- /// @param[in] context
- /// This contains the information about this stop.
- ///
- /// @param[in] breakID
- /// This break ID that we hit.
- ///
- /// @return
- /// \b true if we should stop, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ShouldStop (StoppointCallbackContext *context, lldb::break_id_t breakID);
-
- //------------------------------------------------------------------
- /// Returns the number of elements in the list.
- ///
- /// @result
- /// The number of elements.
- //------------------------------------------------------------------
- size_t
- GetSize() const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_bp_site_list.size();
- }
-
- bool
- IsEmpty() const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_bp_site_list.empty();
- }
+ //------------------------------------------------------------------
+ /// Default constructor makes an empty list.
+ //------------------------------------------------------------------
+ BreakpointSiteList();
+
+ //------------------------------------------------------------------
+ /// Destructor, currently does nothing.
+ //------------------------------------------------------------------
+ ~BreakpointSiteList();
+
+ //------------------------------------------------------------------
+ /// Add a BreakpointSite to the list.
+ ///
+ /// @param[in] bp_site_sp
+ /// A shared pointer to a breakpoint site being added to the list.
+ ///
+ /// @return
+ /// The ID of the BreakpointSite in the list.
+ //------------------------------------------------------------------
+ lldb::break_id_t Add(const lldb::BreakpointSiteSP &bp_site_sp);
+
+ //------------------------------------------------------------------
+ /// Standard Dump routine, doesn't do anything at present.
+ /// @param[in] s
+ /// Stream into which to dump the description.
+ //------------------------------------------------------------------
+ void Dump(Stream *s) const;
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint site at address
+ /// \a addr.
+ ///
+ /// @param[in] addr
+ /// The address to look for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint site. May contain a NULL
+ /// pointer if no breakpoint site exists with a matching address.
+ //------------------------------------------------------------------
+ lldb::BreakpointSiteSP FindByAddress(lldb::addr_t addr);
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint site with id \a breakID.
+ ///
+ /// @param[in] breakID
+ /// The breakpoint site ID to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint site. May contain a NULL pointer if
+ /// the
+ /// breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ lldb::BreakpointSiteSP FindByID(lldb::break_id_t breakID);
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint site with id \a breakID - const
+ /// version.
+ ///
+ /// @param[in] breakID
+ /// The breakpoint site ID to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint site. May contain a NULL pointer if
+ /// the
+ /// breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ const lldb::BreakpointSiteSP FindByID(lldb::break_id_t breakID) const;
+
+ //------------------------------------------------------------------
+ /// Returns the breakpoint site id to the breakpoint site at address \a addr.
+ ///
+ /// @param[in] addr
+ /// The address to match.
+ ///
+ /// @result
+ /// The ID of the breakpoint site, or LLDB_INVALID_BREAK_ID.
+ //------------------------------------------------------------------
+ lldb::break_id_t FindIDByAddress(lldb::addr_t addr);
+
+ //------------------------------------------------------------------
+ /// Returns whether the breakpoint site \a bp_site_id has \a bp_id
+ // as one of its owners.
+ ///
+ /// @param[in] bp_site_id
+ /// The breakpoint site id to query.
+ ///
+ /// @param[in] bp_id
+ /// The breakpoint id to look for in \a bp_site_id.
+ ///
+ /// @result
+ /// True if \a bp_site_id exists in the site list AND \a bp_id is one of the
+ /// owners of that site.
+ //------------------------------------------------------------------
+ bool BreakpointSiteContainsBreakpoint(lldb::break_id_t bp_site_id,
+ lldb::break_id_t bp_id);
+
+ void ForEach(std::function<void(BreakpointSite *)> const &callback);
+
+ //------------------------------------------------------------------
+ /// Removes the breakpoint site given by \b breakID from this list.
+ ///
+ /// @param[in] breakID
+ /// The breakpoint site index to remove.
+ ///
+ /// @result
+ /// \b true if the breakpoint site \a breakID was in the list.
+ //------------------------------------------------------------------
+ bool Remove(lldb::break_id_t breakID);
+
+ //------------------------------------------------------------------
+ /// Removes the breakpoint site at address \a addr from this list.
+ ///
+ /// @param[in] addr
+ /// The address from which to remove a breakpoint site.
+ ///
+ /// @result
+ /// \b true if \a addr had a breakpoint site to remove from the list.
+ //------------------------------------------------------------------
+ bool RemoveByAddress(lldb::addr_t addr);
+
+ bool FindInRange(lldb::addr_t lower_bound, lldb::addr_t upper_bound,
+ BreakpointSiteList &bp_site_list) const;
+
+ typedef void (*BreakpointSiteSPMapFunc)(lldb::BreakpointSiteSP &bp,
+ void *baton);
+
+ //------------------------------------------------------------------
+ /// Enquires of the breakpoint site on in this list with ID \a breakID whether
+ /// we should stop for the breakpoint or not.
+ ///
+ /// @param[in] context
+ /// This contains the information about this stop.
+ ///
+ /// @param[in] breakID
+ /// This break ID that we hit.
+ ///
+ /// @return
+ /// \b true if we should stop, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ShouldStop(StoppointCallbackContext *context, lldb::break_id_t breakID);
+
+ //------------------------------------------------------------------
+ /// Returns the number of elements in the list.
+ ///
+ /// @result
+ /// The number of elements.
+ //------------------------------------------------------------------
+ size_t GetSize() const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_bp_site_list.size();
+ }
+
+ bool IsEmpty() const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_bp_site_list.empty();
+ }
protected:
- typedef std::map<lldb::addr_t, lldb::BreakpointSiteSP> collection;
+ typedef std::map<lldb::addr_t, lldb::BreakpointSiteSP> collection;
- collection::iterator
- GetIDIterator(lldb::break_id_t breakID);
+ collection::iterator GetIDIterator(lldb::break_id_t breakID);
- collection::const_iterator
- GetIDConstIterator(lldb::break_id_t breakID) const;
+ collection::const_iterator GetIDConstIterator(lldb::break_id_t breakID) const;
- mutable std::recursive_mutex m_mutex;
- collection m_bp_site_list; // The breakpoint site list.
+ mutable std::recursive_mutex m_mutex;
+ collection m_bp_site_list; // The breakpoint site list.
};
} // namespace lldb_private
-#endif // liblldb_BreakpointSiteList_h_
+#endif // liblldb_BreakpointSiteList_h_
diff --git a/include/lldb/Breakpoint/Stoppoint.h b/include/lldb/Breakpoint/Stoppoint.h
index c294830f15ec..5d131a556ad1 100644
--- a/include/lldb/Breakpoint/Stoppoint.h
+++ b/include/lldb/Breakpoint/Stoppoint.h
@@ -14,50 +14,43 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/UserID.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class Stoppoint
-{
+class Stoppoint {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- Stoppoint();
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ Stoppoint();
- virtual
- ~Stoppoint();
+ virtual ~Stoppoint();
- //------------------------------------------------------------------
- // Methods
- //------------------------------------------------------------------
- virtual void
- Dump (Stream *) = 0;
+ //------------------------------------------------------------------
+ // Methods
+ //------------------------------------------------------------------
+ virtual void Dump(Stream *) = 0;
- virtual bool
- IsEnabled () = 0;
+ virtual bool IsEnabled() = 0;
- virtual void
- SetEnabled (bool enable) = 0;
+ virtual void SetEnabled(bool enable) = 0;
- lldb::break_id_t
- GetID () const;
+ lldb::break_id_t GetID() const;
- void
- SetID (lldb::break_id_t bid);
+ void SetID(lldb::break_id_t bid);
protected:
- lldb::break_id_t m_bid;
+ lldb::break_id_t m_bid;
private:
- //------------------------------------------------------------------
- // For Stoppoint only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (Stoppoint);
+ //------------------------------------------------------------------
+ // For Stoppoint only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(Stoppoint);
};
} // namespace lldb_private
-#endif // liblldb_Stoppoint_h_
+#endif // liblldb_Stoppoint_h_
diff --git a/include/lldb/Breakpoint/StoppointCallbackContext.h b/include/lldb/Breakpoint/StoppointCallbackContext.h
index 78327e291340..2680584845d7 100644
--- a/include/lldb/Breakpoint/StoppointCallbackContext.h
+++ b/include/lldb/Breakpoint/StoppointCallbackContext.h
@@ -10,49 +10,54 @@
#ifndef liblldb_StoppointCallbackContext_h_
#define liblldb_StoppointCallbackContext_h_
-#include "lldb/lldb-private.h"
#include "lldb/Target/ExecutionContext.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class StoppointCallbackContext StoppointCallbackContext.h "lldb/Breakpoint/StoppointCallbackContext.h"
-/// @brief Class holds the information that a breakpoint callback needs to evaluate this stop.
+/// @class StoppointCallbackContext StoppointCallbackContext.h
+/// "lldb/Breakpoint/StoppointCallbackContext.h"
+/// @brief Class holds the information that a breakpoint callback needs to
+/// evaluate this stop.
//----------------------------------------------------------------------
//----------------------------------------------------------------------
/// General Outline:
-/// When we hit a breakpoint we need to package up whatever information is needed
-/// to evaluate breakpoint commands and conditions. This class is the container of
+/// When we hit a breakpoint we need to package up whatever information is
+/// needed
+/// to evaluate breakpoint commands and conditions. This class is the container
+/// of
/// that information.
//----------------------------------------------------------------------
-class StoppointCallbackContext
-{
+class StoppointCallbackContext {
public:
- StoppointCallbackContext();
-
- StoppointCallbackContext(Event *event, const ExecutionContext &exe_ctx, bool synchronously = false);
-
- //------------------------------------------------------------------
- /// Clear the object's state.
- ///
- /// Sets the event, process and thread to NULL, and the frame index to an
- /// invalid value.
- //------------------------------------------------------------------
- void
- Clear ();
-
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- Event *event; // This is the event, the callback can modify this to indicate
- // the meaning of the breakpoint hit
- ExecutionContextRef exe_ctx_ref; // This tells us where we have stopped, what thread.
- bool is_synchronous; // Is the callback being executed synchronously with the breakpoint,
- // or asynchronously as the event is retrieved?
+ StoppointCallbackContext();
+
+ StoppointCallbackContext(Event *event, const ExecutionContext &exe_ctx,
+ bool synchronously = false);
+
+ //------------------------------------------------------------------
+ /// Clear the object's state.
+ ///
+ /// Sets the event, process and thread to NULL, and the frame index to an
+ /// invalid value.
+ //------------------------------------------------------------------
+ void Clear();
+
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ Event *event; // This is the event, the callback can modify this to indicate
+ // the meaning of the breakpoint hit
+ ExecutionContextRef
+ exe_ctx_ref; // This tells us where we have stopped, what thread.
+ bool is_synchronous; // Is the callback being executed synchronously with the
+ // breakpoint,
+ // or asynchronously as the event is retrieved?
};
} // namespace lldb_private
-#endif // liblldb_StoppointCallbackContext_h_
+#endif // liblldb_StoppointCallbackContext_h_
diff --git a/include/lldb/Breakpoint/StoppointLocation.h b/include/lldb/Breakpoint/StoppointLocation.h
index 32a1dbd4386e..ba03b4ea1f5b 100644
--- a/include/lldb/Breakpoint/StoppointLocation.h
+++ b/include/lldb/Breakpoint/StoppointLocation.h
@@ -14,137 +14,88 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/UserID.h"
+#include "lldb/lldb-private.h"
// #include "lldb/Breakpoint/BreakpointOptions.h"
namespace lldb_private {
-class StoppointLocation
-{
+class StoppointLocation {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- StoppointLocation (lldb::break_id_t bid,
- lldb::addr_t m_addr,
- bool hardware);
-
- StoppointLocation (lldb::break_id_t bid,
- lldb::addr_t m_addr,
- uint32_t byte_size,
- bool hardware);
-
- virtual
- ~StoppointLocation ();
-
- //------------------------------------------------------------------
- // Operators
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- // Methods
- //------------------------------------------------------------------
- virtual lldb::addr_t
- GetLoadAddress() const
- {
- return m_addr;
- }
-
- virtual void
- SetLoadAddress (lldb::addr_t addr)
- {
- m_addr = addr;
- }
-
- uint32_t
- GetByteSize () const
- {
- return m_byte_size;
- }
-
- uint32_t
- GetHitCount () const
- {
- return m_hit_count;
- }
-
- uint32_t
- GetHardwareIndex () const
- {
- return m_hardware_index;
- }
-
-
- bool
- HardwareRequired () const
- {
- return m_hardware;
- }
-
- virtual bool
- IsHardware () const
- {
- return m_hardware_index != LLDB_INVALID_INDEX32;
- }
-
-
- virtual bool
- ShouldStop (StoppointCallbackContext *context)
- {
- return true;
- }
-
- virtual void
- Dump (Stream *stream) const
- {
- }
-
- void
- SetHardwareIndex (uint32_t index)
- {
- m_hardware_index = index;
- }
-
-
- lldb::break_id_t
- GetID () const
- {
- return m_loc_id;
- }
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ StoppointLocation(lldb::break_id_t bid, lldb::addr_t m_addr, bool hardware);
+
+ StoppointLocation(lldb::break_id_t bid, lldb::addr_t m_addr,
+ uint32_t byte_size, bool hardware);
+
+ virtual ~StoppointLocation();
+
+ //------------------------------------------------------------------
+ // Operators
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ // Methods
+ //------------------------------------------------------------------
+ virtual lldb::addr_t GetLoadAddress() const { return m_addr; }
+
+ virtual void SetLoadAddress(lldb::addr_t addr) { m_addr = addr; }
+
+ uint32_t GetByteSize() const { return m_byte_size; }
+
+ uint32_t GetHitCount() const { return m_hit_count; }
+
+ uint32_t GetHardwareIndex() const { return m_hardware_index; }
+
+ bool HardwareRequired() const { return m_hardware; }
+
+ virtual bool IsHardware() const {
+ return m_hardware_index != LLDB_INVALID_INDEX32;
+ }
+
+ virtual bool ShouldStop(StoppointCallbackContext *context) { return true; }
+
+ virtual void Dump(Stream *stream) const {}
+
+ void SetHardwareIndex(uint32_t index) { m_hardware_index = index; }
+
+ lldb::break_id_t GetID() const { return m_loc_id; }
protected:
- //------------------------------------------------------------------
- // Classes that inherit from StoppointLocation can see and modify these
- //------------------------------------------------------------------
- lldb::break_id_t m_loc_id; // Stoppoint location ID
- lldb::addr_t m_addr; // The load address of this stop point. The base Stoppoint doesn't
- // store a full Address since that's not needed for the breakpoint sites.
- bool m_hardware; // True if this point has been is required to use hardware (which may fail due to lack of resources)
- uint32_t m_hardware_index; // The hardware resource index for this breakpoint/watchpoint
- uint32_t m_byte_size; // The size in bytes of stop location. e.g. the length of the trap opcode for
- // software breakpoints, or the optional length in bytes for
- // hardware breakpoints, or the length of the watchpoint.
- uint32_t m_hit_count; // Number of times this breakpoint/watchpoint has been hit
-
- // If you override this, be sure to call the base class to increment the internal counter.
- void
- IncrementHitCount ()
- {
- ++m_hit_count;
- }
-
- void
- DecrementHitCount ();
+ //------------------------------------------------------------------
+ // Classes that inherit from StoppointLocation can see and modify these
+ //------------------------------------------------------------------
+ lldb::break_id_t m_loc_id; // Stoppoint location ID
+ lldb::addr_t
+ m_addr; // The load address of this stop point. The base Stoppoint doesn't
+ // store a full Address since that's not needed for the breakpoint sites.
+ bool m_hardware; // True if this point has been is required to use hardware
+ // (which may fail due to lack of resources)
+ uint32_t m_hardware_index; // The hardware resource index for this
+ // breakpoint/watchpoint
+ uint32_t m_byte_size; // The size in bytes of stop location. e.g. the length
+ // of the trap opcode for
+ // software breakpoints, or the optional length in bytes for
+ // hardware breakpoints, or the length of the watchpoint.
+ uint32_t
+ m_hit_count; // Number of times this breakpoint/watchpoint has been hit
+
+ // If you override this, be sure to call the base class to increment the
+ // internal counter.
+ void IncrementHitCount() { ++m_hit_count; }
+
+ void DecrementHitCount();
private:
- //------------------------------------------------------------------
- // For StoppointLocation only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN(StoppointLocation);
- StoppointLocation(); // Disallow default constructor
+ //------------------------------------------------------------------
+ // For StoppointLocation only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(StoppointLocation);
+ StoppointLocation(); // Disallow default constructor
};
} // namespace lldb_private
-#endif // liblldb_StoppointLocation_h_
+#endif // liblldb_StoppointLocation_h_
diff --git a/include/lldb/Breakpoint/Watchpoint.h b/include/lldb/Breakpoint/Watchpoint.h
index 34df24a92c06..97f2e282acc2 100644
--- a/include/lldb/Breakpoint/Watchpoint.h
+++ b/include/lldb/Breakpoint/Watchpoint.h
@@ -17,240 +17,218 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
-#include "lldb/Breakpoint/WatchpointOptions.h"
#include "lldb/Breakpoint/StoppointLocation.h"
+#include "lldb/Breakpoint/WatchpointOptions.h"
#include "lldb/Core/UserID.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Target/Target.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class Watchpoint :
- public std::enable_shared_from_this<Watchpoint>,
- public StoppointLocation
-{
+class Watchpoint : public std::enable_shared_from_this<Watchpoint>,
+ public StoppointLocation {
public:
- class WatchpointEventData :
- public EventData
- {
- public:
- WatchpointEventData (lldb::WatchpointEventType sub_type,
- const lldb::WatchpointSP &new_watchpoint_sp);
-
- ~WatchpointEventData() override;
-
- static const ConstString &
- GetFlavorString ();
-
- const ConstString &
- GetFlavor() const override;
-
- lldb::WatchpointEventType
- GetWatchpointEventType () const;
-
- lldb::WatchpointSP &
- GetWatchpoint ();
-
- void
- Dump(Stream *s) const override;
-
- static lldb::WatchpointEventType
- GetWatchpointEventTypeFromEvent (const lldb::EventSP &event_sp);
-
- static lldb::WatchpointSP
- GetWatchpointFromEvent (const lldb::EventSP &event_sp);
-
- static const WatchpointEventData *
- GetEventDataFromEvent (const Event *event_sp);
-
- private:
- lldb::WatchpointEventType m_watchpoint_event;
- lldb::WatchpointSP m_new_watchpoint_sp;
-
- DISALLOW_COPY_AND_ASSIGN (WatchpointEventData);
- };
-
- Watchpoint (Target& target, lldb::addr_t addr, uint32_t size, const CompilerType *type, bool hardware = true);
-
- ~Watchpoint() override;
-
- void
- IncrementFalseAlarmsAndReviseHitCount();
-
- bool
- IsEnabled () const;
-
- void
- SetEnabled (bool enabled, bool notify = true);
-
- bool
- IsHardware() const override;
-
- bool
- ShouldStop(StoppointCallbackContext *context) override;
-
- bool WatchpointRead () const;
- bool WatchpointWrite () const;
- uint32_t GetIgnoreCount () const;
- void SetIgnoreCount (uint32_t n);
- void SetWatchpointType (uint32_t type, bool notify = true);
- void SetDeclInfo (const std::string &str);
- std::string GetWatchSpec();
- void SetWatchSpec (const std::string &str);
-
- // Snapshot management interface.
- bool IsWatchVariable() const;
- void SetWatchVariable(bool val);
- bool CaptureWatchedValue (const ExecutionContext &exe_ctx);
-
- void GetDescription (Stream *s, lldb::DescriptionLevel level);
- void Dump (Stream *s) const override;
- void DumpSnapshots(Stream *s, const char *prefix = nullptr) const;
- void DumpWithLevel (Stream *s, lldb::DescriptionLevel description_level) const;
- Target &GetTarget() { return m_target; }
- const Error &GetError() { return m_error; }
-
- //------------------------------------------------------------------
- /// Returns the WatchpointOptions structure set for this watchpoint.
- ///
- /// @return
- /// A pointer to this watchpoint's WatchpointOptions.
- //------------------------------------------------------------------
- WatchpointOptions *
- GetOptions () { return &m_options; }
-
- //------------------------------------------------------------------
- /// Set the callback action invoked when the watchpoint is hit.
- ///
- /// @param[in] callback
- /// The method that will get called when the watchpoint is hit.
- /// @param[in] callback_baton
- /// A void * pointer that will get passed back to the callback function.
- /// @param[in] is_synchronous
- /// If \b true the callback will be run on the private event thread
- /// before the stop event gets reported. If false, the callback will get
- /// handled on the public event thread after the stop has been posted.
- ///
- /// @return
- /// \b true if the process should stop when you hit the watchpoint.
- /// \b false if it should continue.
- //------------------------------------------------------------------
- void
- SetCallback (WatchpointHitCallback callback,
- void *callback_baton,
- bool is_synchronous = false);
-
- void
- SetCallback (WatchpointHitCallback callback,
- const lldb::BatonSP &callback_baton_sp,
- bool is_synchronous = false);
-
- void ClearCallback();
-
- //------------------------------------------------------------------
- /// Invoke the callback action when the watchpoint is hit.
- ///
- /// @param[in] context
- /// Described the watchpoint event.
- ///
- /// @return
- /// \b true if the target should stop at this watchpoint and \b false not.
- //------------------------------------------------------------------
- bool
- InvokeCallback (StoppointCallbackContext *context);
-
- //------------------------------------------------------------------
- // Condition
- //------------------------------------------------------------------
- //------------------------------------------------------------------
- /// Set the watchpoint's condition.
- ///
- /// @param[in] condition
- /// The condition expression to evaluate when the watchpoint is hit.
- /// Pass in nullptr to clear the condition.
- //------------------------------------------------------------------
- void SetCondition (const char *condition);
-
- //------------------------------------------------------------------
- /// Return a pointer to the text of the condition expression.
- ///
- /// @return
- /// A pointer to the condition expression text, or nullptr if no
- // condition has been set.
- //------------------------------------------------------------------
- const char *GetConditionText () const;
-
- void
- TurnOnEphemeralMode();
-
- void
- TurnOffEphemeralMode();
-
- bool
- IsDisabledDuringEphemeralMode();
-
- const CompilerType &
- GetCompilerType()
- {
- return m_type;
- }
+ class WatchpointEventData : public EventData {
+ public:
+ WatchpointEventData(lldb::WatchpointEventType sub_type,
+ const lldb::WatchpointSP &new_watchpoint_sp);
+
+ ~WatchpointEventData() override;
+
+ static const ConstString &GetFlavorString();
+
+ const ConstString &GetFlavor() const override;
+
+ lldb::WatchpointEventType GetWatchpointEventType() const;
+
+ lldb::WatchpointSP &GetWatchpoint();
+
+ void Dump(Stream *s) const override;
+
+ static lldb::WatchpointEventType
+ GetWatchpointEventTypeFromEvent(const lldb::EventSP &event_sp);
+
+ static lldb::WatchpointSP
+ GetWatchpointFromEvent(const lldb::EventSP &event_sp);
+
+ static const WatchpointEventData *
+ GetEventDataFromEvent(const Event *event_sp);
+
+ private:
+ lldb::WatchpointEventType m_watchpoint_event;
+ lldb::WatchpointSP m_new_watchpoint_sp;
+
+ DISALLOW_COPY_AND_ASSIGN(WatchpointEventData);
+ };
+
+ Watchpoint(Target &target, lldb::addr_t addr, uint32_t size,
+ const CompilerType *type, bool hardware = true);
+
+ ~Watchpoint() override;
+
+ void IncrementFalseAlarmsAndReviseHitCount();
+
+ bool IsEnabled() const;
+
+ // This doesn't really enable/disable the watchpoint.
+ // It is currently just for use in the Process plugin's
+ // {Enable,Disable}Watchpoint, which should be used instead.
+
+ void SetEnabled(bool enabled, bool notify = true);
+
+ bool IsHardware() const override;
+
+ bool ShouldStop(StoppointCallbackContext *context) override;
+
+ bool WatchpointRead() const;
+ bool WatchpointWrite() const;
+ uint32_t GetIgnoreCount() const;
+ void SetIgnoreCount(uint32_t n);
+ void SetWatchpointType(uint32_t type, bool notify = true);
+ void SetDeclInfo(const std::string &str);
+ std::string GetWatchSpec();
+ void SetWatchSpec(const std::string &str);
+
+ // Snapshot management interface.
+ bool IsWatchVariable() const;
+ void SetWatchVariable(bool val);
+ bool CaptureWatchedValue(const ExecutionContext &exe_ctx);
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level);
+ void Dump(Stream *s) const override;
+ void DumpSnapshots(Stream *s, const char *prefix = nullptr) const;
+ void DumpWithLevel(Stream *s, lldb::DescriptionLevel description_level) const;
+ Target &GetTarget() { return m_target; }
+ const Error &GetError() { return m_error; }
+
+ //------------------------------------------------------------------
+ /// Returns the WatchpointOptions structure set for this watchpoint.
+ ///
+ /// @return
+ /// A pointer to this watchpoint's WatchpointOptions.
+ //------------------------------------------------------------------
+ WatchpointOptions *GetOptions() { return &m_options; }
+
+ //------------------------------------------------------------------
+ /// Set the callback action invoked when the watchpoint is hit.
+ ///
+ /// @param[in] callback
+ /// The method that will get called when the watchpoint is hit.
+ /// @param[in] callback_baton
+ /// A void * pointer that will get passed back to the callback function.
+ /// @param[in] is_synchronous
+ /// If \b true the callback will be run on the private event thread
+ /// before the stop event gets reported. If false, the callback will get
+ /// handled on the public event thread after the stop has been posted.
+ ///
+ /// @return
+ /// \b true if the process should stop when you hit the watchpoint.
+ /// \b false if it should continue.
+ //------------------------------------------------------------------
+ void SetCallback(WatchpointHitCallback callback, void *callback_baton,
+ bool is_synchronous = false);
+
+ void SetCallback(WatchpointHitCallback callback,
+ const lldb::BatonSP &callback_baton_sp,
+ bool is_synchronous = false);
+
+ void ClearCallback();
+
+ //------------------------------------------------------------------
+ /// Invoke the callback action when the watchpoint is hit.
+ ///
+ /// @param[in] context
+ /// Described the watchpoint event.
+ ///
+ /// @return
+ /// \b true if the target should stop at this watchpoint and \b false not.
+ //------------------------------------------------------------------
+ bool InvokeCallback(StoppointCallbackContext *context);
+
+ //------------------------------------------------------------------
+ // Condition
+ //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ /// Set the watchpoint's condition.
+ ///
+ /// @param[in] condition
+ /// The condition expression to evaluate when the watchpoint is hit.
+ /// Pass in nullptr to clear the condition.
+ //------------------------------------------------------------------
+ void SetCondition(const char *condition);
+
+ //------------------------------------------------------------------
+ /// Return a pointer to the text of the condition expression.
+ ///
+ /// @return
+ /// A pointer to the condition expression text, or nullptr if no
+ // condition has been set.
+ //------------------------------------------------------------------
+ const char *GetConditionText() const;
+
+ void TurnOnEphemeralMode();
+
+ void TurnOffEphemeralMode();
+
+ bool IsDisabledDuringEphemeralMode();
+
+ const CompilerType &GetCompilerType() { return m_type; }
private:
- friend class Target;
- friend class WatchpointList;
-
- void
- ResetHitCount ()
- {
- m_hit_count = 0;
- }
-
- void
- ResetHistoricValues ()
- {
- m_old_value_sp.reset(nullptr);
- m_new_value_sp.reset(nullptr);
- }
-
- Target &m_target;
- bool m_enabled; // Is this watchpoint enabled
- bool m_is_hardware; // Is this a hardware watchpoint
- bool m_is_watch_variable; // True if set via 'watchpoint set variable'.
- bool m_is_ephemeral; // True if the watchpoint is in the ephemeral mode, meaning that it is
- // undergoing a pair of temporary disable/enable actions to avoid recursively
- // triggering further watchpoint events.
- uint32_t m_disabled_count; // Keep track of the count that the watchpoint is disabled while in ephemeral mode.
- // At the end of the ephemeral mode when the watchpoint is to be enabled again,
- // we check the count, if it is more than 1, it means the user-supplied actions
- // actually want the watchpoint to be disabled!
- uint32_t m_watch_read:1, // 1 if we stop when the watched data is read from
- m_watch_write:1, // 1 if we stop when the watched data is written to
- m_watch_was_read:1, // Set to 1 when watchpoint is hit for a read access
- m_watch_was_written:1; // Set to 1 when watchpoint is hit for a write access
- uint32_t m_ignore_count; // Number of times to ignore this watchpoint
- uint32_t m_false_alarms; // Number of false alarms.
- std::string m_decl_str; // Declaration information, if any.
- std::string m_watch_spec_str; // Spec for the watchpoint.
- lldb::ValueObjectSP m_old_value_sp;
- lldb::ValueObjectSP m_new_value_sp;
- CompilerType m_type;
- Error m_error; // An error object describing errors associated with this watchpoint.
- WatchpointOptions m_options; // Settable watchpoint options, which is a delegate to handle
- // the callback machinery.
- bool m_being_created;
-
- std::unique_ptr<UserExpression> m_condition_ap; // The condition to test.
-
- void SetID(lldb::watch_id_t id) { m_loc_id = id; }
-
- void
- SendWatchpointChangedEvent (lldb::WatchpointEventType eventKind);
-
- void
- SendWatchpointChangedEvent (WatchpointEventData *data);
-
- DISALLOW_COPY_AND_ASSIGN (Watchpoint);
+ friend class Target;
+ friend class WatchpointList;
+
+ void ResetHitCount() { m_hit_count = 0; }
+
+ void ResetHistoricValues() {
+ m_old_value_sp.reset(nullptr);
+ m_new_value_sp.reset(nullptr);
+ }
+
+ Target &m_target;
+ bool m_enabled; // Is this watchpoint enabled
+ bool m_is_hardware; // Is this a hardware watchpoint
+ bool m_is_watch_variable; // True if set via 'watchpoint set variable'.
+ bool m_is_ephemeral; // True if the watchpoint is in the ephemeral mode,
+ // meaning that it is
+ // undergoing a pair of temporary disable/enable actions to avoid recursively
+ // triggering further watchpoint events.
+ uint32_t m_disabled_count; // Keep track of the count that the watchpoint is
+ // disabled while in ephemeral mode.
+ // At the end of the ephemeral mode when the watchpoint is to be enabled
+ // again,
+ // we check the count, if it is more than 1, it means the user-supplied
+ // actions
+ // actually want the watchpoint to be disabled!
+ uint32_t m_watch_read : 1, // 1 if we stop when the watched data is read from
+ m_watch_write : 1, // 1 if we stop when the watched data is written to
+ m_watch_was_read : 1, // Set to 1 when watchpoint is hit for a read access
+ m_watch_was_written : 1; // Set to 1 when watchpoint is hit for a write
+ // access
+ uint32_t m_ignore_count; // Number of times to ignore this watchpoint
+ uint32_t m_false_alarms; // Number of false alarms.
+ std::string m_decl_str; // Declaration information, if any.
+ std::string m_watch_spec_str; // Spec for the watchpoint.
+ lldb::ValueObjectSP m_old_value_sp;
+ lldb::ValueObjectSP m_new_value_sp;
+ CompilerType m_type;
+ Error m_error; // An error object describing errors associated with this
+ // watchpoint.
+ WatchpointOptions
+ m_options; // Settable watchpoint options, which is a delegate to handle
+ // the callback machinery.
+ bool m_being_created;
+
+ std::unique_ptr<UserExpression> m_condition_ap; // The condition to test.
+
+ void SetID(lldb::watch_id_t id) { m_loc_id = id; }
+
+ void SendWatchpointChangedEvent(lldb::WatchpointEventType eventKind);
+
+ void SendWatchpointChangedEvent(WatchpointEventData *data);
+
+ DISALLOW_COPY_AND_ASSIGN(Watchpoint);
};
} // namespace lldb_private
diff --git a/include/lldb/Breakpoint/WatchpointList.h b/include/lldb/Breakpoint/WatchpointList.h
index 7369623d1ce2..9abac9167b0b 100644
--- a/include/lldb/Breakpoint/WatchpointList.h
+++ b/include/lldb/Breakpoint/WatchpointList.h
@@ -18,8 +18,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/Address.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -30,248 +30,224 @@ namespace lldb_private {
// well.
//----------------------------------------------------------------------
-class WatchpointList
-{
-// Only Target can make the watchpoint list, or add elements to it.
-// This is not just some random collection of watchpoints. Rather, the act of
-// adding the watchpoint to this list sets its ID.
-friend class Watchpoint;
-friend class Target;
+class WatchpointList {
+ // Only Target can make the watchpoint list, or add elements to it.
+ // This is not just some random collection of watchpoints. Rather, the act of
+ // adding the watchpoint to this list sets its ID.
+ friend class Watchpoint;
+ friend class Target;
public:
- //------------------------------------------------------------------
- /// Default constructor makes an empty list.
- //------------------------------------------------------------------
- WatchpointList();
-
- //------------------------------------------------------------------
- /// Destructor, currently does nothing.
- //------------------------------------------------------------------
- ~WatchpointList();
-
- //------------------------------------------------------------------
- /// Add a Watchpoint to the list.
- ///
- /// @param[in] wp_sp
- /// A shared pointer to a watchpoint being added to the list.
- ///
- /// @return
- /// The ID of the Watchpoint in the list.
- //------------------------------------------------------------------
- lldb::watch_id_t
- Add (const lldb::WatchpointSP& wp_sp, bool notify);
-
- //------------------------------------------------------------------
- /// Standard "Dump" method.
- //------------------------------------------------------------------
- void
- Dump (Stream *s) const;
-
- //------------------------------------------------------------------
- /// Dump with lldb::DescriptionLevel.
- //------------------------------------------------------------------
- void
- DumpWithLevel (Stream *s, lldb::DescriptionLevel description_level) const;
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the watchpoint at address
- /// \a addr -
- /// const version.
- ///
- /// @param[in] addr
- /// The address to look for.
- ///
- /// @result
- /// A shared pointer to the watchpoint. May contain a NULL
- /// pointer if the watchpoint doesn't exist.
- //------------------------------------------------------------------
- const lldb::WatchpointSP
- FindByAddress (lldb::addr_t addr) const;
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the watchpoint with watchpoint spec
- /// \a spec -
- /// const version.
- ///
- /// @param[in] spec
- /// The watchpoint spec to look for.
- ///
- /// @result
- /// A shared pointer to the watchpoint. May contain a NULL
- /// pointer if the watchpoint doesn't exist.
- //------------------------------------------------------------------
- const lldb::WatchpointSP
- FindBySpec (std::string spec) const;
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the watchpoint with id
- /// \a watchID, const
- /// version.
- ///
- /// @param[in] watchID
- /// The watchpoint location ID to seek for.
- ///
- /// @result
- /// A shared pointer to the watchpoint. May contain a NULL
- /// pointer if the watchpoint doesn't exist.
- //------------------------------------------------------------------
- lldb::WatchpointSP
- FindByID (lldb::watch_id_t watchID) const;
-
- //------------------------------------------------------------------
- /// Returns the watchpoint id to the watchpoint
- /// at address \a addr.
- ///
- /// @param[in] addr
- /// The address to match.
- ///
- /// @result
- /// The ID of the watchpoint, or LLDB_INVALID_WATCH_ID.
- //------------------------------------------------------------------
- lldb::watch_id_t
- FindIDByAddress (lldb::addr_t addr);
-
- //------------------------------------------------------------------
- /// Returns the watchpoint id to the watchpoint
- /// with watchpoint spec \a spec.
- ///
- /// @param[in] spec
- /// The watchpoint spec to match.
- ///
- /// @result
- /// The ID of the watchpoint, or LLDB_INVALID_WATCH_ID.
- //------------------------------------------------------------------
- lldb::watch_id_t
- FindIDBySpec (std::string spec);
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the watchpoint with index \a i.
- ///
- /// @param[in] i
- /// The watchpoint index to seek for.
- ///
- /// @result
- /// A shared pointer to the watchpoint. May contain a NULL pointer if
- /// the watchpoint doesn't exist.
- //------------------------------------------------------------------
- lldb::WatchpointSP
- GetByIndex (uint32_t i);
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the watchpoint with index \a i, const
- /// version.
- ///
- /// @param[in] i
- /// The watchpoint index to seek for.
- ///
- /// @result
- /// A shared pointer to the watchpoint. May contain a NULL pointer if
- /// the watchpoint location doesn't exist.
- //------------------------------------------------------------------
- const lldb::WatchpointSP
- GetByIndex (uint32_t i) const;
-
- //------------------------------------------------------------------
- /// Removes the watchpoint given by \b watchID from this list.
- ///
- /// @param[in] watchID
- /// The watchpoint ID to remove.
- ///
- /// @result
- /// \b true if the watchpoint \a watchID was in the list.
- //------------------------------------------------------------------
- bool
- Remove (lldb::watch_id_t watchID, bool notify);
-
- //------------------------------------------------------------------
- /// Returns the number hit count of all watchpoints in this list.
- ///
- /// @result
- /// Hit count of all watchpoints in this list.
- //------------------------------------------------------------------
- uint32_t
- GetHitCount () const;
-
- //------------------------------------------------------------------
- /// Enquires of the watchpoint in this list with ID \a watchID whether we
- /// should stop.
- ///
- /// @param[in] context
- /// This contains the information about this stop.
- ///
- /// @param[in] watchID
- /// This watch ID that we hit.
- ///
- /// @return
- /// \b true if we should stop, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ShouldStop (StoppointCallbackContext *context,
- lldb::watch_id_t watchID);
-
- //------------------------------------------------------------------
- /// Returns the number of elements in this watchpoint list.
- ///
- /// @result
- /// The number of elements.
- //------------------------------------------------------------------
- size_t
- GetSize() const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_watchpoints.size();
- }
-
- //------------------------------------------------------------------
- /// Print a description of the watchpoints in this list to the stream \a s.
- ///
- /// @param[in] s
- /// The stream to which to print the description.
- ///
- /// @param[in] level
- /// The description level that indicates the detail level to
- /// provide.
- ///
- /// @see lldb::DescriptionLevel
- //------------------------------------------------------------------
- void
- GetDescription (Stream *s,
- lldb::DescriptionLevel level);
-
- void
- SetEnabledAll (bool enabled);
-
- void
- RemoveAll (bool notify);
-
- //------------------------------------------------------------------
- /// Sets the passed in Locker to hold the Watchpoint List mutex.
- ///
- /// @param[in] locker
- /// The locker object that is set.
- //------------------------------------------------------------------
- void
- GetListMutex(std::unique_lock<std::recursive_mutex> &lock);
+ //------------------------------------------------------------------
+ /// Default constructor makes an empty list.
+ //------------------------------------------------------------------
+ WatchpointList();
+
+ //------------------------------------------------------------------
+ /// Destructor, currently does nothing.
+ //------------------------------------------------------------------
+ ~WatchpointList();
+
+ //------------------------------------------------------------------
+ /// Add a Watchpoint to the list.
+ ///
+ /// @param[in] wp_sp
+ /// A shared pointer to a watchpoint being added to the list.
+ ///
+ /// @return
+ /// The ID of the Watchpoint in the list.
+ //------------------------------------------------------------------
+ lldb::watch_id_t Add(const lldb::WatchpointSP &wp_sp, bool notify);
+
+ //------------------------------------------------------------------
+ /// Standard "Dump" method.
+ //------------------------------------------------------------------
+ void Dump(Stream *s) const;
+
+ //------------------------------------------------------------------
+ /// Dump with lldb::DescriptionLevel.
+ //------------------------------------------------------------------
+ void DumpWithLevel(Stream *s, lldb::DescriptionLevel description_level) const;
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the watchpoint at address
+ /// \a addr -
+ /// const version.
+ ///
+ /// @param[in] addr
+ /// The address to look for.
+ ///
+ /// @result
+ /// A shared pointer to the watchpoint. May contain a NULL
+ /// pointer if the watchpoint doesn't exist.
+ //------------------------------------------------------------------
+ const lldb::WatchpointSP FindByAddress(lldb::addr_t addr) const;
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the watchpoint with watchpoint spec
+ /// \a spec -
+ /// const version.
+ ///
+ /// @param[in] spec
+ /// The watchpoint spec to look for.
+ ///
+ /// @result
+ /// A shared pointer to the watchpoint. May contain a NULL
+ /// pointer if the watchpoint doesn't exist.
+ //------------------------------------------------------------------
+ const lldb::WatchpointSP FindBySpec(std::string spec) const;
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the watchpoint with id
+ /// \a watchID, const
+ /// version.
+ ///
+ /// @param[in] watchID
+ /// The watchpoint location ID to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the watchpoint. May contain a NULL
+ /// pointer if the watchpoint doesn't exist.
+ //------------------------------------------------------------------
+ lldb::WatchpointSP FindByID(lldb::watch_id_t watchID) const;
+
+ //------------------------------------------------------------------
+ /// Returns the watchpoint id to the watchpoint
+ /// at address \a addr.
+ ///
+ /// @param[in] addr
+ /// The address to match.
+ ///
+ /// @result
+ /// The ID of the watchpoint, or LLDB_INVALID_WATCH_ID.
+ //------------------------------------------------------------------
+ lldb::watch_id_t FindIDByAddress(lldb::addr_t addr);
+
+ //------------------------------------------------------------------
+ /// Returns the watchpoint id to the watchpoint
+ /// with watchpoint spec \a spec.
+ ///
+ /// @param[in] spec
+ /// The watchpoint spec to match.
+ ///
+ /// @result
+ /// The ID of the watchpoint, or LLDB_INVALID_WATCH_ID.
+ //------------------------------------------------------------------
+ lldb::watch_id_t FindIDBySpec(std::string spec);
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the watchpoint with index \a i.
+ ///
+ /// @param[in] i
+ /// The watchpoint index to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the watchpoint. May contain a NULL pointer if
+ /// the watchpoint doesn't exist.
+ //------------------------------------------------------------------
+ lldb::WatchpointSP GetByIndex(uint32_t i);
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the watchpoint with index \a i, const
+ /// version.
+ ///
+ /// @param[in] i
+ /// The watchpoint index to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the watchpoint. May contain a NULL pointer if
+ /// the watchpoint location doesn't exist.
+ //------------------------------------------------------------------
+ const lldb::WatchpointSP GetByIndex(uint32_t i) const;
+
+ //------------------------------------------------------------------
+ /// Removes the watchpoint given by \b watchID from this list.
+ ///
+ /// @param[in] watchID
+ /// The watchpoint ID to remove.
+ ///
+ /// @result
+ /// \b true if the watchpoint \a watchID was in the list.
+ //------------------------------------------------------------------
+ bool Remove(lldb::watch_id_t watchID, bool notify);
+
+ //------------------------------------------------------------------
+ /// Returns the number hit count of all watchpoints in this list.
+ ///
+ /// @result
+ /// Hit count of all watchpoints in this list.
+ //------------------------------------------------------------------
+ uint32_t GetHitCount() const;
+
+ //------------------------------------------------------------------
+ /// Enquires of the watchpoint in this list with ID \a watchID whether we
+ /// should stop.
+ ///
+ /// @param[in] context
+ /// This contains the information about this stop.
+ ///
+ /// @param[in] watchID
+ /// This watch ID that we hit.
+ ///
+ /// @return
+ /// \b true if we should stop, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ShouldStop(StoppointCallbackContext *context, lldb::watch_id_t watchID);
+
+ //------------------------------------------------------------------
+ /// Returns the number of elements in this watchpoint list.
+ ///
+ /// @result
+ /// The number of elements.
+ //------------------------------------------------------------------
+ size_t GetSize() const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_watchpoints.size();
+ }
+
+ //------------------------------------------------------------------
+ /// Print a description of the watchpoints in this list to the stream \a s.
+ ///
+ /// @param[in] s
+ /// The stream to which to print the description.
+ ///
+ /// @param[in] level
+ /// The description level that indicates the detail level to
+ /// provide.
+ ///
+ /// @see lldb::DescriptionLevel
+ //------------------------------------------------------------------
+ void GetDescription(Stream *s, lldb::DescriptionLevel level);
+
+ void SetEnabledAll(bool enabled);
+
+ void RemoveAll(bool notify);
+
+ //------------------------------------------------------------------
+ /// Sets the passed in Locker to hold the Watchpoint List mutex.
+ ///
+ /// @param[in] locker
+ /// The locker object that is set.
+ //------------------------------------------------------------------
+ void GetListMutex(std::unique_lock<std::recursive_mutex> &lock);
protected:
- typedef std::list<lldb::WatchpointSP> wp_collection;
- typedef std::vector<lldb::watch_id_t> id_vector;
+ typedef std::list<lldb::WatchpointSP> wp_collection;
+ typedef std::vector<lldb::watch_id_t> id_vector;
- id_vector
- GetWatchpointIDs() const;
+ id_vector GetWatchpointIDs() const;
- wp_collection::iterator
- GetIDIterator(lldb::watch_id_t watchID);
+ wp_collection::iterator GetIDIterator(lldb::watch_id_t watchID);
- wp_collection::const_iterator
- GetIDConstIterator(lldb::watch_id_t watchID) const;
+ wp_collection::const_iterator
+ GetIDConstIterator(lldb::watch_id_t watchID) const;
- wp_collection m_watchpoints;
- mutable std::recursive_mutex m_mutex;
+ wp_collection m_watchpoints;
+ mutable std::recursive_mutex m_mutex;
- lldb::watch_id_t m_next_wp_id;
+ lldb::watch_id_t m_next_wp_id;
};
} // namespace lldb_private
-#endif // liblldb_WatchpointList_h_
+#endif // liblldb_WatchpointList_h_
diff --git a/include/lldb/Breakpoint/WatchpointOptions.h b/include/lldb/Breakpoint/WatchpointOptions.h
index eb08bb32e6ce..bfb814ecbd54 100644
--- a/include/lldb/Breakpoint/WatchpointOptions.h
+++ b/include/lldb/Breakpoint/WatchpointOptions.h
@@ -17,234 +17,228 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/Baton.h"
#include "lldb/Core/StringList.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class WatchpointOptions WatchpointOptions.h "lldb/Breakpoint/WatchpointOptions.h"
+/// @class WatchpointOptions WatchpointOptions.h
+/// "lldb/Breakpoint/WatchpointOptions.h"
/// @brief Class that manages the options on a watchpoint.
//----------------------------------------------------------------------
-class WatchpointOptions
-{
+class WatchpointOptions {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- //------------------------------------------------------------------
- /// Default constructor. The watchpoint is enabled, and has no condition,
- /// callback, ignore count, etc...
- //------------------------------------------------------------------
- WatchpointOptions();
- WatchpointOptions(const WatchpointOptions& rhs);
-
- static WatchpointOptions *
- CopyOptionsNoCallback (WatchpointOptions &rhs);
- //------------------------------------------------------------------
- /// This constructor allows you to specify all the watchpoint options.
- ///
- /// @param[in] callback
- /// This is the plugin for some code that gets run, returns \b true if we are to stop.
- ///
- /// @param[in] baton
- /// Client data that will get passed to the callback.
- ///
- /// @param[in] thread_id
- /// Only stop if \a thread_id hits the watchpoint.
- //------------------------------------------------------------------
- WatchpointOptions(WatchpointHitCallback callback,
- void *baton,
- lldb::tid_t thread_id = LLDB_INVALID_THREAD_ID);
-
- virtual ~WatchpointOptions();
-
- //------------------------------------------------------------------
- // Operators
- //------------------------------------------------------------------
- const WatchpointOptions&
- operator=(const WatchpointOptions& rhs);
-
- //------------------------------------------------------------------
- // Callbacks
- //
- // Watchpoint callbacks come in two forms, synchronous and asynchronous. Synchronous callbacks will get
- // run before any of the thread plans are consulted, and if they return false the target will continue
- // "under the radar" of the thread plans. There are a couple of restrictions to synchronous callbacks:
- // 1) They should NOT resume the target themselves. Just return false if you want the target to restart.
- // 2) Watchpoints with synchronous callbacks can't have conditions (or rather, they can have them, but they
- // won't do anything. Ditto with ignore counts, etc... You are supposed to control that all through the
- // callback.
- // Asynchronous callbacks get run as part of the "ShouldStop" logic in the thread plan. The logic there is:
- // a) If the watchpoint is thread specific and not for this thread, continue w/o running the callback.
- // b) If the ignore count says we shouldn't stop, then ditto.
- // c) If the condition says we shouldn't stop, then ditto.
- // d) Otherwise, the callback will get run, and if it returns true we will stop, and if false we won't.
- // The asynchronous callback can run the target itself, but at present that should be the last action the
- // callback does. We will relax this condition at some point, but it will take a bit of plumbing to get
- // that to work.
- //
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Adds a callback to the watchpoint option set.
- ///
- /// @param[in] callback
- /// The function to be called when the watchpoint gets hit.
- ///
- /// @param[in] baton_sp
- /// A baton which will get passed back to the callback when it is invoked.
- ///
- /// @param[in] synchronous
- /// Whether this is a synchronous or asynchronous callback. See discussion above.
- //------------------------------------------------------------------
- void SetCallback (WatchpointHitCallback callback, const lldb::BatonSP &baton_sp, bool synchronous = false);
-
- //------------------------------------------------------------------
- /// Remove the callback from this option set.
- //------------------------------------------------------------------
- void ClearCallback ();
-
- // The rest of these functions are meant to be used only within the watchpoint handling mechanism.
-
- //------------------------------------------------------------------
- /// Use this function to invoke the callback for a specific stop.
- ///
- /// @param[in] context
- /// The context in which the callback is to be invoked. This includes the stop event, the
- /// execution context of the stop (since you might hit the same watchpoint on multiple threads) and
- /// whether we are currently executing synchronous or asynchronous callbacks.
- ///
- /// @param[in] watch_id
- /// The watchpoint ID that owns this option set.
- ///
- /// @return
- /// The callback return value.
- //------------------------------------------------------------------
- bool InvokeCallback (StoppointCallbackContext *context, lldb::user_id_t watch_id);
-
- //------------------------------------------------------------------
- /// Used in InvokeCallback to tell whether it is the right time to run this kind of callback.
- ///
- /// @return
- /// The synchronicity of our callback.
- //------------------------------------------------------------------
- bool IsCallbackSynchronous () {
- return m_callback_is_synchronous;
- }
-
- //------------------------------------------------------------------
- /// Fetch the baton from the callback.
- ///
- /// @return
- /// The baton.
- //------------------------------------------------------------------
- Baton *GetBaton ();
-
- //------------------------------------------------------------------
- /// Fetch a const version of the baton from the callback.
- ///
- /// @return
- /// The baton.
- //------------------------------------------------------------------
- const Baton *GetBaton () const;
-
- //------------------------------------------------------------------
- /// Return the current thread spec for this option. This will return nullptr if the no thread
- /// specifications have been set for this Option yet.
- /// @return
- /// The thread specification pointer for this option, or nullptr if none has
- /// been set yet.
- //------------------------------------------------------------------
- const ThreadSpec *
- GetThreadSpecNoCreate () const;
-
- //------------------------------------------------------------------
- /// Returns a pointer to the ThreadSpec for this option, creating it.
- /// if it hasn't been created already. This API is used for setting the
- /// ThreadSpec items for this option.
- //------------------------------------------------------------------
- ThreadSpec *
- GetThreadSpec ();
-
- void
- SetThreadID(lldb::tid_t thread_id);
-
- void
- GetDescription (Stream *s, lldb::DescriptionLevel level) const;
-
- //------------------------------------------------------------------
- /// Get description for callback only.
- //------------------------------------------------------------------
- void
- GetCallbackDescription (Stream *s, lldb::DescriptionLevel level) const;
-
- //------------------------------------------------------------------
- /// Returns true if the watchpoint option has a callback set.
- //------------------------------------------------------------------
- bool
- HasCallback();
-
- //------------------------------------------------------------------
- /// This is the default empty callback.
- /// @return
- /// The thread id for which the watchpoint hit will stop,
- /// LLDB_INVALID_THREAD_ID for all threads.
- //------------------------------------------------------------------
- static bool
- NullCallback (void *baton,
- StoppointCallbackContext *context,
- lldb::user_id_t watch_id);
-
- struct CommandData
- {
- CommandData () :
- user_source(),
- script_source(),
- stop_on_error(true)
- {
- }
-
- ~CommandData() = default;
-
- StringList user_source;
- std::string script_source;
- bool stop_on_error;
- };
-
- class CommandBaton : public Baton
- {
- public:
- CommandBaton (CommandData *data) :
- Baton (data)
- {
- }
-
- ~CommandBaton() override
- {
- delete ((CommandData *)m_data);
- m_data = nullptr;
- }
-
- void
- GetDescription(Stream *s, lldb::DescriptionLevel level) const override;
- };
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ /// Default constructor. The watchpoint is enabled, and has no condition,
+ /// callback, ignore count, etc...
+ //------------------------------------------------------------------
+ WatchpointOptions();
+ WatchpointOptions(const WatchpointOptions &rhs);
+
+ static WatchpointOptions *CopyOptionsNoCallback(WatchpointOptions &rhs);
+ //------------------------------------------------------------------
+ /// This constructor allows you to specify all the watchpoint options.
+ ///
+ /// @param[in] callback
+ /// This is the plugin for some code that gets run, returns \b true if we
+ /// are to stop.
+ ///
+ /// @param[in] baton
+ /// Client data that will get passed to the callback.
+ ///
+ /// @param[in] thread_id
+ /// Only stop if \a thread_id hits the watchpoint.
+ //------------------------------------------------------------------
+ WatchpointOptions(WatchpointHitCallback callback, void *baton,
+ lldb::tid_t thread_id = LLDB_INVALID_THREAD_ID);
+
+ virtual ~WatchpointOptions();
+
+ //------------------------------------------------------------------
+ // Operators
+ //------------------------------------------------------------------
+ const WatchpointOptions &operator=(const WatchpointOptions &rhs);
+
+ //------------------------------------------------------------------
+ // Callbacks
+ //
+ // Watchpoint callbacks come in two forms, synchronous and asynchronous.
+ // Synchronous callbacks will get
+ // run before any of the thread plans are consulted, and if they return false
+ // the target will continue
+ // "under the radar" of the thread plans. There are a couple of restrictions
+ // to synchronous callbacks:
+ // 1) They should NOT resume the target themselves. Just return false if you
+ // want the target to restart.
+ // 2) Watchpoints with synchronous callbacks can't have conditions (or rather,
+ // they can have them, but they
+ // won't do anything. Ditto with ignore counts, etc... You are supposed
+ // to control that all through the
+ // callback.
+ // Asynchronous callbacks get run as part of the "ShouldStop" logic in the
+ // thread plan. The logic there is:
+ // a) If the watchpoint is thread specific and not for this thread, continue
+ // w/o running the callback.
+ // b) If the ignore count says we shouldn't stop, then ditto.
+ // c) If the condition says we shouldn't stop, then ditto.
+ // d) Otherwise, the callback will get run, and if it returns true we will
+ // stop, and if false we won't.
+ // The asynchronous callback can run the target itself, but at present that
+ // should be the last action the
+ // callback does. We will relax this condition at some point, but it will
+ // take a bit of plumbing to get
+ // that to work.
+ //
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Adds a callback to the watchpoint option set.
+ ///
+ /// @param[in] callback
+ /// The function to be called when the watchpoint gets hit.
+ ///
+ /// @param[in] baton_sp
+ /// A baton which will get passed back to the callback when it is invoked.
+ ///
+ /// @param[in] synchronous
+ /// Whether this is a synchronous or asynchronous callback. See discussion
+ /// above.
+ //------------------------------------------------------------------
+ void SetCallback(WatchpointHitCallback callback,
+ const lldb::BatonSP &baton_sp, bool synchronous = false);
+
+ //------------------------------------------------------------------
+ /// Remove the callback from this option set.
+ //------------------------------------------------------------------
+ void ClearCallback();
+
+ // The rest of these functions are meant to be used only within the watchpoint
+ // handling mechanism.
+
+ //------------------------------------------------------------------
+ /// Use this function to invoke the callback for a specific stop.
+ ///
+ /// @param[in] context
+ /// The context in which the callback is to be invoked. This includes the
+ /// stop event, the
+ /// execution context of the stop (since you might hit the same watchpoint
+ /// on multiple threads) and
+ /// whether we are currently executing synchronous or asynchronous
+ /// callbacks.
+ ///
+ /// @param[in] watch_id
+ /// The watchpoint ID that owns this option set.
+ ///
+ /// @return
+ /// The callback return value.
+ //------------------------------------------------------------------
+ bool InvokeCallback(StoppointCallbackContext *context,
+ lldb::user_id_t watch_id);
+
+ //------------------------------------------------------------------
+ /// Used in InvokeCallback to tell whether it is the right time to run this
+ /// kind of callback.
+ ///
+ /// @return
+ /// The synchronicity of our callback.
+ //------------------------------------------------------------------
+ bool IsCallbackSynchronous() { return m_callback_is_synchronous; }
+
+ //------------------------------------------------------------------
+ /// Fetch the baton from the callback.
+ ///
+ /// @return
+ /// The baton.
+ //------------------------------------------------------------------
+ Baton *GetBaton();
+
+ //------------------------------------------------------------------
+ /// Fetch a const version of the baton from the callback.
+ ///
+ /// @return
+ /// The baton.
+ //------------------------------------------------------------------
+ const Baton *GetBaton() const;
+
+ //------------------------------------------------------------------
+ /// Return the current thread spec for this option. This will return nullptr
+ /// if the no thread
+ /// specifications have been set for this Option yet.
+ /// @return
+ /// The thread specification pointer for this option, or nullptr if none
+ /// has
+ /// been set yet.
+ //------------------------------------------------------------------
+ const ThreadSpec *GetThreadSpecNoCreate() const;
+
+ //------------------------------------------------------------------
+ /// Returns a pointer to the ThreadSpec for this option, creating it.
+ /// if it hasn't been created already. This API is used for setting the
+ /// ThreadSpec items for this option.
+ //------------------------------------------------------------------
+ ThreadSpec *GetThreadSpec();
+
+ void SetThreadID(lldb::tid_t thread_id);
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) const;
+
+ //------------------------------------------------------------------
+ /// Get description for callback only.
+ //------------------------------------------------------------------
+ void GetCallbackDescription(Stream *s, lldb::DescriptionLevel level) const;
+
+ //------------------------------------------------------------------
+ /// Returns true if the watchpoint option has a callback set.
+ //------------------------------------------------------------------
+ bool HasCallback();
+
+ //------------------------------------------------------------------
+ /// This is the default empty callback.
+ /// @return
+ /// The thread id for which the watchpoint hit will stop,
+ /// LLDB_INVALID_THREAD_ID for all threads.
+ //------------------------------------------------------------------
+ static bool NullCallback(void *baton, StoppointCallbackContext *context,
+ lldb::user_id_t watch_id);
+
+ struct CommandData {
+ CommandData() : user_source(), script_source(), stop_on_error(true) {}
+
+ ~CommandData() = default;
+
+ StringList user_source;
+ std::string script_source;
+ bool stop_on_error;
+ };
+
+ class CommandBaton : public TypedBaton<CommandData> {
+ public:
+ CommandBaton(std::unique_ptr<CommandData> Data)
+ : TypedBaton(std::move(Data)) {}
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) const override;
+ };
protected:
- //------------------------------------------------------------------
- // Classes that inherit from WatchpointOptions can see and modify these
- //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ // Classes that inherit from WatchpointOptions can see and modify these
+ //------------------------------------------------------------------
private:
- //------------------------------------------------------------------
- // For WatchpointOptions only
- //------------------------------------------------------------------
- WatchpointHitCallback m_callback; // This is the callback function pointer
- lldb::BatonSP m_callback_baton_sp; // This is the client data for the callback
- bool m_callback_is_synchronous;
- std::unique_ptr<ThreadSpec> m_thread_spec_ap; // Thread for which this watchpoint will take
+ //------------------------------------------------------------------
+ // For WatchpointOptions only
+ //------------------------------------------------------------------
+ WatchpointHitCallback m_callback; // This is the callback function pointer
+ lldb::BatonSP m_callback_baton_sp; // This is the client data for the callback
+ bool m_callback_is_synchronous;
+ std::unique_ptr<ThreadSpec>
+ m_thread_spec_ap; // Thread for which this watchpoint will take
};
} // namespace lldb_private
diff --git a/include/lldb/Core/Address.h b/include/lldb/Core/Address.h
index 0afe55b12be3..909a0605eae1 100644
--- a/include/lldb/Core/Address.h
+++ b/include/lldb/Core/Address.h
@@ -12,12 +12,11 @@
// C Includes
// C++ Includes
-#include <atomic>
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Symbol/SymbolContextScope.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -53,541 +52,492 @@ namespace lldb_private {
/// this happens, breakpoints that are in one of these sections can be
/// set/cleared.
//----------------------------------------------------------------------
-class Address
-{
+class Address {
public:
- //------------------------------------------------------------------
- /// Dump styles allow the Address::Dump(Stream *,DumpStyle) const
- /// function to display Address contents in a variety of ways.
- //------------------------------------------------------------------
- typedef enum {
- DumpStyleInvalid, ///< Invalid dump style
- DumpStyleSectionNameOffset, ///< Display as the section name + offset.
- ///< \code
- /// // address for printf in libSystem.B.dylib as a section name + offset
- /// libSystem.B.dylib.__TEXT.__text + 0x0005cfdf
- /// \endcode
- DumpStyleSectionPointerOffset, ///< Display as the section pointer + offset (debug output).
- ///< \code
- /// // address for printf in libSystem.B.dylib as a section pointer + offset
- /// (lldb::Section *)0x35cc50 + 0x000000000005cfdf \endcode
- DumpStyleFileAddress, ///< Display as the file address (if any).
- ///< \code
- /// // address for printf in libSystem.B.dylib as a file address
- /// 0x000000000005dcff \endcode
- DumpStyleModuleWithFileAddress, ///< Display as the file address with the module name prepended (if any).
- ///< \code
- /// // address for printf in libSystem.B.dylib as a file address
- /// libSystem.B.dylib[0x000000000005dcff] \endcode
- DumpStyleLoadAddress, ///< Display as the load address (if resolved).
- ///< \code
- /// // address for printf in libSystem.B.dylib as a load address
- /// 0x00007fff8306bcff \endcode
- DumpStyleResolvedDescription, ///< Display the details about what an address resolves to. This can
- ///< be anything from a symbol context summary (module, function/symbol,
- ///< and file and line), to information about what the pointer points to
- ///< if the address is in a section (section of pointers, c strings, etc).
- DumpStyleResolvedDescriptionNoModule,
- DumpStyleResolvedDescriptionNoFunctionArguments,
- DumpStyleNoFunctionName, ///< Elide the function name; display an offset into the current function.
- ///< Used primarily in disassembly symbolication
- DumpStyleDetailedSymbolContext, ///< Detailed symbol context information for an address for all symbol
- ///< context members.
- DumpStyleResolvedPointerDescription ///< Dereference a pointer at the current address and then lookup the
- ///< dereferenced address using DumpStyleResolvedDescription
- } DumpStyle;
-
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Initialize with a invalid section (NULL) and an invalid
- /// offset (LLDB_INVALID_ADDRESS).
- //------------------------------------------------------------------
- Address () :
- m_section_wp (),
- m_offset (LLDB_INVALID_ADDRESS)
- {
- }
-
- //------------------------------------------------------------------
- /// Copy constructor
- ///
- /// Makes a copy of the another Address object \a rhs.
- ///
- /// @param[in] rhs
- /// A const Address object reference to copy.
- //------------------------------------------------------------------
- Address (const Address& rhs) :
- m_section_wp (rhs.m_section_wp),
- m_offset(rhs.m_offset.load())
- {
- }
-
- //------------------------------------------------------------------
- /// Construct with a section pointer and offset.
- ///
- /// Initialize the address with the supplied \a section and \a
- /// offset.
- ///
- /// @param[in] section
- /// A section pointer to a valid lldb::Section, or NULL if the
- /// address doesn't have a section or will get resolved later.
- ///
- /// @param[in] offset
- /// The offset in bytes into \a section.
- //------------------------------------------------------------------
- Address (const lldb::SectionSP &section_sp, lldb::addr_t offset) :
- m_section_wp (), // Don't init with section_sp in case section_sp is invalid (the weak_ptr will throw)
- m_offset (offset)
- {
- if (section_sp)
- m_section_wp = section_sp;
- }
-
- //------------------------------------------------------------------
- /// Construct with a virtual address and section list.
- ///
- /// Initialize and resolve the address with the supplied virtual
- /// address \a file_addr.
- ///
- /// @param[in] file_addr
- /// A virtual file address.
- ///
- /// @param[in] section_list
- /// A list of sections, one of which may contain the \a file_addr.
- //------------------------------------------------------------------
- Address (lldb::addr_t file_addr, const SectionList * section_list);
-
- Address (lldb::addr_t abs_addr);
-
- //------------------------------------------------------------------
- /// Assignment operator.
- ///
- /// Copies the address value from another Address object \a rhs
- /// into \a this object.
- ///
- /// @param[in] rhs
- /// A const Address object reference to copy.
- ///
- /// @return
- /// A const Address object reference to \a this.
- //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ /// Dump styles allow the Address::Dump(Stream *,DumpStyle) const
+ /// function to display Address contents in a variety of ways.
+ //------------------------------------------------------------------
+ typedef enum {
+ DumpStyleInvalid, ///< Invalid dump style
+ DumpStyleSectionNameOffset, ///< Display as the section name + offset.
+ ///< \code
+ /// // address for printf in libSystem.B.dylib as a section name + offset
+ /// libSystem.B.dylib.__TEXT.__text + 0x0005cfdf
+ /// \endcode
+ DumpStyleSectionPointerOffset, ///< Display as the section pointer + offset
+ ///(debug output).
+ ///< \code
+ /// // address for printf in libSystem.B.dylib as a section pointer + offset
+ /// (lldb::Section *)0x35cc50 + 0x000000000005cfdf \endcode
+ DumpStyleFileAddress, ///< Display as the file address (if any).
+ ///< \code
+ /// // address for printf in libSystem.B.dylib as a file address
+ /// 0x000000000005dcff \endcode
+ DumpStyleModuleWithFileAddress, ///< Display as the file address with the
+ ///module name prepended (if any).
+ ///< \code
+ /// // address for printf in libSystem.B.dylib as a file address
+ /// libSystem.B.dylib[0x000000000005dcff] \endcode
+ DumpStyleLoadAddress, ///< Display as the load address (if resolved).
+ ///< \code
+ /// // address for printf in libSystem.B.dylib as a load address
+ /// 0x00007fff8306bcff \endcode
+ DumpStyleResolvedDescription, ///< Display the details about what an address
+ ///resolves to. This can
+ ///< be anything from a symbol context summary (module, function/symbol,
+ ///< and file and line), to information about what the pointer points to
+ ///< if the address is in a section (section of pointers, c strings, etc).
+ DumpStyleResolvedDescriptionNoModule,
+ DumpStyleResolvedDescriptionNoFunctionArguments,
+ DumpStyleNoFunctionName, ///< Elide the function name; display an offset
+ ///into the current function.
+ ///< Used primarily in disassembly symbolication
+ DumpStyleDetailedSymbolContext, ///< Detailed symbol context information for
+ ///an address for all symbol
+ ///< context members.
+ DumpStyleResolvedPointerDescription ///< Dereference a pointer at the
+ ///current address and then lookup the
+ ///< dereferenced address using DumpStyleResolvedDescription
+ } DumpStyle;
+
+ //------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// Initialize with a invalid section (NULL) and an invalid
+ /// offset (LLDB_INVALID_ADDRESS).
+ //------------------------------------------------------------------
+ Address() : m_section_wp(), m_offset(LLDB_INVALID_ADDRESS) {}
+
+ //------------------------------------------------------------------
+ /// Copy constructor
+ ///
+ /// Makes a copy of the another Address object \a rhs.
+ ///
+ /// @param[in] rhs
+ /// A const Address object reference to copy.
+ //------------------------------------------------------------------
+ Address(const Address &rhs)
+ : m_section_wp(rhs.m_section_wp), m_offset(rhs.m_offset) {}
+
+ //------------------------------------------------------------------
+ /// Construct with a section pointer and offset.
+ ///
+ /// Initialize the address with the supplied \a section and \a
+ /// offset.
+ ///
+ /// @param[in] section
+ /// A section pointer to a valid lldb::Section, or NULL if the
+ /// address doesn't have a section or will get resolved later.
+ ///
+ /// @param[in] offset
+ /// The offset in bytes into \a section.
+ //------------------------------------------------------------------
+ Address(const lldb::SectionSP &section_sp, lldb::addr_t offset)
+ : m_section_wp(), // Don't init with section_sp in case section_sp is
+ // invalid (the weak_ptr will throw)
+ m_offset(offset) {
+ if (section_sp)
+ m_section_wp = section_sp;
+ }
+
+ //------------------------------------------------------------------
+ /// Construct with a virtual address and section list.
+ ///
+ /// Initialize and resolve the address with the supplied virtual
+ /// address \a file_addr.
+ ///
+ /// @param[in] file_addr
+ /// A virtual file address.
+ ///
+ /// @param[in] section_list
+ /// A list of sections, one of which may contain the \a file_addr.
+ //------------------------------------------------------------------
+ Address(lldb::addr_t file_addr, const SectionList *section_list);
+
+ Address(lldb::addr_t abs_addr);
+
+//------------------------------------------------------------------
+/// Assignment operator.
+///
+/// Copies the address value from another Address object \a rhs
+/// into \a this object.
+///
+/// @param[in] rhs
+/// A const Address object reference to copy.
+///
+/// @return
+/// A const Address object reference to \a this.
+//------------------------------------------------------------------
#ifndef SWIG
- const Address&
- operator= (const Address& rhs);
+ const Address &operator=(const Address &rhs);
#endif
- //------------------------------------------------------------------
- /// Clear the object's state.
- ///
- /// Sets the section to an invalid value (NULL) and an invalid
- /// offset (LLDB_INVALID_ADDRESS).
- //------------------------------------------------------------------
- void
- Clear ()
- {
- m_section_wp.reset();
- m_offset = LLDB_INVALID_ADDRESS;
+ //------------------------------------------------------------------
+ /// Clear the object's state.
+ ///
+ /// Sets the section to an invalid value (NULL) and an invalid
+ /// offset (LLDB_INVALID_ADDRESS).
+ //------------------------------------------------------------------
+ void Clear() {
+ m_section_wp.reset();
+ m_offset = LLDB_INVALID_ADDRESS;
+ }
+
+ //------------------------------------------------------------------
+ /// Compare two Address objects.
+ ///
+ /// @param[in] lhs
+ /// The Left Hand Side const Address object reference.
+ ///
+ /// @param[in] rhs
+ /// The Right Hand Side const Address object reference.
+ ///
+ /// @return
+ /// @li -1 if lhs < rhs
+ /// @li 0 if lhs == rhs
+ /// @li 1 if lhs > rhs
+ //------------------------------------------------------------------
+ static int CompareFileAddress(const Address &lhs, const Address &rhs);
+
+ static int CompareLoadAddress(const Address &lhs, const Address &rhs,
+ Target *target);
+
+ static int CompareModulePointerAndOffset(const Address &lhs,
+ const Address &rhs);
+
+ // For use with std::map, std::multi_map
+ class ModulePointerAndOffsetLessThanFunctionObject {
+ public:
+ ModulePointerAndOffsetLessThanFunctionObject() = default;
+
+ bool operator()(const Address &a, const Address &b) const {
+ return Address::CompareModulePointerAndOffset(a, b) < 0;
}
-
- //------------------------------------------------------------------
- /// Compare two Address objects.
- ///
- /// @param[in] lhs
- /// The Left Hand Side const Address object reference.
- ///
- /// @param[in] rhs
- /// The Right Hand Side const Address object reference.
- ///
- /// @return
- /// @li -1 if lhs < rhs
- /// @li 0 if lhs == rhs
- /// @li 1 if lhs > rhs
- //------------------------------------------------------------------
- static int
- CompareFileAddress (const Address& lhs, const Address& rhs);
-
- static int
- CompareLoadAddress (const Address& lhs, const Address& rhs, Target *target);
-
- static int
- CompareModulePointerAndOffset (const Address& lhs, const Address& rhs);
-
- // For use with std::map, std::multi_map
- class ModulePointerAndOffsetLessThanFunctionObject
- {
- public:
- ModulePointerAndOffsetLessThanFunctionObject() = default;
-
- bool
- operator() (const Address& a, const Address& b) const
- {
- return Address::CompareModulePointerAndOffset(a, b) < 0;
- }
- };
-
- //------------------------------------------------------------------
- /// Dump a description of this object to a Stream.
- ///
- /// Dump a description of the contents of this object to the
- /// supplied stream \a s. There are many ways to display a section
- /// offset based address, and \a style lets the user choose.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- ///
- /// @param[in] style
- /// The display style for the address.
- ///
- /// @param[in] fallback_style
- /// The display style for the address.
- ///
- /// @return
- /// Returns \b true if the address was able to be displayed.
- /// File and load addresses may be unresolved and it may not be
- /// possible to display a valid value, \b false will be returned
- /// in such cases.
- ///
- /// @see Address::DumpStyle
- //------------------------------------------------------------------
- bool
- Dump (Stream *s,
- ExecutionContextScope *exe_scope,
- DumpStyle style,
- DumpStyle fallback_style = DumpStyleInvalid,
- uint32_t addr_byte_size = UINT32_MAX) const;
-
- lldb::AddressClass
- GetAddressClass () const;
-
- //------------------------------------------------------------------
- /// Get the file address.
- ///
- /// If an address comes from a file on disk that has section
- /// relative addresses, then it has a virtual address that is
- /// relative to unique section in the object file.
- ///
- /// @return
- /// The valid file virtual address, or LLDB_INVALID_ADDRESS if
- /// the address doesn't have a file virtual address (image is
- /// from memory only with no representation on disk).
- //------------------------------------------------------------------
- lldb::addr_t
- GetFileAddress () const;
-
- //------------------------------------------------------------------
- /// Get the load address.
- ///
- /// If an address comes from a file on disk that has section
- /// relative addresses, then it has a virtual address that is
- /// relative to unique section in the object file. Sections get
- /// resolved at runtime by DynamicLoader plug-ins as images
- /// (executables and shared libraries) get loaded/unloaded. If a
- /// section is loaded, then the load address can be resolved.
- ///
- /// @return
- /// The valid load virtual address, or LLDB_INVALID_ADDRESS if
- /// the address is currently not loaded.
- //------------------------------------------------------------------
- lldb::addr_t
- GetLoadAddress (Target *target) const;
-
- //------------------------------------------------------------------
- /// Get the load address as a callable code load address.
- ///
- /// This function will first resolve its address to a load address.
- /// Then, if the address turns out to be in code address, return the
- /// load address that would be required to call or return to. The
- /// address might have extra bits set (bit zero will be set to Thumb
- /// functions for an ARM target) that are required when changing the
- /// program counter to setting a return address.
- ///
- /// @return
- /// The valid load virtual address, or LLDB_INVALID_ADDRESS if
- /// the address is currently not loaded.
- //------------------------------------------------------------------
- lldb::addr_t
- GetCallableLoadAddress (Target *target, bool is_indirect = false) const;
-
- //------------------------------------------------------------------
- /// Get the load address as an opcode load address.
- ///
- /// This function will first resolve its address to a load address.
- /// Then, if the address turns out to be in code address, return the
- /// load address for an opcode. This address object might have
- /// extra bits set (bit zero will be set to Thumb functions for an
- /// ARM target) that are required for changing the program counter
- /// and this function will remove any bits that are intended for
- /// these special purposes. The result of this function can be used
- /// to safely write a software breakpoint trap to memory.
- ///
- /// @return
- /// The valid load virtual address with extra callable bits
- /// removed, or LLDB_INVALID_ADDRESS if the address is currently
- /// not loaded.
- //------------------------------------------------------------------
- lldb::addr_t
- GetOpcodeLoadAddress (Target *target,
- lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const;
-
- //------------------------------------------------------------------
- /// Get the section relative offset value.
- ///
- /// @return
- /// The current offset, or LLDB_INVALID_ADDRESS if this address
- /// doesn't contain a valid offset.
- //------------------------------------------------------------------
- lldb::addr_t
- GetOffset () const { return m_offset; }
-
- //------------------------------------------------------------------
- /// Check if an address is section offset.
- ///
- /// When converting a virtual file or load address into a section
- /// offset based address, we often need to know if, given a section
- /// list, if the address was able to be converted to section offset.
- /// This function returns true if the current value contained in
- /// this object is section offset based.
- ///
- /// @return
- /// Returns \b true if the address has a valid section and
- /// offset, \b false otherwise.
- //------------------------------------------------------------------
- bool
- IsSectionOffset() const
- {
- return IsValid() && (GetSection().get() != nullptr);
+ };
+
+ //------------------------------------------------------------------
+ /// Dump a description of this object to a Stream.
+ ///
+ /// Dump a description of the contents of this object to the
+ /// supplied stream \a s. There are many ways to display a section
+ /// offset based address, and \a style lets the user choose.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ ///
+ /// @param[in] style
+ /// The display style for the address.
+ ///
+ /// @param[in] fallback_style
+ /// The display style for the address.
+ ///
+ /// @return
+ /// Returns \b true if the address was able to be displayed.
+ /// File and load addresses may be unresolved and it may not be
+ /// possible to display a valid value, \b false will be returned
+ /// in such cases.
+ ///
+ /// @see Address::DumpStyle
+ //------------------------------------------------------------------
+ bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
+ DumpStyle fallback_style = DumpStyleInvalid,
+ uint32_t addr_byte_size = UINT32_MAX) const;
+
+ lldb::AddressClass GetAddressClass() const;
+
+ //------------------------------------------------------------------
+ /// Get the file address.
+ ///
+ /// If an address comes from a file on disk that has section
+ /// relative addresses, then it has a virtual address that is
+ /// relative to unique section in the object file.
+ ///
+ /// @return
+ /// The valid file virtual address, or LLDB_INVALID_ADDRESS if
+ /// the address doesn't have a file virtual address (image is
+ /// from memory only with no representation on disk).
+ //------------------------------------------------------------------
+ lldb::addr_t GetFileAddress() const;
+
+ //------------------------------------------------------------------
+ /// Get the load address.
+ ///
+ /// If an address comes from a file on disk that has section
+ /// relative addresses, then it has a virtual address that is
+ /// relative to unique section in the object file. Sections get
+ /// resolved at runtime by DynamicLoader plug-ins as images
+ /// (executables and shared libraries) get loaded/unloaded. If a
+ /// section is loaded, then the load address can be resolved.
+ ///
+ /// @return
+ /// The valid load virtual address, or LLDB_INVALID_ADDRESS if
+ /// the address is currently not loaded.
+ //------------------------------------------------------------------
+ lldb::addr_t GetLoadAddress(Target *target) const;
+
+ //------------------------------------------------------------------
+ /// Get the load address as a callable code load address.
+ ///
+ /// This function will first resolve its address to a load address.
+ /// Then, if the address turns out to be in code address, return the
+ /// load address that would be required to call or return to. The
+ /// address might have extra bits set (bit zero will be set to Thumb
+ /// functions for an ARM target) that are required when changing the
+ /// program counter to setting a return address.
+ ///
+ /// @return
+ /// The valid load virtual address, or LLDB_INVALID_ADDRESS if
+ /// the address is currently not loaded.
+ //------------------------------------------------------------------
+ lldb::addr_t GetCallableLoadAddress(Target *target,
+ bool is_indirect = false) const;
+
+ //------------------------------------------------------------------
+ /// Get the load address as an opcode load address.
+ ///
+ /// This function will first resolve its address to a load address.
+ /// Then, if the address turns out to be in code address, return the
+ /// load address for an opcode. This address object might have
+ /// extra bits set (bit zero will be set to Thumb functions for an
+ /// ARM target) that are required for changing the program counter
+ /// and this function will remove any bits that are intended for
+ /// these special purposes. The result of this function can be used
+ /// to safely write a software breakpoint trap to memory.
+ ///
+ /// @return
+ /// The valid load virtual address with extra callable bits
+ /// removed, or LLDB_INVALID_ADDRESS if the address is currently
+ /// not loaded.
+ //------------------------------------------------------------------
+ lldb::addr_t GetOpcodeLoadAddress(
+ Target *target,
+ lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const;
+
+ //------------------------------------------------------------------
+ /// Get the section relative offset value.
+ ///
+ /// @return
+ /// The current offset, or LLDB_INVALID_ADDRESS if this address
+ /// doesn't contain a valid offset.
+ //------------------------------------------------------------------
+ lldb::addr_t GetOffset() const { return m_offset; }
+
+ //------------------------------------------------------------------
+ /// Check if an address is section offset.
+ ///
+ /// When converting a virtual file or load address into a section
+ /// offset based address, we often need to know if, given a section
+ /// list, if the address was able to be converted to section offset.
+ /// This function returns true if the current value contained in
+ /// this object is section offset based.
+ ///
+ /// @return
+ /// Returns \b true if the address has a valid section and
+ /// offset, \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsSectionOffset() const {
+ return IsValid() && (GetSection().get() != nullptr);
+ }
+
+ //------------------------------------------------------------------
+ /// Check if the object state is valid.
+ ///
+ /// A valid Address object contains either a section pointer and
+ /// and offset (for section offset based addresses), or just a valid
+ /// offset (for absolute addresses that have no section).
+ ///
+ /// @return
+ /// Returns \b true if the offset is valid, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ bool IsValid() const { return m_offset != LLDB_INVALID_ADDRESS; }
+
+ //------------------------------------------------------------------
+ /// Get the memory cost of this object.
+ ///
+ /// @return
+ /// The number of bytes that this object occupies in memory.
+ //------------------------------------------------------------------
+ size_t MemorySize() const;
+
+ //------------------------------------------------------------------
+ /// Resolve a file virtual address using a section list.
+ ///
+ /// Given a list of sections, attempt to resolve \a addr as a
+ /// an offset into one of the file sections.
+ ///
+ /// @return
+ /// Returns \b true if \a addr was able to be resolved, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ bool ResolveAddressUsingFileSections(lldb::addr_t addr,
+ const SectionList *sections);
+
+ //------------------------------------------------------------------
+ /// Set the address to represent \a load_addr.
+ ///
+ /// The address will attempt to find a loaded section within
+ /// \a target that contains \a load_addr. If successful, this
+ /// address object will have a valid section and offset. Else this
+ /// address object will have no section (NULL) and the offset will
+ /// be \a load_addr.
+ ///
+ /// @param[in] load_addr
+ /// A load address from a current process.
+ ///
+ /// @param[in] target
+ /// The target to use when trying resolve the address into
+ /// a section + offset. The Target's SectionLoadList object
+ /// is used to resolve the address.
+ ///
+ /// @return
+ /// Returns \b true if the load address was resolved to be
+ /// section/offset, \b false otherwise. It is often ok for an
+ /// address no not resolve to a section in a module, this often
+ /// happens for JIT'ed code, or any load addresses on the stack
+ /// or heap.
+ //------------------------------------------------------------------
+ bool SetLoadAddress(lldb::addr_t load_addr, Target *target);
+
+ bool SetOpcodeLoadAddress(
+ lldb::addr_t load_addr, Target *target,
+ lldb::AddressClass addr_class = lldb::eAddressClassInvalid);
+
+ bool SetCallableLoadAddress(lldb::addr_t load_addr, Target *target);
+
+ //------------------------------------------------------------------
+ /// Get accessor for the module for this address.
+ ///
+ /// @return
+ /// Returns the Module pointer that this address is an offset
+ /// in, or NULL if this address doesn't belong in a module, or
+ /// isn't resolved yet.
+ //------------------------------------------------------------------
+ lldb::ModuleSP GetModule() const;
+
+ //------------------------------------------------------------------
+ /// Get const accessor for the section.
+ ///
+ /// @return
+ /// Returns the const lldb::Section pointer that this address is an
+ /// offset in, or NULL if this address is absolute.
+ //------------------------------------------------------------------
+ lldb::SectionSP GetSection() const { return m_section_wp.lock(); }
+
+ //------------------------------------------------------------------
+ /// Set accessor for the offset.
+ ///
+ /// @param[in] offset
+ /// A new offset value for this object.
+ ///
+ /// @return
+ /// Returns \b true if the offset changed, \b false otherwise.
+ //------------------------------------------------------------------
+ bool SetOffset(lldb::addr_t offset) {
+ bool changed = m_offset != offset;
+ m_offset = offset;
+ return changed;
+ }
+
+ void SetRawAddress(lldb::addr_t addr) {
+ m_section_wp.reset();
+ m_offset = addr;
+ }
+
+ bool Slide(int64_t offset) {
+ if (m_offset != LLDB_INVALID_ADDRESS) {
+ m_offset += offset;
+ return true;
}
-
- //------------------------------------------------------------------
- /// Check if the object state is valid.
- ///
- /// A valid Address object contains either a section pointer and
- /// and offset (for section offset based addresses), or just a valid
- /// offset (for absolute addresses that have no section).
- ///
- /// @return
- /// Returns \b true if the offset is valid, \b false
- /// otherwise.
- //------------------------------------------------------------------
- bool
- IsValid() const
- {
- return m_offset != LLDB_INVALID_ADDRESS;
- }
-
- //------------------------------------------------------------------
- /// Get the memory cost of this object.
- ///
- /// @return
- /// The number of bytes that this object occupies in memory.
- //------------------------------------------------------------------
- size_t
- MemorySize () const;
-
- //------------------------------------------------------------------
- /// Resolve a file virtual address using a section list.
- ///
- /// Given a list of sections, attempt to resolve \a addr as a
- /// an offset into one of the file sections.
- ///
- /// @return
- /// Returns \b true if \a addr was able to be resolved, \b false
- /// otherwise.
- //------------------------------------------------------------------
- bool
- ResolveAddressUsingFileSections (lldb::addr_t addr, const SectionList *sections);
-
- //------------------------------------------------------------------
- /// Set the address to represent \a load_addr.
- ///
- /// The address will attempt to find a loaded section within
- /// \a target that contains \a load_addr. If successful, this
- /// address object will have a valid section and offset. Else this
- /// address object will have no section (NULL) and the offset will
- /// be \a load_addr.
- ///
- /// @param[in] load_addr
- /// A load address from a current process.
- ///
- /// @param[in] target
- /// The target to use when trying resolve the address into
- /// a section + offset. The Target's SectionLoadList object
- /// is used to resolve the address.
- ///
- /// @return
- /// Returns \b true if the load address was resolved to be
- /// section/offset, \b false otherwise. It is often ok for an
- /// address no not resolve to a section in a module, this often
- /// happens for JIT'ed code, or any load addresses on the stack
- /// or heap.
- //------------------------------------------------------------------
- bool
- SetLoadAddress (lldb::addr_t load_addr, Target *target);
-
- bool
- SetOpcodeLoadAddress (lldb::addr_t load_addr,
- Target *target,
- lldb::AddressClass addr_class = lldb::eAddressClassInvalid);
-
- bool
- SetCallableLoadAddress (lldb::addr_t load_addr, Target *target);
-
- //------------------------------------------------------------------
- /// Get accessor for the module for this address.
- ///
- /// @return
- /// Returns the Module pointer that this address is an offset
- /// in, or NULL if this address doesn't belong in a module, or
- /// isn't resolved yet.
- //------------------------------------------------------------------
- lldb::ModuleSP
- GetModule () const;
-
- //------------------------------------------------------------------
- /// Get const accessor for the section.
- ///
- /// @return
- /// Returns the const lldb::Section pointer that this address is an
- /// offset in, or NULL if this address is absolute.
- //------------------------------------------------------------------
- lldb::SectionSP
- GetSection () const { return m_section_wp.lock(); }
-
- //------------------------------------------------------------------
- /// Set accessor for the offset.
- ///
- /// @param[in] offset
- /// A new offset value for this object.
- ///
- /// @return
- /// Returns \b true if the offset changed, \b false otherwise.
- //------------------------------------------------------------------
- bool
- SetOffset (lldb::addr_t offset)
- {
- bool changed = m_offset != offset;
- m_offset = offset;
- return changed;
- }
-
- void
- SetRawAddress (lldb::addr_t addr)
- {
- m_section_wp.reset();
- m_offset = addr;
- }
-
- bool
- Slide (int64_t offset)
- {
- if (m_offset != LLDB_INVALID_ADDRESS)
- {
- m_offset += offset;
- return true;
- }
- return false;
- }
-
- //------------------------------------------------------------------
- /// Set accessor for the section.
- ///
- /// @param[in] section
- /// A new lldb::Section pointer to use as the section base. Can
- /// be NULL for absolute addresses that are not relative to
- /// any section.
- //------------------------------------------------------------------
- void
- SetSection (const lldb::SectionSP &section_sp)
- {
- m_section_wp = section_sp;
- }
-
- void
- ClearSection ()
- {
- m_section_wp.reset();
- }
-
- //------------------------------------------------------------------
- /// Reconstruct a symbol context from an address.
- ///
- /// This class doesn't inherit from SymbolContextScope because many
- /// address objects have short lifespans. Address objects that are
- /// section offset can reconstruct their symbol context by looking
- /// up the address in the module found in the section.
- ///
- /// @see SymbolContextScope::CalculateSymbolContext(SymbolContext*)
- //------------------------------------------------------------------
- uint32_t
- CalculateSymbolContext (SymbolContext *sc,
- uint32_t resolve_scope = lldb::eSymbolContextEverything) const;
-
- lldb::ModuleSP
- CalculateSymbolContextModule () const;
-
- CompileUnit *
- CalculateSymbolContextCompileUnit () const;
-
- Function *
- CalculateSymbolContextFunction () const;
-
- Block *
- CalculateSymbolContextBlock () const;
-
- Symbol *
- CalculateSymbolContextSymbol () const;
-
- bool
- CalculateSymbolContextLineEntry (LineEntry &line_entry) const;
-
- //------------------------------------------------------------------
- // Returns true if the section should be valid, but isn't because
- // the shared pointer to the section can't be reconstructed from
- // a weak pointer that contains a valid weak reference to a section.
- // Returns false if the section weak pointer has no reference to
- // a section, or if the section is still valid
- //------------------------------------------------------------------
- bool
- SectionWasDeleted() const;
+ return false;
+ }
+
+ //------------------------------------------------------------------
+ /// Set accessor for the section.
+ ///
+ /// @param[in] section
+ /// A new lldb::Section pointer to use as the section base. Can
+ /// be NULL for absolute addresses that are not relative to
+ /// any section.
+ //------------------------------------------------------------------
+ void SetSection(const lldb::SectionSP &section_sp) {
+ m_section_wp = section_sp;
+ }
+
+ void ClearSection() { m_section_wp.reset(); }
+
+ //------------------------------------------------------------------
+ /// Reconstruct a symbol context from an address.
+ ///
+ /// This class doesn't inherit from SymbolContextScope because many
+ /// address objects have short lifespans. Address objects that are
+ /// section offset can reconstruct their symbol context by looking
+ /// up the address in the module found in the section.
+ ///
+ /// @see SymbolContextScope::CalculateSymbolContext(SymbolContext*)
+ //------------------------------------------------------------------
+ uint32_t CalculateSymbolContext(
+ SymbolContext *sc,
+ uint32_t resolve_scope = lldb::eSymbolContextEverything) const;
+
+ lldb::ModuleSP CalculateSymbolContextModule() const;
+
+ CompileUnit *CalculateSymbolContextCompileUnit() const;
+
+ Function *CalculateSymbolContextFunction() const;
+
+ Block *CalculateSymbolContextBlock() const;
+
+ Symbol *CalculateSymbolContextSymbol() const;
+
+ bool CalculateSymbolContextLineEntry(LineEntry &line_entry) const;
+
+ //------------------------------------------------------------------
+ // Returns true if the section should be valid, but isn't because
+ // the shared pointer to the section can't be reconstructed from
+ // a weak pointer that contains a valid weak reference to a section.
+ // Returns false if the section weak pointer has no reference to
+ // a section, or if the section is still valid
+ //------------------------------------------------------------------
+ bool SectionWasDeleted() const;
protected:
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- lldb::SectionWP m_section_wp; ///< The section for the address, can be NULL.
- std::atomic<lldb::addr_t> m_offset; ///< Offset into section if \a m_section_wp is valid...
-
- //------------------------------------------------------------------
- // Returns true if the m_section_wp once had a reference to a valid
- // section shared pointer, but no longer does. This can happen if
- // we have an address from a module that gets unloaded and deleted.
- // This function should only be called if GetSection() returns an
- // empty shared pointer and you want to know if this address used to
- // have a valid section.
- //------------------------------------------------------------------
- bool
- SectionWasDeletedPrivate() const;
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ lldb::SectionWP m_section_wp; ///< The section for the address, can be NULL.
+ lldb::addr_t m_offset; ///< Offset into section if \a m_section_wp is valid...
+
+ //------------------------------------------------------------------
+ // Returns true if the m_section_wp once had a reference to a valid
+ // section shared pointer, but no longer does. This can happen if
+ // we have an address from a module that gets unloaded and deleted.
+ // This function should only be called if GetSection() returns an
+ // empty shared pointer and you want to know if this address used to
+ // have a valid section.
+ //------------------------------------------------------------------
+ bool SectionWasDeletedPrivate() const;
};
//----------------------------------------------------------------------
-// NOTE: Be careful using this operator. It can correctly compare two
-// addresses from the same Module correctly. It can't compare two
+// NOTE: Be careful using this operator. It can correctly compare two
+// addresses from the same Module correctly. It can't compare two
// addresses from different modules in any meaningful way, but it will
// compare the module pointers.
-//
+//
// To sum things up:
// - works great for addresses within the same module
// - it works for addresses across multiple modules, but don't expect the
// address results to make much sense
//
-// This basically lets Address objects be used in ordered collection
+// This basically lets Address objects be used in ordered collection
// classes.
//----------------------------------------------------------------------
-bool operator< (const Address& lhs, const Address& rhs);
-bool operator> (const Address& lhs, const Address& rhs);
-bool operator== (const Address& lhs, const Address& rhs);
-bool operator!= (const Address& lhs, const Address& rhs);
+bool operator<(const Address &lhs, const Address &rhs);
+bool operator>(const Address &lhs, const Address &rhs);
+bool operator==(const Address &lhs, const Address &rhs);
+bool operator!=(const Address &lhs, const Address &rhs);
} // namespace lldb_private
diff --git a/include/lldb/Core/AddressRange.h b/include/lldb/Core/AddressRange.h
index 31e3286cb110..fa9fefbc0df1 100644
--- a/include/lldb/Core/AddressRange.h
+++ b/include/lldb/Core/AddressRange.h
@@ -22,266 +22,257 @@ namespace lldb_private {
/// @class AddressRange AddressRange.h "lldb/Core/AddressRange.h"
/// @brief A section + offset based address range class.
//----------------------------------------------------------------------
-class AddressRange
-{
+class AddressRange {
public:
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Initialize with a invalid section (NULL), an invalid
- /// offset (LLDB_INVALID_ADDRESS), and zero byte size.
- //------------------------------------------------------------------
- AddressRange ();
+ //------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// Initialize with a invalid section (NULL), an invalid
+ /// offset (LLDB_INVALID_ADDRESS), and zero byte size.
+ //------------------------------------------------------------------
+ AddressRange();
- //------------------------------------------------------------------
- /// Construct with a section pointer, offset, and byte_size.
- ///
- /// Initialize the address with the supplied \a section, \a
- /// offset and \a byte_size.
- ///
- /// @param[in] section
- /// A section pointer to a valid lldb::Section, or NULL if the
- /// address doesn't have a section or will get resolved later.
- ///
- /// @param[in] offset
- /// The offset in bytes into \a section.
- ///
- /// @param[in] byte_size
- /// The size in bytes of the address range.
- //------------------------------------------------------------------
- AddressRange (const lldb::SectionSP &section, lldb::addr_t offset, lldb::addr_t byte_size);
+ //------------------------------------------------------------------
+ /// Construct with a section pointer, offset, and byte_size.
+ ///
+ /// Initialize the address with the supplied \a section, \a
+ /// offset and \a byte_size.
+ ///
+ /// @param[in] section
+ /// A section pointer to a valid lldb::Section, or NULL if the
+ /// address doesn't have a section or will get resolved later.
+ ///
+ /// @param[in] offset
+ /// The offset in bytes into \a section.
+ ///
+ /// @param[in] byte_size
+ /// The size in bytes of the address range.
+ //------------------------------------------------------------------
+ AddressRange(const lldb::SectionSP &section, lldb::addr_t offset,
+ lldb::addr_t byte_size);
- //------------------------------------------------------------------
- /// Construct with a virtual address, section list and byte size.
- ///
- /// Initialize and resolve the address with the supplied virtual
- /// address \a file_addr, and byte size \a byte_size.
- ///
- /// @param[in] file_addr
- /// A virtual address.
- ///
- /// @param[in] byte_size
- /// The size in bytes of the address range.
- ///
- /// @param[in] section_list
- /// A list of sections, one of which may contain the \a vaddr.
- //------------------------------------------------------------------
- AddressRange(lldb::addr_t file_addr, lldb::addr_t byte_size, const SectionList *section_list = nullptr);
+ //------------------------------------------------------------------
+ /// Construct with a virtual address, section list and byte size.
+ ///
+ /// Initialize and resolve the address with the supplied virtual
+ /// address \a file_addr, and byte size \a byte_size.
+ ///
+ /// @param[in] file_addr
+ /// A virtual address.
+ ///
+ /// @param[in] byte_size
+ /// The size in bytes of the address range.
+ ///
+ /// @param[in] section_list
+ /// A list of sections, one of which may contain the \a vaddr.
+ //------------------------------------------------------------------
+ AddressRange(lldb::addr_t file_addr, lldb::addr_t byte_size,
+ const SectionList *section_list = nullptr);
- //------------------------------------------------------------------
- /// Construct with a Address object address and byte size.
- ///
- /// Initialize by copying the section offset address in \a so_addr,
- /// and setting the byte size to \a byte_size.
- ///
- /// @param[in] so_addr
- /// A section offset address object.
- ///
- /// @param[in] byte_size
- /// The size in bytes of the address range.
- //------------------------------------------------------------------
- AddressRange (const Address& so_addr, lldb::addr_t byte_size);
+ //------------------------------------------------------------------
+ /// Construct with a Address object address and byte size.
+ ///
+ /// Initialize by copying the section offset address in \a so_addr,
+ /// and setting the byte size to \a byte_size.
+ ///
+ /// @param[in] so_addr
+ /// A section offset address object.
+ ///
+ /// @param[in] byte_size
+ /// The size in bytes of the address range.
+ //------------------------------------------------------------------
+ AddressRange(const Address &so_addr, lldb::addr_t byte_size);
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// The destructor is virtual in case this class is subclassed.
- //------------------------------------------------------------------
- ~AddressRange ();
+ //------------------------------------------------------------------
+ /// Destructor.
+ ///
+ /// The destructor is virtual in case this class is subclassed.
+ //------------------------------------------------------------------
+ ~AddressRange();
- //------------------------------------------------------------------
- /// Clear the object's state.
- ///
- /// Sets the section to an invalid value (NULL), an invalid offset
- /// (LLDB_INVALID_ADDRESS) and a zero byte size.
- //------------------------------------------------------------------
- void
- Clear ();
+ //------------------------------------------------------------------
+ /// Clear the object's state.
+ ///
+ /// Sets the section to an invalid value (NULL), an invalid offset
+ /// (LLDB_INVALID_ADDRESS) and a zero byte size.
+ //------------------------------------------------------------------
+ void Clear();
- //------------------------------------------------------------------
- /// Check if a section offset address is contained in this range.
- ///
- /// @param[in] so_addr
- /// A section offset address object reference.
- ///
- /// @return
- /// Returns \b true if \a so_addr is contained in this range,
- /// \b false otherwise.
- //------------------------------------------------------------------
-// bool
-// Contains (const Address &so_addr) const;
+ //------------------------------------------------------------------
+ /// Check if a section offset address is contained in this range.
+ ///
+ /// @param[in] so_addr
+ /// A section offset address object reference.
+ ///
+ /// @return
+ /// Returns \b true if \a so_addr is contained in this range,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ // bool
+ // Contains (const Address &so_addr) const;
- //------------------------------------------------------------------
- /// Check if a section offset address is contained in this range.
- ///
- /// @param[in] so_addr_ptr
- /// A section offset address object pointer.
- ///
- /// @return
- /// Returns \b true if \a so_addr is contained in this range,
- /// \b false otherwise.
- //------------------------------------------------------------------
-// bool
-// Contains (const Address *so_addr_ptr) const;
+ //------------------------------------------------------------------
+ /// Check if a section offset address is contained in this range.
+ ///
+ /// @param[in] so_addr_ptr
+ /// A section offset address object pointer.
+ ///
+ /// @return
+ /// Returns \b true if \a so_addr is contained in this range,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ // bool
+ // Contains (const Address *so_addr_ptr) const;
- //------------------------------------------------------------------
- /// Check if a section offset \a so_addr when represented as a file
- /// address is contained within this object's file address range.
- ///
- /// @param[in] so_addr
- /// A section offset address object reference.
- ///
- /// @return
- /// Returns \b true if both \a this and \a so_addr have
- /// resolvable file address values and \a so_addr is contained
- /// in the address range, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ContainsFileAddress (const Address &so_addr) const;
+ //------------------------------------------------------------------
+ /// Check if a section offset \a so_addr when represented as a file
+ /// address is contained within this object's file address range.
+ ///
+ /// @param[in] so_addr
+ /// A section offset address object reference.
+ ///
+ /// @return
+ /// Returns \b true if both \a this and \a so_addr have
+ /// resolvable file address values and \a so_addr is contained
+ /// in the address range, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ContainsFileAddress(const Address &so_addr) const;
- //------------------------------------------------------------------
- /// Check if the resolved file address \a file_addr is contained
- /// within this object's file address range.
- ///
- /// @param[in] so_addr
- /// A section offset address object reference.
- ///
- /// @return
- /// Returns \b true if both \a this has a resolvable file
- /// address value and \a so_addr is contained in the address
- /// range, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ContainsFileAddress (lldb::addr_t file_addr) const;
+ //------------------------------------------------------------------
+ /// Check if the resolved file address \a file_addr is contained
+ /// within this object's file address range.
+ ///
+ /// @param[in] so_addr
+ /// A section offset address object reference.
+ ///
+ /// @return
+ /// Returns \b true if both \a this has a resolvable file
+ /// address value and \a so_addr is contained in the address
+ /// range, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ContainsFileAddress(lldb::addr_t file_addr) const;
- //------------------------------------------------------------------
- /// Check if a section offset \a so_addr when represented as a load
- /// address is contained within this object's load address range.
- ///
- /// @param[in] so_addr
- /// A section offset address object reference.
- ///
- /// @return
- /// Returns \b true if both \a this and \a so_addr have
- /// resolvable load address values and \a so_addr is contained
- /// in the address range, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ContainsLoadAddress (const Address &so_addr, Target *target) const;
+ //------------------------------------------------------------------
+ /// Check if a section offset \a so_addr when represented as a load
+ /// address is contained within this object's load address range.
+ ///
+ /// @param[in] so_addr
+ /// A section offset address object reference.
+ ///
+ /// @return
+ /// Returns \b true if both \a this and \a so_addr have
+ /// resolvable load address values and \a so_addr is contained
+ /// in the address range, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ContainsLoadAddress(const Address &so_addr, Target *target) const;
- //------------------------------------------------------------------
- /// Check if the resolved load address \a load_addr is contained
- /// within this object's load address range.
- ///
- /// @param[in] so_addr
- /// A section offset address object reference.
- ///
- /// @return
- /// Returns \b true if both \a this has a resolvable load
- /// address value and \a so_addr is contained in the address
- /// range, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ContainsLoadAddress (lldb::addr_t load_addr, Target *target) const;
+ //------------------------------------------------------------------
+ /// Check if the resolved load address \a load_addr is contained
+ /// within this object's load address range.
+ ///
+ /// @param[in] so_addr
+ /// A section offset address object reference.
+ ///
+ /// @return
+ /// Returns \b true if both \a this has a resolvable load
+ /// address value and \a so_addr is contained in the address
+ /// range, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ContainsLoadAddress(lldb::addr_t load_addr, Target *target) const;
- //------------------------------------------------------------------
- /// Dump a description of this object to a Stream.
- ///
- /// Dump a description of the contents of this object to the
- /// supplied stream \a s. There are many ways to display a section
- /// offset based address range, and \a style lets the user choose
- /// how the base address gets displayed.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- ///
- /// @param[in] style
- /// The display style for the address.
- ///
- /// @return
- /// Returns \b true if the address was able to be displayed.
- /// File and load addresses may be unresolved and it may not be
- /// possible to display a valid value, \b false will be returned
- /// in such cases.
- ///
- /// @see Address::DumpStyle
- //------------------------------------------------------------------
- bool
- Dump (Stream *s, Target *target, Address::DumpStyle style, Address::DumpStyle fallback_style = Address::DumpStyleInvalid) const;
+ //------------------------------------------------------------------
+ /// Dump a description of this object to a Stream.
+ ///
+ /// Dump a description of the contents of this object to the
+ /// supplied stream \a s. There are many ways to display a section
+ /// offset based address range, and \a style lets the user choose
+ /// how the base address gets displayed.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ ///
+ /// @param[in] style
+ /// The display style for the address.
+ ///
+ /// @return
+ /// Returns \b true if the address was able to be displayed.
+ /// File and load addresses may be unresolved and it may not be
+ /// possible to display a valid value, \b false will be returned
+ /// in such cases.
+ ///
+ /// @see Address::DumpStyle
+ //------------------------------------------------------------------
+ bool
+ Dump(Stream *s, Target *target, Address::DumpStyle style,
+ Address::DumpStyle fallback_style = Address::DumpStyleInvalid) const;
- //------------------------------------------------------------------
- /// Dump a debug description of this object to a Stream.
- ///
- /// Dump a debug description of the contents of this object to the
- /// supplied stream \a s.
- ///
- /// The debug description contains verbose internal state such
- /// and pointer values, reference counts, etc.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- //------------------------------------------------------------------
- void
- DumpDebug (Stream *s) const;
+ //------------------------------------------------------------------
+ /// Dump a debug description of this object to a Stream.
+ ///
+ /// Dump a debug description of the contents of this object to the
+ /// supplied stream \a s.
+ ///
+ /// The debug description contains verbose internal state such
+ /// and pointer values, reference counts, etc.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ //------------------------------------------------------------------
+ void DumpDebug(Stream *s) const;
- //------------------------------------------------------------------
- /// Get accessor for the base address of the range.
- ///
- /// @return
- /// A reference to the base address object.
- //------------------------------------------------------------------
- Address &
- GetBaseAddress() { return m_base_addr; }
+ //------------------------------------------------------------------
+ /// Get accessor for the base address of the range.
+ ///
+ /// @return
+ /// A reference to the base address object.
+ //------------------------------------------------------------------
+ Address &GetBaseAddress() { return m_base_addr; }
- //------------------------------------------------------------------
- /// Get const accessor for the base address of the range.
- ///
- /// @return
- /// A const reference to the base address object.
- //------------------------------------------------------------------
- const Address &
- GetBaseAddress() const { return m_base_addr; }
+ //------------------------------------------------------------------
+ /// Get const accessor for the base address of the range.
+ ///
+ /// @return
+ /// A const reference to the base address object.
+ //------------------------------------------------------------------
+ const Address &GetBaseAddress() const { return m_base_addr; }
- //------------------------------------------------------------------
- /// Get accessor for the byte size of this range.
- ///
- /// @return
- /// The size in bytes of this address range.
- //------------------------------------------------------------------
- lldb::addr_t
- GetByteSize () const { return m_byte_size; }
+ //------------------------------------------------------------------
+ /// Get accessor for the byte size of this range.
+ ///
+ /// @return
+ /// The size in bytes of this address range.
+ //------------------------------------------------------------------
+ lldb::addr_t GetByteSize() const { return m_byte_size; }
- //------------------------------------------------------------------
- /// Get the memory cost of this object.
- ///
- /// @return
- /// The number of bytes that this object occupies in memory.
- //------------------------------------------------------------------
- size_t
- MemorySize () const {
- // Noting special for the memory size of a single AddressRange object,
- // it is just the size of itself.
- return sizeof(AddressRange);
- }
+ //------------------------------------------------------------------
+ /// Get the memory cost of this object.
+ ///
+ /// @return
+ /// The number of bytes that this object occupies in memory.
+ //------------------------------------------------------------------
+ size_t MemorySize() const {
+ // Noting special for the memory size of a single AddressRange object,
+ // it is just the size of itself.
+ return sizeof(AddressRange);
+ }
- //------------------------------------------------------------------
- /// Set accessor for the byte size of this range.
- ///
- /// @param[in] byte_size
- /// The new size in bytes of this address range.
- //------------------------------------------------------------------
- void
- SetByteSize (lldb::addr_t byte_size) { m_byte_size = byte_size; }
+ //------------------------------------------------------------------
+ /// Set accessor for the byte size of this range.
+ ///
+ /// @param[in] byte_size
+ /// The new size in bytes of this address range.
+ //------------------------------------------------------------------
+ void SetByteSize(lldb::addr_t byte_size) { m_byte_size = byte_size; }
protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- Address m_base_addr; ///< The section offset base address of this range.
- lldb::addr_t m_byte_size; ///< The size in bytes of this address range.
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ Address m_base_addr; ///< The section offset base address of this range.
+ lldb::addr_t m_byte_size; ///< The size in bytes of this address range.
};
-//bool operator== (const AddressRange& lhs, const AddressRange& rhs);
+// bool operator== (const AddressRange& lhs, const AddressRange& rhs);
} // namespace lldb_private
diff --git a/include/lldb/Core/AddressResolver.h b/include/lldb/Core/AddressResolver.h
index 711cc57c14a4..5fe2ec1eaec6 100644
--- a/include/lldb/Core/AddressResolver.h
+++ b/include/lldb/Core/AddressResolver.h
@@ -16,12 +16,12 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/AddressRange.h"
-#include "lldb/Host/FileSpec.h"
-#include "lldb/Core/SearchFilter.h"
#include "lldb/Core/ConstString.h"
+#include "lldb/Core/SearchFilter.h"
+#include "lldb/Host/FileSpec.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -35,52 +35,38 @@ namespace lldb_private {
/// General Outline:
/// The AddressResolver is a Searcher. In that protocol,
/// the SearchFilter asks the question "At what depth of the symbol context
-/// descent do you want your callback to get called?" of the filter. The resolver
-/// answers this question (in the GetDepth method) and provides the resolution callback.
+/// descent do you want your callback to get called?" of the filter. The
+/// resolver
+/// answers this question (in the GetDepth method) and provides the resolution
+/// callback.
//----------------------------------------------------------------------
-class AddressResolver :
- public Searcher
-{
+class AddressResolver : public Searcher {
public:
+ typedef enum { Exact, Regexp, Glob } MatchType;
- typedef enum
- {
- Exact,
- Regexp,
- Glob
- } MatchType;
-
+ AddressResolver();
- AddressResolver ();
+ ~AddressResolver() override;
- ~AddressResolver () override;
+ virtual void ResolveAddress(SearchFilter &filter);
- virtual void
- ResolveAddress (SearchFilter &filter);
+ virtual void ResolveAddressInModules(SearchFilter &filter,
+ ModuleList &modules);
- virtual void
- ResolveAddressInModules (SearchFilter &filter,
- ModuleList &modules);
+ void GetDescription(Stream *s) override = 0;
- void
- GetDescription (Stream *s) override = 0;
+ std::vector<AddressRange> &GetAddressRanges();
- std::vector<AddressRange> &
- GetAddressRanges ();
+ size_t GetNumberOfAddresses();
- size_t
- GetNumberOfAddresses ();
-
- AddressRange &
- GetAddressRangeAtIndex (size_t idx);
+ AddressRange &GetAddressRangeAtIndex(size_t idx);
protected:
-
- std::vector<AddressRange> m_address_ranges;
+ std::vector<AddressRange> m_address_ranges;
private:
- DISALLOW_COPY_AND_ASSIGN(AddressResolver);
+ DISALLOW_COPY_AND_ASSIGN(AddressResolver);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/AddressResolverFileLine.h b/include/lldb/Core/AddressResolverFileLine.h
index 5b47379ed18e..950750e5bfa4 100644
--- a/include/lldb/Core/AddressResolverFileLine.h
+++ b/include/lldb/Core/AddressResolverFileLine.h
@@ -16,41 +16,36 @@
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class AddressResolverFileLine AddressResolverFileLine.h "lldb/Core/AddressResolverFileLine.h"
-/// @brief This class finds address for source file and line. Optionally, it will look for inlined
+/// @class AddressResolverFileLine AddressResolverFileLine.h
+/// "lldb/Core/AddressResolverFileLine.h"
+/// @brief This class finds address for source file and line. Optionally, it
+/// will look for inlined
/// instances of the file and line specification.
//----------------------------------------------------------------------
-class AddressResolverFileLine :
- public AddressResolver
-{
+class AddressResolverFileLine : public AddressResolver {
public:
+ AddressResolverFileLine(const FileSpec &resolver, uint32_t line_no,
+ bool check_inlines);
- AddressResolverFileLine (const FileSpec &resolver,
- uint32_t line_no,
- bool check_inlines);
+ ~AddressResolverFileLine() override;
- ~AddressResolverFileLine () override;
+ Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
+ SymbolContext &context, Address *addr,
+ bool containing) override;
- Searcher::CallbackReturn
- SearchCallback (SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool containing) override;
+ Searcher::Depth GetDepth() override;
- Searcher::Depth
- GetDepth () override;
-
- void
- GetDescription (Stream *s) override;
+ void GetDescription(Stream *s) override;
protected:
- FileSpec m_file_spec; // This is the file spec we are looking for.
- uint32_t m_line_number; // This is the line number that we are looking for.
- bool m_inlines; // This determines whether the resolver looks for inlined functions or not.
+ FileSpec m_file_spec; // This is the file spec we are looking for.
+ uint32_t m_line_number; // This is the line number that we are looking for.
+ bool m_inlines; // This determines whether the resolver looks for inlined
+ // functions or not.
private:
- DISALLOW_COPY_AND_ASSIGN(AddressResolverFileLine);
+ DISALLOW_COPY_AND_ASSIGN(AddressResolverFileLine);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/AddressResolverName.h b/include/lldb/Core/AddressResolverName.h
index cf792f5054e6..e93d16fbc6aa 100644
--- a/include/lldb/Core/AddressResolverName.h
+++ b/include/lldb/Core/AddressResolverName.h
@@ -18,48 +18,44 @@
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class AddressResolverName AddressResolverName.h "lldb/Core/AddressResolverName.h"
-/// @brief This class finds addresses for a given function name, either by exact match
+/// @class AddressResolverName AddressResolverName.h
+/// "lldb/Core/AddressResolverName.h"
+/// @brief This class finds addresses for a given function name, either by exact
+/// match
/// or by regular expression.
//----------------------------------------------------------------------
-class AddressResolverName:
- public AddressResolver
-{
+class AddressResolverName : public AddressResolver {
public:
+ AddressResolverName(const char *func_name,
+ AddressResolver::MatchType type = Exact);
- AddressResolverName (const char *func_name,
- AddressResolver::MatchType type = Exact);
+ // Creates a function breakpoint by regular expression. Takes over control of
+ // the lifespan of func_regex.
+ AddressResolverName(RegularExpression &func_regex);
- // Creates a function breakpoint by regular expression. Takes over control of the lifespan of func_regex.
- AddressResolverName (RegularExpression &func_regex);
+ AddressResolverName(const char *class_name, const char *method,
+ AddressResolver::MatchType type);
- AddressResolverName (const char *class_name,
- const char *method,
- AddressResolver::MatchType type);
+ ~AddressResolverName() override;
- ~AddressResolverName () override;
+ Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
+ SymbolContext &context, Address *addr,
+ bool containing) override;
- Searcher::CallbackReturn
- SearchCallback (SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool containing) override;
+ Searcher::Depth GetDepth() override;
- Searcher::Depth
- GetDepth () override;
-
- void
- GetDescription (Stream *s) override;
+ void GetDescription(Stream *s) override;
protected:
- ConstString m_func_name;
- ConstString m_class_name; // FIXME: Not used yet. The idea would be to stop on methods of this class.
- RegularExpression m_regex;
- AddressResolver::MatchType m_match_type;
+ ConstString m_func_name;
+ ConstString m_class_name; // FIXME: Not used yet. The idea would be to stop
+ // on methods of this class.
+ RegularExpression m_regex;
+ AddressResolver::MatchType m_match_type;
private:
- DISALLOW_COPY_AND_ASSIGN(AddressResolverName);
+ DISALLOW_COPY_AND_ASSIGN(AddressResolverName);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/ArchSpec.h b/include/lldb/Core/ArchSpec.h
index b2d5f2d7f1a2..7f663f7abd12 100644
--- a/include/lldb/Core/ArchSpec.h
+++ b/include/lldb/Core/ArchSpec.h
@@ -12,13 +12,13 @@
#if defined(__cplusplus)
-#include "lldb/lldb-forward.h"
#include "lldb/Core/ConstString.h"
+#include "lldb/lldb-forward.h"
#include "llvm/ADT/Triple.h"
namespace lldb_private {
-struct CoreDefinition;
+struct CoreDefinition;
//----------------------------------------------------------------------
/// @class ArchSpec ArchSpec.h "lldb/Core/ArchSpec.h"
@@ -29,683 +29,599 @@ struct CoreDefinition;
/// conversions of strings to architecture enumeration values confined
/// to this class allows new architecture support to be added easily.
//----------------------------------------------------------------------
-class ArchSpec
-{
+class ArchSpec {
public:
- enum MIPSSubType
- {
- eMIPSSubType_unknown,
- eMIPSSubType_mips32,
- eMIPSSubType_mips32r2,
- eMIPSSubType_mips32r6,
- eMIPSSubType_mips32el,
- eMIPSSubType_mips32r2el,
- eMIPSSubType_mips32r6el,
- eMIPSSubType_mips64,
- eMIPSSubType_mips64r2,
- eMIPSSubType_mips64r6,
- eMIPSSubType_mips64el,
- eMIPSSubType_mips64r2el,
- eMIPSSubType_mips64r6el,
- };
-
- // Masks for the ases word of an ABI flags structure.
- enum MIPSASE
- {
- eMIPSAse_dsp = 0x00000001, // DSP ASE
- eMIPSAse_dspr2 = 0x00000002, // DSP R2 ASE
- eMIPSAse_eva = 0x00000004, // Enhanced VA Scheme
- eMIPSAse_mcu = 0x00000008, // MCU (MicroController) ASE
- eMIPSAse_mdmx = 0x00000010, // MDMX ASE
- eMIPSAse_mips3d = 0x00000020, // MIPS-3D ASE
- eMIPSAse_mt = 0x00000040, // MT ASE
- eMIPSAse_smartmips = 0x00000080, // SmartMIPS ASE
- eMIPSAse_virt = 0x00000100, // VZ ASE
- eMIPSAse_msa = 0x00000200, // MSA ASE
- eMIPSAse_mips16 = 0x00000400, // MIPS16 ASE
- eMIPSAse_micromips = 0x00000800, // MICROMIPS ASE
- eMIPSAse_xpa = 0x00001000, // XPA ASE
- eMIPSAse_mask = 0x00001fff,
- eMIPSABI_O32 = 0x00002000,
- eMIPSABI_N32 = 0x00004000,
- eMIPSABI_N64 = 0x00008000,
- eMIPSABI_O64 = 0x00020000,
- eMIPSABI_EABI32 = 0x00040000,
- eMIPSABI_EABI64 = 0x00080000,
- eMIPSABI_mask = 0x000ff000
- };
-
- // MIPS Floating point ABI Values
- enum MIPS_ABI_FP
- {
- eMIPS_ABI_FP_ANY = 0x00000000,
- eMIPS_ABI_FP_DOUBLE = 0x00100000, // hard float / -mdouble-float
- eMIPS_ABI_FP_SINGLE = 0x00200000, // hard float / -msingle-float
- eMIPS_ABI_FP_SOFT = 0x00300000, // soft float
- eMIPS_ABI_FP_OLD_64 = 0x00400000, // -mips32r2 -mfp64
- eMIPS_ABI_FP_XX = 0x00500000, // -mfpxx
- eMIPS_ABI_FP_64 = 0x00600000, // -mips32r2 -mfp64
- eMIPS_ABI_FP_64A = 0x00700000, // -mips32r2 -mfp64 -mno-odd-spreg
- eMIPS_ABI_FP_mask = 0x00700000
- };
-
- // ARM specific e_flags
- enum ARMeflags
- {
- eARM_abi_soft_float = 0x00000200,
- eARM_abi_hard_float = 0x00000400
- };
-
- enum Core
- {
- eCore_arm_generic,
- eCore_arm_armv4,
- eCore_arm_armv4t,
- eCore_arm_armv5,
- eCore_arm_armv5e,
- eCore_arm_armv5t,
- eCore_arm_armv6,
- eCore_arm_armv6m,
- eCore_arm_armv7,
- eCore_arm_armv7f,
- eCore_arm_armv7s,
- eCore_arm_armv7k,
- eCore_arm_armv7m,
- eCore_arm_armv7em,
- eCore_arm_xscale,
-
- eCore_thumb,
- eCore_thumbv4t,
- eCore_thumbv5,
- eCore_thumbv5e,
- eCore_thumbv6,
- eCore_thumbv6m,
- eCore_thumbv7,
- eCore_thumbv7s,
- eCore_thumbv7k,
- eCore_thumbv7f,
- eCore_thumbv7m,
- eCore_thumbv7em,
- eCore_arm_arm64,
- eCore_arm_armv8,
- eCore_arm_aarch64,
-
- eCore_mips32,
- eCore_mips32r2,
- eCore_mips32r3,
- eCore_mips32r5,
- eCore_mips32r6,
- eCore_mips32el,
- eCore_mips32r2el,
- eCore_mips32r3el,
- eCore_mips32r5el,
- eCore_mips32r6el,
- eCore_mips64,
- eCore_mips64r2,
- eCore_mips64r3,
- eCore_mips64r5,
- eCore_mips64r6,
- eCore_mips64el,
- eCore_mips64r2el,
- eCore_mips64r3el,
- eCore_mips64r5el,
- eCore_mips64r6el,
-
- eCore_ppc_generic,
- eCore_ppc_ppc601,
- eCore_ppc_ppc602,
- eCore_ppc_ppc603,
- eCore_ppc_ppc603e,
- eCore_ppc_ppc603ev,
- eCore_ppc_ppc604,
- eCore_ppc_ppc604e,
- eCore_ppc_ppc620,
- eCore_ppc_ppc750,
- eCore_ppc_ppc7400,
- eCore_ppc_ppc7450,
- eCore_ppc_ppc970,
-
- eCore_ppc64_generic,
- eCore_ppc64_ppc970_64,
-
- eCore_s390x_generic,
-
- eCore_sparc_generic,
-
- eCore_sparc9_generic,
-
- eCore_x86_32_i386,
- eCore_x86_32_i486,
- eCore_x86_32_i486sx,
- eCore_x86_32_i686,
-
- eCore_x86_64_x86_64,
- eCore_x86_64_x86_64h, // Haswell enabled x86_64
- eCore_hexagon_generic,
- eCore_hexagon_hexagonv4,
- eCore_hexagon_hexagonv5,
-
- eCore_uknownMach32,
- eCore_uknownMach64,
-
- eCore_kalimba3,
- eCore_kalimba4,
- eCore_kalimba5,
-
- kNumCores,
-
- kCore_invalid,
- // The following constants are used for wildcard matching only
- kCore_any,
- kCore_arm_any,
- kCore_ppc_any,
- kCore_ppc64_any,
- kCore_x86_32_any,
- kCore_x86_64_any,
- kCore_hexagon_any,
-
- kCore_arm_first = eCore_arm_generic,
- kCore_arm_last = eCore_arm_xscale,
-
- kCore_thumb_first = eCore_thumb,
- kCore_thumb_last = eCore_thumbv7em,
-
- kCore_ppc_first = eCore_ppc_generic,
- kCore_ppc_last = eCore_ppc_ppc970,
-
- kCore_ppc64_first = eCore_ppc64_generic,
- kCore_ppc64_last = eCore_ppc64_ppc970_64,
-
- kCore_x86_32_first = eCore_x86_32_i386,
- kCore_x86_32_last = eCore_x86_32_i686,
-
- kCore_x86_64_first = eCore_x86_64_x86_64,
- kCore_x86_64_last = eCore_x86_64_x86_64h,
-
- kCore_hexagon_first = eCore_hexagon_generic,
- kCore_hexagon_last = eCore_hexagon_hexagonv5,
-
- kCore_kalimba_first = eCore_kalimba3,
- kCore_kalimba_last = eCore_kalimba5,
-
- kCore_mips32_first = eCore_mips32,
- kCore_mips32_last = eCore_mips32r6,
-
- kCore_mips32el_first = eCore_mips32el,
- kCore_mips32el_last = eCore_mips32r6el,
-
- kCore_mips64_first = eCore_mips64,
- kCore_mips64_last = eCore_mips64r6,
-
- kCore_mips64el_first = eCore_mips64el,
- kCore_mips64el_last = eCore_mips64r6el,
-
- kCore_mips_first = eCore_mips32,
- kCore_mips_last = eCore_mips64r6el
-
- };
-
- typedef void (* StopInfoOverrideCallbackType)(lldb_private::Thread &thread);
-
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Default constructor that initializes the object with invalid
- /// cpu type and subtype values.
- //------------------------------------------------------------------
- ArchSpec ();
-
- //------------------------------------------------------------------
- /// Constructor over triple.
- ///
- /// Constructs an ArchSpec with properties consistent with the given
- /// Triple.
- //------------------------------------------------------------------
- explicit
- ArchSpec (const llvm::Triple &triple);
- explicit
- ArchSpec (const char *triple_cstr);
- explicit
- ArchSpec (const char *triple_cstr, Platform *platform);
- //------------------------------------------------------------------
- /// Constructor over architecture name.
- ///
- /// Constructs an ArchSpec with properties consistent with the given
- /// object type and architecture name.
- //------------------------------------------------------------------
- explicit
- ArchSpec (ArchitectureType arch_type,
- uint32_t cpu_type,
- uint32_t cpu_subtype);
-
- //------------------------------------------------------------------
- /// Destructor.
- //------------------------------------------------------------------
- ~ArchSpec ();
-
- //------------------------------------------------------------------
- /// Assignment operator.
- ///
- /// @param[in] rhs another ArchSpec object to copy.
- ///
- /// @return A const reference to this object.
- //------------------------------------------------------------------
- const ArchSpec&
- operator= (const ArchSpec& rhs);
-
- static size_t
- AutoComplete (const char *name,
- StringList &matches);
-
- //------------------------------------------------------------------
- /// Returns a static string representing the current architecture.
- ///
- /// @return A static string correcponding to the current
- /// architecture.
- //------------------------------------------------------------------
- const char *
- GetArchitectureName () const;
-
- //-----------------------------------------------------------------
- /// if MIPS architecture return true.
- ///
- /// @return a boolean value.
- //-----------------------------------------------------------------
- bool
- IsMIPS() const;
-
- //------------------------------------------------------------------
- /// Returns a string representing current architecture as a target CPU
- /// for tools like compiler, disassembler etc.
- ///
- /// @return A string representing target CPU for the current
- /// architecture.
- //------------------------------------------------------------------
- std::string
- GetClangTargetCPU ();
-
- //------------------------------------------------------------------
- /// Clears the object state.
- ///
- /// Clears the object state back to a default invalid state.
- //------------------------------------------------------------------
- void
- Clear ();
-
- //------------------------------------------------------------------
- /// Returns the size in bytes of an address of the current
- /// architecture.
- ///
- /// @return The byte size of an address of the current architecture.
- //------------------------------------------------------------------
- uint32_t
- GetAddressByteSize () const;
-
- //------------------------------------------------------------------
- /// Returns a machine family for the current architecture.
- ///
- /// @return An LLVM arch type.
- //------------------------------------------------------------------
- llvm::Triple::ArchType
- GetMachine () const;
-
- //------------------------------------------------------------------
- /// Returns the distribution id of the architecture.
- ///
- /// This will be something like "ubuntu", "fedora", etc. on Linux.
- ///
- /// @return A ConstString ref containing the distribution id,
- /// potentially empty.
- //------------------------------------------------------------------
- const ConstString&
- GetDistributionId () const;
-
- //------------------------------------------------------------------
- /// Set the distribution id of the architecture.
- ///
- /// This will be something like "ubuntu", "fedora", etc. on Linux.
- /// This should be the same value returned by
- /// HostInfo::GetDistributionId ().
- ///------------------------------------------------------------------
- void
- SetDistributionId (const char* distribution_id);
-
- //------------------------------------------------------------------
- /// Tests if this ArchSpec is valid.
- ///
- /// @return True if the current architecture is valid, false
- /// otherwise.
- //------------------------------------------------------------------
- bool
- IsValid () const
- {
- return m_core >= eCore_arm_generic && m_core < kNumCores;
- }
-
- //------------------------------------------------------------------
- /// Return a string representing target application ABI.
- ///
- /// @return A string representing target application ABI.
- //------------------------------------------------------------------
- std::string GetTargetABI() const;
-
-
- bool
- TripleVendorWasSpecified() const
- {
- return !m_triple.getVendorName().empty();
- }
-
- bool
- TripleVendorIsUnspecifiedUnknown() const
- {
- return m_triple.getVendor() == llvm::Triple::UnknownVendor && m_triple.getVendorName().empty();
- }
-
- bool
- TripleOSWasSpecified() const
- {
- return !m_triple.getOSName().empty();
- }
-
- bool
- TripleEnvironmentWasSpecified () const
- {
- return !m_triple.getEnvironmentName().empty();
- }
-
- bool
- TripleOSIsUnspecifiedUnknown() const
- {
- return m_triple.getOS() == llvm::Triple::UnknownOS && m_triple.getOSName().empty();
- }
-
- //------------------------------------------------------------------
- /// Merges fields from another ArchSpec into this ArchSpec.
- ///
- /// This will use the supplied ArchSpec to fill in any fields of
- /// the triple in this ArchSpec which were unspecified. This can
- /// be used to refine a generic ArchSpec with a more specific one.
- /// For example, if this ArchSpec's triple is something like
- /// i386-unknown-unknown-unknown, and we have a triple which is
- /// x64-pc-windows-msvc, then merging that triple into this one
- /// will result in the triple i386-pc-windows-msvc.
- ///
- //------------------------------------------------------------------
- void
- MergeFrom(const ArchSpec &other);
-
- //------------------------------------------------------------------
- /// Change the architecture object type, CPU type and OS type.
- ///
- /// @param[in] arch_type The object type of this ArchSpec.
- ///
- /// @param[in] cpu The required CPU type.
- ///
- /// @param[in] os The optional OS type
- /// The default value of 0 was choosen to from the ELF spec value
- /// ELFOSABI_NONE. ELF is the only one using this parameter. If another
- /// format uses this parameter and 0 does not work, use a value over
- /// 255 because in the ELF header this is value is only a byte.
- ///
- /// @return True if the object, and CPU were successfully set.
- ///
- /// As a side effect, the vendor value is usually set to unknown.
- /// The exections are
- /// aarch64-apple-ios
- /// arm-apple-ios
- /// thumb-apple-ios
- /// x86-apple-
- /// x86_64-apple-
- ///
- /// As a side effect, the os value is usually set to unknown
- /// The exceptions are
- /// *-*-aix
- /// aarch64-apple-ios
- /// arm-apple-ios
- /// thumb-apple-ios
- /// powerpc-apple-darwin
- /// *-*-freebsd
- /// *-*-linux
- /// *-*-netbsd
- /// *-*-openbsd
- /// *-*-solaris
- //------------------------------------------------------------------
- bool
- SetArchitecture (ArchitectureType arch_type,
- uint32_t cpu,
- uint32_t sub,
- uint32_t os = 0);
-
- //------------------------------------------------------------------
- /// Returns the byte order for the architecture specification.
- ///
- /// @return The endian enumeration for the current endianness of
- /// the architecture specification
- //------------------------------------------------------------------
- lldb::ByteOrder
- GetByteOrder () const;
-
- //------------------------------------------------------------------
- /// Sets this ArchSpec's byte order.
- ///
- /// In the common case there is no need to call this method as the
- /// byte order can almost always be determined by the architecture.
- /// However, many CPU's are bi-endian (ARM, Alpha, PowerPC, etc)
- /// and the default/assumed byte order may be incorrect.
- //------------------------------------------------------------------
- void
- SetByteOrder (lldb::ByteOrder byte_order)
- {
- m_byte_order = byte_order;
- }
-
- uint32_t
- GetMinimumOpcodeByteSize() const;
-
- uint32_t
- GetMaximumOpcodeByteSize() const;
-
- Core
- GetCore () const
- {
- return m_core;
- }
-
- uint32_t
- GetMachOCPUType () const;
-
- uint32_t
- GetMachOCPUSubType () const;
-
- //------------------------------------------------------------------
- /// Architecture data byte width accessor
- ///
- /// @return the size in 8-bit (host) bytes of a minimum addressable
- /// unit from the Architecture's data bus
- //------------------------------------------------------------------
- uint32_t
- GetDataByteSize() const;
-
- //------------------------------------------------------------------
- /// Architecture code byte width accessor
- ///
- /// @return the size in 8-bit (host) bytes of a minimum addressable
- /// unit from the Architecture's code bus
- //------------------------------------------------------------------
- uint32_t
- GetCodeByteSize() const;
-
- //------------------------------------------------------------------
- /// Architecture tripple accessor.
- ///
- /// @return A triple describing this ArchSpec.
- //------------------------------------------------------------------
- llvm::Triple &
- GetTriple ()
- {
- return m_triple;
- }
-
- //------------------------------------------------------------------
- /// Architecture tripple accessor.
- ///
- /// @return A triple describing this ArchSpec.
- //------------------------------------------------------------------
- const llvm::Triple &
- GetTriple () const
- {
- return m_triple;
- }
-
- void
- DumpTriple(Stream &s) const;
-
- //------------------------------------------------------------------
- /// Architecture tripple setter.
- ///
- /// Configures this ArchSpec according to the given triple. If the
- /// triple has unknown components in all of the vendor, OS, and
- /// the optional environment field (i.e. "i386-unknown-unknown")
- /// then default values are taken from the host. Architecture and
- /// environment components are used to further resolve the CPU type
- /// and subtype, endian characteristics, etc.
- ///
- /// @return A triple describing this ArchSpec.
- //------------------------------------------------------------------
- bool
- SetTriple (const llvm::Triple &triple);
-
- bool
- SetTriple (const char *triple_cstr);
-
- bool
- SetTriple (const char *triple_cstr,
- Platform *platform);
-
- //------------------------------------------------------------------
- /// Returns the default endianness of the architecture.
- ///
- /// @return The endian enumeration for the default endianness of
- /// the architecture.
- //------------------------------------------------------------------
- lldb::ByteOrder
- GetDefaultEndian () const;
-
- //------------------------------------------------------------------
- /// Returns true if 'char' is a signed type by defualt in the
- /// architecture false otherwise
- ///
- /// @return True if 'char' is a signed type by default on the
- /// architecture and false otherwise.
- //------------------------------------------------------------------
- bool
- CharIsSignedByDefault () const;
-
- //------------------------------------------------------------------
- /// Compare an ArchSpec to another ArchSpec, requiring an exact cpu
- /// type match between them.
- /// e.g. armv7s is not an exact match with armv7 - this would return false
- ///
- /// @return true if the two ArchSpecs match.
- //------------------------------------------------------------------
- bool
- IsExactMatch (const ArchSpec& rhs) const;
-
- //------------------------------------------------------------------
- /// Compare an ArchSpec to another ArchSpec, requiring a compatible
- /// cpu type match between them.
- /// e.g. armv7s is compatible with armv7 - this method would return true
- ///
- /// @return true if the two ArchSpecs are compatible
- //------------------------------------------------------------------
- bool
- IsCompatibleMatch (const ArchSpec& rhs) const;
-
- //------------------------------------------------------------------
- /// Get a stop info override callback for the current architecture.
- ///
- /// Most platform specific code should go in lldb_private::Platform,
- /// but there are cases where no matter which platform you are on
- /// certain things hold true.
- ///
- /// This callback is currently intended to handle cases where a
- /// program stops at an instruction that won't get executed and it
- /// allows the stop reasonm, like "breakpoint hit", to be replaced
- /// with a different stop reason like "no stop reason".
- ///
- /// This is specifically used for ARM in Thumb code when we stop in
- /// an IT instruction (if/then/else) where the instruction won't get
- /// executed and therefore it wouldn't be correct to show the program
- /// stopped at the current PC. The code is generic and applies to all
- /// ARM CPUs.
- ///
- /// @return NULL or a valid stop info override callback for the
- /// current architecture.
- //------------------------------------------------------------------
- StopInfoOverrideCallbackType
- GetStopInfoOverrideCallback () const;
-
- bool
- IsFullySpecifiedTriple () const;
-
- void
- PiecewiseTripleCompare (const ArchSpec &other,
- bool &arch_different,
- bool &vendor_different,
- bool &os_different,
- bool &os_version_different,
- bool &env_different);
-
- //------------------------------------------------------------------
- /// Detect whether this architecture uses thumb code exclusively
- ///
- /// Some embedded ARM chips (e.g. the ARM Cortex M0-7 line) can
- /// only execute the Thumb instructions, never Arm. We should normally
- /// pick up arm/thumbness from their the processor status bits (cpsr/xpsr)
- /// or hints on each function - but when doing bare-boards low level
- /// debugging (especially common with these embedded processors), we may
- /// not have those things easily accessible.
- ///
- /// @return true if this is an arm ArchSpec which can only execute Thumb
- /// instructions
- //------------------------------------------------------------------
- bool
- IsAlwaysThumbInstructions () const;
-
- uint32_t
- GetFlags () const
- {
- return m_flags;
- }
-
- void
- SetFlags (uint32_t flags)
- {
- m_flags = flags;
- }
+ enum MIPSSubType {
+ eMIPSSubType_unknown,
+ eMIPSSubType_mips32,
+ eMIPSSubType_mips32r2,
+ eMIPSSubType_mips32r6,
+ eMIPSSubType_mips32el,
+ eMIPSSubType_mips32r2el,
+ eMIPSSubType_mips32r6el,
+ eMIPSSubType_mips64,
+ eMIPSSubType_mips64r2,
+ eMIPSSubType_mips64r6,
+ eMIPSSubType_mips64el,
+ eMIPSSubType_mips64r2el,
+ eMIPSSubType_mips64r6el,
+ };
+
+ // Masks for the ases word of an ABI flags structure.
+ enum MIPSASE {
+ eMIPSAse_dsp = 0x00000001, // DSP ASE
+ eMIPSAse_dspr2 = 0x00000002, // DSP R2 ASE
+ eMIPSAse_eva = 0x00000004, // Enhanced VA Scheme
+ eMIPSAse_mcu = 0x00000008, // MCU (MicroController) ASE
+ eMIPSAse_mdmx = 0x00000010, // MDMX ASE
+ eMIPSAse_mips3d = 0x00000020, // MIPS-3D ASE
+ eMIPSAse_mt = 0x00000040, // MT ASE
+ eMIPSAse_smartmips = 0x00000080, // SmartMIPS ASE
+ eMIPSAse_virt = 0x00000100, // VZ ASE
+ eMIPSAse_msa = 0x00000200, // MSA ASE
+ eMIPSAse_mips16 = 0x00000400, // MIPS16 ASE
+ eMIPSAse_micromips = 0x00000800, // MICROMIPS ASE
+ eMIPSAse_xpa = 0x00001000, // XPA ASE
+ eMIPSAse_mask = 0x00001fff,
+ eMIPSABI_O32 = 0x00002000,
+ eMIPSABI_N32 = 0x00004000,
+ eMIPSABI_N64 = 0x00008000,
+ eMIPSABI_O64 = 0x00020000,
+ eMIPSABI_EABI32 = 0x00040000,
+ eMIPSABI_EABI64 = 0x00080000,
+ eMIPSABI_mask = 0x000ff000
+ };
+
+ // MIPS Floating point ABI Values
+ enum MIPS_ABI_FP {
+ eMIPS_ABI_FP_ANY = 0x00000000,
+ eMIPS_ABI_FP_DOUBLE = 0x00100000, // hard float / -mdouble-float
+ eMIPS_ABI_FP_SINGLE = 0x00200000, // hard float / -msingle-float
+ eMIPS_ABI_FP_SOFT = 0x00300000, // soft float
+ eMIPS_ABI_FP_OLD_64 = 0x00400000, // -mips32r2 -mfp64
+ eMIPS_ABI_FP_XX = 0x00500000, // -mfpxx
+ eMIPS_ABI_FP_64 = 0x00600000, // -mips32r2 -mfp64
+ eMIPS_ABI_FP_64A = 0x00700000, // -mips32r2 -mfp64 -mno-odd-spreg
+ eMIPS_ABI_FP_mask = 0x00700000
+ };
+
+ // ARM specific e_flags
+ enum ARMeflags {
+ eARM_abi_soft_float = 0x00000200,
+ eARM_abi_hard_float = 0x00000400
+ };
+
+ enum Core {
+ eCore_arm_generic,
+ eCore_arm_armv4,
+ eCore_arm_armv4t,
+ eCore_arm_armv5,
+ eCore_arm_armv5e,
+ eCore_arm_armv5t,
+ eCore_arm_armv6,
+ eCore_arm_armv6m,
+ eCore_arm_armv7,
+ eCore_arm_armv7f,
+ eCore_arm_armv7s,
+ eCore_arm_armv7k,
+ eCore_arm_armv7m,
+ eCore_arm_armv7em,
+ eCore_arm_xscale,
+
+ eCore_thumb,
+ eCore_thumbv4t,
+ eCore_thumbv5,
+ eCore_thumbv5e,
+ eCore_thumbv6,
+ eCore_thumbv6m,
+ eCore_thumbv7,
+ eCore_thumbv7s,
+ eCore_thumbv7k,
+ eCore_thumbv7f,
+ eCore_thumbv7m,
+ eCore_thumbv7em,
+ eCore_arm_arm64,
+ eCore_arm_armv8,
+ eCore_arm_aarch64,
+
+ eCore_mips32,
+ eCore_mips32r2,
+ eCore_mips32r3,
+ eCore_mips32r5,
+ eCore_mips32r6,
+ eCore_mips32el,
+ eCore_mips32r2el,
+ eCore_mips32r3el,
+ eCore_mips32r5el,
+ eCore_mips32r6el,
+ eCore_mips64,
+ eCore_mips64r2,
+ eCore_mips64r3,
+ eCore_mips64r5,
+ eCore_mips64r6,
+ eCore_mips64el,
+ eCore_mips64r2el,
+ eCore_mips64r3el,
+ eCore_mips64r5el,
+ eCore_mips64r6el,
+
+ eCore_ppc_generic,
+ eCore_ppc_ppc601,
+ eCore_ppc_ppc602,
+ eCore_ppc_ppc603,
+ eCore_ppc_ppc603e,
+ eCore_ppc_ppc603ev,
+ eCore_ppc_ppc604,
+ eCore_ppc_ppc604e,
+ eCore_ppc_ppc620,
+ eCore_ppc_ppc750,
+ eCore_ppc_ppc7400,
+ eCore_ppc_ppc7450,
+ eCore_ppc_ppc970,
+
+ eCore_ppc64_generic,
+ eCore_ppc64_ppc970_64,
+
+ eCore_s390x_generic,
+
+ eCore_sparc_generic,
+
+ eCore_sparc9_generic,
+
+ eCore_x86_32_i386,
+ eCore_x86_32_i486,
+ eCore_x86_32_i486sx,
+ eCore_x86_32_i686,
+
+ eCore_x86_64_x86_64,
+ eCore_x86_64_x86_64h, // Haswell enabled x86_64
+ eCore_hexagon_generic,
+ eCore_hexagon_hexagonv4,
+ eCore_hexagon_hexagonv5,
+
+ eCore_uknownMach32,
+ eCore_uknownMach64,
+
+ eCore_kalimba3,
+ eCore_kalimba4,
+ eCore_kalimba5,
+
+ kNumCores,
+
+ kCore_invalid,
+ // The following constants are used for wildcard matching only
+ kCore_any,
+ kCore_arm_any,
+ kCore_ppc_any,
+ kCore_ppc64_any,
+ kCore_x86_32_any,
+ kCore_x86_64_any,
+ kCore_hexagon_any,
+
+ kCore_arm_first = eCore_arm_generic,
+ kCore_arm_last = eCore_arm_xscale,
+
+ kCore_thumb_first = eCore_thumb,
+ kCore_thumb_last = eCore_thumbv7em,
+
+ kCore_ppc_first = eCore_ppc_generic,
+ kCore_ppc_last = eCore_ppc_ppc970,
+
+ kCore_ppc64_first = eCore_ppc64_generic,
+ kCore_ppc64_last = eCore_ppc64_ppc970_64,
+
+ kCore_x86_32_first = eCore_x86_32_i386,
+ kCore_x86_32_last = eCore_x86_32_i686,
+
+ kCore_x86_64_first = eCore_x86_64_x86_64,
+ kCore_x86_64_last = eCore_x86_64_x86_64h,
+
+ kCore_hexagon_first = eCore_hexagon_generic,
+ kCore_hexagon_last = eCore_hexagon_hexagonv5,
+
+ kCore_kalimba_first = eCore_kalimba3,
+ kCore_kalimba_last = eCore_kalimba5,
+
+ kCore_mips32_first = eCore_mips32,
+ kCore_mips32_last = eCore_mips32r6,
+
+ kCore_mips32el_first = eCore_mips32el,
+ kCore_mips32el_last = eCore_mips32r6el,
+
+ kCore_mips64_first = eCore_mips64,
+ kCore_mips64_last = eCore_mips64r6,
+
+ kCore_mips64el_first = eCore_mips64el,
+ kCore_mips64el_last = eCore_mips64r6el,
+
+ kCore_mips_first = eCore_mips32,
+ kCore_mips_last = eCore_mips64r6el
+
+ };
+
+ typedef void (*StopInfoOverrideCallbackType)(lldb_private::Thread &thread);
+
+ //------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// Default constructor that initializes the object with invalid
+ /// cpu type and subtype values.
+ //------------------------------------------------------------------
+ ArchSpec();
+
+ //------------------------------------------------------------------
+ /// Constructor over triple.
+ ///
+ /// Constructs an ArchSpec with properties consistent with the given
+ /// Triple.
+ //------------------------------------------------------------------
+ explicit ArchSpec(const llvm::Triple &triple);
+ explicit ArchSpec(const char *triple_cstr);
+ explicit ArchSpec(llvm::StringRef triple_str);
+ ArchSpec(const char *triple_cstr, Platform *platform);
+ ArchSpec(llvm::StringRef triple_str, Platform *platform);
+ //------------------------------------------------------------------
+ /// Constructor over architecture name.
+ ///
+ /// Constructs an ArchSpec with properties consistent with the given
+ /// object type and architecture name.
+ //------------------------------------------------------------------
+ explicit ArchSpec(ArchitectureType arch_type, uint32_t cpu_type,
+ uint32_t cpu_subtype);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ //------------------------------------------------------------------
+ ~ArchSpec();
+
+ //------------------------------------------------------------------
+ /// Assignment operator.
+ ///
+ /// @param[in] rhs another ArchSpec object to copy.
+ ///
+ /// @return A const reference to this object.
+ //------------------------------------------------------------------
+ const ArchSpec &operator=(const ArchSpec &rhs);
+
+ static size_t AutoComplete(llvm::StringRef name, StringList &matches);
+
+ //------------------------------------------------------------------
+ /// Returns a static string representing the current architecture.
+ ///
+ /// @return A static string correcponding to the current
+ /// architecture.
+ //------------------------------------------------------------------
+ const char *GetArchitectureName() const;
+
+ //-----------------------------------------------------------------
+ /// if MIPS architecture return true.
+ ///
+ /// @return a boolean value.
+ //-----------------------------------------------------------------
+ bool IsMIPS() const;
+
+ //------------------------------------------------------------------
+ /// Returns a string representing current architecture as a target CPU
+ /// for tools like compiler, disassembler etc.
+ ///
+ /// @return A string representing target CPU for the current
+ /// architecture.
+ //------------------------------------------------------------------
+ std::string GetClangTargetCPU();
+
+ //------------------------------------------------------------------
+ /// Return a string representing target application ABI.
+ ///
+ /// @return A string representing target application ABI.
+ //------------------------------------------------------------------
+ std::string GetTargetABI() const;
+
+ //------------------------------------------------------------------
+ /// Clears the object state.
+ ///
+ /// Clears the object state back to a default invalid state.
+ //------------------------------------------------------------------
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Returns the size in bytes of an address of the current
+ /// architecture.
+ ///
+ /// @return The byte size of an address of the current architecture.
+ //------------------------------------------------------------------
+ uint32_t GetAddressByteSize() const;
+
+ //------------------------------------------------------------------
+ /// Returns a machine family for the current architecture.
+ ///
+ /// @return An LLVM arch type.
+ //------------------------------------------------------------------
+ llvm::Triple::ArchType GetMachine() const;
+
+ //------------------------------------------------------------------
+ /// Returns the distribution id of the architecture.
+ ///
+ /// This will be something like "ubuntu", "fedora", etc. on Linux.
+ ///
+ /// @return A ConstString ref containing the distribution id,
+ /// potentially empty.
+ //------------------------------------------------------------------
+ const ConstString &GetDistributionId() const;
+
+ //------------------------------------------------------------------
+ /// Set the distribution id of the architecture.
+ ///
+ /// This will be something like "ubuntu", "fedora", etc. on Linux.
+ /// This should be the same value returned by
+ /// HostInfo::GetDistributionId ().
+ ///------------------------------------------------------------------
+ void SetDistributionId(const char *distribution_id);
+
+ //------------------------------------------------------------------
+ /// Tests if this ArchSpec is valid.
+ ///
+ /// @return True if the current architecture is valid, false
+ /// otherwise.
+ //------------------------------------------------------------------
+ bool IsValid() const {
+ return m_core >= eCore_arm_generic && m_core < kNumCores;
+ }
+
+ bool TripleVendorWasSpecified() const {
+ return !m_triple.getVendorName().empty();
+ }
+
+ bool TripleVendorIsUnspecifiedUnknown() const {
+ return m_triple.getVendor() == llvm::Triple::UnknownVendor &&
+ m_triple.getVendorName().empty();
+ }
+
+ bool TripleOSWasSpecified() const { return !m_triple.getOSName().empty(); }
+
+ bool TripleEnvironmentWasSpecified() const {
+ return !m_triple.getEnvironmentName().empty();
+ }
+
+ bool TripleOSIsUnspecifiedUnknown() const {
+ return m_triple.getOS() == llvm::Triple::UnknownOS &&
+ m_triple.getOSName().empty();
+ }
+
+ //------------------------------------------------------------------
+ /// Merges fields from another ArchSpec into this ArchSpec.
+ ///
+ /// This will use the supplied ArchSpec to fill in any fields of
+ /// the triple in this ArchSpec which were unspecified. This can
+ /// be used to refine a generic ArchSpec with a more specific one.
+ /// For example, if this ArchSpec's triple is something like
+ /// i386-unknown-unknown-unknown, and we have a triple which is
+ /// x64-pc-windows-msvc, then merging that triple into this one
+ /// will result in the triple i386-pc-windows-msvc.
+ ///
+ //------------------------------------------------------------------
+ void MergeFrom(const ArchSpec &other);
+
+ //------------------------------------------------------------------
+ /// Change the architecture object type, CPU type and OS type.
+ ///
+ /// @param[in] arch_type The object type of this ArchSpec.
+ ///
+ /// @param[in] cpu The required CPU type.
+ ///
+ /// @param[in] os The optional OS type
+ /// The default value of 0 was chosen to from the ELF spec value
+ /// ELFOSABI_NONE. ELF is the only one using this parameter. If another
+ /// format uses this parameter and 0 does not work, use a value over
+ /// 255 because in the ELF header this is value is only a byte.
+ ///
+ /// @return True if the object, and CPU were successfully set.
+ ///
+ /// As a side effect, the vendor value is usually set to unknown.
+ /// The exections are
+ /// aarch64-apple-ios
+ /// arm-apple-ios
+ /// thumb-apple-ios
+ /// x86-apple-
+ /// x86_64-apple-
+ ///
+ /// As a side effect, the os value is usually set to unknown
+ /// The exceptions are
+ /// *-*-aix
+ /// aarch64-apple-ios
+ /// arm-apple-ios
+ /// thumb-apple-ios
+ /// powerpc-apple-darwin
+ /// *-*-freebsd
+ /// *-*-linux
+ /// *-*-netbsd
+ /// *-*-openbsd
+ /// *-*-solaris
+ //------------------------------------------------------------------
+ bool SetArchitecture(ArchitectureType arch_type, uint32_t cpu, uint32_t sub,
+ uint32_t os = 0);
+
+ //------------------------------------------------------------------
+ /// Returns the byte order for the architecture specification.
+ ///
+ /// @return The endian enumeration for the current endianness of
+ /// the architecture specification
+ //------------------------------------------------------------------
+ lldb::ByteOrder GetByteOrder() const;
+
+ //------------------------------------------------------------------
+ /// Sets this ArchSpec's byte order.
+ ///
+ /// In the common case there is no need to call this method as the
+ /// byte order can almost always be determined by the architecture.
+ /// However, many CPU's are bi-endian (ARM, Alpha, PowerPC, etc)
+ /// and the default/assumed byte order may be incorrect.
+ //------------------------------------------------------------------
+ void SetByteOrder(lldb::ByteOrder byte_order) { m_byte_order = byte_order; }
+
+ uint32_t GetMinimumOpcodeByteSize() const;
+
+ uint32_t GetMaximumOpcodeByteSize() const;
+
+ Core GetCore() const { return m_core; }
+
+ uint32_t GetMachOCPUType() const;
+
+ uint32_t GetMachOCPUSubType() const;
+
+ //------------------------------------------------------------------
+ /// Architecture data byte width accessor
+ ///
+ /// @return the size in 8-bit (host) bytes of a minimum addressable
+ /// unit from the Architecture's data bus
+ //------------------------------------------------------------------
+ uint32_t GetDataByteSize() const;
+
+ //------------------------------------------------------------------
+ /// Architecture code byte width accessor
+ ///
+ /// @return the size in 8-bit (host) bytes of a minimum addressable
+ /// unit from the Architecture's code bus
+ //------------------------------------------------------------------
+ uint32_t GetCodeByteSize() const;
+
+ //------------------------------------------------------------------
+ /// Architecture tripple accessor.
+ ///
+ /// @return A triple describing this ArchSpec.
+ //------------------------------------------------------------------
+ llvm::Triple &GetTriple() { return m_triple; }
+
+ //------------------------------------------------------------------
+ /// Architecture tripple accessor.
+ ///
+ /// @return A triple describing this ArchSpec.
+ //------------------------------------------------------------------
+ const llvm::Triple &GetTriple() const { return m_triple; }
+
+ void DumpTriple(Stream &s) const;
+
+ //------------------------------------------------------------------
+ /// Architecture tripple setter.
+ ///
+ /// Configures this ArchSpec according to the given triple. If the
+ /// triple has unknown components in all of the vendor, OS, and
+ /// the optional environment field (i.e. "i386-unknown-unknown")
+ /// then default values are taken from the host. Architecture and
+ /// environment components are used to further resolve the CPU type
+ /// and subtype, endian characteristics, etc.
+ ///
+ /// @return A triple describing this ArchSpec.
+ //------------------------------------------------------------------
+ bool SetTriple(const llvm::Triple &triple);
+
+ bool SetTriple(llvm::StringRef triple_str);
+ bool SetTriple(llvm::StringRef triple_str, Platform *platform);
+
+ bool SetTriple(const char *triple_cstr);
+ bool SetTriple(const char *triple_cstr, Platform *platform);
+
+ //------------------------------------------------------------------
+ /// Returns the default endianness of the architecture.
+ ///
+ /// @return The endian enumeration for the default endianness of
+ /// the architecture.
+ //------------------------------------------------------------------
+ lldb::ByteOrder GetDefaultEndian() const;
+
+ //------------------------------------------------------------------
+ /// Returns true if 'char' is a signed type by defualt in the
+ /// architecture false otherwise
+ ///
+ /// @return True if 'char' is a signed type by default on the
+ /// architecture and false otherwise.
+ //------------------------------------------------------------------
+ bool CharIsSignedByDefault() const;
+
+ //------------------------------------------------------------------
+ /// Compare an ArchSpec to another ArchSpec, requiring an exact cpu
+ /// type match between them.
+ /// e.g. armv7s is not an exact match with armv7 - this would return false
+ ///
+ /// @return true if the two ArchSpecs match.
+ //------------------------------------------------------------------
+ bool IsExactMatch(const ArchSpec &rhs) const;
+
+ //------------------------------------------------------------------
+ /// Compare an ArchSpec to another ArchSpec, requiring a compatible
+ /// cpu type match between them.
+ /// e.g. armv7s is compatible with armv7 - this method would return true
+ ///
+ /// @return true if the two ArchSpecs are compatible
+ //------------------------------------------------------------------
+ bool IsCompatibleMatch(const ArchSpec &rhs) const;
+
+ //------------------------------------------------------------------
+ /// Get a stop info override callback for the current architecture.
+ ///
+ /// Most platform specific code should go in lldb_private::Platform,
+ /// but there are cases where no matter which platform you are on
+ /// certain things hold true.
+ ///
+ /// This callback is currently intended to handle cases where a
+ /// program stops at an instruction that won't get executed and it
+ /// allows the stop reasonm, like "breakpoint hit", to be replaced
+ /// with a different stop reason like "no stop reason".
+ ///
+ /// This is specifically used for ARM in Thumb code when we stop in
+ /// an IT instruction (if/then/else) where the instruction won't get
+ /// executed and therefore it wouldn't be correct to show the program
+ /// stopped at the current PC. The code is generic and applies to all
+ /// ARM CPUs.
+ ///
+ /// @return NULL or a valid stop info override callback for the
+ /// current architecture.
+ //------------------------------------------------------------------
+ StopInfoOverrideCallbackType GetStopInfoOverrideCallback() const;
+
+ bool IsFullySpecifiedTriple() const;
+
+ void PiecewiseTripleCompare(const ArchSpec &other, bool &arch_different,
+ bool &vendor_different, bool &os_different,
+ bool &os_version_different, bool &env_different);
+
+ //------------------------------------------------------------------
+ /// Detect whether this architecture uses thumb code exclusively
+ ///
+ /// Some embedded ARM chips (e.g. the ARM Cortex M0-7 line) can
+ /// only execute the Thumb instructions, never Arm. We should normally
+ /// pick up arm/thumbness from their the processor status bits (cpsr/xpsr)
+ /// or hints on each function - but when doing bare-boards low level
+ /// debugging (especially common with these embedded processors), we may
+ /// not have those things easily accessible.
+ ///
+ /// @return true if this is an arm ArchSpec which can only execute Thumb
+ /// instructions
+ //------------------------------------------------------------------
+ bool IsAlwaysThumbInstructions() const;
+
+ uint32_t GetFlags() const { return m_flags; }
+
+ void SetFlags(uint32_t flags) { m_flags = flags; }
void SetFlags(std::string elf_abi);
protected:
- bool
- IsEqualTo (const ArchSpec& rhs, bool exact_match) const;
+ bool IsEqualTo(const ArchSpec &rhs, bool exact_match) const;
- llvm::Triple m_triple;
- Core m_core;
- lldb::ByteOrder m_byte_order;
+ llvm::Triple m_triple;
+ Core m_core = kCore_invalid;
+ lldb::ByteOrder m_byte_order = lldb::eByteOrderInvalid;
- // Additional arch flags which we cannot get from triple and core
- // For MIPS these are application specific extensions like
- // micromips, mips16 etc.
- uint32_t m_flags;
+ // Additional arch flags which we cannot get from triple and core
+ // For MIPS these are application specific extensions like
+ // micromips, mips16 etc.
+ uint32_t m_flags = 0;
- ConstString m_distribution_id;
+ ConstString m_distribution_id;
- // Called when m_def or m_entry are changed. Fills in all remaining
- // members with default values.
- void
- CoreUpdated (bool update_triple);
+ // Called when m_def or m_entry are changed. Fills in all remaining
+ // members with default values.
+ void CoreUpdated(bool update_triple);
};
//------------------------------------------------------------------
@@ -720,9 +636,11 @@ protected:
///
/// @return true if \a lhs is less than \a rhs
//------------------------------------------------------------------
-bool operator< (const ArchSpec& lhs, const ArchSpec& rhs);
+bool operator<(const ArchSpec &lhs, const ArchSpec &rhs);
+
+bool ParseMachCPUDashSubtypeTriple(llvm::StringRef triple_str, ArchSpec &arch);
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif // #ifndef liblldb_ArchSpec_h_
+#endif // #if defined(__cplusplus)
+#endif // #ifndef liblldb_ArchSpec_h_
diff --git a/include/lldb/Core/Baton.h b/include/lldb/Core/Baton.h
index 627e7203a4ac..c2ab9f74907d 100644
--- a/include/lldb/Core/Baton.h
+++ b/include/lldb/Core/Baton.h
@@ -23,40 +23,53 @@ namespace lldb_private {
/// @brief A class designed to wrap callback batons so they can cleanup
/// any acquired resources
///
-/// This class is designed to be used by any objects that have a
+/// This class is designed to be used by any objects that have a
/// callback function that takes a baton where the baton might need to
/// free/delete/close itself.
///
-/// The default behavior is to not free anything. Subclasses can
+/// The default behavior is to not free anything. Subclasses can
/// free any needed resources in their destructors.
//----------------------------------------------------------------------
-class Baton
-{
+class Baton {
public:
- explicit Baton(void *p) :
- m_data (p)
- {
- }
-
- virtual
- ~Baton()
- {
- // The default destructor for a baton does NOT attempt to clean up
- // anything in m_baton
- }
-
- virtual void
- GetDescription (Stream *s, lldb::DescriptionLevel level) const;
-
- void *m_data; // Leave baton public for easy access
-
-private:
- //------------------------------------------------------------------
- // For Baton only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (Baton);
+ Baton() {}
+ virtual ~Baton() {}
+
+ virtual void *data() = 0;
+
+ virtual void GetDescription(Stream *s,
+ lldb::DescriptionLevel level) const = 0;
+};
+
+class UntypedBaton : public Baton {
+public:
+ UntypedBaton(void *Data) : m_data(Data) {}
+ virtual ~UntypedBaton() {
+ // The default destructor for an untyped baton does NOT attempt to clean up
+ // anything in m_data.
+ }
+
+ void *data() override { return m_data; }
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) const override;
+
+ void *m_data; // Leave baton public for easy access
+};
+
+template <typename T> class TypedBaton : public Baton {
+public:
+ explicit TypedBaton(std::unique_ptr<T> Item) : Item(std::move(Item)) {}
+
+ T *getItem() { return Item.get(); }
+ const T *getItem() const { return Item.get(); }
+
+ void *data() override { return Item.get(); }
+ virtual void GetDescription(Stream *s,
+ lldb::DescriptionLevel level) const override {}
+
+protected:
+ std::unique_ptr<T> Item;
};
} // namespace lldb_private
-#endif // lldb_Baton_h_
+#endif // lldb_Baton_h_
diff --git a/include/lldb/Core/Broadcaster.h b/include/lldb/Core/Broadcaster.h
index 33172fa73780..c23f12c30b9c 100644
--- a/include/lldb/Core/Broadcaster.h
+++ b/include/lldb/Core/Broadcaster.h
@@ -21,8 +21,10 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/ConstString.h"
+#include "lldb/lldb-private.h"
+
+#include "llvm/ADT/SmallVector.h"
namespace lldb_private {
@@ -32,217 +34,181 @@ namespace lldb_private {
// This class is used to specify a kind of event to register for. The Debugger
// maintains a list of BroadcastEventSpec's and when it is made
//----------------------------------------------------------------------
-class BroadcastEventSpec
-{
+class BroadcastEventSpec {
public:
- BroadcastEventSpec (const ConstString &broadcaster_class, uint32_t event_bits) :
- m_broadcaster_class (broadcaster_class),
- m_event_bits (event_bits)
- {
- }
-
- BroadcastEventSpec (const BroadcastEventSpec &rhs);
-
- ~BroadcastEventSpec() = default;
-
- const ConstString &GetBroadcasterClass() const
- {
- return m_broadcaster_class;
+ BroadcastEventSpec(const ConstString &broadcaster_class, uint32_t event_bits)
+ : m_broadcaster_class(broadcaster_class), m_event_bits(event_bits) {}
+
+ BroadcastEventSpec(const BroadcastEventSpec &rhs);
+
+ ~BroadcastEventSpec() = default;
+
+ const ConstString &GetBroadcasterClass() const { return m_broadcaster_class; }
+
+ uint32_t GetEventBits() const { return m_event_bits; }
+
+ // Tell whether this BroadcastEventSpec is contained in in_spec.
+ // That is:
+ // (a) the two spec's share the same broadcaster class
+ // (b) the event bits of this spec are wholly contained in those of in_spec.
+ bool IsContainedIn(BroadcastEventSpec in_spec) const {
+ if (m_broadcaster_class != in_spec.GetBroadcasterClass())
+ return false;
+ uint32_t in_bits = in_spec.GetEventBits();
+ if (in_bits == m_event_bits)
+ return true;
+ else {
+ if ((m_event_bits & in_bits) != 0 && (m_event_bits & ~in_bits) == 0)
+ return true;
}
-
- uint32_t GetEventBits () const
- {
- return m_event_bits;
- }
-
- // Tell whether this BroadcastEventSpec is contained in in_spec.
- // That is:
- // (a) the two spec's share the same broadcaster class
- // (b) the event bits of this spec are wholly contained in those of in_spec.
- bool IsContainedIn (BroadcastEventSpec in_spec) const
- {
- if (m_broadcaster_class != in_spec.GetBroadcasterClass())
- return false;
- uint32_t in_bits = in_spec.GetEventBits();
- if (in_bits == m_event_bits)
- return true;
- else
- {
- if ((m_event_bits & in_bits) != 0
- && (m_event_bits & ~in_bits) == 0)
- return true;
- }
- return false;
- }
-
- bool operator< (const BroadcastEventSpec &rhs) const;
- BroadcastEventSpec &operator=(const BroadcastEventSpec &rhs);
-
+ return false;
+ }
+
+ bool operator<(const BroadcastEventSpec &rhs) const;
+ BroadcastEventSpec &operator=(const BroadcastEventSpec &rhs);
+
private:
- ConstString m_broadcaster_class;
- uint32_t m_event_bits;
+ ConstString m_broadcaster_class;
+ uint32_t m_event_bits;
};
-class BroadcasterManager :
- public std::enable_shared_from_this<BroadcasterManager>
-{
+class BroadcasterManager
+ : public std::enable_shared_from_this<BroadcasterManager> {
public:
- friend class Listener;
+ friend class Listener;
protected:
- BroadcasterManager ();
+ BroadcasterManager();
+
public:
- // Listeners hold onto weak pointers to their broadcaster managers. So they must be
- // made into shared pointers, which you do with MakeBroadcasterManager.
-
- static lldb::BroadcasterManagerSP
- MakeBroadcasterManager();
-
- ~BroadcasterManager() = default;
-
- uint32_t
- RegisterListenerForEvents (const lldb::ListenerSP &listener_sp, BroadcastEventSpec event_spec);
-
- bool
- UnregisterListenerForEvents (const lldb::ListenerSP &listener_sp, BroadcastEventSpec event_spec);
-
- lldb::ListenerSP
- GetListenerForEventSpec (BroadcastEventSpec event_spec) const;
-
- void
- SignUpListenersForBroadcaster (Broadcaster &broadcaster);
-
- void
- RemoveListener (const lldb::ListenerSP &listener_sp);
-
- void
- RemoveListener (Listener *listener);
+ // Listeners hold onto weak pointers to their broadcaster managers. So they
+ // must be
+ // made into shared pointers, which you do with MakeBroadcasterManager.
+
+ static lldb::BroadcasterManagerSP MakeBroadcasterManager();
+
+ ~BroadcasterManager() = default;
+
+ uint32_t RegisterListenerForEvents(const lldb::ListenerSP &listener_sp,
+ BroadcastEventSpec event_spec);
+
+ bool UnregisterListenerForEvents(const lldb::ListenerSP &listener_sp,
+ BroadcastEventSpec event_spec);
+
+ lldb::ListenerSP GetListenerForEventSpec(BroadcastEventSpec event_spec) const;
+
+ void SignUpListenersForBroadcaster(Broadcaster &broadcaster);
+
+ void RemoveListener(const lldb::ListenerSP &listener_sp);
+
+ void RemoveListener(Listener *listener);
+
+ void Clear();
- void Clear();
-
private:
- typedef std::pair<BroadcastEventSpec, lldb::ListenerSP> event_listener_key;
- typedef std::map<BroadcastEventSpec, lldb::ListenerSP> collection;
- typedef std::set<lldb::ListenerSP> listener_collection;
- collection m_event_map;
- listener_collection m_listeners;
-
- mutable std::recursive_mutex m_manager_mutex;
-
- // A couple of comparator classes for find_if:
-
- class BroadcasterClassMatches
- {
- public:
- BroadcasterClassMatches (const ConstString &broadcaster_class) :
- m_broadcaster_class (broadcaster_class)
- {
- }
-
- ~BroadcasterClassMatches() = default;
-
- bool operator() (const event_listener_key input) const
- {
- return (input.first.GetBroadcasterClass() == m_broadcaster_class);
- }
-
- private:
- ConstString m_broadcaster_class;
- };
-
- class BroadcastEventSpecMatches
- {
- public:
- BroadcastEventSpecMatches (BroadcastEventSpec broadcaster_spec) :
- m_broadcaster_spec (broadcaster_spec)
- {
- }
-
- ~BroadcastEventSpecMatches() = default;
-
- bool operator() (const event_listener_key input) const
- {
- return (input.first.IsContainedIn (m_broadcaster_spec));
- }
-
- private:
- BroadcastEventSpec m_broadcaster_spec;
- };
-
- class ListenerMatchesAndSharedBits
- {
- public:
- explicit ListenerMatchesAndSharedBits (BroadcastEventSpec broadcaster_spec, const lldb::ListenerSP listener_sp) :
- m_broadcaster_spec (broadcaster_spec),
- m_listener_sp (listener_sp)
- {
- }
-
- ~ListenerMatchesAndSharedBits() = default;
-
- bool operator() (const event_listener_key input) const
- {
- return (input.first.GetBroadcasterClass() == m_broadcaster_spec.GetBroadcasterClass()
- && (input.first.GetEventBits() & m_broadcaster_spec.GetEventBits()) != 0
- && input.second == m_listener_sp);
- }
-
- private:
- BroadcastEventSpec m_broadcaster_spec;
- const lldb::ListenerSP m_listener_sp;
- };
-
- class ListenerMatches
- {
- public:
- explicit ListenerMatches (const lldb::ListenerSP in_listener_sp) :
- m_listener_sp (in_listener_sp)
- {
- }
-
- ~ListenerMatches() = default;
-
- bool operator () (const event_listener_key input) const
- {
- if (input.second == m_listener_sp)
- return true;
- else
- return false;
- }
-
- private:
- const lldb::ListenerSP m_listener_sp;
- };
-
- class ListenerMatchesPointer
- {
- public:
- ListenerMatchesPointer (const Listener *in_listener) :
- m_listener (in_listener)
- {
- }
-
- ~ListenerMatchesPointer() = default;
-
- bool operator () (const event_listener_key input) const
- {
- if (input.second.get() == m_listener)
- return true;
- else
- return false;
- }
-
- bool operator () (const lldb::ListenerSP input) const
- {
- if (input.get() == m_listener)
- return true;
- else
- return false;
- }
-
- private:
- const Listener *m_listener;
- };
+ typedef std::pair<BroadcastEventSpec, lldb::ListenerSP> event_listener_key;
+ typedef std::map<BroadcastEventSpec, lldb::ListenerSP> collection;
+ typedef std::set<lldb::ListenerSP> listener_collection;
+ collection m_event_map;
+ listener_collection m_listeners;
+
+ mutable std::recursive_mutex m_manager_mutex;
+
+ // A couple of comparator classes for find_if:
+
+ class BroadcasterClassMatches {
+ public:
+ BroadcasterClassMatches(const ConstString &broadcaster_class)
+ : m_broadcaster_class(broadcaster_class) {}
+
+ ~BroadcasterClassMatches() = default;
+
+ bool operator()(const event_listener_key input) const {
+ return (input.first.GetBroadcasterClass() == m_broadcaster_class);
+ }
+
+ private:
+ ConstString m_broadcaster_class;
+ };
+
+ class BroadcastEventSpecMatches {
+ public:
+ BroadcastEventSpecMatches(BroadcastEventSpec broadcaster_spec)
+ : m_broadcaster_spec(broadcaster_spec) {}
+
+ ~BroadcastEventSpecMatches() = default;
+
+ bool operator()(const event_listener_key input) const {
+ return (input.first.IsContainedIn(m_broadcaster_spec));
+ }
+
+ private:
+ BroadcastEventSpec m_broadcaster_spec;
+ };
+
+ class ListenerMatchesAndSharedBits {
+ public:
+ explicit ListenerMatchesAndSharedBits(BroadcastEventSpec broadcaster_spec,
+ const lldb::ListenerSP listener_sp)
+ : m_broadcaster_spec(broadcaster_spec), m_listener_sp(listener_sp) {}
+
+ ~ListenerMatchesAndSharedBits() = default;
+
+ bool operator()(const event_listener_key input) const {
+ return (input.first.GetBroadcasterClass() ==
+ m_broadcaster_spec.GetBroadcasterClass() &&
+ (input.first.GetEventBits() &
+ m_broadcaster_spec.GetEventBits()) != 0 &&
+ input.second == m_listener_sp);
+ }
+
+ private:
+ BroadcastEventSpec m_broadcaster_spec;
+ const lldb::ListenerSP m_listener_sp;
+ };
+
+ class ListenerMatches {
+ public:
+ explicit ListenerMatches(const lldb::ListenerSP in_listener_sp)
+ : m_listener_sp(in_listener_sp) {}
+
+ ~ListenerMatches() = default;
+
+ bool operator()(const event_listener_key input) const {
+ if (input.second == m_listener_sp)
+ return true;
+ else
+ return false;
+ }
+
+ private:
+ const lldb::ListenerSP m_listener_sp;
+ };
+
+ class ListenerMatchesPointer {
+ public:
+ ListenerMatchesPointer(const Listener *in_listener)
+ : m_listener(in_listener) {}
+
+ ~ListenerMatchesPointer() = default;
+
+ bool operator()(const event_listener_key input) const {
+ if (input.second.get() == m_listener)
+ return true;
+ else
+ return false;
+ }
+
+ bool operator()(const lldb::ListenerSP input) const {
+ if (input.get() == m_listener)
+ return true;
+ else
+ return false;
+ }
+
+ private:
+ const Listener *m_listener;
+ };
};
//----------------------------------------------------------------------
@@ -270,401 +236,358 @@ private:
/// //----------------------------------------------------------
/// enum
/// {
-/// eBroadcastBitStateChanged = (1 << 0),
-/// eBroadcastBitInterrupt = (1 << 1),
-/// eBroadcastBitSTDOUT = (1 << 2),
-/// eBroadcastBitSTDERR = (1 << 3),
-/// eBroadcastBitProfileData = (1 << 4)
+/// eBroadcastBitOne = (1 << 0),
+/// eBroadcastBitTwo = (1 << 1),
+/// eBroadcastBitThree = (1 << 2),
+/// ...
/// };
/// \endcode
//----------------------------------------------------------------------
-class Broadcaster
-{
-friend class Listener;
-friend class Event;
+class Broadcaster {
+ friend class Listener;
+ friend class Event;
+
public:
- //------------------------------------------------------------------
- /// Construct with a broadcaster with a name.
- ///
- /// @param[in] name
- /// A NULL terminated C string that contains the name of the
- /// broadcaster object.
- //------------------------------------------------------------------
- Broadcaster (lldb::BroadcasterManagerSP manager_sp, const char *name);
+ //------------------------------------------------------------------
+ /// Construct with a broadcaster with a name.
+ ///
+ /// @param[in] name
+ /// A NULL terminated C string that contains the name of the
+ /// broadcaster object.
+ //------------------------------------------------------------------
+ Broadcaster(lldb::BroadcasterManagerSP manager_sp, const char *name);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ ///
+ /// The destructor is virtual since this class gets subclassed.
+ //------------------------------------------------------------------
+ virtual ~Broadcaster();
+
+ void CheckInWithManager();
+
+ //------------------------------------------------------------------
+ /// Broadcast an event which has no associated data.
+ ///
+ /// @param[in] event_type
+ /// The element from the enum defining this broadcaster's events
+ /// that is being broadcast.
+ ///
+ /// @param[in] event_data
+ /// User event data that will be owned by the lldb::Event that
+ /// is created internally.
+ ///
+ /// @param[in] unique
+ /// If true, then only add an event of this type if there isn't
+ /// one already in the queue.
+ ///
+ //------------------------------------------------------------------
+ void BroadcastEvent(lldb::EventSP &event_sp) {
+ m_broadcaster_sp->BroadcastEvent(event_sp);
+ }
+
+ void BroadcastEventIfUnique(lldb::EventSP &event_sp) {
+ m_broadcaster_sp->BroadcastEventIfUnique(event_sp);
+ }
+
+ void BroadcastEvent(uint32_t event_type,
+ const lldb::EventDataSP &event_data_sp) {
+ m_broadcaster_sp->BroadcastEvent(event_type, event_data_sp);
+ }
+
+ void BroadcastEvent(uint32_t event_type, EventData *event_data = nullptr) {
+ m_broadcaster_sp->BroadcastEvent(event_type, event_data);
+ }
+
+ void BroadcastEventIfUnique(uint32_t event_type,
+ EventData *event_data = nullptr) {
+ m_broadcaster_sp->BroadcastEventIfUnique(event_type, event_data);
+ }
+
+ void Clear() { m_broadcaster_sp->Clear(); }
+
+ virtual void AddInitialEventsToListener(const lldb::ListenerSP &listener_sp,
+ uint32_t requested_events);
+
+ //------------------------------------------------------------------
+ /// Listen for any events specified by \a event_mask.
+ ///
+ /// Only one listener can listen to each event bit in a given
+ /// Broadcaster. Once a listener has acquired an event bit, no
+ /// other broadcaster will have access to it until it is
+ /// relinquished by the first listener that gets it. The actual
+ /// event bits that get acquired by \a listener may be different
+ /// from what is requested in \a event_mask, and to track this the
+ /// actual event bits that are acquired get returned.
+ ///
+ /// @param[in] listener
+ /// The Listener object that wants to monitor the events that
+ /// get broadcast by this object.
+ ///
+ /// @param[in] event_mask
+ /// A bit mask that indicates which events the listener is
+ /// asking to monitor.
+ ///
+ /// @return
+ /// The actual event bits that were acquired by \a listener.
+ //------------------------------------------------------------------
+ uint32_t AddListener(const lldb::ListenerSP &listener_sp,
+ uint32_t event_mask) {
+ return m_broadcaster_sp->AddListener(listener_sp, event_mask);
+ }
+
+ //------------------------------------------------------------------
+ /// Get the NULL terminated C string name of this Broadcaster
+ /// object.
+ ///
+ /// @return
+ /// The NULL terminated C string name of this Broadcaster.
+ //------------------------------------------------------------------
+ const ConstString &GetBroadcasterName() { return m_broadcaster_name; }
+
+ //------------------------------------------------------------------
+ /// Get the event name(s) for one or more event bits.
+ ///
+ /// @param[in] event_mask
+ /// A bit mask that indicates which events to get names for.
+ ///
+ /// @return
+ /// The NULL terminated C string name of this Broadcaster.
+ //------------------------------------------------------------------
+ bool GetEventNames(Stream &s, const uint32_t event_mask,
+ bool prefix_with_broadcaster_name) const {
+ return m_broadcaster_sp->GetEventNames(s, event_mask,
+ prefix_with_broadcaster_name);
+ }
+
+ //------------------------------------------------------------------
+ /// Set the name for an event bit.
+ ///
+ /// @param[in] event_mask
+ /// A bit mask that indicates which events the listener is
+ /// asking to monitor.
+ ///
+ /// @return
+ /// The NULL terminated C string name of this Broadcaster.
+ //------------------------------------------------------------------
+ void SetEventName(uint32_t event_mask, const char *name) {
+ m_broadcaster_sp->SetEventName(event_mask, name);
+ }
+
+ const char *GetEventName(uint32_t event_mask) const {
+ return m_broadcaster_sp->GetEventName(event_mask);
+ }
+
+ bool EventTypeHasListeners(uint32_t event_type) {
+ return m_broadcaster_sp->EventTypeHasListeners(event_type);
+ }
+
+ //------------------------------------------------------------------
+ /// Removes a Listener from this broadcasters list and frees the
+ /// event bits specified by \a event_mask that were previously
+ /// acquired by \a listener (assuming \a listener was listening to
+ /// this object) for other listener objects to use.
+ ///
+ /// @param[in] listener
+ /// A Listener object that previously called AddListener.
+ ///
+ /// @param[in] event_mask
+ /// The event bits \a listener wishes to relinquish.
+ ///
+ /// @return
+ /// \b True if the listener was listening to this broadcaster
+ /// and was removed, \b false otherwise.
+ ///
+ /// @see uint32_t Broadcaster::AddListener (Listener*, uint32_t)
+ //------------------------------------------------------------------
+ bool RemoveListener(const lldb::ListenerSP &listener_sp,
+ uint32_t event_mask = UINT32_MAX) {
+ return m_broadcaster_sp->RemoveListener(listener_sp, event_mask);
+ }
+
+ //------------------------------------------------------------------
+ /// Provides a simple mechanism to temporarily redirect events from
+ /// broadcaster. When you call this function passing in a listener and
+ /// event type mask, all events from the broadcaster matching the mask
+ /// will now go to the hijacking listener.
+ /// Only one hijack can occur at a time. If we need more than this we
+ /// will have to implement a Listener stack.
+ ///
+ /// @param[in] listener
+ /// A Listener object. You do not need to call StartListeningForEvents
+ /// for this broadcaster (that would fail anyway since the event bits
+ /// would most likely be taken by the listener(s) you are usurping.
+ ///
+ /// @param[in] event_mask
+ /// The event bits \a listener wishes to hijack.
+ ///
+ /// @return
+ /// \b True if the event mask could be hijacked, \b false otherwise.
+ ///
+ /// @see uint32_t Broadcaster::AddListener (Listener*, uint32_t)
+ //------------------------------------------------------------------
+ bool HijackBroadcaster(const lldb::ListenerSP &listener_sp,
+ uint32_t event_mask = UINT32_MAX) {
+ return m_broadcaster_sp->HijackBroadcaster(listener_sp, event_mask);
+ }
+
+ bool IsHijackedForEvent(uint32_t event_mask) {
+ return m_broadcaster_sp->IsHijackedForEvent(event_mask);
+ }
+
+ //------------------------------------------------------------------
+ /// Restore the state of the Broadcaster from a previous hijack attempt.
+ ///
+ //------------------------------------------------------------------
+ void RestoreBroadcaster() { m_broadcaster_sp->RestoreBroadcaster(); }
+
+ // This needs to be filled in if you are going to register the broadcaster
+ // with the broadcaster
+ // manager and do broadcaster class matching.
+ // FIXME: Probably should make a ManagedBroadcaster subclass with all the bits
+ // needed to work
+ // with the BroadcasterManager, so that it is clearer how to add one.
+ virtual ConstString &GetBroadcasterClass() const;
+
+ lldb::BroadcasterManagerSP GetManager();
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// The destructor is virtual since this class gets subclassed.
- //------------------------------------------------------------------
- virtual
- ~Broadcaster();
+protected:
+ // BroadcasterImpl contains the actual Broadcaster implementation. The
+ // Broadcaster makes a BroadcasterImpl
+ // which lives as long as it does. The Listeners & the Events hold a weak
+ // pointer to the BroadcasterImpl,
+ // so that they can survive if a Broadcaster they were listening to is
+ // destroyed w/o their being able to
+ // unregister from it (which can happen if the Broadcasters & Listeners are
+ // being destroyed on separate threads
+ // simultaneously.
+ // The Broadcaster itself can't be shared out as a weak pointer, because some
+ // things that are broadcasters
+ // (e.g. the Target and the Process) are shared in their own right.
+ //
+ // For the most part, the Broadcaster functions dispatch to the
+ // BroadcasterImpl, and are documented in the
+ // public Broadcaster API above.
+
+ class BroadcasterImpl {
+ friend class Listener;
+ friend class Broadcaster;
- void
- CheckInWithManager ();
-
- //------------------------------------------------------------------
- /// Broadcast an event which has no associated data.
- ///
- /// @param[in] event_type
- /// The element from the enum defining this broadcaster's events
- /// that is being broadcast.
- ///
- /// @param[in] event_data
- /// User event data that will be owned by the lldb::Event that
- /// is created internally.
- ///
- /// @param[in] unique
- /// If true, then only add an event of this type if there isn't
- /// one already in the queue.
- ///
- //------------------------------------------------------------------
- void
- BroadcastEvent (lldb::EventSP &event_sp)
- {
- m_broadcaster_sp->BroadcastEvent(event_sp);
- }
+ public:
+ BroadcasterImpl(Broadcaster &broadcaster);
- void
- BroadcastEventIfUnique (lldb::EventSP &event_sp)
- {
- m_broadcaster_sp->BroadcastEventIfUnique(event_sp);
- }
+ ~BroadcasterImpl() = default;
- void
- BroadcastEvent(uint32_t event_type, const lldb::EventDataSP &event_data_sp)
- {
- m_broadcaster_sp->BroadcastEvent(event_type, event_data_sp);
- }
+ void BroadcastEvent(lldb::EventSP &event_sp);
- void
- BroadcastEvent(uint32_t event_type, EventData *event_data = nullptr)
- {
- m_broadcaster_sp->BroadcastEvent(event_type, event_data);
- }
+ void BroadcastEventIfUnique(lldb::EventSP &event_sp);
- void
- BroadcastEventIfUnique(uint32_t event_type, EventData *event_data = nullptr)
- {
- m_broadcaster_sp->BroadcastEventIfUnique(event_type, event_data);
- }
+ void BroadcastEvent(uint32_t event_type, EventData *event_data = nullptr);
- void
- Clear()
- {
- m_broadcaster_sp->Clear();
- }
+ void BroadcastEvent(uint32_t event_type,
+ const lldb::EventDataSP &event_data_sp);
- virtual void
- AddInitialEventsToListener (const lldb::ListenerSP &listener_sp, uint32_t requested_events);
+ void BroadcastEventIfUnique(uint32_t event_type,
+ EventData *event_data = nullptr);
- //------------------------------------------------------------------
- /// Listen for any events specified by \a event_mask.
- ///
- /// Only one listener can listen to each event bit in a given
- /// Broadcaster. Once a listener has acquired an event bit, no
- /// other broadcaster will have access to it until it is
- /// relinquished by the first listener that gets it. The actual
- /// event bits that get acquired by \a listener may be different
- /// from what is requested in \a event_mask, and to track this the
- /// actual event bits that are acquired get returned.
- ///
- /// @param[in] listener
- /// The Listener object that wants to monitor the events that
- /// get broadcast by this object.
- ///
- /// @param[in] event_mask
- /// A bit mask that indicates which events the listener is
- /// asking to monitor.
- ///
- /// @return
- /// The actual event bits that were acquired by \a listener.
- //------------------------------------------------------------------
- uint32_t
- AddListener (const lldb::ListenerSP &listener_sp, uint32_t event_mask)
- {
- return m_broadcaster_sp->AddListener(listener_sp, event_mask);
- }
+ void Clear();
- //------------------------------------------------------------------
- /// Get the NULL terminated C string name of this Broadcaster
- /// object.
- ///
- /// @return
- /// The NULL terminated C string name of this Broadcaster.
- //------------------------------------------------------------------
- const ConstString &
- GetBroadcasterName ()
- {
- return m_broadcaster_name;
- }
+ uint32_t AddListener(const lldb::ListenerSP &listener_sp,
+ uint32_t event_mask);
- //------------------------------------------------------------------
- /// Get the event name(s) for one or more event bits.
- ///
- /// @param[in] event_mask
- /// A bit mask that indicates which events to get names for.
- ///
- /// @return
- /// The NULL terminated C string name of this Broadcaster.
- //------------------------------------------------------------------
- bool
- GetEventNames (Stream &s, const uint32_t event_mask, bool prefix_with_broadcaster_name) const
- {
- return m_broadcaster_sp->GetEventNames(s, event_mask, prefix_with_broadcaster_name);
+ const char *GetBroadcasterName() const {
+ return m_broadcaster.GetBroadcasterName().AsCString();
}
- //------------------------------------------------------------------
- /// Set the name for an event bit.
- ///
- /// @param[in] event_mask
- /// A bit mask that indicates which events the listener is
- /// asking to monitor.
- ///
- /// @return
- /// The NULL terminated C string name of this Broadcaster.
- //------------------------------------------------------------------
- void
- SetEventName (uint32_t event_mask, const char *name)
- {
- m_broadcaster_sp->SetEventName(event_mask, name);
- }
-
- const char *
- GetEventName (uint32_t event_mask) const
- {
- return m_broadcaster_sp->GetEventName(event_mask);
- }
+ Broadcaster *GetBroadcaster();
- bool
- EventTypeHasListeners (uint32_t event_type)
- {
- return m_broadcaster_sp->EventTypeHasListeners(event_type);
- }
+ bool GetEventNames(Stream &s, const uint32_t event_mask,
+ bool prefix_with_broadcaster_name) const;
- //------------------------------------------------------------------
- /// Removes a Listener from this broadcasters list and frees the
- /// event bits specified by \a event_mask that were previously
- /// acquired by \a listener (assuming \a listener was listening to
- /// this object) for other listener objects to use.
- ///
- /// @param[in] listener
- /// A Listener object that previously called AddListener.
- ///
- /// @param[in] event_mask
- /// The event bits \a listener wishes to relinquish.
- ///
- /// @return
- /// \b True if the listener was listening to this broadcaster
- /// and was removed, \b false otherwise.
- ///
- /// @see uint32_t Broadcaster::AddListener (Listener*, uint32_t)
- //------------------------------------------------------------------
- bool
- RemoveListener (const lldb::ListenerSP &listener_sp, uint32_t event_mask = UINT32_MAX)
- {
- return m_broadcaster_sp->RemoveListener(listener_sp, event_mask);
- }
-
- //------------------------------------------------------------------
- /// Provides a simple mechanism to temporarily redirect events from
- /// broadcaster. When you call this function passing in a listener and
- /// event type mask, all events from the broadcaster matching the mask
- /// will now go to the hijacking listener.
- /// Only one hijack can occur at a time. If we need more than this we
- /// will have to implement a Listener stack.
- ///
- /// @param[in] listener
- /// A Listener object. You do not need to call StartListeningForEvents
- /// for this broadcaster (that would fail anyway since the event bits
- /// would most likely be taken by the listener(s) you are usurping.
- ///
- /// @param[in] event_mask
- /// The event bits \a listener wishes to hijack.
- ///
- /// @return
- /// \b True if the event mask could be hijacked, \b false otherwise.
- ///
- /// @see uint32_t Broadcaster::AddListener (Listener*, uint32_t)
- //------------------------------------------------------------------
- bool
- HijackBroadcaster (const lldb::ListenerSP &listener_sp, uint32_t event_mask = UINT32_MAX)
- {
- return m_broadcaster_sp->HijackBroadcaster(listener_sp, event_mask);
- }
-
- bool
- IsHijackedForEvent (uint32_t event_mask)
- {
- return m_broadcaster_sp->IsHijackedForEvent(event_mask);
+ void SetEventName(uint32_t event_mask, const char *name) {
+ m_event_names[event_mask] = name;
}
- //------------------------------------------------------------------
- /// Restore the state of the Broadcaster from a previous hijack attempt.
- ///
- //------------------------------------------------------------------
- void
- RestoreBroadcaster ()
- {
- m_broadcaster_sp->RestoreBroadcaster();
+ const char *GetEventName(uint32_t event_mask) const {
+ const auto pos = m_event_names.find(event_mask);
+ if (pos != m_event_names.end())
+ return pos->second.c_str();
+ return nullptr;
}
-
- // This needs to be filled in if you are going to register the broadcaster with the broadcaster
- // manager and do broadcaster class matching.
- // FIXME: Probably should make a ManagedBroadcaster subclass with all the bits needed to work
- // with the BroadcasterManager, so that it is clearer how to add one.
- virtual ConstString &GetBroadcasterClass() const;
-
- lldb::BroadcasterManagerSP GetManager();
-protected:
- // BroadcasterImpl contains the actual Broadcaster implementation. The Broadcaster makes a BroadcasterImpl
- // which lives as long as it does. The Listeners & the Events hold a weak pointer to the BroadcasterImpl,
- // so that they can survive if a Broadcaster they were listening to is destroyed w/o their being able to
- // unregister from it (which can happen if the Broadcasters & Listeners are being destroyed on separate threads
- // simultaneously.
- // The Broadcaster itself can't be shared out as a weak pointer, because some things that are broadcasters
- // (e.g. the Target and the Process) are shared in their own right.
- //
- // For the most part, the Broadcaster functions dispatch to the BroadcasterImpl, and are documented in the
- // public Broadcaster API above.
-
-
- class BroadcasterImpl
- {
- friend class Listener;
- friend class Broadcaster;
- public:
- BroadcasterImpl (Broadcaster &broadcaster);
-
- ~BroadcasterImpl() = default;
-
- void
- BroadcastEvent (lldb::EventSP &event_sp);
-
- void
- BroadcastEventIfUnique (lldb::EventSP &event_sp);
-
- void
- BroadcastEvent(uint32_t event_type, EventData *event_data = nullptr);
-
- void
- BroadcastEvent(uint32_t event_type, const lldb::EventDataSP &event_data_sp);
-
- void
- BroadcastEventIfUnique(uint32_t event_type, EventData *event_data = nullptr);
-
- void
- Clear();
-
- uint32_t
- AddListener (const lldb::ListenerSP &listener_sp, uint32_t event_mask);
-
- const char *
- GetBroadcasterName () const
- {
- return m_broadcaster.GetBroadcasterName().AsCString();
- }
-
- Broadcaster *
- GetBroadcaster();
-
- bool
- GetEventNames (Stream &s, const uint32_t event_mask, bool prefix_with_broadcaster_name) const;
-
- void
- SetEventName (uint32_t event_mask, const char *name)
- {
- m_event_names[event_mask] = name;
- }
-
- const char *
- GetEventName (uint32_t event_mask) const
- {
- const auto pos = m_event_names.find (event_mask);
- if (pos != m_event_names.end())
- return pos->second.c_str();
- return nullptr;
- }
-
- bool
- EventTypeHasListeners (uint32_t event_type);
-
- bool
- RemoveListener (lldb_private::Listener *listener, uint32_t event_mask = UINT32_MAX);
-
- bool
- RemoveListener (const lldb::ListenerSP &listener_sp, uint32_t event_mask = UINT32_MAX);
-
- bool
- HijackBroadcaster (const lldb::ListenerSP &listener_sp, uint32_t event_mask = UINT32_MAX);
-
- bool
- IsHijackedForEvent (uint32_t event_mask);
-
- void
- RestoreBroadcaster ();
-
- protected:
- void
- PrivateBroadcastEvent (lldb::EventSP &event_sp, bool unique);
-
- const char *
- GetHijackingListenerName();
-
- //------------------------------------------------------------------
- //
- //------------------------------------------------------------------
- typedef std::list< std::pair<lldb::ListenerWP,uint32_t> > collection;
- typedef std::map<uint32_t, std::string> event_names_map;
-
- void
- ListenerIterator (std::function <bool (const lldb::ListenerSP &listener_sp, uint32_t &event_mask)> const &callback);
-
-
- Broadcaster &m_broadcaster; ///< The broadcsater that this implements
- event_names_map m_event_names; ///< Optionally define event names for readability and logging for each event bit
- collection m_listeners; ///< A list of Listener / event_mask pairs that are listening to this broadcaster.
- std::recursive_mutex m_listeners_mutex; ///< A mutex that protects \a m_listeners.
- std::vector<lldb::ListenerSP> m_hijacking_listeners; // A simple mechanism to intercept events from a broadcaster
- std::vector<uint32_t> m_hijacking_masks; // At some point we may want to have a stack or Listener
- // collections, but for now this is just for private hijacking.
-
- private:
- //------------------------------------------------------------------
- // For Broadcaster only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (BroadcasterImpl);
- };
-
- typedef std::shared_ptr<BroadcasterImpl> BroadcasterImplSP;
- typedef std::weak_ptr<BroadcasterImpl> BroadcasterImplWP;
-
- BroadcasterImplSP
- GetBroadcasterImpl()
- {
- return m_broadcaster_sp;
- }
-
- const char *
- GetHijackingListenerName()
- {
- return m_broadcaster_sp->GetHijackingListenerName();
- }
+ bool EventTypeHasListeners(uint32_t event_type);
+
+ bool RemoveListener(lldb_private::Listener *listener,
+ uint32_t event_mask = UINT32_MAX);
+
+ bool RemoveListener(const lldb::ListenerSP &listener_sp,
+ uint32_t event_mask = UINT32_MAX);
+
+ bool HijackBroadcaster(const lldb::ListenerSP &listener_sp,
+ uint32_t event_mask = UINT32_MAX);
+
+ bool IsHijackedForEvent(uint32_t event_mask);
+
+ void RestoreBroadcaster();
+
+ protected:
+ void PrivateBroadcastEvent(lldb::EventSP &event_sp, bool unique);
+
+ const char *GetHijackingListenerName();
+
//------------------------------------------------------------------
- // Classes that inherit from Broadcaster can see and modify these
+ //
//------------------------------------------------------------------
-
-
-private:
+ typedef llvm::SmallVector<std::pair<lldb::ListenerWP, uint32_t>, 4>
+ collection;
+ typedef std::map<uint32_t, std::string> event_names_map;
+
+ llvm::SmallVector<std::pair<lldb::ListenerSP, uint32_t &>, 4>
+ GetListeners();
+
+ Broadcaster &m_broadcaster; ///< The broadcsater that this implements
+ event_names_map m_event_names; ///< Optionally define event names for
+ ///readability and logging for each event bit
+ collection m_listeners; ///< A list of Listener / event_mask pairs that are
+ ///listening to this broadcaster.
+ std::recursive_mutex
+ m_listeners_mutex; ///< A mutex that protects \a m_listeners.
+ std::vector<lldb::ListenerSP> m_hijacking_listeners; // A simple mechanism
+ // to intercept events
+ // from a broadcaster
+ std::vector<uint32_t> m_hijacking_masks; // At some point we may want to
+ // have a stack or Listener
+ // collections, but for now this is just for private hijacking.
+
+ private:
//------------------------------------------------------------------
// For Broadcaster only
//------------------------------------------------------------------
- BroadcasterImplSP m_broadcaster_sp;
- lldb::BroadcasterManagerSP m_manager_sp;
- const ConstString m_broadcaster_name; ///< The name of this broadcaster object.
-
- DISALLOW_COPY_AND_ASSIGN (Broadcaster);
+ DISALLOW_COPY_AND_ASSIGN(BroadcasterImpl);
+ };
+
+ typedef std::shared_ptr<BroadcasterImpl> BroadcasterImplSP;
+ typedef std::weak_ptr<BroadcasterImpl> BroadcasterImplWP;
+
+ BroadcasterImplSP GetBroadcasterImpl() { return m_broadcaster_sp; }
+
+ const char *GetHijackingListenerName() {
+ return m_broadcaster_sp->GetHijackingListenerName();
+ }
+ //------------------------------------------------------------------
+ // Classes that inherit from Broadcaster can see and modify these
+ //------------------------------------------------------------------
+
+private:
+ //------------------------------------------------------------------
+ // For Broadcaster only
+ //------------------------------------------------------------------
+ BroadcasterImplSP m_broadcaster_sp;
+ lldb::BroadcasterManagerSP m_manager_sp;
+ const ConstString
+ m_broadcaster_name; ///< The name of this broadcaster object.
+
+ DISALLOW_COPY_AND_ASSIGN(Broadcaster);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/ClangForward.h b/include/lldb/Core/ClangForward.h
index 80abc15f671c..b3cab8a22f21 100644
--- a/include/lldb/Core/ClangForward.h
+++ b/include/lldb/Core/ClangForward.h
@@ -17,126 +17,123 @@
#if defined(__cplusplus)
-namespace clang
-{
- namespace Builtin
- {
- class Context;
- }
+namespace clang {
+namespace Builtin {
+class Context;
+}
- class Action;
- class ASTConsumer;
- class ASTContext;
- class ASTRecordLayout;
- class AddrLabelExpr;
- class AnalyzerOptions;
- class BinaryOperator;
- class ClassTemplateDecl;
- class ClassTemplateSpecializationDecl;
- class CodeGenOptions;
- class CodeGenerator;
- class CompilerInstance;
- class CompoundStmt;
- class CXXBaseSpecifier;
- class CXXBoolLiteralExpr;
- class CXXFunctionalCastExpr;
- class CXXMethodDecl;
- class CXXNamedCastExpr;
- class CXXRecordDecl;
- class CXXThisExpr;
- class CharacterLiteral;
- class CompoundAssignOperator;
- class Decl;
- class DeclarationName;
- class DeclaratorDecl;
- class DeclContext;
- class DeclRefExpr;
- class DeclStmt;
- class DependencyOutputOptions;
- class Diagnostic;
- class DiagnosticConsumer;
- class DiagnosticsEngine;
- class DiagnosticOptions;
- class EnumDecl;
- class EnumConstantDecl;
- class Expr;
- class ExternalASTSource;
- class ExtVectorElementExpr;
- class FieldDecl;
- class FileManager;
- class FileSystemOptions;
- class FloatingLiteral;
- class FrontendOptions;
- class FunctionDecl;
- class FunctionTemplateDecl;
- class FunctionTemplateSpecializationInfo;
- class GotoStmt;
- class HeaderSearchOptions;
- class IdentifierInfo;
- class IdentifierTable;
- class IntegerLiteral;
- class LabelStmt;
- class LangOptions;
- class MacroDirective;
- class MemberExpr;
- class Module;
- class NamedDecl;
- class NamespaceDecl;
- class NonTypeTemplateParmDecl;
- class ObjCEncodeExpr;
- class ObjCImplicitSetterGetterRefExpr;
- class ObjCInterfaceDecl;
- class ObjCIvarDecl;
- class ObjCIvarRefExpr;
- class ObjCMessageExpr;
- class ObjCMethodDecl;
- class ObjCPropertyRefExpr;
- class ObjCProtocolDecl;
- class ObjCProtocolExpr;
- class ObjCSelectorExpr;
- class ObjCSuperExpr;
- class ParenExpr;
- class ParmVarDecl;
- class PredefinedExpr;
- class PreprocessorOptions;
- class PreprocessorOutputOptions;
- class QualType;
- class QualifiedNameType;
- class RecordDecl;
- class SelectorTable;
- class SizeOfAlignOfExpr;
- class SourceLocation;
- class SourceManager;
- class Stmt;
- class StmtIteratorBase;
- class StringLiteral;
- class TagDecl;
- class TargetInfo;
- class TargetOptions;
- class TemplateArgument;
- class TemplateDecl;
- class TemplateParameterList;
- class TemplateTemplateParmDecl;
- class TemplateTypeParmDecl;
- class TextDiagnosticBuffer;
- class TranslationUnitDecl;
- class Type;
- class TypeDecl;
- class TypedefDecl;
- class TypesCompatibleExpr;
- class UnaryOperator;
- class ValueDecl;
- class VarDecl;
- struct PrintingPolicy;
+class Action;
+class ASTConsumer;
+class ASTContext;
+class ASTRecordLayout;
+class AddrLabelExpr;
+class AnalyzerOptions;
+class BinaryOperator;
+class ClassTemplateDecl;
+class ClassTemplateSpecializationDecl;
+class CodeGenOptions;
+class CodeGenerator;
+class CompilerInstance;
+class CompoundStmt;
+class CXXBaseSpecifier;
+class CXXBoolLiteralExpr;
+class CXXFunctionalCastExpr;
+class CXXMethodDecl;
+class CXXNamedCastExpr;
+class CXXRecordDecl;
+class CXXThisExpr;
+class CharacterLiteral;
+class CompoundAssignOperator;
+class Decl;
+class DeclarationName;
+class DeclaratorDecl;
+class DeclContext;
+class DeclRefExpr;
+class DeclStmt;
+class DependencyOutputOptions;
+class Diagnostic;
+class DiagnosticConsumer;
+class DiagnosticsEngine;
+class DiagnosticOptions;
+class EnumDecl;
+class EnumConstantDecl;
+class Expr;
+class ExternalASTSource;
+class ExtVectorElementExpr;
+class FieldDecl;
+class FileManager;
+class FileSystemOptions;
+class FloatingLiteral;
+class FrontendOptions;
+class FunctionDecl;
+class FunctionTemplateDecl;
+class FunctionTemplateSpecializationInfo;
+class GotoStmt;
+class HeaderSearchOptions;
+class IdentifierInfo;
+class IdentifierTable;
+class IntegerLiteral;
+class LabelStmt;
+class LangOptions;
+class MacroDirective;
+class MemberExpr;
+class Module;
+class NamedDecl;
+class NamespaceDecl;
+class NonTypeTemplateParmDecl;
+class ObjCEncodeExpr;
+class ObjCImplicitSetterGetterRefExpr;
+class ObjCInterfaceDecl;
+class ObjCIvarDecl;
+class ObjCIvarRefExpr;
+class ObjCMessageExpr;
+class ObjCMethodDecl;
+class ObjCPropertyRefExpr;
+class ObjCProtocolDecl;
+class ObjCProtocolExpr;
+class ObjCSelectorExpr;
+class ObjCSuperExpr;
+class ParenExpr;
+class ParmVarDecl;
+class PredefinedExpr;
+class PreprocessorOptions;
+class PreprocessorOutputOptions;
+class QualType;
+class QualifiedNameType;
+class RecordDecl;
+class SelectorTable;
+class SizeOfAlignOfExpr;
+class SourceLocation;
+class SourceManager;
+class Stmt;
+class StmtIteratorBase;
+class StringLiteral;
+class TagDecl;
+class TargetInfo;
+class TargetOptions;
+class TemplateArgument;
+class TemplateDecl;
+class TemplateParameterList;
+class TemplateTemplateParmDecl;
+class TemplateTypeParmDecl;
+class TextDiagnosticBuffer;
+class TranslationUnitDecl;
+class Type;
+class TypeDecl;
+class TypedefDecl;
+class TypesCompatibleExpr;
+class UnaryOperator;
+class ValueDecl;
+class VarDecl;
+struct PrintingPolicy;
}
-namespace llvm
-{
- class APInt;
- class APSInt;
- class LLVMContext;
- class ExecutionEngine;
+namespace llvm {
+class APInt;
+class APSInt;
+class LLVMContext;
+class ExecutionEngine;
}
-#endif // #if defined(__cplusplus)
-#endif // liblldb_ClangForward_h_
+#endif // #if defined(__cplusplus)
+#endif // liblldb_ClangForward_h_
diff --git a/include/lldb/Core/Communication.h b/include/lldb/Core/Communication.h
index 8913f1631a8b..8a875ddad1f8 100644
--- a/include/lldb/Core/Communication.h
+++ b/include/lldb/Core/Communication.h
@@ -18,10 +18,10 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Error.h"
#include "lldb/Host/HostThread.h"
+#include "lldb/Utility/Timeout.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -82,343 +82,321 @@ namespace lldb_private {
/// can also post a \b eBroadcastBitReadThreadShouldExit event to this
/// object which will cause the read thread to exit.
//----------------------------------------------------------------------
-class Communication : public Broadcaster
-{
+class Communication : public Broadcaster {
public:
- FLAGS_ANONYMOUS_ENUM()
- {
- eBroadcastBitDisconnected = (1u << 0), ///< Sent when the communications connection is lost.
- eBroadcastBitReadThreadGotBytes = (1u << 1), ///< Sent by the read thread when bytes become available.
- eBroadcastBitReadThreadDidExit = (1u << 2), ///< Sent by the read thread when it exits to inform clients.
- eBroadcastBitReadThreadShouldExit = (1u << 3), ///< Sent by clients that need to cancel the read thread.
- eBroadcastBitPacketAvailable = (1u << 4), ///< Sent when data received makes a complete packet.
- eBroadcastBitNoMorePendingInput = (1u << 5), ///< Sent by the read thread to indicate all pending input has been processed.
- kLoUserBroadcastBit = (1u << 16),///< Subclasses can used bits 31:16 for any needed events.
- kHiUserBroadcastBit = (1u << 31),
- eAllEventBits = 0xffffffff
- };
-
- typedef void (*ReadThreadBytesReceived) (void *baton, const void *src, size_t src_len);
-
- //------------------------------------------------------------------
- /// Construct the Communication object with the specified name for
- /// the Broadcaster that this object inherits from.
- ///
- /// @param[in] broadcaster_name
- /// The name of the broadcaster object. This name should be as
- /// complete as possible to uniquely identify this object. The
- /// broadcaster name can be updated after the connect function
- /// is called.
- //------------------------------------------------------------------
- Communication(const char * broadcaster_name);
-
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// The destructor is virtual since this class gets subclassed.
- //------------------------------------------------------------------
- ~Communication() override;
-
- void
- Clear ();
-
- //------------------------------------------------------------------
- /// Connect using the current connection by passing \a url to its
- /// connect function.
- /// string.
- ///
- /// @param[in] url
- /// A string that contains all information needed by the
- /// subclass to connect to another client.
- ///
- /// @return
- /// \b True if the connect succeeded, \b false otherwise. The
- /// internal error object should be filled in with an
- /// appropriate value based on the result of this function.
- ///
- /// @see Error& Communication::GetError ();
- /// @see bool Connection::Connect (const char *url);
- //------------------------------------------------------------------
- lldb::ConnectionStatus
- Connect (const char *url, Error *error_ptr);
-
- //------------------------------------------------------------------
- /// Disconnect the communications connection if one is currently
- /// connected.
- ///
- /// @return
- /// \b True if the disconnect succeeded, \b false otherwise. The
- /// internal error object should be filled in with an
- /// appropriate value based on the result of this function.
- ///
- /// @see Error& Communication::GetError ();
- /// @see bool Connection::Disconnect ();
- //------------------------------------------------------------------
- lldb::ConnectionStatus
- Disconnect(Error *error_ptr = nullptr);
-
- //------------------------------------------------------------------
- /// Check if the connection is valid.
- ///
- /// @return
- /// \b True if this object is currently connected, \b false
- /// otherwise.
- //------------------------------------------------------------------
- bool
- IsConnected () const;
-
- bool
- HasConnection () const;
-
- lldb_private::Connection *
- GetConnection ()
- {
- return m_connection_sp.get();
- }
-
- //------------------------------------------------------------------
- /// Read bytes from the current connection.
- ///
- /// If no read thread is running, this function call the
- /// connection's Connection::Read(...) function to get any available.
- ///
- /// If a read thread has been started, this function will check for
- /// any cached bytes that have already been read and return any
- /// currently available bytes. If no bytes are cached, it will wait
- /// for the bytes to become available by listening for the \a
- /// eBroadcastBitReadThreadGotBytes event. If this function consumes
- /// all of the bytes in the cache, it will reset the
- /// \a eBroadcastBitReadThreadGotBytes event bit.
- ///
- /// @param[in] dst
- /// A destination buffer that must be at least \a dst_len bytes
- /// long.
- ///
- /// @param[in] dst_len
- /// The number of bytes to attempt to read, and also the max
- /// number of bytes that can be placed into \a dst.
- ///
- /// @param[in] timeout_usec
- /// A timeout value in micro-seconds.
- ///
- /// @return
- /// The number of bytes actually read.
- ///
- /// @see size_t Connection::Read (void *, size_t);
- //------------------------------------------------------------------
- size_t
- Read (void *dst,
- size_t dst_len,
- uint32_t timeout_usec,
- lldb::ConnectionStatus &status,
- Error *error_ptr);
-
- //------------------------------------------------------------------
- /// The actual write function that attempts to write to the
- /// communications protocol.
- ///
- /// Subclasses must override this function.
- ///
- /// @param[in] src
- /// A source buffer that must be at least \a src_len bytes
- /// long.
- ///
- /// @param[in] src_len
- /// The number of bytes to attempt to write, and also the
- /// number of bytes are currently available in \a src.
- ///
- /// @return
- /// The number of bytes actually Written.
- //------------------------------------------------------------------
- size_t
- Write (const void *src,
- size_t src_len,
- lldb::ConnectionStatus &status,
- Error *error_ptr);
-
- //------------------------------------------------------------------
- /// Sets the connection that it to be used by this class.
- ///
- /// By making a communication class that uses different connections
- /// it allows a single communication interface to negotiate and
- /// change its connection without any interruption to the client.
- /// It also allows the Communication class to be subclassed for
- /// packet based communication.
- ///
- /// @param[in] connection
- /// A connection that this class will own and destroy.
- ///
- /// @see
- /// class Connection
- //------------------------------------------------------------------
- void
- SetConnection (Connection *connection);
-
- //------------------------------------------------------------------
- /// Starts a read thread whose sole purpose it to read bytes from
- /// the current connection. This function will call connection's
- /// read function:
- ///
- /// size_t Connection::Read (void *, size_t);
- ///
- /// When bytes are read and cached, this function will call:
- ///
- /// Communication::AppendBytesToCache (const uint8_t * bytes, size_t len, bool broadcast);
- ///
- /// Subclasses should override this function if they wish to override
- /// the default action of caching the bytes and broadcasting a \b
- /// eBroadcastBitReadThreadGotBytes event.
- ///
- /// @return
- /// \b True if the read thread was successfully started, \b
- /// false otherwise.
- ///
- /// @see size_t Connection::Read (void *, size_t);
- /// @see void Communication::AppendBytesToCache (const uint8_t * bytes, size_t len, bool broadcast);
- //------------------------------------------------------------------
- virtual bool
- StartReadThread(Error *error_ptr = nullptr);
-
- //------------------------------------------------------------------
- /// Stops the read thread by cancelling it.
- ///
- /// @return
- /// \b True if the read thread was successfully canceled, \b
- /// false otherwise.
- //------------------------------------------------------------------
- virtual bool
- StopReadThread(Error *error_ptr = nullptr);
-
- virtual bool
- JoinReadThread(Error *error_ptr = nullptr);
- //------------------------------------------------------------------
- /// Checks if there is a currently running read thread.
- ///
- /// @return
- /// \b True if the read thread is running, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ReadThreadIsRunning ();
-
- //------------------------------------------------------------------
- /// The static read thread function. This function will call
- /// the "DoRead" function continuously and wait for data to become
- /// available. When data is received it will append the available
- /// data to the internal cache and broadcast a
- /// \b eBroadcastBitReadThreadGotBytes event.
- ///
- /// @param[in] comm_ptr
- /// A pointer to an instance of this class.
- ///
- /// @return
- /// \b NULL.
- ///
- /// @see void Communication::ReadThreadGotBytes (const uint8_t *, size_t);
- //------------------------------------------------------------------
- static lldb::thread_result_t
- ReadThread (lldb::thread_arg_t comm_ptr);
-
- void
- SetReadThreadBytesReceivedCallback (ReadThreadBytesReceived callback,
- void *callback_baton);
-
- //------------------------------------------------------------------
- /// Wait for the read thread to process all outstanding data.
- ///
- /// After this function returns, the read thread has processed all data that
- /// has been waiting in the Connection queue.
- ///
- //------------------------------------------------------------------
- void SynchronizeWithReadThread ();
-
- static const char *
- ConnectionStatusAsCString (lldb::ConnectionStatus status);
-
- bool
- GetCloseOnEOF () const
- {
- return m_close_on_eof;
- }
-
- void
- SetCloseOnEOF (bool b)
- {
- m_close_on_eof = b;
- }
-
- static ConstString &GetStaticBroadcasterClass ();
-
- ConstString &GetBroadcasterClass() const override
- {
- return GetStaticBroadcasterClass();
- }
+ FLAGS_ANONYMOUS_ENUM(){
+ eBroadcastBitDisconnected =
+ (1u << 0), ///< Sent when the communications connection is lost.
+ eBroadcastBitReadThreadGotBytes =
+ (1u << 1), ///< Sent by the read thread when bytes become available.
+ eBroadcastBitReadThreadDidExit =
+ (1u
+ << 2), ///< Sent by the read thread when it exits to inform clients.
+ eBroadcastBitReadThreadShouldExit =
+ (1u << 3), ///< Sent by clients that need to cancel the read thread.
+ eBroadcastBitPacketAvailable =
+ (1u << 4), ///< Sent when data received makes a complete packet.
+ eBroadcastBitNoMorePendingInput = (1u << 5), ///< Sent by the read thread
+ ///to indicate all pending
+ ///input has been processed.
+ kLoUserBroadcastBit =
+ (1u << 16), ///< Subclasses can used bits 31:16 for any needed events.
+ kHiUserBroadcastBit = (1u << 31),
+ eAllEventBits = 0xffffffff};
+
+ typedef void (*ReadThreadBytesReceived)(void *baton, const void *src,
+ size_t src_len);
+
+ //------------------------------------------------------------------
+ /// Construct the Communication object with the specified name for
+ /// the Broadcaster that this object inherits from.
+ ///
+ /// @param[in] broadcaster_name
+ /// The name of the broadcaster object. This name should be as
+ /// complete as possible to uniquely identify this object. The
+ /// broadcaster name can be updated after the connect function
+ /// is called.
+ //------------------------------------------------------------------
+ Communication(const char *broadcaster_name);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ ///
+ /// The destructor is virtual since this class gets subclassed.
+ //------------------------------------------------------------------
+ ~Communication() override;
+
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Connect using the current connection by passing \a url to its
+ /// connect function.
+ /// string.
+ ///
+ /// @param[in] url
+ /// A string that contains all information needed by the
+ /// subclass to connect to another client.
+ ///
+ /// @return
+ /// \b True if the connect succeeded, \b false otherwise. The
+ /// internal error object should be filled in with an
+ /// appropriate value based on the result of this function.
+ ///
+ /// @see Error& Communication::GetError ();
+ /// @see bool Connection::Connect (const char *url);
+ //------------------------------------------------------------------
+ lldb::ConnectionStatus Connect(const char *url, Error *error_ptr);
+
+ //------------------------------------------------------------------
+ /// Disconnect the communications connection if one is currently
+ /// connected.
+ ///
+ /// @return
+ /// \b True if the disconnect succeeded, \b false otherwise. The
+ /// internal error object should be filled in with an
+ /// appropriate value based on the result of this function.
+ ///
+ /// @see Error& Communication::GetError ();
+ /// @see bool Connection::Disconnect ();
+ //------------------------------------------------------------------
+ lldb::ConnectionStatus Disconnect(Error *error_ptr = nullptr);
+
+ //------------------------------------------------------------------
+ /// Check if the connection is valid.
+ ///
+ /// @return
+ /// \b True if this object is currently connected, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ bool IsConnected() const;
+
+ bool HasConnection() const;
+
+ lldb_private::Connection *GetConnection() { return m_connection_sp.get(); }
+
+ //------------------------------------------------------------------
+ /// Read bytes from the current connection.
+ ///
+ /// If no read thread is running, this function call the
+ /// connection's Connection::Read(...) function to get any available.
+ ///
+ /// If a read thread has been started, this function will check for
+ /// any cached bytes that have already been read and return any
+ /// currently available bytes. If no bytes are cached, it will wait
+ /// for the bytes to become available by listening for the \a
+ /// eBroadcastBitReadThreadGotBytes event. If this function consumes
+ /// all of the bytes in the cache, it will reset the
+ /// \a eBroadcastBitReadThreadGotBytes event bit.
+ ///
+ /// @param[in] dst
+ /// A destination buffer that must be at least \a dst_len bytes
+ /// long.
+ ///
+ /// @param[in] dst_len
+ /// The number of bytes to attempt to read, and also the max
+ /// number of bytes that can be placed into \a dst.
+ ///
+ /// @param[in] timeout
+ /// A timeout value or llvm::None for no timeout.
+ ///
+ /// @return
+ /// The number of bytes actually read.
+ ///
+ /// @see size_t Connection::Read (void *, size_t);
+ //------------------------------------------------------------------
+ size_t Read(void *dst, size_t dst_len, const Timeout<std::micro> &timeout,
+ lldb::ConnectionStatus &status, Error *error_ptr);
+
+ //------------------------------------------------------------------
+ /// The actual write function that attempts to write to the
+ /// communications protocol.
+ ///
+ /// Subclasses must override this function.
+ ///
+ /// @param[in] src
+ /// A source buffer that must be at least \a src_len bytes
+ /// long.
+ ///
+ /// @param[in] src_len
+ /// The number of bytes to attempt to write, and also the
+ /// number of bytes are currently available in \a src.
+ ///
+ /// @return
+ /// The number of bytes actually Written.
+ //------------------------------------------------------------------
+ size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status,
+ Error *error_ptr);
+
+ //------------------------------------------------------------------
+ /// Sets the connection that it to be used by this class.
+ ///
+ /// By making a communication class that uses different connections
+ /// it allows a single communication interface to negotiate and
+ /// change its connection without any interruption to the client.
+ /// It also allows the Communication class to be subclassed for
+ /// packet based communication.
+ ///
+ /// @param[in] connection
+ /// A connection that this class will own and destroy.
+ ///
+ /// @see
+ /// class Connection
+ //------------------------------------------------------------------
+ void SetConnection(Connection *connection);
+
+ //------------------------------------------------------------------
+ /// Starts a read thread whose sole purpose it to read bytes from
+ /// the current connection. This function will call connection's
+ /// read function:
+ ///
+ /// size_t Connection::Read (void *, size_t);
+ ///
+ /// When bytes are read and cached, this function will call:
+ ///
+ /// Communication::AppendBytesToCache (const uint8_t * bytes, size_t len, bool
+ /// broadcast);
+ ///
+ /// Subclasses should override this function if they wish to override
+ /// the default action of caching the bytes and broadcasting a \b
+ /// eBroadcastBitReadThreadGotBytes event.
+ ///
+ /// @return
+ /// \b True if the read thread was successfully started, \b
+ /// false otherwise.
+ ///
+ /// @see size_t Connection::Read (void *, size_t);
+ /// @see void Communication::AppendBytesToCache (const uint8_t * bytes, size_t
+ /// len, bool broadcast);
+ //------------------------------------------------------------------
+ virtual bool StartReadThread(Error *error_ptr = nullptr);
+
+ //------------------------------------------------------------------
+ /// Stops the read thread by cancelling it.
+ ///
+ /// @return
+ /// \b True if the read thread was successfully canceled, \b
+ /// false otherwise.
+ //------------------------------------------------------------------
+ virtual bool StopReadThread(Error *error_ptr = nullptr);
+
+ virtual bool JoinReadThread(Error *error_ptr = nullptr);
+ //------------------------------------------------------------------
+ /// Checks if there is a currently running read thread.
+ ///
+ /// @return
+ /// \b True if the read thread is running, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ReadThreadIsRunning();
+
+ //------------------------------------------------------------------
+ /// The static read thread function. This function will call
+ /// the "DoRead" function continuously and wait for data to become
+ /// available. When data is received it will append the available
+ /// data to the internal cache and broadcast a
+ /// \b eBroadcastBitReadThreadGotBytes event.
+ ///
+ /// @param[in] comm_ptr
+ /// A pointer to an instance of this class.
+ ///
+ /// @return
+ /// \b NULL.
+ ///
+ /// @see void Communication::ReadThreadGotBytes (const uint8_t *, size_t);
+ //------------------------------------------------------------------
+ static lldb::thread_result_t ReadThread(lldb::thread_arg_t comm_ptr);
+
+ void SetReadThreadBytesReceivedCallback(ReadThreadBytesReceived callback,
+ void *callback_baton);
+
+ //------------------------------------------------------------------
+ /// Wait for the read thread to process all outstanding data.
+ ///
+ /// After this function returns, the read thread has processed all data that
+ /// has been waiting in the Connection queue.
+ ///
+ //------------------------------------------------------------------
+ void SynchronizeWithReadThread();
+
+ static const char *ConnectionStatusAsCString(lldb::ConnectionStatus status);
+
+ bool GetCloseOnEOF() const { return m_close_on_eof; }
+
+ void SetCloseOnEOF(bool b) { m_close_on_eof = b; }
+
+ static ConstString &GetStaticBroadcasterClass();
+
+ ConstString &GetBroadcasterClass() const override {
+ return GetStaticBroadcasterClass();
+ }
protected:
- lldb::ConnectionSP m_connection_sp; ///< The connection that is current in use by this communications class.
- HostThread m_read_thread; ///< The read thread handle in case we need to cancel the thread.
- std::atomic<bool> m_read_thread_enabled;
- std::atomic<bool> m_read_thread_did_exit;
- std::string m_bytes; ///< A buffer to cache bytes read in the ReadThread function.
- std::recursive_mutex m_bytes_mutex; ///< A mutex to protect multi-threaded access to the cached bytes.
- std::mutex m_write_mutex; ///< Don't let multiple threads write at the same time...
- std::mutex m_synchronize_mutex;
- ReadThreadBytesReceived m_callback;
- void *m_callback_baton;
- bool m_close_on_eof;
-
- size_t
- ReadFromConnection (void *dst,
- size_t dst_len,
- uint32_t timeout_usec,
- lldb::ConnectionStatus &status,
- Error *error_ptr);
-
- //------------------------------------------------------------------
- /// Append new bytes that get read from the read thread into the
- /// internal object byte cache. This will cause a \b
- /// eBroadcastBitReadThreadGotBytes event to be broadcast if \a
- /// broadcast is true.
- ///
- /// Subclasses can override this function in order to inspect the
- /// received data and check if a packet is available.
- ///
- /// Subclasses can also still call this function from the
- /// overridden method to allow the caching to correctly happen and
- /// suppress the broadcasting of the \a eBroadcastBitReadThreadGotBytes
- /// event by setting \a broadcast to false.
- ///
- /// @param[in] src
- /// A source buffer that must be at least \a src_len bytes
- /// long.
- ///
- /// @param[in] src_len
- /// The number of bytes to append to the cache.
- //------------------------------------------------------------------
- virtual void
- AppendBytesToCache (const uint8_t *src, size_t src_len, bool broadcast, lldb::ConnectionStatus status);
-
- //------------------------------------------------------------------
- /// Get any available bytes from our data cache. If this call
- /// empties the data cache, the \b eBroadcastBitReadThreadGotBytes event
- /// will be reset to signify no more bytes are available.
- ///
- /// @param[in] dst
- /// A destination buffer that must be at least \a dst_len bytes
- /// long.
- ///
- /// @param[in] dst_len
- /// The number of bytes to attempt to read from the cache,
- /// and also the max number of bytes that can be placed into
- /// \a dst.
- ///
- /// @return
- /// The number of bytes extracted from the data cache.
- //------------------------------------------------------------------
- size_t
- GetCachedBytes (void *dst, size_t dst_len);
+ lldb::ConnectionSP m_connection_sp; ///< The connection that is current in use
+ ///by this communications class.
+ HostThread m_read_thread; ///< The read thread handle in case we need to
+ ///cancel the thread.
+ std::atomic<bool> m_read_thread_enabled;
+ std::atomic<bool> m_read_thread_did_exit;
+ std::string
+ m_bytes; ///< A buffer to cache bytes read in the ReadThread function.
+ std::recursive_mutex m_bytes_mutex; ///< A mutex to protect multi-threaded
+ ///access to the cached bytes.
+ std::mutex
+ m_write_mutex; ///< Don't let multiple threads write at the same time...
+ std::mutex m_synchronize_mutex;
+ ReadThreadBytesReceived m_callback;
+ void *m_callback_baton;
+ bool m_close_on_eof;
+
+ size_t ReadFromConnection(void *dst, size_t dst_len,
+ const Timeout<std::micro> &timeout,
+ lldb::ConnectionStatus &status, Error *error_ptr);
+
+ //------------------------------------------------------------------
+ /// Append new bytes that get read from the read thread into the
+ /// internal object byte cache. This will cause a \b
+ /// eBroadcastBitReadThreadGotBytes event to be broadcast if \a
+ /// broadcast is true.
+ ///
+ /// Subclasses can override this function in order to inspect the
+ /// received data and check if a packet is available.
+ ///
+ /// Subclasses can also still call this function from the
+ /// overridden method to allow the caching to correctly happen and
+ /// suppress the broadcasting of the \a eBroadcastBitReadThreadGotBytes
+ /// event by setting \a broadcast to false.
+ ///
+ /// @param[in] src
+ /// A source buffer that must be at least \a src_len bytes
+ /// long.
+ ///
+ /// @param[in] src_len
+ /// The number of bytes to append to the cache.
+ //------------------------------------------------------------------
+ virtual void AppendBytesToCache(const uint8_t *src, size_t src_len,
+ bool broadcast,
+ lldb::ConnectionStatus status);
+
+ //------------------------------------------------------------------
+ /// Get any available bytes from our data cache. If this call
+ /// empties the data cache, the \b eBroadcastBitReadThreadGotBytes event
+ /// will be reset to signify no more bytes are available.
+ ///
+ /// @param[in] dst
+ /// A destination buffer that must be at least \a dst_len bytes
+ /// long.
+ ///
+ /// @param[in] dst_len
+ /// The number of bytes to attempt to read from the cache,
+ /// and also the max number of bytes that can be placed into
+ /// \a dst.
+ ///
+ /// @return
+ /// The number of bytes extracted from the data cache.
+ //------------------------------------------------------------------
+ size_t GetCachedBytes(void *dst, size_t dst_len);
private:
- DISALLOW_COPY_AND_ASSIGN (Communication);
+ DISALLOW_COPY_AND_ASSIGN(Communication);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/Connection.h b/include/lldb/Core/Connection.h
index 4b3024ebdc57..6ff7b001a709 100644
--- a/include/lldb/Core/Connection.h
+++ b/include/lldb/Core/Connection.h
@@ -10,13 +10,15 @@
#ifndef liblldb_Connection_h_
#define liblldb_Connection_h_
-// C Includes
-// C++ Includes
-#include <string>
// Other libraries and framework includes
// Project includes
+#include "lldb/Utility/Timeout.h"
#include "lldb/lldb-private.h"
+// C Includes
+// C++ Includes
+#include <string>
+
namespace lldb_private {
//----------------------------------------------------------------------
@@ -32,182 +34,172 @@ namespace lldb_private {
/// Communication class to perform communications where clients can
/// listen for broadcasts, and perform other higher level communications.
//----------------------------------------------------------------------
-class Connection
-{
+class Connection {
public:
- //------------------------------------------------------------------
- /// Default constructor
- //------------------------------------------------------------------
- Connection ();
-
- //------------------------------------------------------------------
- /// Virtual destructor since this class gets subclassed and handed
- /// to a Communication object.
- //------------------------------------------------------------------
- virtual
- ~Connection ();
-
- static Connection *CreateDefaultConnection(const char *url);
-
- //------------------------------------------------------------------
- /// Connect using the connect string \a url.
- ///
- /// @param[in] url
- /// A string that contains all information needed by the
- /// subclass to connect to another client.
- ///
- /// @param[out] error_ptr
- /// A pointer to an error object that should be given an
- /// appropriate error value if this method returns false. This
- /// value can be NULL if the error value should be ignored.
- ///
- /// @return
- /// \b True if the connect succeeded, \b false otherwise. The
- /// internal error object should be filled in with an
- /// appropriate value based on the result of this function.
- ///
- /// @see Error& Communication::GetError ();
- //------------------------------------------------------------------
- virtual lldb::ConnectionStatus
- Connect (const char *url, Error *error_ptr) = 0;
-
- //------------------------------------------------------------------
- /// Disconnect the communications connection if one is currently
- /// connected.
- ///
- /// @param[out] error_ptr
- /// A pointer to an error object that should be given an
- /// appropriate error value if this method returns false. This
- /// value can be NULL if the error value should be ignored.
- ///
- /// @return
- /// \b True if the disconnect succeeded, \b false otherwise. The
- /// internal error object should be filled in with an
- /// appropriate value based on the result of this function.
- ///
- /// @see Error& Communication::GetError ();
- //------------------------------------------------------------------
- virtual lldb::ConnectionStatus
- Disconnect (Error *error_ptr) = 0;
-
- //------------------------------------------------------------------
- /// Check if the connection is valid.
- ///
- /// @return
- /// \b True if this object is currently connected, \b false
- /// otherwise.
- //------------------------------------------------------------------
- virtual bool
- IsConnected () const = 0;
-
- //------------------------------------------------------------------
- /// The read function that attempts to read from the connection.
- ///
- /// @param[in] dst
- /// A destination buffer that must be at least \a dst_len bytes
- /// long.
- ///
- /// @param[in] dst_len
- /// The number of bytes to attempt to read, and also the max
- /// number of bytes that can be placed into \a dst.
- ///
- /// @param[in] timeout_usec
- /// The number of microseconds to wait for the data.
- ///
- /// @param[out] status
- /// On return, indicates whether the call was successful or terminated
- /// due to some error condition.
- ///
- /// @param[out] error_ptr
- /// A pointer to an error object that should be given an
- /// appropriate error value if this method returns zero. This
- /// value can be NULL if the error value should be ignored.
- ///
- /// @return
- /// The number of bytes actually read.
- ///
- /// @see size_t Communication::Read (void *, size_t, uint32_t);
- //------------------------------------------------------------------
- virtual size_t
- Read (void *dst,
- size_t dst_len,
- uint32_t timeout_usec,
- lldb::ConnectionStatus &status,
- Error *error_ptr) = 0;
-
- //------------------------------------------------------------------
- /// The actual write function that attempts to write to the
- /// communications protocol.
- ///
- /// Subclasses must override this function.
- ///
- /// @param[in] dst
- /// A desination buffer that must be at least \a dst_len bytes
- /// long.
- ///
- /// @param[in] dst_len
- /// The number of bytes to attempt to write, and also the
- /// number of bytes are currently available in \a dst.
- ///
- /// @param[out] error_ptr
- /// A pointer to an error object that should be given an
- /// appropriate error value if this method returns zero. This
- /// value can be NULL if the error value should be ignored.
- ///
- /// @return
- /// The number of bytes actually Written.
- //------------------------------------------------------------------
- virtual size_t
- Write (const void *dst, size_t dst_len, lldb::ConnectionStatus &status, Error *error_ptr) = 0;
-
- //------------------------------------------------------------------
- /// Returns a URI that describes this connection object
- ///
- /// Subclasses may override this function.
- ///
- /// @return
- /// Returns URI or an empty string if disconnecteds
- //------------------------------------------------------------------
- virtual std::string
- GetURI() = 0;
-
- //------------------------------------------------------------------
- /// Interrupts an ongoing Read() operation.
- ///
- /// If there is an ongoing read operation in another thread, this operation
- /// return with status == eConnectionStatusInterrupted. Note that if there
- /// data waiting to be read and an interrupt request is issued, the Read()
- /// function will return the data immediately without processing the
- /// interrupt request (which will remain queued for the next Read()
- /// operation).
- ///
- /// @return
- /// Returns true is the interrupt request was successful.
- //------------------------------------------------------------------
- virtual bool
- InterruptRead() = 0;
-
- //------------------------------------------------------------------
- /// Returns the underlying IOObject used by the Connection.
- ///
- /// The IOObject can be used to wait for data to become available
- /// on the connection. If the Connection does not use IOObjects (and
- /// hence does not support waiting) this function should return a
- /// null pointer.
- ///
- /// @return
- /// The underlying IOObject used for reading.
- //------------------------------------------------------------------
- virtual lldb::IOObjectSP
- GetReadObject() { return lldb::IOObjectSP(); }
+ //------------------------------------------------------------------
+ /// Default constructor
+ //------------------------------------------------------------------
+ Connection();
+
+ //------------------------------------------------------------------
+ /// Virtual destructor since this class gets subclassed and handed
+ /// to a Communication object.
+ //------------------------------------------------------------------
+ virtual ~Connection();
+
+ static Connection *CreateDefaultConnection(const char *url);
+
+ //------------------------------------------------------------------
+ /// Connect using the connect string \a url.
+ ///
+ /// @param[in] url
+ /// A string that contains all information needed by the
+ /// subclass to connect to another client.
+ ///
+ /// @param[out] error_ptr
+ /// A pointer to an error object that should be given an
+ /// appropriate error value if this method returns false. This
+ /// value can be NULL if the error value should be ignored.
+ ///
+ /// @return
+ /// \b True if the connect succeeded, \b false otherwise. The
+ /// internal error object should be filled in with an
+ /// appropriate value based on the result of this function.
+ ///
+ /// @see Error& Communication::GetError ();
+ //------------------------------------------------------------------
+ virtual lldb::ConnectionStatus Connect(llvm::StringRef url,
+ Error *error_ptr) = 0;
+
+ //------------------------------------------------------------------
+ /// Disconnect the communications connection if one is currently
+ /// connected.
+ ///
+ /// @param[out] error_ptr
+ /// A pointer to an error object that should be given an
+ /// appropriate error value if this method returns false. This
+ /// value can be NULL if the error value should be ignored.
+ ///
+ /// @return
+ /// \b True if the disconnect succeeded, \b false otherwise. The
+ /// internal error object should be filled in with an
+ /// appropriate value based on the result of this function.
+ ///
+ /// @see Error& Communication::GetError ();
+ //------------------------------------------------------------------
+ virtual lldb::ConnectionStatus Disconnect(Error *error_ptr) = 0;
+
+ //------------------------------------------------------------------
+ /// Check if the connection is valid.
+ ///
+ /// @return
+ /// \b True if this object is currently connected, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ virtual bool IsConnected() const = 0;
+
+ //------------------------------------------------------------------
+ /// The read function that attempts to read from the connection.
+ ///
+ /// @param[in] dst
+ /// A destination buffer that must be at least \a dst_len bytes
+ /// long.
+ ///
+ /// @param[in] dst_len
+ /// The number of bytes to attempt to read, and also the max
+ /// number of bytes that can be placed into \a dst.
+ ///
+ /// @param[in] timeout
+ /// The number of microseconds to wait for the data.
+ ///
+ /// @param[out] status
+ /// On return, indicates whether the call was successful or terminated
+ /// due to some error condition.
+ ///
+ /// @param[out] error_ptr
+ /// A pointer to an error object that should be given an
+ /// appropriate error value if this method returns zero. This
+ /// value can be NULL if the error value should be ignored.
+ ///
+ /// @return
+ /// The number of bytes actually read.
+ ///
+ /// @see size_t Communication::Read (void *, size_t, uint32_t);
+ //------------------------------------------------------------------
+ virtual size_t Read(void *dst, size_t dst_len,
+ const Timeout<std::micro> &timeout,
+ lldb::ConnectionStatus &status, Error *error_ptr) = 0;
+
+ //------------------------------------------------------------------
+ /// The actual write function that attempts to write to the
+ /// communications protocol.
+ ///
+ /// Subclasses must override this function.
+ ///
+ /// @param[in] dst
+ /// A desination buffer that must be at least \a dst_len bytes
+ /// long.
+ ///
+ /// @param[in] dst_len
+ /// The number of bytes to attempt to write, and also the
+ /// number of bytes are currently available in \a dst.
+ ///
+ /// @param[out] error_ptr
+ /// A pointer to an error object that should be given an
+ /// appropriate error value if this method returns zero. This
+ /// value can be NULL if the error value should be ignored.
+ ///
+ /// @return
+ /// The number of bytes actually Written.
+ //------------------------------------------------------------------
+ virtual size_t Write(const void *dst, size_t dst_len,
+ lldb::ConnectionStatus &status, Error *error_ptr) = 0;
+
+ //------------------------------------------------------------------
+ /// Returns a URI that describes this connection object
+ ///
+ /// Subclasses may override this function.
+ ///
+ /// @return
+ /// Returns URI or an empty string if disconnecteds
+ //------------------------------------------------------------------
+ virtual std::string GetURI() = 0;
+
+ //------------------------------------------------------------------
+ /// Interrupts an ongoing Read() operation.
+ ///
+ /// If there is an ongoing read operation in another thread, this operation
+ /// return with status == eConnectionStatusInterrupted. Note that if there
+ /// data waiting to be read and an interrupt request is issued, the Read()
+ /// function will return the data immediately without processing the
+ /// interrupt request (which will remain queued for the next Read()
+ /// operation).
+ ///
+ /// @return
+ /// Returns true is the interrupt request was successful.
+ //------------------------------------------------------------------
+ virtual bool InterruptRead() = 0;
+
+ //------------------------------------------------------------------
+ /// Returns the underlying IOObject used by the Connection.
+ ///
+ /// The IOObject can be used to wait for data to become available
+ /// on the connection. If the Connection does not use IOObjects (and
+ /// hence does not support waiting) this function should return a
+ /// null pointer.
+ ///
+ /// @return
+ /// The underlying IOObject used for reading.
+ //------------------------------------------------------------------
+ virtual lldb::IOObjectSP GetReadObject() { return lldb::IOObjectSP(); }
private:
- //------------------------------------------------------------------
- // For Connection only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (Connection);
+ //------------------------------------------------------------------
+ // For Connection only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(Connection);
};
} // namespace lldb_private
-#endif // liblldb_Connection_h_
+#endif // liblldb_Connection_h_
diff --git a/include/lldb/Core/ConnectionMachPort.h b/include/lldb/Core/ConnectionMachPort.h
deleted file mode 100644
index 78eb78cb95f4..000000000000
--- a/include/lldb/Core/ConnectionMachPort.h
+++ /dev/null
@@ -1,97 +0,0 @@
-//===-- ConnectionMachPort.h --------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-#if defined(__APPLE__)
-
-#ifndef liblldb_ConnectionMachPort_h_
-#define liblldb_ConnectionMachPort_h_
-
-// C Includes
-#include <mach/port.h>
-#include <mach/kern_return.h>
-
-// C++ Includes
-#include <string>
-
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/Connection.h"
-
-class ConnectionMachPort :
- public lldb_private::Connection
-{
-public:
- ConnectionMachPort ();
-
- virtual
- ~ConnectionMachPort ();
-
- virtual bool
- IsConnected () const;
-
- virtual lldb::ConnectionStatus
- BytesAvailable (uint32_t timeout_usec, lldb_private::Error *error_ptr);
-
- virtual lldb::ConnectionStatus
- Connect (const char *s, lldb_private::Error *error_ptr);
-
- virtual lldb::ConnectionStatus
- Disconnect (lldb_private::Error *error_ptr);
-
- virtual size_t
- Read (void *dst,
- size_t dst_len,
- uint32_t timeout_usec,
- lldb::ConnectionStatus &status,
- lldb_private::Error *error_ptr);
-
- virtual size_t
- Write (const void *src,
- size_t src_len,
- lldb::ConnectionStatus &status,
- lldb_private::Error *error_ptr);
-
- virtual std::string
- GetURI();
-
- lldb::ConnectionStatus
- BootstrapCheckIn (const char *port_name,
- lldb_private::Error *error_ptr);
-
- lldb::ConnectionStatus
- BootstrapLookup (const char *port_name,
- lldb_private::Error *error_ptr);
-
- struct PayloadType
- {
- uint32_t command;
- uint32_t data_length;
- uint8_t data[32];
- };
-
- kern_return_t
- Send (const PayloadType &payload);
-
- kern_return_t
- Receive (PayloadType &payload);
-
-
-protected:
- mach_port_t m_task;
- mach_port_t m_port;
-
-private:
- std::string m_uri;
-
-
- DISALLOW_COPY_AND_ASSIGN (ConnectionMachPort);
-};
-
-#endif // liblldb_ConnectionMachPort_h_
-
-#endif // #if defined(__APPLE__)
diff --git a/include/lldb/Core/ConnectionSharedMemory.h b/include/lldb/Core/ConnectionSharedMemory.h
deleted file mode 100644
index d0553699e14e..000000000000
--- a/include/lldb/Core/ConnectionSharedMemory.h
+++ /dev/null
@@ -1,74 +0,0 @@
-//===-- ConnectionSharedMemory.h --------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_ConnectionSharedMemory_h_
-#define liblldb_ConnectionSharedMemory_h_
-
-// C Includes
-// C++ Includes
-#include <string>
-
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/Connection.h"
-#include "lldb/Core/DataBufferMemoryMap.h"
-
-namespace lldb_private {
-
-class ConnectionSharedMemory :
- public Connection
-{
-public:
-
- ConnectionSharedMemory ();
-
- ~ConnectionSharedMemory () override;
-
- bool
- IsConnected () const override;
-
- virtual lldb::ConnectionStatus
- BytesAvailable (uint32_t timeout_usec, Error *error_ptr);
-
- lldb::ConnectionStatus
- Connect (const char *s, Error *error_ptr) override;
-
- lldb::ConnectionStatus
- Disconnect (Error *error_ptr) override;
-
- size_t
- Read (void *dst,
- size_t dst_len,
- uint32_t timeout_usec,
- lldb::ConnectionStatus &status,
- Error *error_ptr) override;
-
- size_t
- Write (const void *src, size_t src_len, lldb::ConnectionStatus &status, Error *error_ptr) override;
-
- std::string
- GetURI() override;
-
- lldb::ConnectionStatus
- Open (bool create, const char *name, size_t size, Error *error_ptr);
-
-protected:
-
- std::string m_name;
- int m_fd; // One buffer that contains all we need
- DataBufferMemoryMap m_mmap;
-
-private:
-
- DISALLOW_COPY_AND_ASSIGN (ConnectionSharedMemory);
-};
-
-} // namespace lldb_private
-
-#endif // liblldb_ConnectionSharedMemory_h_
diff --git a/include/lldb/Core/ConstString.h b/include/lldb/Core/ConstString.h
index c678168790a8..c6531cab3cf6 100644
--- a/include/lldb/Core/ConstString.h
+++ b/include/lldb/Core/ConstString.h
@@ -25,503 +25,454 @@ namespace lldb_private {
/// @brief A uniqued constant string class.
///
/// Provides an efficient way to store strings as uniqued strings. After
-/// the strings are uniqued, finding strings that are equal to one
-/// another is very fast as just the pointers need to be compared. It
+/// the strings are uniqued, finding strings that are equal to one
+/// another is very fast as just the pointers need to be compared. It
/// also allows for many common strings from many different sources to
/// be shared to keep the memory footprint low.
///
-/// No reference counting is done on strings that are added to the
+/// No reference counting is done on strings that are added to the
/// string pool, once strings are added they are in the string pool for
/// the life of the program.
//----------------------------------------------------------------------
-class ConstString
-{
+class ConstString {
public:
- //------------------------------------------------------------------
- /// Default constructor
- ///
- /// Initializes the string to an empty string.
- //------------------------------------------------------------------
- ConstString():
- m_string(nullptr)
- {
- }
-
- //------------------------------------------------------------------
- /// Copy constructor
- ///
- /// Copies the string value in \a rhs into this object.
- ///
- /// @param[in] rhs
- /// Another string object to copy.
- //------------------------------------------------------------------
- ConstString (const ConstString& rhs) :
- m_string (rhs.m_string)
- {
- }
-
- explicit ConstString (const llvm::StringRef &s);
-
- //------------------------------------------------------------------
- /// Construct with C String value
- ///
- /// Constructs this object with a C string by looking to see if the
- /// C string already exists in the global string pool. If it doesn't
- /// exist, it is added to the string pool.
- ///
- /// @param[in] cstr
- /// A NULL terminated C string to add to the string pool.
- //------------------------------------------------------------------
- explicit ConstString (const char *cstr);
-
- //------------------------------------------------------------------
- /// Construct with C String value with max length
- ///
- /// Constructs this object with a C string with a length. If
- /// \a max_cstr_len is greater than the actual length of the string,
- /// the string length will be truncated. This allows substrings to
- /// be created without the need to NULL terminate the string as it
- /// is passed into this function.
- ///
- /// @param[in] cstr
- /// A pointer to the first character in the C string. The C
- /// string can be NULL terminated in a buffer that contains
- /// more characters than the length of the string, or the
- /// string can be part of another string and a new substring
- /// can be created.
- ///
- /// @param[in] max_cstr_len
- /// The max length of \a cstr. If the string length of \a cstr
- /// is less than \a max_cstr_len, then the string will be
- /// truncated. If the string length of \a cstr is greater than
- /// \a max_cstr_len, then only max_cstr_len bytes will be used
- /// from \a cstr.
- //------------------------------------------------------------------
- explicit ConstString (const char *cstr, size_t max_cstr_len);
-
- //------------------------------------------------------------------
- /// Destructor
- ///
- /// Since constant string values are currently not reference counted,
- /// there isn't much to do here.
- //------------------------------------------------------------------
- ~ConstString() = default;
-
- //----------------------------------------------------------------------
- /// C string equality binary predicate function object for ConstString
- /// objects.
- //----------------------------------------------------------------------
- struct StringIsEqual
- {
- //--------------------------------------------------------------
- /// C equality test.
- ///
- /// Two C strings are equal when they are contained in ConstString
- /// objects when their pointer values are equal to each other.
- ///
- /// @return
- /// Returns \b true if the C string in \a lhs is equal to
- /// the C string value in \a rhs, \b false otherwise.
- //--------------------------------------------------------------
- bool operator()(const char* lhs, const char* rhs) const
- {
- return lhs == rhs;
- }
- };
-
- //------------------------------------------------------------------
- /// Convert to bool operator.
- ///
- /// This allows code to check a ConstString object to see if it
- /// contains a valid string using code such as:
- ///
- /// @code
- /// ConstString str(...);
- /// if (str)
- /// { ...
- /// @endcode
- ///
- /// @return
- /// /b True this object contains a valid non-empty C string, \b
- /// false otherwise.
- //------------------------------------------------------------------
- explicit operator bool() const
- {
- return m_string && m_string[0];
- }
-
- //------------------------------------------------------------------
- /// Assignment operator
- ///
- /// Assigns the string in this object with the value from \a rhs.
- ///
- /// @param[in] rhs
- /// Another string object to copy into this object.
- ///
- /// @return
- /// A const reference to this object.
- //------------------------------------------------------------------
- const ConstString&
- operator = (const ConstString& rhs)
- {
- m_string = rhs.m_string;
- return *this;
- }
-
- //------------------------------------------------------------------
- /// Equal to operator
- ///
- /// Returns true if this string is equal to the string in \a rhs.
- /// This operation is very fast as it results in a pointer
- /// comparison since all strings are in a uniqued in a global string
- /// pool.
- ///
- /// @param[in] rhs
- /// Another string object to compare this object to.
- ///
- /// @return
- /// @li \b true if this object is equal to \a rhs.
- /// @li \b false if this object is not equal to \a rhs.
- //------------------------------------------------------------------
- bool
- operator == (const ConstString& rhs) const
- {
- // We can do a pointer compare to compare these strings since they
- // must come from the same pool in order to be equal.
- return m_string == rhs.m_string;
- }
-
- //------------------------------------------------------------------
- /// Not equal to operator
- ///
- /// Returns true if this string is not equal to the string in \a rhs.
- /// This operation is very fast as it results in a pointer
- /// comparison since all strings are in a uniqued in a global string
- /// pool.
- ///
- /// @param[in] rhs
- /// Another string object to compare this object to.
- ///
- /// @return
- /// @li \b true if this object is not equal to \a rhs.
- /// @li \b false if this object is equal to \a rhs.
- //------------------------------------------------------------------
- bool
- operator != (const ConstString& rhs) const
- {
- return m_string != rhs.m_string;
- }
-
- bool
- operator < (const ConstString& rhs) const;
-
- //------------------------------------------------------------------
- /// Get the string value as a C string.
- ///
- /// Get the value of the contained string as a NULL terminated C
- /// string value.
- ///
- /// If \a value_if_empty is nullptr, then nullptr will be returned.
- ///
- /// @return
- /// Returns \a value_if_empty if the string is empty, otherwise
- /// the C string value contained in this object.
- //------------------------------------------------------------------
- const char *
- AsCString(const char *value_if_empty = nullptr) const
- {
- return (IsEmpty() ? value_if_empty : m_string);
- }
-
- //------------------------------------------------------------------
- /// Get the string value as a llvm::StringRef
- ///
- /// @return
- /// Returns a new llvm::StringRef object filled in with the
- /// needed data.
- //------------------------------------------------------------------
- llvm::StringRef
- GetStringRef () const
- {
- return llvm::StringRef (m_string, GetLength());
- }
-
- //------------------------------------------------------------------
- /// Get the string value as a C string.
- ///
- /// Get the value of the contained string as a NULL terminated C
- /// string value. Similar to the ConstString::AsCString() function,
- /// yet this function will always return nullptr if the string is not
- /// valid. So this function is a direct accessor to the string
- /// pointer value.
- ///
- /// @return
- /// Returns nullptr the string is invalid, otherwise the C string
- /// value contained in this object.
- //------------------------------------------------------------------
- const char *
- GetCString () const
- {
- return m_string;
- }
-
- //------------------------------------------------------------------
- /// Get the length in bytes of string value.
- ///
- /// The string pool stores the length of the string, so we can avoid
- /// calling strlen() on the pointer value with this function.
- ///
- /// @return
- /// Returns the number of bytes that this string occupies in
- /// memory, not including the NULL termination byte.
- //------------------------------------------------------------------
- size_t
- GetLength () const;
-
- //------------------------------------------------------------------
- /// Clear this object's state.
- ///
- /// Clear any contained string and reset the value to the an empty
- /// string value.
- //------------------------------------------------------------------
- void
- Clear ()
- {
- m_string = nullptr;
- }
-
- //------------------------------------------------------------------
- /// Equal to operator
- ///
- /// Returns true if this string is equal to the string in \a rhs.
- /// If case sensitive equality is tested, this operation is very
- /// fast as it results in a pointer comparison since all strings
- /// are in a uniqued in a global string pool.
- ///
- /// @param[in] rhs
- /// The Left Hand Side const ConstString object reference.
- ///
- /// @param[in] rhs
- /// The Right Hand Side const ConstString object reference.
- ///
- /// @param[in] case_sensitive
- /// Case sensitivity. If true, case sensitive equality
- /// will be tested, otherwise character case will be ignored
- ///
- /// @return
- /// @li \b true if this object is equal to \a rhs.
- /// @li \b false if this object is not equal to \a rhs.
- //------------------------------------------------------------------
- static bool
- Equals(const ConstString &lhs, const ConstString &rhs, const bool case_sensitive = true);
-
- //------------------------------------------------------------------
- /// Compare two string objects.
- ///
- /// Compares the C string values contained in \a lhs and \a rhs and
- /// returns an integer result.
- ///
- /// NOTE: only call this function when you want a true string
- /// comparison. If you want string equality use the, use the ==
- /// operator as it is much more efficient. Also if you want string
- /// inequality, use the != operator for the same reasons.
- ///
- /// @param[in] lhs
- /// The Left Hand Side const ConstString object reference.
- ///
- /// @param[in] rhs
- /// The Right Hand Side const ConstString object reference.
- ///
- /// @param[in] case_sensitive
- /// Case sensitivity of compare. If true, case sensitive compare
- /// will be performed, otherwise character case will be ignored
+ //------------------------------------------------------------------
+ /// Default constructor
+ ///
+ /// Initializes the string to an empty string.
+ //------------------------------------------------------------------
+ ConstString() : m_string(nullptr) {}
+
+ //------------------------------------------------------------------
+ /// Copy constructor
+ ///
+ /// Copies the string value in \a rhs into this object.
+ ///
+ /// @param[in] rhs
+ /// Another string object to copy.
+ //------------------------------------------------------------------
+ ConstString(const ConstString &rhs) : m_string(rhs.m_string) {}
+
+ explicit ConstString(const llvm::StringRef &s);
+
+ //------------------------------------------------------------------
+ /// Construct with C String value
+ ///
+ /// Constructs this object with a C string by looking to see if the
+ /// C string already exists in the global string pool. If it doesn't
+ /// exist, it is added to the string pool.
+ ///
+ /// @param[in] cstr
+ /// A NULL terminated C string to add to the string pool.
+ //------------------------------------------------------------------
+ explicit ConstString(const char *cstr);
+
+ //------------------------------------------------------------------
+ /// Construct with C String value with max length
+ ///
+ /// Constructs this object with a C string with a length. If
+ /// \a max_cstr_len is greater than the actual length of the string,
+ /// the string length will be truncated. This allows substrings to
+ /// be created without the need to NULL terminate the string as it
+ /// is passed into this function.
+ ///
+ /// @param[in] cstr
+ /// A pointer to the first character in the C string. The C
+ /// string can be NULL terminated in a buffer that contains
+ /// more characters than the length of the string, or the
+ /// string can be part of another string and a new substring
+ /// can be created.
+ ///
+ /// @param[in] max_cstr_len
+ /// The max length of \a cstr. If the string length of \a cstr
+ /// is less than \a max_cstr_len, then the string will be
+ /// truncated. If the string length of \a cstr is greater than
+ /// \a max_cstr_len, then only max_cstr_len bytes will be used
+ /// from \a cstr.
+ //------------------------------------------------------------------
+ explicit ConstString(const char *cstr, size_t max_cstr_len);
+
+ //------------------------------------------------------------------
+ /// Destructor
+ ///
+ /// Since constant string values are currently not reference counted,
+ /// there isn't much to do here.
+ //------------------------------------------------------------------
+ ~ConstString() = default;
+
+ //----------------------------------------------------------------------
+ /// C string equality binary predicate function object for ConstString
+ /// objects.
+ //----------------------------------------------------------------------
+ struct StringIsEqual {
+ //--------------------------------------------------------------
+ /// C equality test.
+ ///
+ /// Two C strings are equal when they are contained in ConstString
+ /// objects when their pointer values are equal to each other.
///
/// @return
- /// @li -1 if lhs < rhs
- /// @li 0 if lhs == rhs
- /// @li 1 if lhs > rhs
- //------------------------------------------------------------------
- static int
- Compare(const ConstString &lhs, const ConstString &rhs, const bool case_sensitive = true);
-
- //------------------------------------------------------------------
- /// Dump the object description to a stream.
- ///
- /// Dump the string value to the stream \a s. If the contained string
- /// is empty, print \a value_if_empty to the stream instead. If
- /// \a value_if_empty is nullptr, then nothing will be dumped to the
- /// stream.
- ///
- /// @param[in] s
- /// The stream that will be used to dump the object description.
- ///
- /// @param[in] value_if_empty
- /// The value to dump if the string is empty. If nullptr, nothing
- /// will be output to the stream.
- //------------------------------------------------------------------
- void
- Dump(Stream *s, const char *value_if_empty = nullptr) const;
-
- //------------------------------------------------------------------
- /// Dump the object debug description to a stream.
- ///
- /// @param[in] s
- /// The stream that will be used to dump the object description.
- //------------------------------------------------------------------
- void
- DumpDebug (Stream *s) const;
-
- //------------------------------------------------------------------
- /// Test for empty string.
- ///
- /// @return
- /// @li \b true if the contained string is empty.
- /// @li \b false if the contained string is not empty.
- //------------------------------------------------------------------
- bool
- IsEmpty () const
- {
- return m_string == nullptr || m_string[0] == '\0';
+ /// Returns \b true if the C string in \a lhs is equal to
+ /// the C string value in \a rhs, \b false otherwise.
+ //--------------------------------------------------------------
+ bool operator()(const char *lhs, const char *rhs) const {
+ return lhs == rhs;
}
-
- //------------------------------------------------------------------
- /// Set the C string value.
- ///
- /// Set the string value in the object by uniquing the \a cstr
- /// string value in our global string pool.
- ///
- /// If the C string already exists in the global string pool, it
- /// finds the current entry and returns the existing value. If it
- /// doesn't exist, it is added to the string pool.
- ///
- /// @param[in] cstr
- /// A NULL terminated C string to add to the string pool.
- //------------------------------------------------------------------
- void
- SetCString (const char *cstr);
-
- void
- SetString (const llvm::StringRef &s);
-
- //------------------------------------------------------------------
- /// Set the C string value and its mangled counterpart.
- ///
- /// Object files and debug symbols often use mangled string to
- /// represent the linkage name for a symbol, function or global.
- /// The string pool can efficiently store these values and their
- /// counterparts so when we run into another instance of a mangled
- /// name, we can avoid calling the name demangler over and over on
- /// the same strings and then trying to unique them.
- ///
- /// @param[in] demangled
- /// The demangled C string to correlate with the \a mangled
- /// name.
- ///
- /// @param[in] mangled
- /// The already uniqued mangled ConstString to correlate the
- /// soon to be uniqued version of \a demangled.
- //------------------------------------------------------------------
- void
- SetCStringWithMangledCounterpart (const char *demangled,
- const ConstString &mangled);
-
- //------------------------------------------------------------------
- /// Retrieve the mangled or demangled counterpart for a mangled
- /// or demangled ConstString.
- ///
- /// Object files and debug symbols often use mangled string to
- /// represent the linkage name for a symbol, function or global.
- /// The string pool can efficiently store these values and their
- /// counterparts so when we run into another instance of a mangled
- /// name, we can avoid calling the name demangler over and over on
- /// the same strings and then trying to unique them.
- ///
- /// @param[in] counterpart
- /// A reference to a ConstString object that might get filled in
- /// with the demangled/mangled counterpart.
- ///
- /// @return
- /// /b True if \a counterpart was filled in with the counterpart
- /// /b false otherwise.
- //------------------------------------------------------------------
- bool
- GetMangledCounterpart (ConstString &counterpart) const;
-
- //------------------------------------------------------------------
- /// Set the C string value with length.
- ///
- /// Set the string value in the object by uniquing \a cstr_len bytes
- /// starting at the \a cstr string value in our global string pool.
- /// If trim is true, then \a cstr_len indicates a maximum length of
- /// the CString and if the actual length of the string is less, then
- /// it will be trimmed.
- ///
- /// If the C string already exists in the global string pool, it
- /// finds the current entry and returns the existing value. If it
- /// doesn't exist, it is added to the string pool.
- ///
- /// @param[in] cstr
- /// A NULL terminated C string to add to the string pool.
- ///
- /// @param[in] cstr_len
- /// The maximum length of the C string.
- //------------------------------------------------------------------
- void
- SetCStringWithLength (const char *cstr, size_t cstr_len);
-
- //------------------------------------------------------------------
- /// Set the C string value with the minimum length between
- /// \a fixed_cstr_len and the actual length of the C string. This
- /// can be used for data structures that have a fixed length to
- /// store a C string where the string might not be NULL terminated
- /// if the string takes the entire buffer.
- //------------------------------------------------------------------
- void
- SetTrimmedCStringWithLength (const char *cstr, size_t fixed_cstr_len);
-
- //------------------------------------------------------------------
- /// Get the memory cost of this object.
- ///
- /// Return the size in bytes that this object takes in memory. This
- /// returns the size in bytes of this object, which does not include
- /// any the shared string values it may refer to.
- ///
- /// @return
- /// The number of bytes that this object occupies in memory.
- ///
- /// @see ConstString::StaticMemorySize ()
- //------------------------------------------------------------------
- size_t
- MemorySize () const
- {
- return sizeof(ConstString);
- }
-
- //------------------------------------------------------------------
- /// Get the size in bytes of the current global string pool.
- ///
- /// Reports the size in bytes of all shared C string values,
- /// containers and any other values as a byte size for the
- /// entire string pool.
- ///
- /// @return
- /// The number of bytes that the global string pool occupies
- /// in memory.
- //------------------------------------------------------------------
- static size_t
- StaticMemorySize ();
+ };
+
+ //------------------------------------------------------------------
+ /// Convert to bool operator.
+ ///
+ /// This allows code to check a ConstString object to see if it
+ /// contains a valid string using code such as:
+ ///
+ /// @code
+ /// ConstString str(...);
+ /// if (str)
+ /// { ...
+ /// @endcode
+ ///
+ /// @return
+ /// /b True this object contains a valid non-empty C string, \b
+ /// false otherwise.
+ //------------------------------------------------------------------
+ explicit operator bool() const { return m_string && m_string[0]; }
+
+ //------------------------------------------------------------------
+ /// Assignment operator
+ ///
+ /// Assigns the string in this object with the value from \a rhs.
+ ///
+ /// @param[in] rhs
+ /// Another string object to copy into this object.
+ ///
+ /// @return
+ /// A const reference to this object.
+ //------------------------------------------------------------------
+ const ConstString &operator=(const ConstString &rhs) {
+ m_string = rhs.m_string;
+ return *this;
+ }
+
+ //------------------------------------------------------------------
+ /// Equal to operator
+ ///
+ /// Returns true if this string is equal to the string in \a rhs.
+ /// This operation is very fast as it results in a pointer
+ /// comparison since all strings are in a uniqued in a global string
+ /// pool.
+ ///
+ /// @param[in] rhs
+ /// Another string object to compare this object to.
+ ///
+ /// @return
+ /// @li \b true if this object is equal to \a rhs.
+ /// @li \b false if this object is not equal to \a rhs.
+ //------------------------------------------------------------------
+ bool operator==(const ConstString &rhs) const {
+ // We can do a pointer compare to compare these strings since they
+ // must come from the same pool in order to be equal.
+ return m_string == rhs.m_string;
+ }
+
+ //------------------------------------------------------------------
+ /// Not equal to operator
+ ///
+ /// Returns true if this string is not equal to the string in \a rhs.
+ /// This operation is very fast as it results in a pointer
+ /// comparison since all strings are in a uniqued in a global string
+ /// pool.
+ ///
+ /// @param[in] rhs
+ /// Another string object to compare this object to.
+ ///
+ /// @return
+ /// @li \b true if this object is not equal to \a rhs.
+ /// @li \b false if this object is equal to \a rhs.
+ //------------------------------------------------------------------
+ bool operator!=(const ConstString &rhs) const {
+ return m_string != rhs.m_string;
+ }
+
+ bool operator<(const ConstString &rhs) const;
+
+ //------------------------------------------------------------------
+ /// Get the string value as a C string.
+ ///
+ /// Get the value of the contained string as a NULL terminated C
+ /// string value.
+ ///
+ /// If \a value_if_empty is nullptr, then nullptr will be returned.
+ ///
+ /// @return
+ /// Returns \a value_if_empty if the string is empty, otherwise
+ /// the C string value contained in this object.
+ //------------------------------------------------------------------
+ const char *AsCString(const char *value_if_empty = nullptr) const {
+ return (IsEmpty() ? value_if_empty : m_string);
+ }
+
+ //------------------------------------------------------------------
+ /// Get the string value as a llvm::StringRef
+ ///
+ /// @return
+ /// Returns a new llvm::StringRef object filled in with the
+ /// needed data.
+ //------------------------------------------------------------------
+ llvm::StringRef GetStringRef() const {
+ return llvm::StringRef(m_string, GetLength());
+ }
+
+ //------------------------------------------------------------------
+ /// Get the string value as a C string.
+ ///
+ /// Get the value of the contained string as a NULL terminated C
+ /// string value. Similar to the ConstString::AsCString() function,
+ /// yet this function will always return nullptr if the string is not
+ /// valid. So this function is a direct accessor to the string
+ /// pointer value.
+ ///
+ /// @return
+ /// Returns nullptr the string is invalid, otherwise the C string
+ /// value contained in this object.
+ //------------------------------------------------------------------
+ const char *GetCString() const { return m_string; }
+
+ //------------------------------------------------------------------
+ /// Get the length in bytes of string value.
+ ///
+ /// The string pool stores the length of the string, so we can avoid
+ /// calling strlen() on the pointer value with this function.
+ ///
+ /// @return
+ /// Returns the number of bytes that this string occupies in
+ /// memory, not including the NULL termination byte.
+ //------------------------------------------------------------------
+ size_t GetLength() const;
+
+ //------------------------------------------------------------------
+ /// Clear this object's state.
+ ///
+ /// Clear any contained string and reset the value to the an empty
+ /// string value.
+ //------------------------------------------------------------------
+ void Clear() { m_string = nullptr; }
+
+ //------------------------------------------------------------------
+ /// Equal to operator
+ ///
+ /// Returns true if this string is equal to the string in \a rhs.
+ /// If case sensitive equality is tested, this operation is very
+ /// fast as it results in a pointer comparison since all strings
+ /// are in a uniqued in a global string pool.
+ ///
+ /// @param[in] rhs
+ /// The Left Hand Side const ConstString object reference.
+ ///
+ /// @param[in] rhs
+ /// The Right Hand Side const ConstString object reference.
+ ///
+ /// @param[in] case_sensitive
+ /// Case sensitivity. If true, case sensitive equality
+ /// will be tested, otherwise character case will be ignored
+ ///
+ /// @return
+ /// @li \b true if this object is equal to \a rhs.
+ /// @li \b false if this object is not equal to \a rhs.
+ //------------------------------------------------------------------
+ static bool Equals(const ConstString &lhs, const ConstString &rhs,
+ const bool case_sensitive = true);
+
+ //------------------------------------------------------------------
+ /// Compare two string objects.
+ ///
+ /// Compares the C string values contained in \a lhs and \a rhs and
+ /// returns an integer result.
+ ///
+ /// NOTE: only call this function when you want a true string
+ /// comparison. If you want string equality use the, use the ==
+ /// operator as it is much more efficient. Also if you want string
+ /// inequality, use the != operator for the same reasons.
+ ///
+ /// @param[in] lhs
+ /// The Left Hand Side const ConstString object reference.
+ ///
+ /// @param[in] rhs
+ /// The Right Hand Side const ConstString object reference.
+ ///
+ /// @param[in] case_sensitive
+ /// Case sensitivity of compare. If true, case sensitive compare
+ /// will be performed, otherwise character case will be ignored
+ ///
+ /// @return
+ /// @li -1 if lhs < rhs
+ /// @li 0 if lhs == rhs
+ /// @li 1 if lhs > rhs
+ //------------------------------------------------------------------
+ static int Compare(const ConstString &lhs, const ConstString &rhs,
+ const bool case_sensitive = true);
+
+ //------------------------------------------------------------------
+ /// Dump the object description to a stream.
+ ///
+ /// Dump the string value to the stream \a s. If the contained string
+ /// is empty, print \a value_if_empty to the stream instead. If
+ /// \a value_if_empty is nullptr, then nothing will be dumped to the
+ /// stream.
+ ///
+ /// @param[in] s
+ /// The stream that will be used to dump the object description.
+ ///
+ /// @param[in] value_if_empty
+ /// The value to dump if the string is empty. If nullptr, nothing
+ /// will be output to the stream.
+ //------------------------------------------------------------------
+ void Dump(Stream *s, const char *value_if_empty = nullptr) const;
+
+ //------------------------------------------------------------------
+ /// Dump the object debug description to a stream.
+ ///
+ /// @param[in] s
+ /// The stream that will be used to dump the object description.
+ //------------------------------------------------------------------
+ void DumpDebug(Stream *s) const;
+
+ //------------------------------------------------------------------
+ /// Test for empty string.
+ ///
+ /// @return
+ /// @li \b true if the contained string is empty.
+ /// @li \b false if the contained string is not empty.
+ //------------------------------------------------------------------
+ bool IsEmpty() const { return m_string == nullptr || m_string[0] == '\0'; }
+
+ //------------------------------------------------------------------
+ /// Set the C string value.
+ ///
+ /// Set the string value in the object by uniquing the \a cstr
+ /// string value in our global string pool.
+ ///
+ /// If the C string already exists in the global string pool, it
+ /// finds the current entry and returns the existing value. If it
+ /// doesn't exist, it is added to the string pool.
+ ///
+ /// @param[in] cstr
+ /// A NULL terminated C string to add to the string pool.
+ //------------------------------------------------------------------
+ void SetCString(const char *cstr);
+
+ void SetString(const llvm::StringRef &s);
+
+ //------------------------------------------------------------------
+ /// Set the C string value and its mangled counterpart.
+ ///
+ /// Object files and debug symbols often use mangled string to
+ /// represent the linkage name for a symbol, function or global.
+ /// The string pool can efficiently store these values and their
+ /// counterparts so when we run into another instance of a mangled
+ /// name, we can avoid calling the name demangler over and over on
+ /// the same strings and then trying to unique them.
+ ///
+ /// @param[in] demangled
+ /// The demangled C string to correlate with the \a mangled
+ /// name.
+ ///
+ /// @param[in] mangled
+ /// The already uniqued mangled ConstString to correlate the
+ /// soon to be uniqued version of \a demangled.
+ //------------------------------------------------------------------
+ void SetCStringWithMangledCounterpart(const char *demangled,
+ const ConstString &mangled);
+
+ //------------------------------------------------------------------
+ /// Retrieve the mangled or demangled counterpart for a mangled
+ /// or demangled ConstString.
+ ///
+ /// Object files and debug symbols often use mangled string to
+ /// represent the linkage name for a symbol, function or global.
+ /// The string pool can efficiently store these values and their
+ /// counterparts so when we run into another instance of a mangled
+ /// name, we can avoid calling the name demangler over and over on
+ /// the same strings and then trying to unique them.
+ ///
+ /// @param[in] counterpart
+ /// A reference to a ConstString object that might get filled in
+ /// with the demangled/mangled counterpart.
+ ///
+ /// @return
+ /// /b True if \a counterpart was filled in with the counterpart
+ /// /b false otherwise.
+ //------------------------------------------------------------------
+ bool GetMangledCounterpart(ConstString &counterpart) const;
+
+ //------------------------------------------------------------------
+ /// Set the C string value with length.
+ ///
+ /// Set the string value in the object by uniquing \a cstr_len bytes
+ /// starting at the \a cstr string value in our global string pool.
+ /// If trim is true, then \a cstr_len indicates a maximum length of
+ /// the CString and if the actual length of the string is less, then
+ /// it will be trimmed.
+ ///
+ /// If the C string already exists in the global string pool, it
+ /// finds the current entry and returns the existing value. If it
+ /// doesn't exist, it is added to the string pool.
+ ///
+ /// @param[in] cstr
+ /// A NULL terminated C string to add to the string pool.
+ ///
+ /// @param[in] cstr_len
+ /// The maximum length of the C string.
+ //------------------------------------------------------------------
+ void SetCStringWithLength(const char *cstr, size_t cstr_len);
+
+ //------------------------------------------------------------------
+ /// Set the C string value with the minimum length between
+ /// \a fixed_cstr_len and the actual length of the C string. This
+ /// can be used for data structures that have a fixed length to
+ /// store a C string where the string might not be NULL terminated
+ /// if the string takes the entire buffer.
+ //------------------------------------------------------------------
+ void SetTrimmedCStringWithLength(const char *cstr, size_t fixed_cstr_len);
+
+ //------------------------------------------------------------------
+ /// Get the memory cost of this object.
+ ///
+ /// Return the size in bytes that this object takes in memory. This
+ /// returns the size in bytes of this object, which does not include
+ /// any the shared string values it may refer to.
+ ///
+ /// @return
+ /// The number of bytes that this object occupies in memory.
+ ///
+ /// @see ConstString::StaticMemorySize ()
+ //------------------------------------------------------------------
+ size_t MemorySize() const { return sizeof(ConstString); }
+
+ //------------------------------------------------------------------
+ /// Get the size in bytes of the current global string pool.
+ ///
+ /// Reports the size in bytes of all shared C string values,
+ /// containers and any other values as a byte size for the
+ /// entire string pool.
+ ///
+ /// @return
+ /// The number of bytes that the global string pool occupies
+ /// in memory.
+ //------------------------------------------------------------------
+ static size_t StaticMemorySize();
protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- const char *m_string;
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ const char *m_string;
};
//------------------------------------------------------------------
/// Stream the string value \a str to the stream \a s
//------------------------------------------------------------------
-Stream& operator << (Stream& s, const ConstString& str);
+Stream &operator<<(Stream &s, const ConstString &str);
} // namespace lldb_private
diff --git a/include/lldb/Core/CxaDemangle.h b/include/lldb/Core/CxaDemangle.h
deleted file mode 100644
index 0cd54fb36a32..000000000000
--- a/include/lldb/Core/CxaDemangle.h
+++ /dev/null
@@ -1,21 +0,0 @@
-//===-- CxaDemangle.h -------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_CxaDemangle_h_
-#define liblldb_CxaDemangle_h_
-
-namespace lldb_private
-{
-
- char*
- __cxa_demangle(const char* mangled_name, char* buf, size_t* n, int* status);
-
-}
-
-#endif
diff --git a/include/lldb/Core/DataBuffer.h b/include/lldb/Core/DataBuffer.h
index da4934457233..ffa71c06be80 100644
--- a/include/lldb/Core/DataBuffer.h
+++ b/include/lldb/Core/DataBuffer.h
@@ -16,6 +16,8 @@
#include "lldb/lldb-types.h"
+#include "llvm/ADT/ArrayRef.h"
+
namespace lldb_private {
//----------------------------------------------------------------------
@@ -43,54 +45,55 @@ namespace lldb_private {
/// data on demand with some extra function calls to load the data
/// before it gets accessed.
//----------------------------------------------------------------------
-class DataBuffer
-{
+class DataBuffer {
public:
- //------------------------------------------------------------------
- /// Destructor
- ///
- /// The destructor is virtual as other classes will inherit from
- /// this class and be downcast to the DataBuffer pure virtual
- /// interface. The virtual destructor ensures that destructing the
- /// base class will destruct the class that inherited from it
- /// correctly.
- //------------------------------------------------------------------
- virtual
- ~DataBuffer()
- {
- }
+ //------------------------------------------------------------------
+ /// Destructor
+ ///
+ /// The destructor is virtual as other classes will inherit from
+ /// this class and be downcast to the DataBuffer pure virtual
+ /// interface. The virtual destructor ensures that destructing the
+ /// base class will destruct the class that inherited from it
+ /// correctly.
+ //------------------------------------------------------------------
+ virtual ~DataBuffer() {}
+
+ //------------------------------------------------------------------
+ /// Get a pointer to the data.
+ ///
+ /// @return
+ /// A pointer to the bytes owned by this object, or NULL if the
+ /// object contains no bytes.
+ //------------------------------------------------------------------
+ virtual uint8_t *GetBytes() = 0;
+
+ //------------------------------------------------------------------
+ /// Get a const pointer to the data.
+ ///
+ /// @return
+ /// A const pointer to the bytes owned by this object, or NULL
+ /// if the object contains no bytes.
+ //------------------------------------------------------------------
+ virtual const uint8_t *GetBytes() const = 0;
- //------------------------------------------------------------------
- /// Get a pointer to the data.
- ///
- /// @return
- /// A pointer to the bytes owned by this object, or NULL if the
- /// object contains no bytes.
- //------------------------------------------------------------------
- virtual uint8_t *
- GetBytes () = 0;
+ //------------------------------------------------------------------
+ /// Get the number of bytes in the data buffer.
+ ///
+ /// @return
+ /// The number of bytes this object currently contains.
+ //------------------------------------------------------------------
+ virtual lldb::offset_t GetByteSize() const = 0;
- //------------------------------------------------------------------
- /// Get a const pointer to the data.
- ///
- /// @return
- /// A const pointer to the bytes owned by this object, or NULL
- /// if the object contains no bytes.
- //------------------------------------------------------------------
- virtual const uint8_t *
- GetBytes () const = 0;
+ llvm::ArrayRef<uint8_t> GetData() const {
+ return llvm::ArrayRef<uint8_t>(GetBytes(), GetByteSize());
+ }
- //------------------------------------------------------------------
- /// Get the number of bytes in the data buffer.
- ///
- /// @return
- /// The number of bytes this object currently contains.
- //------------------------------------------------------------------
- virtual lldb::offset_t
- GetByteSize() const = 0;
+ llvm::MutableArrayRef<uint8_t> GetData() {
+ return llvm::MutableArrayRef<uint8_t>(GetBytes(), GetByteSize());
+ }
};
} // namespace lldb_private
-#endif /// #if defined(__cplusplus)
-#endif /// lldb_DataBuffer_h_
+#endif /// #if defined(__cplusplus)
+#endif /// lldb_DataBuffer_h_
diff --git a/include/lldb/Core/DataBufferHeap.h b/include/lldb/Core/DataBufferHeap.h
index d379c4cf4e86..5528ebd9135f 100644
--- a/include/lldb/Core/DataBufferHeap.h
+++ b/include/lldb/Core/DataBufferHeap.h
@@ -12,8 +12,8 @@
#include <vector>
-#include "lldb/lldb-private.h"
#include "lldb/Core/DataBuffer.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -27,111 +27,104 @@ namespace lldb_private {
/// fault new data pages in. Large amounts of data that comes from files
/// should probably use the DataBufferMemoryMap class.
//----------------------------------------------------------------------
-class DataBufferHeap : public DataBuffer
-{
+class DataBufferHeap : public DataBuffer {
public:
- //------------------------------------------------------------------
- /// Default constructor
- ///
- /// Initializes the heap based buffer with no bytes.
- //------------------------------------------------------------------
- DataBufferHeap ();
-
- //------------------------------------------------------------------
- /// Construct with size \a n and fill with \a ch.
- ///
- /// Initialize this class with \a n bytes and fills the buffer with
- /// \a ch.
- ///
- /// @param[in] n
- /// The number of bytes that heap based buffer should contain.
- ///
- /// @param[in] ch
- /// The character to use when filling the buffer initially.
- //------------------------------------------------------------------
- DataBufferHeap (lldb::offset_t n, uint8_t ch);
-
- //------------------------------------------------------------------
- /// Construct by making a copy of \a src_len bytes from \a src.
- ///
- /// @param[in] src
- /// A pointer to the data to copy.
- ///
- /// @param[in] src_len
- /// The number of bytes in \a src to copy.
- //------------------------------------------------------------------
- DataBufferHeap (const void *src, lldb::offset_t src_len);
-
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// Virtual destructor since this class inherits from a pure virtual
- /// base class #DataBuffer.
- //------------------------------------------------------------------
- ~DataBufferHeap() override;
-
- //------------------------------------------------------------------
- /// @copydoc DataBuffer::GetBytes()
- //------------------------------------------------------------------
- uint8_t *
- GetBytes () override;
-
- //------------------------------------------------------------------
- /// @copydoc DataBuffer::GetBytes() const
- //------------------------------------------------------------------
- const uint8_t *
- GetBytes () const override;
-
- //------------------------------------------------------------------
- /// @copydoc DataBuffer::GetByteSize() const
- //------------------------------------------------------------------
- lldb::offset_t
- GetByteSize () const override;
-
- //------------------------------------------------------------------
- /// Set the number of bytes in the data buffer.
- ///
- /// Sets the number of bytes that this object should be able to
- /// contain. This can be used prior to copying data into the buffer.
- ///
- /// @param[in] byte_size
- /// The new size in bytes that this data buffer should attempt
- /// to resize itself to.
- ///
- /// @return
- /// The size in bytes after that this heap buffer was
- /// successfully resized to.
- //------------------------------------------------------------------
- lldb::offset_t
- SetByteSize (lldb::offset_t byte_size);
-
- //------------------------------------------------------------------
- /// Makes a copy of the \a src_len bytes in \a src.
- ///
- /// Copies the data in \a src into an internal buffer.
- ///
- /// @param[in] src
- /// A pointer to the data to copy.
- ///
- /// @param[in] src_len
- /// The number of bytes in \a src to copy.
- //------------------------------------------------------------------
- void
- CopyData (const void *src, lldb::offset_t src_len);
-
- void
- AppendData (const void *src, uint64_t src_len);
-
- void
- Clear();
+ //------------------------------------------------------------------
+ /// Default constructor
+ ///
+ /// Initializes the heap based buffer with no bytes.
+ //------------------------------------------------------------------
+ DataBufferHeap();
+
+ //------------------------------------------------------------------
+ /// Construct with size \a n and fill with \a ch.
+ ///
+ /// Initialize this class with \a n bytes and fills the buffer with
+ /// \a ch.
+ ///
+ /// @param[in] n
+ /// The number of bytes that heap based buffer should contain.
+ ///
+ /// @param[in] ch
+ /// The character to use when filling the buffer initially.
+ //------------------------------------------------------------------
+ DataBufferHeap(lldb::offset_t n, uint8_t ch);
+
+ //------------------------------------------------------------------
+ /// Construct by making a copy of \a src_len bytes from \a src.
+ ///
+ /// @param[in] src
+ /// A pointer to the data to copy.
+ ///
+ /// @param[in] src_len
+ /// The number of bytes in \a src to copy.
+ //------------------------------------------------------------------
+ DataBufferHeap(const void *src, lldb::offset_t src_len);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ ///
+ /// Virtual destructor since this class inherits from a pure virtual
+ /// base class #DataBuffer.
+ //------------------------------------------------------------------
+ ~DataBufferHeap() override;
+
+ //------------------------------------------------------------------
+ /// @copydoc DataBuffer::GetBytes()
+ //------------------------------------------------------------------
+ uint8_t *GetBytes() override;
+
+ //------------------------------------------------------------------
+ /// @copydoc DataBuffer::GetBytes() const
+ //------------------------------------------------------------------
+ const uint8_t *GetBytes() const override;
+
+ //------------------------------------------------------------------
+ /// @copydoc DataBuffer::GetByteSize() const
+ //------------------------------------------------------------------
+ lldb::offset_t GetByteSize() const override;
+
+ //------------------------------------------------------------------
+ /// Set the number of bytes in the data buffer.
+ ///
+ /// Sets the number of bytes that this object should be able to
+ /// contain. This can be used prior to copying data into the buffer.
+ ///
+ /// @param[in] byte_size
+ /// The new size in bytes that this data buffer should attempt
+ /// to resize itself to.
+ ///
+ /// @return
+ /// The size in bytes after that this heap buffer was
+ /// successfully resized to.
+ //------------------------------------------------------------------
+ lldb::offset_t SetByteSize(lldb::offset_t byte_size);
+
+ //------------------------------------------------------------------
+ /// Makes a copy of the \a src_len bytes in \a src.
+ ///
+ /// Copies the data in \a src into an internal buffer.
+ ///
+ /// @param[in] src
+ /// A pointer to the data to copy.
+ ///
+ /// @param[in] src_len
+ /// The number of bytes in \a src to copy.
+ //------------------------------------------------------------------
+ void CopyData(const void *src, lldb::offset_t src_len);
+ void CopyData(llvm::StringRef src) { CopyData(src.data(), src.size()); }
+
+ void AppendData(const void *src, uint64_t src_len);
+
+ void Clear();
private:
- //------------------------------------------------------------------
- // This object uses a std::vector<uint8_t> to store its data. This
- // takes care of free the data when the object is deleted.
- //------------------------------------------------------------------
- typedef std::vector<uint8_t> buffer_t; ///< Buffer type
- buffer_t m_data; ///< The heap based buffer where data is stored
+ //------------------------------------------------------------------
+ // This object uses a std::vector<uint8_t> to store its data. This
+ // takes care of free the data when the object is deleted.
+ //------------------------------------------------------------------
+ typedef std::vector<uint8_t> buffer_t; ///< Buffer type
+ buffer_t m_data; ///< The heap based buffer where data is stored
};
} // namespace lldb_private
diff --git a/include/lldb/Core/DataBufferMemoryMap.h b/include/lldb/Core/DataBufferMemoryMap.h
index 9479d4e1a455..1b8277b50488 100644
--- a/include/lldb/Core/DataBufferMemoryMap.h
+++ b/include/lldb/Core/DataBufferMemoryMap.h
@@ -10,15 +10,16 @@
#ifndef liblldb_DataBufferMemoryMap_h_
#define liblldb_DataBufferMemoryMap_h_
-#include "lldb/lldb-private.h"
#include "lldb/Core/DataBuffer.h"
#include "lldb/Core/Error.h"
+#include "lldb/lldb-private.h"
#include <string>
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class DataBufferMemoryMap DataBufferMemoryMap.h "lldb/Core/DataBufferMemoryMap.h"
+/// @class DataBufferMemoryMap DataBufferMemoryMap.h
+/// "lldb/Core/DataBufferMemoryMap.h"
/// @brief A subclass of DataBuffer that memory maps data.
///
/// This class memory maps data and stores any needed data for the
@@ -29,131 +30,123 @@ namespace lldb_private {
/// This class is designed to allow pages to be faulted in as needed and
/// works well data from large files that won't be accessed all at once.
//----------------------------------------------------------------------
-class DataBufferMemoryMap : public DataBuffer
-{
+class DataBufferMemoryMap : public DataBuffer {
public:
- //------------------------------------------------------------------
- /// Default Constructor
- //------------------------------------------------------------------
- DataBufferMemoryMap ();
-
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// Virtual destructor since this class inherits from a pure virtual
- /// base class #DataBuffer.
- //------------------------------------------------------------------
- ~DataBufferMemoryMap () override;
-
- //------------------------------------------------------------------
- /// Reverts this object to an empty state by unmapping any memory
- /// that is currently owned.
- //------------------------------------------------------------------
- void
- Clear ();
-
- //------------------------------------------------------------------
- /// @copydoc DataBuffer::GetBytes()
- //------------------------------------------------------------------
- uint8_t *
- GetBytes () override;
-
- //------------------------------------------------------------------
- /// @copydoc DataBuffer::GetBytes() const
- //------------------------------------------------------------------
- const uint8_t *
- GetBytes () const override;
-
- //------------------------------------------------------------------
- /// @copydoc DataBuffer::GetByteSize() const
- //------------------------------------------------------------------
- lldb::offset_t
- GetByteSize () const override;
-
- //------------------------------------------------------------------
- /// Error get accessor.
- ///
- /// @return
- /// A const reference to Error object in case memory mapping
- /// fails.
- //------------------------------------------------------------------
- const Error &
- GetError() const;
-
- //------------------------------------------------------------------
- /// Memory map all or part of a file.
- ///
- /// Memory map \a length bytes from \a file starting \a offset
- /// bytes into the file. If \a length is set to \c SIZE_MAX,
- /// then map as many bytes as possible.
- ///
- /// @param[in] file
- /// The file specification from which to map data.
- ///
- /// @param[in] offset
- /// The offset in bytes from the beginning of the file where
- /// memory mapping should begin.
- ///
- /// @param[in] length
- /// The size in bytes that should be mapped starting \a offset
- /// bytes into the file. If \a length is \c SIZE_MAX, map
- /// as many bytes as possible. Even though it may be possible
- /// for a 32-bit host debugger to debug a 64-bit target, size_t
- /// still dictates the maximum possible size that can be mapped
- /// into this process. For this kind of cross-arch debugging
- /// scenario, mappings and views should be managed at a higher
- /// level.
- ///
- /// @return
- /// The number of bytes mapped starting from the \a offset.
- //------------------------------------------------------------------
- size_t
- MemoryMapFromFileSpec (const FileSpec* file,
- lldb::offset_t offset = 0,
- size_t length = SIZE_MAX,
- bool writeable = false);
-
- //------------------------------------------------------------------
- /// Memory map all or part of a file.
- ///
- /// Memory map \a length bytes from an opened file descriptor \a fd
- /// starting \a offset bytes into the file. If \a length is set to
- /// \c SIZE_MAX, then map as many bytes as possible.
- ///
- /// @param[in] fd
- /// The posix file descriptor for an already opened file
- /// from which to map data.
- ///
- /// @param[in] offset
- /// The offset in bytes from the beginning of the file where
- /// memory mapping should begin.
- ///
- /// @param[in] length
- /// The size in bytes that should be mapped starting \a offset
- /// bytes into the file. If \a length is \c SIZE_MAX, map
- /// as many bytes as possible.
- ///
- /// @return
- /// The number of bytes mapped starting from the \a offset.
- //------------------------------------------------------------------
- size_t
- MemoryMapFromFileDescriptor (int fd,
- lldb::offset_t offset,
- size_t length,
- bool write,
- bool fd_is_file);
+ //------------------------------------------------------------------
+ /// Default Constructor
+ //------------------------------------------------------------------
+ DataBufferMemoryMap();
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ ///
+ /// Virtual destructor since this class inherits from a pure virtual
+ /// base class #DataBuffer.
+ //------------------------------------------------------------------
+ ~DataBufferMemoryMap() override;
+
+ //------------------------------------------------------------------
+ /// Reverts this object to an empty state by unmapping any memory
+ /// that is currently owned.
+ //------------------------------------------------------------------
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// @copydoc DataBuffer::GetBytes()
+ //------------------------------------------------------------------
+ uint8_t *GetBytes() override;
+
+ //------------------------------------------------------------------
+ /// @copydoc DataBuffer::GetBytes() const
+ //------------------------------------------------------------------
+ const uint8_t *GetBytes() const override;
+
+ //------------------------------------------------------------------
+ /// @copydoc DataBuffer::GetByteSize() const
+ //------------------------------------------------------------------
+ lldb::offset_t GetByteSize() const override;
+
+ //------------------------------------------------------------------
+ /// Error get accessor.
+ ///
+ /// @return
+ /// A const reference to Error object in case memory mapping
+ /// fails.
+ //------------------------------------------------------------------
+ const Error &GetError() const;
+
+ //------------------------------------------------------------------
+ /// Memory map all or part of a file.
+ ///
+ /// Memory map \a length bytes from \a file starting \a offset
+ /// bytes into the file. If \a length is set to \c SIZE_MAX,
+ /// then map as many bytes as possible.
+ ///
+ /// @param[in] file
+ /// The file specification from which to map data.
+ ///
+ /// @param[in] offset
+ /// The offset in bytes from the beginning of the file where
+ /// memory mapping should begin.
+ ///
+ /// @param[in] length
+ /// The size in bytes that should be mapped starting \a offset
+ /// bytes into the file. If \a length is \c SIZE_MAX, map
+ /// as many bytes as possible. Even though it may be possible
+ /// for a 32-bit host debugger to debug a 64-bit target, size_t
+ /// still dictates the maximum possible size that can be mapped
+ /// into this process. For this kind of cross-arch debugging
+ /// scenario, mappings and views should be managed at a higher
+ /// level.
+ ///
+ /// @return
+ /// The number of bytes mapped starting from the \a offset.
+ //------------------------------------------------------------------
+ size_t MemoryMapFromFileSpec(const FileSpec *file, lldb::offset_t offset = 0,
+ size_t length = SIZE_MAX,
+ bool writeable = false);
+
+ //------------------------------------------------------------------
+ /// Memory map all or part of a file.
+ ///
+ /// Memory map \a length bytes from an opened file descriptor \a fd
+ /// starting \a offset bytes into the file. If \a length is set to
+ /// \c SIZE_MAX, then map as many bytes as possible.
+ ///
+ /// @param[in] fd
+ /// The posix file descriptor for an already opened file
+ /// from which to map data.
+ ///
+ /// @param[in] offset
+ /// The offset in bytes from the beginning of the file where
+ /// memory mapping should begin.
+ ///
+ /// @param[in] length
+ /// The size in bytes that should be mapped starting \a offset
+ /// bytes into the file. If \a length is \c SIZE_MAX, map
+ /// as many bytes as possible.
+ ///
+ /// @return
+ /// The number of bytes mapped starting from the \a offset.
+ //------------------------------------------------------------------
+ size_t MemoryMapFromFileDescriptor(int fd, lldb::offset_t offset,
+ size_t length, bool write,
+ bool fd_is_file);
protected:
- //------------------------------------------------------------------
- // Classes that inherit from DataBufferMemoryMap can see and modify these
- //------------------------------------------------------------------
- uint8_t * m_mmap_addr; ///< The actual pointer that was returned from \c mmap()
- size_t m_mmap_size; ///< The actual number of bytes that were mapped when \c mmap() was called
- uint8_t *m_data; ///< The data the user requested somewhere within the memory mapped data.
- lldb::offset_t m_size; ///< The size of the data the user got when data was requested
+ //------------------------------------------------------------------
+ // Classes that inherit from DataBufferMemoryMap can see and modify these
+ //------------------------------------------------------------------
+ uint8_t *m_mmap_addr; ///< The actual pointer that was returned from \c mmap()
+ size_t m_mmap_size; ///< The actual number of bytes that were mapped when \c
+ ///mmap() was called
+ uint8_t *m_data; ///< The data the user requested somewhere within the memory
+ ///mapped data.
+ lldb::offset_t
+ m_size; ///< The size of the data the user got when data was requested
private:
- DISALLOW_COPY_AND_ASSIGN (DataBufferMemoryMap);
+ DISALLOW_COPY_AND_ASSIGN(DataBufferMemoryMap);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/DataEncoder.h b/include/lldb/Core/DataEncoder.h
index 8b4727eb2de2..a2bc4dcce330 100644
--- a/include/lldb/Core/DataEncoder.h
+++ b/include/lldb/Core/DataEncoder.h
@@ -10,7 +10,7 @@
#ifndef liblldb_DataEncoder_h_
#define liblldb_DataEncoder_h_
-#if defined (__cplusplus)
+#if defined(__cplusplus)
#include "lldb/lldb-private.h"
#include <limits.h>
@@ -25,435 +25,374 @@ namespace lldb_private {
/// DataEncoder is a class that can encode binary data (swapping if needed)
/// to a data buffer. The data buffer can be caller owned, or can be
/// shared data that can be shared between multiple DataEncoder or
-/// DataEncoder instances.
+/// DataEncoder instances.
///
/// @see DataBuffer
//----------------------------------------------------------------------
-class DataEncoder
-{
+class DataEncoder {
public:
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Initialize all members to a default empty state.
- //------------------------------------------------------------------
- DataEncoder ();
-
- //------------------------------------------------------------------
- /// Construct with a buffer that is owned by the caller.
- ///
- /// This constructor allows us to use data that is owned by the
- /// caller. The data must stay around as long as this object is
- /// valid.
- ///
- /// @param[in] data
- /// A pointer to caller owned data.
- ///
- /// @param[in] data_length
- /// The length in bytes of \a data.
- ///
- /// @param[in] byte_order
- /// A byte order of the data that we are extracting from.
- ///
- /// @param[in] addr_size
- /// A new address byte size value.
- //------------------------------------------------------------------
- DataEncoder (void* data, uint32_t data_length, lldb::ByteOrder byte_order, uint8_t addr_size);
-
- //------------------------------------------------------------------
- /// Construct with shared data.
- ///
- /// Copies the data shared pointer which adds a reference to the
- /// contained in \a data_sp. The shared data reference is reference
- /// counted to ensure the data lives as long as anyone still has a
- /// valid shared pointer to the data in \a data_sp.
- ///
- /// @param[in] data_sp
- /// A shared pointer to data.
- ///
- /// @param[in] byte_order
- /// A byte order of the data that we are extracting from.
- ///
- /// @param[in] addr_size
- /// A new address byte size value.
- //------------------------------------------------------------------
- DataEncoder (const lldb::DataBufferSP& data_sp, lldb::ByteOrder byte_order, uint8_t addr_size);
-
- //------------------------------------------------------------------
- /// Destructor
- ///
- /// If this object contains a valid shared data reference, the
- /// reference count on the data will be decremented, and if zero,
- /// the data will be freed.
- //------------------------------------------------------------------
- ~DataEncoder ();
-
- //------------------------------------------------------------------
- /// Clears the object state.
- ///
- /// Clears the object contents back to a default invalid state, and
- /// release any references to shared data that this object may
- /// contain.
- //------------------------------------------------------------------
- void
- Clear ();
-
- //------------------------------------------------------------------
- /// Get the current address size.
- ///
- /// Return the size in bytes of any address values this object will
- /// extract.
- ///
- /// @return
- /// The size in bytes of address values that will be extracted.
- //------------------------------------------------------------------
- uint8_t
- GetAddressByteSize () const
- {
- return m_addr_size;
- }
-
-
- //------------------------------------------------------------------
- /// Get the number of bytes contained in this object.
- ///
- /// @return
- /// The total number of bytes of data this object refers to.
- //------------------------------------------------------------------
- size_t
- GetByteSize () const
- {
- return m_end - m_start;
- }
-
- //------------------------------------------------------------------
- /// Get the data end pointer.
- ///
- /// @return
- /// Returns a pointer to the next byte contained in this
- /// object's data, or NULL of there is no data in this object.
- //------------------------------------------------------------------
- uint8_t *
- GetDataEnd ()
- {
- return m_end;
- }
-
- const uint8_t *
- GetDataEnd () const
- {
- return m_end;
- }
-
- //------------------------------------------------------------------
- /// Get the shared data offset.
- ///
- /// Get the offset of the first byte of data in the shared data (if
- /// any).
- ///
- /// @return
- /// If this object contains shared data, this function returns
- /// the offset in bytes into that shared data, zero otherwise.
- //------------------------------------------------------------------
- size_t
- GetSharedDataOffset () const;
-
-
- //------------------------------------------------------------------
- /// Get the current byte order value.
- ///
- /// @return
- /// The current byte order value from this object's internal
- /// state.
- //------------------------------------------------------------------
- lldb::ByteOrder
- GetByteOrder() const
- {
- return m_byte_order;
- }
-
- //------------------------------------------------------------------
- /// Get the data start pointer.
- ///
- /// @return
- /// Returns a pointer to the first byte contained in this
- /// object's data, or NULL of there is no data in this object.
- //------------------------------------------------------------------
- uint8_t *
- GetDataStart ()
- {
- return m_start;
- }
-
- const uint8_t *
- GetDataStart () const
- {
- return m_start;
- }
-
- //------------------------------------------------------------------
- /// Encode unsigned integer values into the data at \a offset.
- ///
- /// @param[in] offset
- /// The offset within the contained data at which to put the
- /// data.
- ///
- /// @param[in] value
- /// The value to encode into the data.
- ///
- /// @return
- /// The next offset in the bytes of this data if the data
- /// was successfully encoded, UINT32_MAX if the encoding failed.
- //------------------------------------------------------------------
- uint32_t
- PutU8 (uint32_t offset, uint8_t value);
-
- uint32_t
- PutU16 (uint32_t offset, uint16_t value);
-
- uint32_t
- PutU32 (uint32_t offset, uint32_t value);
-
- uint32_t
- PutU64 (uint32_t offset, uint64_t value);
-
- //------------------------------------------------------------------
- /// Encode an unsigned integer of size \a byte_size to \a offset.
- ///
- /// Encode a single integer value at \a offset and return the offset
- /// that follows the newly encoded integer when the data is successfully
- /// encoded into the existing data. There must be enough room in the
- /// data, else UINT32_MAX will be returned to indicate that encoding
- /// failed.
- ///
- /// @param[in] offset
- /// The offset within the contained data at which to put the
- /// encoded integer.
- ///
- /// @param[in] byte_size
- /// The size in byte of the integer to encode.
- ///
- /// @param[in] value
- /// The integer value to write. The least significant bytes of
- /// the integer value will be written if the size is less than
- /// 8 bytes.
- ///
- /// @return
- /// The next offset in the bytes of this data if the integer
- /// was successfully encoded, UINT32_MAX if the encoding failed.
- //------------------------------------------------------------------
- uint32_t
- PutMaxU64 (uint32_t offset, uint32_t byte_size, uint64_t value);
-
- //------------------------------------------------------------------
- /// Encode an arbitrary number of bytes.
- ///
- /// @param[in] offset
- /// The offset in bytes into the contained data at which to
- /// start encoding.
- ///
- /// @param[in] src
- /// The buffer that contains the bytes to encode.
- ///
- /// @param[in] src_len
- /// The number of bytes to encode.
- ///
- /// @return
- /// The next valid offset within data if the put operation
- /// was successful, else UINT32_MAX to indicate the put failed.
- //------------------------------------------------------------------
- uint32_t
- PutData (uint32_t offset,
- const void *src,
- uint32_t src_len);
-
- //------------------------------------------------------------------
- /// Encode an address in the existing buffer at \a offset bytes into
- /// the buffer.
- ///
- /// Encode a single address (honoring the m_addr_size member) to
- /// the data and return the next offset where subsequent data would
- /// go.
- /// pointed to by \a offset_ptr. The size of the extracted address
- /// comes from the \a m_addr_size member variable and should be
- /// set correctly prior to extracting any address values.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// The next valid offset within data if the put operation
- /// was successful, else UINT32_MAX to indicate the put failed.
- //------------------------------------------------------------------
- uint32_t
- PutAddress (uint32_t offset, lldb::addr_t addr);
-
- //------------------------------------------------------------------
- /// Put a C string to \a offset.
- ///
- /// Encodes a C string into the existing data including the
- /// terminating
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// A pointer to the C string value in the data. If the offset
- /// pointed to by \a offset_ptr is out of bounds, or if the
- /// offset plus the length of the C string is out of bounds,
- /// NULL will be returned.
- //------------------------------------------------------------------
- uint32_t
- PutCString (uint32_t offset_ptr, const char *cstr);
-
- lldb::DataBufferSP &
- GetSharedDataBuffer ()
- {
- return m_data_sp;
- }
-
- //------------------------------------------------------------------
- /// Set the address byte size.
- ///
- /// Set the size in bytes that will be used when extracting any
- /// address and pointer values from data contained in this object.
- ///
- /// @param[in] addr_size
- /// The size in bytes to use when extracting addresses.
- //------------------------------------------------------------------
- void
- SetAddressByteSize (uint8_t addr_size)
- {
- m_addr_size = addr_size;
- }
-
- //------------------------------------------------------------------
- /// Set data with a buffer that is caller owned.
- ///
- /// Use data that is owned by the caller when extracting values.
- /// The data must stay around as long as this object, or any object
- /// that copies a subset of this object's data, is valid. If \a
- /// bytes is NULL, or \a length is zero, this object will contain
- /// no data.
- ///
- /// @param[in] bytes
- /// A pointer to caller owned data.
- ///
- /// @param[in] length
- /// The length in bytes of \a bytes.
- ///
- /// @param[in] byte_order
- /// A byte order of the data that we are extracting from.
- ///
- /// @return
- /// The number of bytes that this object now contains.
- //------------------------------------------------------------------
- uint32_t
- SetData (void *bytes, uint32_t length, lldb::ByteOrder byte_order);
-
- //------------------------------------------------------------------
- /// Adopt a subset of shared data in \a data_sp.
- ///
- /// Copies the data shared pointer which adds a reference to the
- /// contained in \a data_sp. The shared data reference is reference
- /// counted to ensure the data lives as long as anyone still has a
- /// valid shared pointer to the data in \a data_sp. The byte order
- /// and address byte size settings remain the same. If
- /// \a offset is not a valid offset in \a data_sp, then no reference
- /// to the shared data will be added. If there are not \a length
- /// bytes available in \a data starting at \a offset, the length
- /// will be truncated to contains as many bytes as possible.
- ///
- /// @param[in] data_sp
- /// A shared pointer to data.
- ///
- /// @param[in] offset
- /// The offset into \a data_sp at which the subset starts.
- ///
- /// @param[in] length
- /// The length in bytes of the subset of \a data_sp.
- ///
- /// @return
- /// The number of bytes that this object now contains.
- //------------------------------------------------------------------
- uint32_t
- SetData (const lldb::DataBufferSP& data_sp, uint32_t offset = 0, uint32_t length = UINT32_MAX);
-
- //------------------------------------------------------------------
- /// Set the byte_order value.
- ///
- /// Sets the byte order of the data to extract. Extracted values
- /// will be swapped if necessary when decoding.
- ///
- /// @param[in] byte_order
- /// The byte order value to use when extracting data.
- //------------------------------------------------------------------
- void
- SetByteOrder (lldb::ByteOrder byte_order)
- {
- m_byte_order = byte_order;
- }
-
-
- //------------------------------------------------------------------
- /// Test the validity of \a offset.
- ///
- /// @return
- /// \b true if \a offset is a valid offset into the data in this
- /// object, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ValidOffset (uint32_t offset) const
- {
- return offset < GetByteSize();
- }
-
- //------------------------------------------------------------------
- /// Test the availability of \a length bytes of data from \a offset.
- ///
- /// @return
- /// \b true if \a offset is a valid offset and there are \a
- /// length bytes available at that offset, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ValidOffsetForDataOfSize (uint32_t offset, uint32_t length) const
- {
- return length <= BytesLeft (offset);
- }
-
- uint32_t
- BytesLeft (uint32_t offset) const
- {
- const uint32_t size = GetByteSize();
- if (size > offset)
- return size - offset;
- return 0;
- }
+ //------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// Initialize all members to a default empty state.
+ //------------------------------------------------------------------
+ DataEncoder();
+
+ //------------------------------------------------------------------
+ /// Construct with a buffer that is owned by the caller.
+ ///
+ /// This constructor allows us to use data that is owned by the
+ /// caller. The data must stay around as long as this object is
+ /// valid.
+ ///
+ /// @param[in] data
+ /// A pointer to caller owned data.
+ ///
+ /// @param[in] data_length
+ /// The length in bytes of \a data.
+ ///
+ /// @param[in] byte_order
+ /// A byte order of the data that we are extracting from.
+ ///
+ /// @param[in] addr_size
+ /// A new address byte size value.
+ //------------------------------------------------------------------
+ DataEncoder(void *data, uint32_t data_length, lldb::ByteOrder byte_order,
+ uint8_t addr_size);
+
+ //------------------------------------------------------------------
+ /// Construct with shared data.
+ ///
+ /// Copies the data shared pointer which adds a reference to the
+ /// contained in \a data_sp. The shared data reference is reference
+ /// counted to ensure the data lives as long as anyone still has a
+ /// valid shared pointer to the data in \a data_sp.
+ ///
+ /// @param[in] data_sp
+ /// A shared pointer to data.
+ ///
+ /// @param[in] byte_order
+ /// A byte order of the data that we are extracting from.
+ ///
+ /// @param[in] addr_size
+ /// A new address byte size value.
+ //------------------------------------------------------------------
+ DataEncoder(const lldb::DataBufferSP &data_sp, lldb::ByteOrder byte_order,
+ uint8_t addr_size);
+
+ //------------------------------------------------------------------
+ /// Destructor
+ ///
+ /// If this object contains a valid shared data reference, the
+ /// reference count on the data will be decremented, and if zero,
+ /// the data will be freed.
+ //------------------------------------------------------------------
+ ~DataEncoder();
+
+ //------------------------------------------------------------------
+ /// Clears the object state.
+ ///
+ /// Clears the object contents back to a default invalid state, and
+ /// release any references to shared data that this object may
+ /// contain.
+ //------------------------------------------------------------------
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Get the current address size.
+ ///
+ /// Return the size in bytes of any address values this object will
+ /// extract.
+ ///
+ /// @return
+ /// The size in bytes of address values that will be extracted.
+ //------------------------------------------------------------------
+ uint8_t GetAddressByteSize() const { return m_addr_size; }
+
+ //------------------------------------------------------------------
+ /// Get the number of bytes contained in this object.
+ ///
+ /// @return
+ /// The total number of bytes of data this object refers to.
+ //------------------------------------------------------------------
+ size_t GetByteSize() const { return m_end - m_start; }
+
+ //------------------------------------------------------------------
+ /// Get the data end pointer.
+ ///
+ /// @return
+ /// Returns a pointer to the next byte contained in this
+ /// object's data, or NULL of there is no data in this object.
+ //------------------------------------------------------------------
+ uint8_t *GetDataEnd() { return m_end; }
+
+ const uint8_t *GetDataEnd() const { return m_end; }
+
+ //------------------------------------------------------------------
+ /// Get the shared data offset.
+ ///
+ /// Get the offset of the first byte of data in the shared data (if
+ /// any).
+ ///
+ /// @return
+ /// If this object contains shared data, this function returns
+ /// the offset in bytes into that shared data, zero otherwise.
+ //------------------------------------------------------------------
+ size_t GetSharedDataOffset() const;
+
+ //------------------------------------------------------------------
+ /// Get the current byte order value.
+ ///
+ /// @return
+ /// The current byte order value from this object's internal
+ /// state.
+ //------------------------------------------------------------------
+ lldb::ByteOrder GetByteOrder() const { return m_byte_order; }
+
+ //------------------------------------------------------------------
+ /// Get the data start pointer.
+ ///
+ /// @return
+ /// Returns a pointer to the first byte contained in this
+ /// object's data, or NULL of there is no data in this object.
+ //------------------------------------------------------------------
+ uint8_t *GetDataStart() { return m_start; }
+
+ const uint8_t *GetDataStart() const { return m_start; }
+
+ //------------------------------------------------------------------
+ /// Encode unsigned integer values into the data at \a offset.
+ ///
+ /// @param[in] offset
+ /// The offset within the contained data at which to put the
+ /// data.
+ ///
+ /// @param[in] value
+ /// The value to encode into the data.
+ ///
+ /// @return
+ /// The next offset in the bytes of this data if the data
+ /// was successfully encoded, UINT32_MAX if the encoding failed.
+ //------------------------------------------------------------------
+ uint32_t PutU8(uint32_t offset, uint8_t value);
+
+ uint32_t PutU16(uint32_t offset, uint16_t value);
+
+ uint32_t PutU32(uint32_t offset, uint32_t value);
+
+ uint32_t PutU64(uint32_t offset, uint64_t value);
+
+ //------------------------------------------------------------------
+ /// Encode an unsigned integer of size \a byte_size to \a offset.
+ ///
+ /// Encode a single integer value at \a offset and return the offset
+ /// that follows the newly encoded integer when the data is successfully
+ /// encoded into the existing data. There must be enough room in the
+ /// data, else UINT32_MAX will be returned to indicate that encoding
+ /// failed.
+ ///
+ /// @param[in] offset
+ /// The offset within the contained data at which to put the
+ /// encoded integer.
+ ///
+ /// @param[in] byte_size
+ /// The size in byte of the integer to encode.
+ ///
+ /// @param[in] value
+ /// The integer value to write. The least significant bytes of
+ /// the integer value will be written if the size is less than
+ /// 8 bytes.
+ ///
+ /// @return
+ /// The next offset in the bytes of this data if the integer
+ /// was successfully encoded, UINT32_MAX if the encoding failed.
+ //------------------------------------------------------------------
+ uint32_t PutMaxU64(uint32_t offset, uint32_t byte_size, uint64_t value);
+
+ //------------------------------------------------------------------
+ /// Encode an arbitrary number of bytes.
+ ///
+ /// @param[in] offset
+ /// The offset in bytes into the contained data at which to
+ /// start encoding.
+ ///
+ /// @param[in] src
+ /// The buffer that contains the bytes to encode.
+ ///
+ /// @param[in] src_len
+ /// The number of bytes to encode.
+ ///
+ /// @return
+ /// The next valid offset within data if the put operation
+ /// was successful, else UINT32_MAX to indicate the put failed.
+ //------------------------------------------------------------------
+ uint32_t PutData(uint32_t offset, const void *src, uint32_t src_len);
+
+ //------------------------------------------------------------------
+ /// Encode an address in the existing buffer at \a offset bytes into
+ /// the buffer.
+ ///
+ /// Encode a single address (honoring the m_addr_size member) to
+ /// the data and return the next offset where subsequent data would
+ /// go.
+ /// pointed to by \a offset_ptr. The size of the extracted address
+ /// comes from the \a m_addr_size member variable and should be
+ /// set correctly prior to extracting any address values.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// The next valid offset within data if the put operation
+ /// was successful, else UINT32_MAX to indicate the put failed.
+ //------------------------------------------------------------------
+ uint32_t PutAddress(uint32_t offset, lldb::addr_t addr);
+
+ //------------------------------------------------------------------
+ /// Put a C string to \a offset.
+ ///
+ /// Encodes a C string into the existing data including the
+ /// terminating
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// A pointer to the C string value in the data. If the offset
+ /// pointed to by \a offset_ptr is out of bounds, or if the
+ /// offset plus the length of the C string is out of bounds,
+ /// NULL will be returned.
+ //------------------------------------------------------------------
+ uint32_t PutCString(uint32_t offset_ptr, const char *cstr);
+
+ lldb::DataBufferSP &GetSharedDataBuffer() { return m_data_sp; }
+
+ //------------------------------------------------------------------
+ /// Set the address byte size.
+ ///
+ /// Set the size in bytes that will be used when extracting any
+ /// address and pointer values from data contained in this object.
+ ///
+ /// @param[in] addr_size
+ /// The size in bytes to use when extracting addresses.
+ //------------------------------------------------------------------
+ void SetAddressByteSize(uint8_t addr_size) { m_addr_size = addr_size; }
+
+ //------------------------------------------------------------------
+ /// Set data with a buffer that is caller owned.
+ ///
+ /// Use data that is owned by the caller when extracting values.
+ /// The data must stay around as long as this object, or any object
+ /// that copies a subset of this object's data, is valid. If \a
+ /// bytes is NULL, or \a length is zero, this object will contain
+ /// no data.
+ ///
+ /// @param[in] bytes
+ /// A pointer to caller owned data.
+ ///
+ /// @param[in] length
+ /// The length in bytes of \a bytes.
+ ///
+ /// @param[in] byte_order
+ /// A byte order of the data that we are extracting from.
+ ///
+ /// @return
+ /// The number of bytes that this object now contains.
+ //------------------------------------------------------------------
+ uint32_t SetData(void *bytes, uint32_t length, lldb::ByteOrder byte_order);
+
+ //------------------------------------------------------------------
+ /// Adopt a subset of shared data in \a data_sp.
+ ///
+ /// Copies the data shared pointer which adds a reference to the
+ /// contained in \a data_sp. The shared data reference is reference
+ /// counted to ensure the data lives as long as anyone still has a
+ /// valid shared pointer to the data in \a data_sp. The byte order
+ /// and address byte size settings remain the same. If
+ /// \a offset is not a valid offset in \a data_sp, then no reference
+ /// to the shared data will be added. If there are not \a length
+ /// bytes available in \a data starting at \a offset, the length
+ /// will be truncated to contains as many bytes as possible.
+ ///
+ /// @param[in] data_sp
+ /// A shared pointer to data.
+ ///
+ /// @param[in] offset
+ /// The offset into \a data_sp at which the subset starts.
+ ///
+ /// @param[in] length
+ /// The length in bytes of the subset of \a data_sp.
+ ///
+ /// @return
+ /// The number of bytes that this object now contains.
+ //------------------------------------------------------------------
+ uint32_t SetData(const lldb::DataBufferSP &data_sp, uint32_t offset = 0,
+ uint32_t length = UINT32_MAX);
+
+ //------------------------------------------------------------------
+ /// Set the byte_order value.
+ ///
+ /// Sets the byte order of the data to extract. Extracted values
+ /// will be swapped if necessary when decoding.
+ ///
+ /// @param[in] byte_order
+ /// The byte order value to use when extracting data.
+ //------------------------------------------------------------------
+ void SetByteOrder(lldb::ByteOrder byte_order) { m_byte_order = byte_order; }
+
+ //------------------------------------------------------------------
+ /// Test the validity of \a offset.
+ ///
+ /// @return
+ /// \b true if \a offset is a valid offset into the data in this
+ /// object, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ValidOffset(uint32_t offset) const { return offset < GetByteSize(); }
+
+ //------------------------------------------------------------------
+ /// Test the availability of \a length bytes of data from \a offset.
+ ///
+ /// @return
+ /// \b true if \a offset is a valid offset and there are \a
+ /// length bytes available at that offset, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ValidOffsetForDataOfSize(uint32_t offset, uint32_t length) const {
+ return length <= BytesLeft(offset);
+ }
+
+ uint32_t BytesLeft(uint32_t offset) const {
+ const uint32_t size = GetByteSize();
+ if (size > offset)
+ return size - offset;
+ return 0;
+ }
protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- uint8_t *m_start; ///< A pointer to the first byte of data.
- uint8_t *m_end; ///< A pointer to the byte that is past the end of the data.
- lldb::ByteOrder m_byte_order; ///< The byte order of the data we are extracting from.
- uint8_t m_addr_size; ///< The address size to use when extracting pointers or addresses
- mutable lldb::DataBufferSP m_data_sp; ///< The shared pointer to data that can be shared among multiple instances
-
-private:
- DISALLOW_COPY_AND_ASSIGN (DataEncoder);
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ uint8_t *m_start; ///< A pointer to the first byte of data.
+ uint8_t *m_end; ///< A pointer to the byte that is past the end of the data.
+ lldb::ByteOrder
+ m_byte_order; ///< The byte order of the data we are extracting from.
+ uint8_t m_addr_size; ///< The address size to use when extracting pointers or
+ ///addresses
+ mutable lldb::DataBufferSP m_data_sp; ///< The shared pointer to data that can
+ ///be shared among multiple instances
+private:
+ DISALLOW_COPY_AND_ASSIGN(DataEncoder);
};
} // namespace lldb_private
-#endif // #if defined (__cplusplus)
-#endif // #ifndef liblldb_DataEncoder_h_
+#endif // #if defined (__cplusplus)
+#endif // #ifndef liblldb_DataEncoder_h_
diff --git a/include/lldb/Core/DataExtractor.h b/include/lldb/Core/DataExtractor.h
index 51ecade2d374..89cc00548e46 100644
--- a/include/lldb/Core/DataExtractor.h
+++ b/include/lldb/Core/DataExtractor.h
@@ -38,1305 +38,1215 @@ namespace lldb_private {
///
/// @see DataBuffer
//----------------------------------------------------------------------
-class DataExtractor
-{
+class DataExtractor {
public:
- //------------------------------------------------------------------
- /// @typedef DataExtractor::Type
- /// @brief Type enumerations used in the dump routines.
- /// @see DataExtractor::Dump()
- /// @see DataExtractor::DumpRawHexBytes()
- //------------------------------------------------------------------
- typedef enum
- {
- TypeUInt8, ///< Format output as unsigned 8 bit integers
- TypeChar, ///< Format output as characters
- TypeUInt16, ///< Format output as unsigned 16 bit integers
- TypeUInt32, ///< Format output as unsigned 32 bit integers
- TypeUInt64, ///< Format output as unsigned 64 bit integers
- TypePointer, ///< Format output as pointers
- TypeULEB128, ///< Format output as ULEB128 numbers
- TypeSLEB128 ///< Format output as SLEB128 numbers
- } Type;
-
- static void
- DumpHexBytes (Stream *s,
- const void *src,
- size_t src_len,
- uint32_t bytes_per_line,
- lldb::addr_t base_addr); // Pass LLDB_INVALID_ADDRESS to not show address at start of line
-
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Initialize all members to a default empty state.
- //------------------------------------------------------------------
- DataExtractor ();
-
- //------------------------------------------------------------------
- /// Construct with a buffer that is owned by the caller.
- ///
- /// This constructor allows us to use data that is owned by the
- /// caller. The data must stay around as long as this object is
- /// valid.
- ///
- /// @param[in] data
- /// A pointer to caller owned data.
- ///
- /// @param[in] data_length
- /// The length in bytes of \a data.
- ///
- /// @param[in] byte_order
- /// A byte order of the data that we are extracting from.
- ///
- /// @param[in] addr_size
- /// A new address byte size value.
- ///
- /// @param[in] target_byte_size
- /// A size of a target byte in 8-bit host bytes
- //------------------------------------------------------------------
- DataExtractor (const void* data, lldb::offset_t data_length, lldb::ByteOrder byte_order, uint32_t addr_size, uint32_t target_byte_size = 1);
-
- //------------------------------------------------------------------
- /// Construct with shared data.
- ///
- /// Copies the data shared pointer which adds a reference to the
- /// contained in \a data_sp. The shared data reference is reference
- /// counted to ensure the data lives as long as anyone still has a
- /// valid shared pointer to the data in \a data_sp.
- ///
- /// @param[in] data_sp
- /// A shared pointer to data.
- ///
- /// @param[in] byte_order
- /// A byte order of the data that we are extracting from.
- ///
- /// @param[in] addr_size
- /// A new address byte size value.
- ///
- /// @param[in] target_byte_size
- /// A size of a target byte in 8-bit host bytes
- //------------------------------------------------------------------
- DataExtractor (const lldb::DataBufferSP& data_sp, lldb::ByteOrder byte_order, uint32_t addr_size, uint32_t target_byte_size = 1);
-
- //------------------------------------------------------------------
- /// Construct with a subset of \a data.
- ///
- /// Initialize this object with a subset of the data bytes in \a
- /// data. If \a data contains shared data, then a reference to the
- /// shared data will be added to ensure the shared data stays around
- /// as long as any objects have references to the shared data. The
- /// byte order value and the address size settings are copied from \a
- /// data. If \a offset is not a valid offset in \a data, then no
- /// reference to the shared data will be added. If there are not
- /// \a length bytes available in \a data starting at \a offset,
- /// the length will be truncated to contain as many bytes as
- /// possible.
- ///
- /// @param[in] data
- /// Another DataExtractor object that contains data.
- ///
- /// @param[in] offset
- /// The offset into \a data at which the subset starts.
- ///
- /// @param[in] length
- /// The length in bytes of the subset of data.
- ///
- /// @param[in] target_byte_size
- /// A size of a target byte in 8-bit host bytes
- //------------------------------------------------------------------
- DataExtractor (const DataExtractor& data, lldb::offset_t offset, lldb::offset_t length, uint32_t target_byte_size = 1);
-
- DataExtractor (const DataExtractor& rhs);
-
- //------------------------------------------------------------------
- /// Assignment operator.
- ///
- /// Copies all data, byte order and address size settings from \a rhs into
- /// this object. If \a rhs contains shared data, a reference to that
- /// shared data will be added.
- ///
- /// @param[in] rhs
- /// Another DataExtractor object to copy.
- ///
- /// @return
- /// A const reference to this object.
- //------------------------------------------------------------------
- const DataExtractor&
- operator= (const DataExtractor& rhs);
-
- //------------------------------------------------------------------
- /// Destructor
- ///
- /// If this object contains a valid shared data reference, the
- /// reference count on the data will be decremented, and if zero,
- /// the data will be freed.
- //------------------------------------------------------------------
- ~DataExtractor ();
-
- //------------------------------------------------------------------
- /// Clears the object state.
- ///
- /// Clears the object contents back to a default invalid state, and
- /// release any references to shared data that this object may
- /// contain.
- //------------------------------------------------------------------
- void
- Clear ();
-
- //------------------------------------------------------------------
- /// Dumps the binary data as \a type objects to stream \a s (or to
- /// Log() if \a s is nullptr) starting \a offset bytes into the data
- /// and stopping after dumping \a length bytes. The offset into the
- /// data is displayed at the beginning of each line and can be
- /// offset by base address \a base_addr. \a num_per_line objects
- /// will be displayed on each line.
- ///
- /// @param[in] s
- /// The stream to dump the output to. If nullptr the output will
- /// be dumped to Log().
- ///
- /// @param[in] offset
- /// The offset into the data at which to start dumping.
- ///
- /// @param[in] length
- /// The number of bytes to dump.
- ///
- /// @param[in] base_addr
- /// The base address that gets added to the offset displayed on
- /// each line.
- ///
- /// @param[in] num_per_line
- /// The number of \a type objects to display on each line.
- ///
- /// @param[in] type
- /// The type of objects to use when dumping data from this
- /// object. See DataExtractor::Type.
- ///
- /// @param[in] type_format
- /// The optional format to use for the \a type objects. If this
- /// is nullptr, the default format for the \a type will be used.
- ///
- /// @return
- /// The offset at which dumping ended.
- //------------------------------------------------------------------
- lldb::offset_t
- PutToLog(Log *log,
- lldb::offset_t offset,
- lldb::offset_t length,
- uint64_t base_addr,
- uint32_t num_per_line,
- Type type,
- const char *type_format = nullptr) const;
-
- //------------------------------------------------------------------
- /// Dumps \a item_count objects into the stream \a s.
- ///
- /// Dumps \a item_count objects using \a item_format, each of which
- /// are \a item_byte_size bytes long starting at offset \a offset
- /// bytes into the contained data, into the stream \a s. \a
- /// num_per_line objects will be dumped on each line before a new
- /// line will be output. If \a base_addr is a valid address, then
- /// each new line of output will be preceded by the address value
- /// plus appropriate offset, and a colon and space. Bitfield values
- /// can be dumped by calling this function multiple times with the
- /// same start offset, format and size, yet differing \a
- /// item_bit_size and \a item_bit_offset values.
- ///
- /// @param[in] s
- /// The stream to dump the output to. This value can not be nullptr.
- ///
- /// @param[in] offset
- /// The offset into the data at which to start dumping.
- ///
- /// @param[in] item_format
- /// The format to use when dumping each item.
- ///
- /// @param[in] item_byte_size
- /// The byte size of each item.
- ///
- /// @param[in] item_count
- /// The number of items to dump.
- ///
- /// @param[in] num_per_line
- /// The number of items to display on each line.
- ///
- /// @param[in] base_addr
- /// The base address that gets added to the offset displayed on
- /// each line if the value is valid. Is \a base_addr is
- /// LLDB_INVALID_ADDRESS then no address values will be prepended
- /// to any lines.
- ///
- /// @param[in] item_bit_size
- /// If the value to display is a bitfield, this value should
- /// be the number of bits that the bitfield item has within the
- /// item's byte size value. This function will need to be called
- /// multiple times with identical \a offset and \a item_byte_size
- /// values in order to display multiple bitfield values that
- /// exist within the same integer value. If the items being
- /// displayed are not bitfields, this value should be zero.
- ///
- /// @param[in] item_bit_offset
- /// If the value to display is a bitfield, this value should
- /// be the offset in bits, or shift right amount, that the
- /// bitfield item occupies within the item's byte size value.
- /// This function will need to be called multiple times with
- /// identical \a offset and \a item_byte_size values in order
- /// to display multiple bitfield values that exist within the
- /// same integer value. If the items being displayed are not
- /// bitfields, this value should be zero.
- ///
- /// @return
- /// The offset at which dumping ended.
- //------------------------------------------------------------------
- lldb::offset_t
- Dump(Stream *s,
- lldb::offset_t offset,
- lldb::Format item_format,
- size_t item_byte_size,
- size_t item_count,
- size_t num_per_line,
- uint64_t base_addr,
- uint32_t item_bit_size,
- uint32_t item_bit_offset,
- ExecutionContextScope *exe_scope = nullptr) const;
-
- //------------------------------------------------------------------
- /// Dump a UUID value at \a offset.
- ///
- /// Dump a UUID starting at \a offset bytes into this object's data.
- /// If the stream \a s is nullptr, the output will be sent to Log().
- ///
- /// @param[in] s
- /// The stream to dump the output to. If nullptr the output will
- /// be dumped to Log().
- ///
- /// @param[in] offset
- /// The offset into the data at which to extract and dump a
- /// UUID value.
- //------------------------------------------------------------------
- void
- DumpUUID (Stream *s, lldb::offset_t offset) const;
-
- //------------------------------------------------------------------
- /// Extract an arbitrary number of bytes in the specified byte
- /// order.
- ///
- /// Attemps to extract \a length bytes starting at \a offset bytes
- /// into this data in the requested byte order (\a dst_byte_order)
- /// and place the results in \a dst. \a dst must be at least \a
- /// length bytes long.
- ///
- /// @param[in] offset
- /// The offset in bytes into the contained data at which to
- /// start extracting.
- ///
- /// @param[in] length
- /// The number of bytes to extract.
- ///
- /// @param[in] dst_byte_order
- /// A byte order of the data that we want when the value in
- /// copied to \a dst.
- ///
- /// @param[out] dst
- /// The buffer that will receive the extracted value if there
- /// are enough bytes available in the current data.
- ///
- /// @return
- /// The number of bytes that were extracted which will be \a
- /// length when the value is successfully extracted, or zero
- /// if there aren't enough bytes at the specified offset.
- //------------------------------------------------------------------
- size_t
- ExtractBytes (lldb::offset_t offset, lldb::offset_t length, lldb::ByteOrder dst_byte_order, void *dst) const;
-
- //------------------------------------------------------------------
- /// Extract an address from \a *offset_ptr.
- ///
- /// Extract a single address from the data and update the offset
- /// pointed to by \a offset_ptr. The size of the extracted address
- /// comes from the \a m_addr_size member variable and should be
- /// set correctly prior to extracting any address values.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// The extracted address value.
- //------------------------------------------------------------------
- uint64_t
- GetAddress (lldb::offset_t *offset_ptr) const;
-
- uint64_t
- GetAddress_unchecked (lldb::offset_t *offset_ptr) const;
-
- //------------------------------------------------------------------
- /// Get the current address size.
- ///
- /// Return the size in bytes of any address values this object will
- /// extract.
- ///
- /// @return
- /// The size in bytes of address values that will be extracted.
- //------------------------------------------------------------------
- uint32_t
- GetAddressByteSize () const
- {
- return m_addr_size;
- }
-
- //------------------------------------------------------------------
- /// Get the number of bytes contained in this object.
- ///
- /// @return
- /// The total number of bytes of data this object refers to.
- //------------------------------------------------------------------
- uint64_t
- GetByteSize () const
- {
- return m_end - m_start;
- }
-
- //------------------------------------------------------------------
- /// Extract a C string from \a *offset_ptr.
- ///
- /// Returns a pointer to a C String from the data at the offset
- /// pointed to by \a offset_ptr. A variable length NULL terminated C
- /// string will be extracted and the \a offset_ptr will be
- /// updated with the offset of the byte that follows the NULL
- /// terminator byte.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// A pointer to the C string value in the data. If the offset
- /// pointed to by \a offset_ptr is out of bounds, or if the
- /// offset plus the length of the C string is out of bounds,
- /// nullptr will be returned.
- //------------------------------------------------------------------
- const char *
- GetCStr (lldb::offset_t *offset_ptr) const;
-
- //------------------------------------------------------------------
- /// Extract a C string from \a *offset_ptr with field size \a len.
- ///
- /// Returns a pointer to a C String from the data at the offset
- /// pointed to by \a offset_ptr, with a field length of \a len.
- /// A NULL terminated C string will be extracted and the \a offset_ptr
- /// will be updated with the offset of the byte that follows the fixed
- /// length field.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// A pointer to the C string value in the data. If the offset
- /// pointed to by \a offset_ptr is out of bounds, or if the
- /// offset plus the length of the field is out of bounds, or if
- /// the field does not contain a NULL terminator byte, nullptr will
- /// be returned.
- const char *
- GetCStr (lldb::offset_t *offset_ptr, lldb::offset_t len) const;
-
- //------------------------------------------------------------------
- /// Extract \a length bytes from \a *offset_ptr.
- ///
- /// Returns a pointer to a bytes in this object's data at the offset
- /// pointed to by \a offset_ptr. If \a length is zero or too large,
- /// then the offset pointed to by \a offset_ptr will not be updated
- /// and nullptr will be returned.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @param[in] length
- /// The optional length of a string to extract. If the value is
- /// zero, a NULL terminated C string will be extracted.
- ///
- /// @return
- /// A pointer to the bytes in this object's data if the offset
- /// and length are valid, or nullptr otherwise.
- //------------------------------------------------------------------
- const void*
- GetData (lldb::offset_t *offset_ptr, lldb::offset_t length) const
- {
- const uint8_t *ptr = PeekData (*offset_ptr, length);
- if (ptr)
- *offset_ptr += length;
- return ptr;
- }
-
- //------------------------------------------------------------------
- /// Copy \a length bytes from \a *offset, without swapping bytes.
- ///
- /// @param[in] offset
- /// The offset into this data from which to start copying
- ///
- /// @param[in] length
- /// The length of the data to copy from this object
- ///
- /// @param[out] dst
- /// The buffer to place the output data.
- ///
- /// @return
- /// Returns the number of bytes that were copied, or zero if
- /// anything goes wrong.
- //------------------------------------------------------------------
- lldb::offset_t
- CopyData (lldb::offset_t offset,
- lldb::offset_t length,
- void *dst) const;
-
- //------------------------------------------------------------------
- /// Copy \a dst_len bytes from \a *offset_ptr and ensure the copied
- /// data is treated as a value that can be swapped to match the
- /// specified byte order.
- ///
- /// For values that are larger than the supported integer sizes,
- /// this function can be used to extract data in a specified byte
- /// order. It can also be used to copy a smaller integer value from
- /// to a larger value. The extra bytes left over will be padded
- /// correctly according to the byte order of this object and the
- /// \a dst_byte_order. This can be very handy when say copying a
- /// partial data value into a register.
- ///
- /// @param[in] src_offset
- /// The offset into this data from which to start copying an
- /// endian entity
- ///
- /// @param[in] src_len
- /// The length of the endian data to copy from this object
- /// into the \a dst object
- ///
- /// @param[out] dst
- /// The buffer where to place the endian data. The data might
- /// need to be byte swapped (and appropriately padded with
- /// zeroes if \a src_len != \a dst_len) if \a dst_byte_order
- /// does not match the byte order in this object.
- ///
- /// @param[in] dst_len
- /// The length number of bytes that the endian value will
- /// occupy is \a dst.
- ///
- /// @param[in] byte_order
- /// The byte order that the endian value should be in the \a dst
- /// buffer.
- ///
- /// @return
- /// Returns the number of bytes that were copied, or zero if
- /// anything goes wrong.
- //------------------------------------------------------------------
- lldb::offset_t
- CopyByteOrderedData (lldb::offset_t src_offset,
- lldb::offset_t src_len,
- void *dst,
- lldb::offset_t dst_len,
- lldb::ByteOrder dst_byte_order) const;
-
- //------------------------------------------------------------------
- /// Get the data end pointer.
- ///
- /// @return
- /// Returns a pointer to the next byte contained in this
- /// object's data, or nullptr of there is no data in this object.
- //------------------------------------------------------------------
- const uint8_t *
- GetDataEnd () const
- {
- return m_end;
- }
-
- //------------------------------------------------------------------
- /// Get the shared data offset.
- ///
- /// Get the offset of the first byte of data in the shared data (if
- /// any).
- ///
- /// @return
- /// If this object contains shared data, this function returns
- /// the offset in bytes into that shared data, zero otherwise.
- //------------------------------------------------------------------
- size_t
- GetSharedDataOffset () const;
-
- //------------------------------------------------------------------
- /// Get the data start pointer.
- ///
- /// @return
- /// Returns a pointer to the first byte contained in this
- /// object's data, or nullptr of there is no data in this object.
- //------------------------------------------------------------------
- const uint8_t *
- GetDataStart () const
- {
- return m_start;
- }
-
- //------------------------------------------------------------------
- /// Extract a float from \a *offset_ptr.
- ///
- /// Extract a single float value.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// The floating value that was extracted, or zero on failure.
- //------------------------------------------------------------------
- float
- GetFloat (lldb::offset_t *offset_ptr) const;
-
- double
- GetDouble (lldb::offset_t *offset_ptr) const;
-
- long double
- GetLongDouble (lldb::offset_t *offset_ptr) const;
-
- //------------------------------------------------------------------
- /// Extract a GNU encoded pointer value from \a *offset_ptr.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @param[in] eh_ptr_enc
- /// The GNU pointer encoding type.
- ///
- /// @param[in] pc_rel_addr
- /// The PC relative address to use when the encoding is
- /// \c DW_GNU_EH_PE_pcrel.
- ///
- /// @param[in] text_addr
- /// The text (code) relative address to use when the encoding is
- /// \c DW_GNU_EH_PE_textrel.
- ///
- /// @param[in] data_addr
- /// The data relative address to use when the encoding is
- /// \c DW_GNU_EH_PE_datarel.
- ///
- /// @return
- /// The extracted GNU encoded pointer value.
- //------------------------------------------------------------------
- uint64_t
- GetGNUEHPointer (lldb::offset_t *offset_ptr,
- uint32_t eh_ptr_enc,
- lldb::addr_t pc_rel_addr,
- lldb::addr_t text_addr,
- lldb::addr_t data_addr);
-
- //------------------------------------------------------------------
- /// Extract an integer of size \a byte_size from \a *offset_ptr.
- ///
- /// Extract a single integer value and update the offset pointed to
- /// by \a offset_ptr. The size of the extracted integer is specified
- /// by the \a byte_size argument. \a byte_size should have a value
- /// >= 1 and <= 4 since the return value is only 32 bits wide. Any
- /// \a byte_size values less than 1 or greater than 4 will result in
- /// nothing being extracted, and zero being returned.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @param[in] byte_size
- /// The size in byte of the integer to extract.
- ///
- /// @return
- /// The integer value that was extracted, or zero on failure.
- //------------------------------------------------------------------
- uint32_t
- GetMaxU32 (lldb::offset_t *offset_ptr, size_t byte_size) const;
-
- //------------------------------------------------------------------
- /// Extract an unsigned integer of size \a byte_size from \a
- /// *offset_ptr.
- ///
- /// Extract a single unsigned integer value and update the offset
- /// pointed to by \a offset_ptr. The size of the extracted integer
- /// is specified by the \a byte_size argument. \a byte_size should
- /// have a value greater than or equal to one and less than or equal
- /// to eight since the return value is 64 bits wide. Any
- /// \a byte_size values less than 1 or greater than 8 will result in
- /// nothing being extracted, and zero being returned.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @param[in] byte_size
- /// The size in byte of the integer to extract.
- ///
- /// @return
- /// The unsigned integer value that was extracted, or zero on
- /// failure.
- //------------------------------------------------------------------
- uint64_t
- GetMaxU64 (lldb::offset_t *offset_ptr, size_t byte_size) const;
-
- uint64_t
- GetMaxU64_unchecked (lldb::offset_t *offset_ptr, size_t byte_size) const;
-
- //------------------------------------------------------------------
- /// Extract an signed integer of size \a byte_size from \a *offset_ptr.
- ///
- /// Extract a single signed integer value (sign extending if required)
- /// and update the offset pointed to by \a offset_ptr. The size of
- /// the extracted integer is specified by the \a byte_size argument.
- /// \a byte_size should have a value greater than or equal to one
- /// and less than or equal to eight since the return value is 64
- /// bits wide. Any \a byte_size values less than 1 or greater than
- /// 8 will result in nothing being extracted, and zero being returned.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @param[in] byte_size
- /// The size in byte of the integer to extract.
- ///
- /// @return
- /// The sign extended signed integer value that was extracted,
- /// or zero on failure.
- //------------------------------------------------------------------
- int64_t
- GetMaxS64 (lldb::offset_t *offset_ptr, size_t size) const;
-
- //------------------------------------------------------------------
- /// Extract an unsigned integer of size \a byte_size from \a
- /// *offset_ptr, then extract the bitfield from this value if
- /// \a bitfield_bit_size is non-zero.
- ///
- /// Extract a single unsigned integer value and update the offset
- /// pointed to by \a offset_ptr. The size of the extracted integer
- /// is specified by the \a byte_size argument. \a byte_size should
- /// have a value greater than or equal to one and less than or equal
- /// to 8 since the return value is 64 bits wide. Any
- /// \a byte_size values less than 1 or greater than 8 will result in
- /// nothing being extracted, and zero being returned.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @param[in] byte_size
- /// The size in byte of the integer to extract.
- ///
- /// @param[in] bitfield_bit_size
- /// The size in bits of the bitfield value to extract, or zero
- /// to just extract the entire integer value.
- ///
- /// @param[in] bitfield_bit_offset
- /// The bit offset of the bitfield value in the extracted
- /// integer. For little-endian data, this is the offset of
- /// the LSB of the bitfield from the LSB of the integer.
- /// For big-endian data, this is the offset of the MSB of the
- /// bitfield from the MSB of the integer.
- ///
- /// @return
- /// The unsigned bitfield integer value that was extracted, or
- /// zero on failure.
- //------------------------------------------------------------------
- uint64_t
- GetMaxU64Bitfield (lldb::offset_t *offset_ptr,
- size_t size,
- uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset) const;
-
- //------------------------------------------------------------------
- /// Extract an signed integer of size \a byte_size from \a
- /// *offset_ptr, then extract and signe extend the bitfield from
- /// this value if \a bitfield_bit_size is non-zero.
- ///
- /// Extract a single signed integer value (sign extending if required)
- /// and update the offset pointed to by \a offset_ptr. The size of
- /// the extracted integer is specified by the \a byte_size argument.
- /// \a byte_size should have a value greater than or equal to one
- /// and less than or equal to eight since the return value is 64
- /// bits wide. Any \a byte_size values less than 1 or greater than
- /// 8 will result in nothing being extracted, and zero being returned.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @param[in] byte_size
- /// The size in bytes of the integer to extract.
- ///
- /// @param[in] bitfield_bit_size
- /// The size in bits of the bitfield value to extract, or zero
- /// to just extract the entire integer value.
- ///
- /// @param[in] bitfield_bit_offset
- /// The bit offset of the bitfield value in the extracted
- /// integer. For little-endian data, this is the offset of
- /// the LSB of the bitfield from the LSB of the integer.
- /// For big-endian data, this is the offset of the MSB of the
- /// bitfield from the MSB of the integer.
- ///
- /// @return
- /// The signed bitfield integer value that was extracted, or
- /// zero on failure.
- //------------------------------------------------------------------
- int64_t
- GetMaxS64Bitfield (lldb::offset_t *offset_ptr,
- size_t size,
- uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset) const;
-
- //------------------------------------------------------------------
- /// Extract an pointer from \a *offset_ptr.
- ///
- /// Extract a single pointer from the data and update the offset
- /// pointed to by \a offset_ptr. The size of the extracted pointer
- /// comes from the \a m_addr_size member variable and should be
- /// set correctly prior to extracting any pointer values.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// The extracted pointer value as a 64 integer.
- //------------------------------------------------------------------
- uint64_t
- GetPointer (lldb::offset_t *offset_ptr) const;
-
- //------------------------------------------------------------------
- /// Get the current byte order value.
- ///
- /// @return
- /// The current byte order value from this object's internal
- /// state.
- //------------------------------------------------------------------
- lldb::ByteOrder
- GetByteOrder() const
- {
- return m_byte_order;
- }
-
- //------------------------------------------------------------------
- /// Extract a uint8_t value from \a *offset_ptr.
- ///
- /// Extract a single uint8_t from the binary data at the offset
- /// pointed to by \a offset_ptr, and advance the offset on success.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// The extracted uint8_t value.
- //------------------------------------------------------------------
- uint8_t
- GetU8 ( lldb::offset_t *offset_ptr) const;
-
- uint8_t
- GetU8_unchecked (lldb::offset_t *offset_ptr) const
- {
- uint8_t val = m_start[*offset_ptr];
- *offset_ptr += 1;
- return val;
- }
-
- uint16_t
- GetU16_unchecked (lldb::offset_t *offset_ptr) const;
-
- uint32_t
- GetU32_unchecked (lldb::offset_t *offset_ptr) const;
-
- uint64_t
- GetU64_unchecked (lldb::offset_t *offset_ptr) const;
- //------------------------------------------------------------------
- /// Extract \a count uint8_t values from \a *offset_ptr.
- ///
- /// Extract \a count uint8_t values from the binary data at the
- /// offset pointed to by \a offset_ptr, and advance the offset on
- /// success. The extracted values are copied into \a dst.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @param[out] dst
- /// A buffer to copy \a count uint8_t values into. \a dst must
- /// be large enough to hold all requested data.
- ///
- /// @param[in] count
- /// The number of uint8_t values to extract.
- ///
- /// @return
- /// \a dst if all values were properly extracted and copied,
- /// nullptr otherwise.
- //------------------------------------------------------------------
- void *
- GetU8 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;
-
- //------------------------------------------------------------------
- /// Extract a uint16_t value from \a *offset_ptr.
- ///
- /// Extract a single uint16_t from the binary data at the offset
- /// pointed to by \a offset_ptr, and update the offset on success.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// The extracted uint16_t value.
- //------------------------------------------------------------------
- uint16_t
- GetU16 (lldb::offset_t *offset_ptr) const;
-
- //------------------------------------------------------------------
- /// Extract \a count uint16_t values from \a *offset_ptr.
- ///
- /// Extract \a count uint16_t values from the binary data at the
- /// offset pointed to by \a offset_ptr, and advance the offset on
- /// success. The extracted values are copied into \a dst.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @param[out] dst
- /// A buffer to copy \a count uint16_t values into. \a dst must
- /// be large enough to hold all requested data.
- ///
- /// @param[in] count
- /// The number of uint16_t values to extract.
- ///
- /// @return
- /// \a dst if all values were properly extracted and copied,
- /// nullptr otherwise.
- //------------------------------------------------------------------
- void *
- GetU16 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;
-
- //------------------------------------------------------------------
- /// Extract a uint32_t value from \a *offset_ptr.
- ///
- /// Extract a single uint32_t from the binary data at the offset
- /// pointed to by \a offset_ptr, and update the offset on success.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// The extracted uint32_t value.
- //------------------------------------------------------------------
- uint32_t
- GetU32 (lldb::offset_t *offset_ptr) const;
-
- //------------------------------------------------------------------
- /// Extract \a count uint32_t values from \a *offset_ptr.
- ///
- /// Extract \a count uint32_t values from the binary data at the
- /// offset pointed to by \a offset_ptr, and advance the offset on
- /// success. The extracted values are copied into \a dst.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @param[out] dst
- /// A buffer to copy \a count uint32_t values into. \a dst must
- /// be large enough to hold all requested data.
- ///
- /// @param[in] count
- /// The number of uint32_t values to extract.
- ///
- /// @return
- /// \a dst if all values were properly extracted and copied,
- /// nullptr otherwise.
- //------------------------------------------------------------------
- void *
- GetU32 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;
-
- //------------------------------------------------------------------
- /// Extract a uint64_t value from \a *offset_ptr.
- ///
- /// Extract a single uint64_t from the binary data at the offset
- /// pointed to by \a offset_ptr, and update the offset on success.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// The extracted uint64_t value.
- //------------------------------------------------------------------
- uint64_t
- GetU64 (lldb::offset_t *offset_ptr) const;
-
- //------------------------------------------------------------------
- /// Extract \a count uint64_t values from \a *offset_ptr.
- ///
- /// Extract \a count uint64_t values from the binary data at the
- /// offset pointed to by \a offset_ptr, and advance the offset on
- /// success. The extracted values are copied into \a dst.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @param[out] dst
- /// A buffer to copy \a count uint64_t values into. \a dst must
- /// be large enough to hold all requested data.
- ///
- /// @param[in] count
- /// The number of uint64_t values to extract.
- ///
- /// @return
- /// \a dst if all values were properly extracted and copied,
- /// nullptr otherwise.
- //------------------------------------------------------------------
- void *
- GetU64 ( lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;
-
- //------------------------------------------------------------------
- /// Extract a signed LEB128 value from \a *offset_ptr.
- ///
- /// Extracts an signed LEB128 number from this object's data
- /// starting at the offset pointed to by \a offset_ptr. The offset
- /// pointed to by \a offset_ptr will be updated with the offset of
- /// the byte following the last extracted byte.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// The extracted signed integer value.
- //------------------------------------------------------------------
- int64_t
- GetSLEB128 (lldb::offset_t *offset_ptr) const;
-
- //------------------------------------------------------------------
- /// Extract a unsigned LEB128 value from \a *offset_ptr.
- ///
- /// Extracts an unsigned LEB128 number from this object's data
- /// starting at the offset pointed to by \a offset_ptr. The offset
- /// pointed to by \a offset_ptr will be updated with the offset of
- /// the byte following the last extracted byte.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// The extracted unsigned integer value.
- //------------------------------------------------------------------
- uint64_t
- GetULEB128 (lldb::offset_t *offset_ptr) const;
-
- lldb::DataBufferSP &
- GetSharedDataBuffer ()
- {
- return m_data_sp;
- }
-
- //------------------------------------------------------------------
- /// Peek at a C string at \a offset.
- ///
- /// Peeks at a string in the contained data. No verification is done
- /// to make sure the entire string lies within the bounds of this
- /// object's data, only \a offset is verified to be a valid offset.
- ///
- /// @param[in] offset
- /// An offset into the data.
- ///
- /// @return
- /// A non-nullptr C string pointer if \a offset is a valid offset,
- /// nullptr otherwise.
- //------------------------------------------------------------------
- const char *
- PeekCStr (lldb::offset_t offset) const;
-
- //------------------------------------------------------------------
- /// Peek at a bytes at \a offset.
- ///
- /// Returns a pointer to \a length bytes at \a offset as long as
- /// there are \a length bytes available starting at \a offset.
- ///
- /// @return
- /// A non-nullptr data pointer if \a offset is a valid offset and
- /// there are \a length bytes available at that offset, nullptr
- /// otherwise.
- //------------------------------------------------------------------
- const uint8_t*
- PeekData (lldb::offset_t offset, lldb::offset_t length) const
- {
- if (length > 0 && ValidOffsetForDataOfSize(offset, length))
- return m_start + offset;
- return nullptr;
- }
-
- //------------------------------------------------------------------
- /// Set the address byte size.
- ///
- /// Set the size in bytes that will be used when extracting any
- /// address and pointer values from data contained in this object.
- ///
- /// @param[in] addr_size
- /// The size in bytes to use when extracting addresses.
- //------------------------------------------------------------------
- void
- SetAddressByteSize (uint32_t addr_size)
- {
+ //------------------------------------------------------------------
+ /// @typedef DataExtractor::Type
+ /// @brief Type enumerations used in the dump routines.
+ /// @see DataExtractor::Dump()
+ /// @see DataExtractor::DumpRawHexBytes()
+ //------------------------------------------------------------------
+ typedef enum {
+ TypeUInt8, ///< Format output as unsigned 8 bit integers
+ TypeChar, ///< Format output as characters
+ TypeUInt16, ///< Format output as unsigned 16 bit integers
+ TypeUInt32, ///< Format output as unsigned 32 bit integers
+ TypeUInt64, ///< Format output as unsigned 64 bit integers
+ TypePointer, ///< Format output as pointers
+ TypeULEB128, ///< Format output as ULEB128 numbers
+ TypeSLEB128 ///< Format output as SLEB128 numbers
+ } Type;
+
+ static void DumpHexBytes(Stream *s, const void *src, size_t src_len,
+ uint32_t bytes_per_line,
+ lldb::addr_t base_addr); // Pass LLDB_INVALID_ADDRESS
+ // to not show address at
+ // start of line
+
+ //------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// Initialize all members to a default empty state.
+ //------------------------------------------------------------------
+ DataExtractor();
+
+ //------------------------------------------------------------------
+ /// Construct with a buffer that is owned by the caller.
+ ///
+ /// This constructor allows us to use data that is owned by the
+ /// caller. The data must stay around as long as this object is
+ /// valid.
+ ///
+ /// @param[in] data
+ /// A pointer to caller owned data.
+ ///
+ /// @param[in] data_length
+ /// The length in bytes of \a data.
+ ///
+ /// @param[in] byte_order
+ /// A byte order of the data that we are extracting from.
+ ///
+ /// @param[in] addr_size
+ /// A new address byte size value.
+ ///
+ /// @param[in] target_byte_size
+ /// A size of a target byte in 8-bit host bytes
+ //------------------------------------------------------------------
+ DataExtractor(const void *data, lldb::offset_t data_length,
+ lldb::ByteOrder byte_order, uint32_t addr_size,
+ uint32_t target_byte_size = 1);
+
+ //------------------------------------------------------------------
+ /// Construct with shared data.
+ ///
+ /// Copies the data shared pointer which adds a reference to the
+ /// contained in \a data_sp. The shared data reference is reference
+ /// counted to ensure the data lives as long as anyone still has a
+ /// valid shared pointer to the data in \a data_sp.
+ ///
+ /// @param[in] data_sp
+ /// A shared pointer to data.
+ ///
+ /// @param[in] byte_order
+ /// A byte order of the data that we are extracting from.
+ ///
+ /// @param[in] addr_size
+ /// A new address byte size value.
+ ///
+ /// @param[in] target_byte_size
+ /// A size of a target byte in 8-bit host bytes
+ //------------------------------------------------------------------
+ DataExtractor(const lldb::DataBufferSP &data_sp, lldb::ByteOrder byte_order,
+ uint32_t addr_size, uint32_t target_byte_size = 1);
+
+ //------------------------------------------------------------------
+ /// Construct with a subset of \a data.
+ ///
+ /// Initialize this object with a subset of the data bytes in \a
+ /// data. If \a data contains shared data, then a reference to the
+ /// shared data will be added to ensure the shared data stays around
+ /// as long as any objects have references to the shared data. The
+ /// byte order value and the address size settings are copied from \a
+ /// data. If \a offset is not a valid offset in \a data, then no
+ /// reference to the shared data will be added. If there are not
+ /// \a length bytes available in \a data starting at \a offset,
+ /// the length will be truncated to contain as many bytes as
+ /// possible.
+ ///
+ /// @param[in] data
+ /// Another DataExtractor object that contains data.
+ ///
+ /// @param[in] offset
+ /// The offset into \a data at which the subset starts.
+ ///
+ /// @param[in] length
+ /// The length in bytes of the subset of data.
+ ///
+ /// @param[in] target_byte_size
+ /// A size of a target byte in 8-bit host bytes
+ //------------------------------------------------------------------
+ DataExtractor(const DataExtractor &data, lldb::offset_t offset,
+ lldb::offset_t length, uint32_t target_byte_size = 1);
+
+ DataExtractor(const DataExtractor &rhs);
+
+ //------------------------------------------------------------------
+ /// Assignment operator.
+ ///
+ /// Copies all data, byte order and address size settings from \a rhs into
+ /// this object. If \a rhs contains shared data, a reference to that
+ /// shared data will be added.
+ ///
+ /// @param[in] rhs
+ /// Another DataExtractor object to copy.
+ ///
+ /// @return
+ /// A const reference to this object.
+ //------------------------------------------------------------------
+ const DataExtractor &operator=(const DataExtractor &rhs);
+
+ //------------------------------------------------------------------
+ /// Destructor
+ ///
+ /// If this object contains a valid shared data reference, the
+ /// reference count on the data will be decremented, and if zero,
+ /// the data will be freed.
+ //------------------------------------------------------------------
+ ~DataExtractor();
+
+ //------------------------------------------------------------------
+ /// Clears the object state.
+ ///
+ /// Clears the object contents back to a default invalid state, and
+ /// release any references to shared data that this object may
+ /// contain.
+ //------------------------------------------------------------------
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Dumps the binary data as \a type objects to stream \a s (or to
+ /// Log() if \a s is nullptr) starting \a offset bytes into the data
+ /// and stopping after dumping \a length bytes. The offset into the
+ /// data is displayed at the beginning of each line and can be
+ /// offset by base address \a base_addr. \a num_per_line objects
+ /// will be displayed on each line.
+ ///
+ /// @param[in] s
+ /// The stream to dump the output to. If nullptr the output will
+ /// be dumped to Log().
+ ///
+ /// @param[in] offset
+ /// The offset into the data at which to start dumping.
+ ///
+ /// @param[in] length
+ /// The number of bytes to dump.
+ ///
+ /// @param[in] base_addr
+ /// The base address that gets added to the offset displayed on
+ /// each line.
+ ///
+ /// @param[in] num_per_line
+ /// The number of \a type objects to display on each line.
+ ///
+ /// @param[in] type
+ /// The type of objects to use when dumping data from this
+ /// object. See DataExtractor::Type.
+ ///
+ /// @param[in] type_format
+ /// The optional format to use for the \a type objects. If this
+ /// is nullptr, the default format for the \a type will be used.
+ ///
+ /// @return
+ /// The offset at which dumping ended.
+ //------------------------------------------------------------------
+ lldb::offset_t PutToLog(Log *log, lldb::offset_t offset,
+ lldb::offset_t length, uint64_t base_addr,
+ uint32_t num_per_line, Type type,
+ const char *type_format = nullptr) const;
+
+ //------------------------------------------------------------------
+ /// Dumps \a item_count objects into the stream \a s.
+ ///
+ /// Dumps \a item_count objects using \a item_format, each of which
+ /// are \a item_byte_size bytes long starting at offset \a offset
+ /// bytes into the contained data, into the stream \a s. \a
+ /// num_per_line objects will be dumped on each line before a new
+ /// line will be output. If \a base_addr is a valid address, then
+ /// each new line of output will be preceded by the address value
+ /// plus appropriate offset, and a colon and space. Bitfield values
+ /// can be dumped by calling this function multiple times with the
+ /// same start offset, format and size, yet differing \a
+ /// item_bit_size and \a item_bit_offset values.
+ ///
+ /// @param[in] s
+ /// The stream to dump the output to. This value can not be nullptr.
+ ///
+ /// @param[in] offset
+ /// The offset into the data at which to start dumping.
+ ///
+ /// @param[in] item_format
+ /// The format to use when dumping each item.
+ ///
+ /// @param[in] item_byte_size
+ /// The byte size of each item.
+ ///
+ /// @param[in] item_count
+ /// The number of items to dump.
+ ///
+ /// @param[in] num_per_line
+ /// The number of items to display on each line.
+ ///
+ /// @param[in] base_addr
+ /// The base address that gets added to the offset displayed on
+ /// each line if the value is valid. Is \a base_addr is
+ /// LLDB_INVALID_ADDRESS then no address values will be prepended
+ /// to any lines.
+ ///
+ /// @param[in] item_bit_size
+ /// If the value to display is a bitfield, this value should
+ /// be the number of bits that the bitfield item has within the
+ /// item's byte size value. This function will need to be called
+ /// multiple times with identical \a offset and \a item_byte_size
+ /// values in order to display multiple bitfield values that
+ /// exist within the same integer value. If the items being
+ /// displayed are not bitfields, this value should be zero.
+ ///
+ /// @param[in] item_bit_offset
+ /// If the value to display is a bitfield, this value should
+ /// be the offset in bits, or shift right amount, that the
+ /// bitfield item occupies within the item's byte size value.
+ /// This function will need to be called multiple times with
+ /// identical \a offset and \a item_byte_size values in order
+ /// to display multiple bitfield values that exist within the
+ /// same integer value. If the items being displayed are not
+ /// bitfields, this value should be zero.
+ ///
+ /// @return
+ /// The offset at which dumping ended.
+ //------------------------------------------------------------------
+ lldb::offset_t Dump(Stream *s, lldb::offset_t offset,
+ lldb::Format item_format, size_t item_byte_size,
+ size_t item_count, size_t num_per_line,
+ uint64_t base_addr, uint32_t item_bit_size,
+ uint32_t item_bit_offset,
+ ExecutionContextScope *exe_scope = nullptr) const;
+
+ //------------------------------------------------------------------
+ /// Dump a UUID value at \a offset.
+ ///
+ /// Dump a UUID starting at \a offset bytes into this object's data.
+ /// If the stream \a s is nullptr, the output will be sent to Log().
+ ///
+ /// @param[in] s
+ /// The stream to dump the output to. If nullptr the output will
+ /// be dumped to Log().
+ ///
+ /// @param[in] offset
+ /// The offset into the data at which to extract and dump a
+ /// UUID value.
+ //------------------------------------------------------------------
+ void DumpUUID(Stream *s, lldb::offset_t offset) const;
+
+ //------------------------------------------------------------------
+ /// Extract an arbitrary number of bytes in the specified byte
+ /// order.
+ ///
+ /// Attemps to extract \a length bytes starting at \a offset bytes
+ /// into this data in the requested byte order (\a dst_byte_order)
+ /// and place the results in \a dst. \a dst must be at least \a
+ /// length bytes long.
+ ///
+ /// @param[in] offset
+ /// The offset in bytes into the contained data at which to
+ /// start extracting.
+ ///
+ /// @param[in] length
+ /// The number of bytes to extract.
+ ///
+ /// @param[in] dst_byte_order
+ /// A byte order of the data that we want when the value in
+ /// copied to \a dst.
+ ///
+ /// @param[out] dst
+ /// The buffer that will receive the extracted value if there
+ /// are enough bytes available in the current data.
+ ///
+ /// @return
+ /// The number of bytes that were extracted which will be \a
+ /// length when the value is successfully extracted, or zero
+ /// if there aren't enough bytes at the specified offset.
+ //------------------------------------------------------------------
+ size_t ExtractBytes(lldb::offset_t offset, lldb::offset_t length,
+ lldb::ByteOrder dst_byte_order, void *dst) const;
+
+ //------------------------------------------------------------------
+ /// Extract an address from \a *offset_ptr.
+ ///
+ /// Extract a single address from the data and update the offset
+ /// pointed to by \a offset_ptr. The size of the extracted address
+ /// comes from the \a m_addr_size member variable and should be
+ /// set correctly prior to extracting any address values.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// The extracted address value.
+ //------------------------------------------------------------------
+ uint64_t GetAddress(lldb::offset_t *offset_ptr) const;
+
+ uint64_t GetAddress_unchecked(lldb::offset_t *offset_ptr) const;
+
+ //------------------------------------------------------------------
+ /// Get the current address size.
+ ///
+ /// Return the size in bytes of any address values this object will
+ /// extract.
+ ///
+ /// @return
+ /// The size in bytes of address values that will be extracted.
+ //------------------------------------------------------------------
+ uint32_t GetAddressByteSize() const { return m_addr_size; }
+
+ //------------------------------------------------------------------
+ /// Get the number of bytes contained in this object.
+ ///
+ /// @return
+ /// The total number of bytes of data this object refers to.
+ //------------------------------------------------------------------
+ uint64_t GetByteSize() const { return m_end - m_start; }
+
+ //------------------------------------------------------------------
+ /// Extract a C string from \a *offset_ptr.
+ ///
+ /// Returns a pointer to a C String from the data at the offset
+ /// pointed to by \a offset_ptr. A variable length NULL terminated C
+ /// string will be extracted and the \a offset_ptr will be
+ /// updated with the offset of the byte that follows the NULL
+ /// terminator byte.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// A pointer to the C string value in the data. If the offset
+ /// pointed to by \a offset_ptr is out of bounds, or if the
+ /// offset plus the length of the C string is out of bounds,
+ /// nullptr will be returned.
+ //------------------------------------------------------------------
+ const char *GetCStr(lldb::offset_t *offset_ptr) const;
+
+ //------------------------------------------------------------------
+ /// Extract a C string from \a *offset_ptr with field size \a len.
+ ///
+ /// Returns a pointer to a C String from the data at the offset
+ /// pointed to by \a offset_ptr, with a field length of \a len.
+ /// A NULL terminated C string will be extracted and the \a offset_ptr
+ /// will be updated with the offset of the byte that follows the fixed
+ /// length field.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// A pointer to the C string value in the data. If the offset
+ /// pointed to by \a offset_ptr is out of bounds, or if the
+ /// offset plus the length of the field is out of bounds, or if
+ /// the field does not contain a NULL terminator byte, nullptr will
+ /// be returned.
+ const char *GetCStr(lldb::offset_t *offset_ptr, lldb::offset_t len) const;
+
+ //------------------------------------------------------------------
+ /// Extract \a length bytes from \a *offset_ptr.
+ ///
+ /// Returns a pointer to a bytes in this object's data at the offset
+ /// pointed to by \a offset_ptr. If \a length is zero or too large,
+ /// then the offset pointed to by \a offset_ptr will not be updated
+ /// and nullptr will be returned.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @param[in] length
+ /// The optional length of a string to extract. If the value is
+ /// zero, a NULL terminated C string will be extracted.
+ ///
+ /// @return
+ /// A pointer to the bytes in this object's data if the offset
+ /// and length are valid, or nullptr otherwise.
+ //------------------------------------------------------------------
+ const void *GetData(lldb::offset_t *offset_ptr, lldb::offset_t length) const {
+ const uint8_t *ptr = PeekData(*offset_ptr, length);
+ if (ptr)
+ *offset_ptr += length;
+ return ptr;
+ }
+
+ //------------------------------------------------------------------
+ /// Copy \a length bytes from \a *offset, without swapping bytes.
+ ///
+ /// @param[in] offset
+ /// The offset into this data from which to start copying
+ ///
+ /// @param[in] length
+ /// The length of the data to copy from this object
+ ///
+ /// @param[out] dst
+ /// The buffer to place the output data.
+ ///
+ /// @return
+ /// Returns the number of bytes that were copied, or zero if
+ /// anything goes wrong.
+ //------------------------------------------------------------------
+ lldb::offset_t CopyData(lldb::offset_t offset, lldb::offset_t length,
+ void *dst) const;
+
+ //------------------------------------------------------------------
+ /// Copy \a dst_len bytes from \a *offset_ptr and ensure the copied
+ /// data is treated as a value that can be swapped to match the
+ /// specified byte order.
+ ///
+ /// For values that are larger than the supported integer sizes,
+ /// this function can be used to extract data in a specified byte
+ /// order. It can also be used to copy a smaller integer value from
+ /// to a larger value. The extra bytes left over will be padded
+ /// correctly according to the byte order of this object and the
+ /// \a dst_byte_order. This can be very handy when say copying a
+ /// partial data value into a register.
+ ///
+ /// @param[in] src_offset
+ /// The offset into this data from which to start copying an
+ /// endian entity
+ ///
+ /// @param[in] src_len
+ /// The length of the endian data to copy from this object
+ /// into the \a dst object
+ ///
+ /// @param[out] dst
+ /// The buffer where to place the endian data. The data might
+ /// need to be byte swapped (and appropriately padded with
+ /// zeroes if \a src_len != \a dst_len) if \a dst_byte_order
+ /// does not match the byte order in this object.
+ ///
+ /// @param[in] dst_len
+ /// The length number of bytes that the endian value will
+ /// occupy is \a dst.
+ ///
+ /// @param[in] byte_order
+ /// The byte order that the endian value should be in the \a dst
+ /// buffer.
+ ///
+ /// @return
+ /// Returns the number of bytes that were copied, or zero if
+ /// anything goes wrong.
+ //------------------------------------------------------------------
+ lldb::offset_t CopyByteOrderedData(lldb::offset_t src_offset,
+ lldb::offset_t src_len, void *dst,
+ lldb::offset_t dst_len,
+ lldb::ByteOrder dst_byte_order) const;
+
+ //------------------------------------------------------------------
+ /// Get the data end pointer.
+ ///
+ /// @return
+ /// Returns a pointer to the next byte contained in this
+ /// object's data, or nullptr of there is no data in this object.
+ //------------------------------------------------------------------
+ const uint8_t *GetDataEnd() const { return m_end; }
+
+ //------------------------------------------------------------------
+ /// Get the shared data offset.
+ ///
+ /// Get the offset of the first byte of data in the shared data (if
+ /// any).
+ ///
+ /// @return
+ /// If this object contains shared data, this function returns
+ /// the offset in bytes into that shared data, zero otherwise.
+ //------------------------------------------------------------------
+ size_t GetSharedDataOffset() const;
+
+ //------------------------------------------------------------------
+ /// Get the data start pointer.
+ ///
+ /// @return
+ /// Returns a pointer to the first byte contained in this
+ /// object's data, or nullptr of there is no data in this object.
+ //------------------------------------------------------------------
+ const uint8_t *GetDataStart() const { return m_start; }
+
+ //------------------------------------------------------------------
+ /// Extract a float from \a *offset_ptr.
+ ///
+ /// Extract a single float value.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// The floating value that was extracted, or zero on failure.
+ //------------------------------------------------------------------
+ float GetFloat(lldb::offset_t *offset_ptr) const;
+
+ double GetDouble(lldb::offset_t *offset_ptr) const;
+
+ long double GetLongDouble(lldb::offset_t *offset_ptr) const;
+
+ //------------------------------------------------------------------
+ /// Extract a GNU encoded pointer value from \a *offset_ptr.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @param[in] eh_ptr_enc
+ /// The GNU pointer encoding type.
+ ///
+ /// @param[in] pc_rel_addr
+ /// The PC relative address to use when the encoding is
+ /// \c DW_GNU_EH_PE_pcrel.
+ ///
+ /// @param[in] text_addr
+ /// The text (code) relative address to use when the encoding is
+ /// \c DW_GNU_EH_PE_textrel.
+ ///
+ /// @param[in] data_addr
+ /// The data relative address to use when the encoding is
+ /// \c DW_GNU_EH_PE_datarel.
+ ///
+ /// @return
+ /// The extracted GNU encoded pointer value.
+ //------------------------------------------------------------------
+ uint64_t GetGNUEHPointer(lldb::offset_t *offset_ptr, uint32_t eh_ptr_enc,
+ lldb::addr_t pc_rel_addr, lldb::addr_t text_addr,
+ lldb::addr_t data_addr);
+
+ //------------------------------------------------------------------
+ /// Extract an integer of size \a byte_size from \a *offset_ptr.
+ ///
+ /// Extract a single integer value and update the offset pointed to
+ /// by \a offset_ptr. The size of the extracted integer is specified
+ /// by the \a byte_size argument. \a byte_size should have a value
+ /// >= 1 and <= 4 since the return value is only 32 bits wide. Any
+ /// \a byte_size values less than 1 or greater than 4 will result in
+ /// nothing being extracted, and zero being returned.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @param[in] byte_size
+ /// The size in byte of the integer to extract.
+ ///
+ /// @return
+ /// The integer value that was extracted, or zero on failure.
+ //------------------------------------------------------------------
+ uint32_t GetMaxU32(lldb::offset_t *offset_ptr, size_t byte_size) const;
+
+ //------------------------------------------------------------------
+ /// Extract an unsigned integer of size \a byte_size from \a
+ /// *offset_ptr.
+ ///
+ /// Extract a single unsigned integer value and update the offset
+ /// pointed to by \a offset_ptr. The size of the extracted integer
+ /// is specified by the \a byte_size argument. \a byte_size should
+ /// have a value greater than or equal to one and less than or equal
+ /// to eight since the return value is 64 bits wide. Any
+ /// \a byte_size values less than 1 or greater than 8 will result in
+ /// nothing being extracted, and zero being returned.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @param[in] byte_size
+ /// The size in byte of the integer to extract.
+ ///
+ /// @return
+ /// The unsigned integer value that was extracted, or zero on
+ /// failure.
+ //------------------------------------------------------------------
+ uint64_t GetMaxU64(lldb::offset_t *offset_ptr, size_t byte_size) const;
+
+ uint64_t GetMaxU64_unchecked(lldb::offset_t *offset_ptr,
+ size_t byte_size) const;
+
+ //------------------------------------------------------------------
+ /// Extract an signed integer of size \a byte_size from \a *offset_ptr.
+ ///
+ /// Extract a single signed integer value (sign extending if required)
+ /// and update the offset pointed to by \a offset_ptr. The size of
+ /// the extracted integer is specified by the \a byte_size argument.
+ /// \a byte_size should have a value greater than or equal to one
+ /// and less than or equal to eight since the return value is 64
+ /// bits wide. Any \a byte_size values less than 1 or greater than
+ /// 8 will result in nothing being extracted, and zero being returned.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @param[in] byte_size
+ /// The size in byte of the integer to extract.
+ ///
+ /// @return
+ /// The sign extended signed integer value that was extracted,
+ /// or zero on failure.
+ //------------------------------------------------------------------
+ int64_t GetMaxS64(lldb::offset_t *offset_ptr, size_t size) const;
+
+ //------------------------------------------------------------------
+ /// Extract an unsigned integer of size \a byte_size from \a
+ /// *offset_ptr, then extract the bitfield from this value if
+ /// \a bitfield_bit_size is non-zero.
+ ///
+ /// Extract a single unsigned integer value and update the offset
+ /// pointed to by \a offset_ptr. The size of the extracted integer
+ /// is specified by the \a byte_size argument. \a byte_size should
+ /// have a value greater than or equal to one and less than or equal
+ /// to 8 since the return value is 64 bits wide. Any
+ /// \a byte_size values less than 1 or greater than 8 will result in
+ /// nothing being extracted, and zero being returned.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @param[in] byte_size
+ /// The size in byte of the integer to extract.
+ ///
+ /// @param[in] bitfield_bit_size
+ /// The size in bits of the bitfield value to extract, or zero
+ /// to just extract the entire integer value.
+ ///
+ /// @param[in] bitfield_bit_offset
+ /// The bit offset of the bitfield value in the extracted
+ /// integer. For little-endian data, this is the offset of
+ /// the LSB of the bitfield from the LSB of the integer.
+ /// For big-endian data, this is the offset of the MSB of the
+ /// bitfield from the MSB of the integer.
+ ///
+ /// @return
+ /// The unsigned bitfield integer value that was extracted, or
+ /// zero on failure.
+ //------------------------------------------------------------------
+ uint64_t GetMaxU64Bitfield(lldb::offset_t *offset_ptr, size_t size,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset) const;
+
+ //------------------------------------------------------------------
+ /// Extract an signed integer of size \a byte_size from \a
+ /// *offset_ptr, then extract and signe extend the bitfield from
+ /// this value if \a bitfield_bit_size is non-zero.
+ ///
+ /// Extract a single signed integer value (sign extending if required)
+ /// and update the offset pointed to by \a offset_ptr. The size of
+ /// the extracted integer is specified by the \a byte_size argument.
+ /// \a byte_size should have a value greater than or equal to one
+ /// and less than or equal to eight since the return value is 64
+ /// bits wide. Any \a byte_size values less than 1 or greater than
+ /// 8 will result in nothing being extracted, and zero being returned.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @param[in] byte_size
+ /// The size in bytes of the integer to extract.
+ ///
+ /// @param[in] bitfield_bit_size
+ /// The size in bits of the bitfield value to extract, or zero
+ /// to just extract the entire integer value.
+ ///
+ /// @param[in] bitfield_bit_offset
+ /// The bit offset of the bitfield value in the extracted
+ /// integer. For little-endian data, this is the offset of
+ /// the LSB of the bitfield from the LSB of the integer.
+ /// For big-endian data, this is the offset of the MSB of the
+ /// bitfield from the MSB of the integer.
+ ///
+ /// @return
+ /// The signed bitfield integer value that was extracted, or
+ /// zero on failure.
+ //------------------------------------------------------------------
+ int64_t GetMaxS64Bitfield(lldb::offset_t *offset_ptr, size_t size,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset) const;
+
+ //------------------------------------------------------------------
+ /// Extract an pointer from \a *offset_ptr.
+ ///
+ /// Extract a single pointer from the data and update the offset
+ /// pointed to by \a offset_ptr. The size of the extracted pointer
+ /// comes from the \a m_addr_size member variable and should be
+ /// set correctly prior to extracting any pointer values.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// The extracted pointer value as a 64 integer.
+ //------------------------------------------------------------------
+ uint64_t GetPointer(lldb::offset_t *offset_ptr) const;
+
+ //------------------------------------------------------------------
+ /// Get the current byte order value.
+ ///
+ /// @return
+ /// The current byte order value from this object's internal
+ /// state.
+ //------------------------------------------------------------------
+ lldb::ByteOrder GetByteOrder() const { return m_byte_order; }
+
+ //------------------------------------------------------------------
+ /// Extract a uint8_t value from \a *offset_ptr.
+ ///
+ /// Extract a single uint8_t from the binary data at the offset
+ /// pointed to by \a offset_ptr, and advance the offset on success.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// The extracted uint8_t value.
+ //------------------------------------------------------------------
+ uint8_t GetU8(lldb::offset_t *offset_ptr) const;
+
+ uint8_t GetU8_unchecked(lldb::offset_t *offset_ptr) const {
+ uint8_t val = m_start[*offset_ptr];
+ *offset_ptr += 1;
+ return val;
+ }
+
+ uint16_t GetU16_unchecked(lldb::offset_t *offset_ptr) const;
+
+ uint32_t GetU32_unchecked(lldb::offset_t *offset_ptr) const;
+
+ uint64_t GetU64_unchecked(lldb::offset_t *offset_ptr) const;
+ //------------------------------------------------------------------
+ /// Extract \a count uint8_t values from \a *offset_ptr.
+ ///
+ /// Extract \a count uint8_t values from the binary data at the
+ /// offset pointed to by \a offset_ptr, and advance the offset on
+ /// success. The extracted values are copied into \a dst.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @param[out] dst
+ /// A buffer to copy \a count uint8_t values into. \a dst must
+ /// be large enough to hold all requested data.
+ ///
+ /// @param[in] count
+ /// The number of uint8_t values to extract.
+ ///
+ /// @return
+ /// \a dst if all values were properly extracted and copied,
+ /// nullptr otherwise.
+ //------------------------------------------------------------------
+ void *GetU8(lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;
+
+ //------------------------------------------------------------------
+ /// Extract a uint16_t value from \a *offset_ptr.
+ ///
+ /// Extract a single uint16_t from the binary data at the offset
+ /// pointed to by \a offset_ptr, and update the offset on success.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// The extracted uint16_t value.
+ //------------------------------------------------------------------
+ uint16_t GetU16(lldb::offset_t *offset_ptr) const;
+
+ //------------------------------------------------------------------
+ /// Extract \a count uint16_t values from \a *offset_ptr.
+ ///
+ /// Extract \a count uint16_t values from the binary data at the
+ /// offset pointed to by \a offset_ptr, and advance the offset on
+ /// success. The extracted values are copied into \a dst.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @param[out] dst
+ /// A buffer to copy \a count uint16_t values into. \a dst must
+ /// be large enough to hold all requested data.
+ ///
+ /// @param[in] count
+ /// The number of uint16_t values to extract.
+ ///
+ /// @return
+ /// \a dst if all values were properly extracted and copied,
+ /// nullptr otherwise.
+ //------------------------------------------------------------------
+ void *GetU16(lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;
+
+ //------------------------------------------------------------------
+ /// Extract a uint32_t value from \a *offset_ptr.
+ ///
+ /// Extract a single uint32_t from the binary data at the offset
+ /// pointed to by \a offset_ptr, and update the offset on success.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// The extracted uint32_t value.
+ //------------------------------------------------------------------
+ uint32_t GetU32(lldb::offset_t *offset_ptr) const;
+
+ //------------------------------------------------------------------
+ /// Extract \a count uint32_t values from \a *offset_ptr.
+ ///
+ /// Extract \a count uint32_t values from the binary data at the
+ /// offset pointed to by \a offset_ptr, and advance the offset on
+ /// success. The extracted values are copied into \a dst.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @param[out] dst
+ /// A buffer to copy \a count uint32_t values into. \a dst must
+ /// be large enough to hold all requested data.
+ ///
+ /// @param[in] count
+ /// The number of uint32_t values to extract.
+ ///
+ /// @return
+ /// \a dst if all values were properly extracted and copied,
+ /// nullptr otherwise.
+ //------------------------------------------------------------------
+ void *GetU32(lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;
+
+ //------------------------------------------------------------------
+ /// Extract a uint64_t value from \a *offset_ptr.
+ ///
+ /// Extract a single uint64_t from the binary data at the offset
+ /// pointed to by \a offset_ptr, and update the offset on success.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// The extracted uint64_t value.
+ //------------------------------------------------------------------
+ uint64_t GetU64(lldb::offset_t *offset_ptr) const;
+
+ //------------------------------------------------------------------
+ /// Extract \a count uint64_t values from \a *offset_ptr.
+ ///
+ /// Extract \a count uint64_t values from the binary data at the
+ /// offset pointed to by \a offset_ptr, and advance the offset on
+ /// success. The extracted values are copied into \a dst.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @param[out] dst
+ /// A buffer to copy \a count uint64_t values into. \a dst must
+ /// be large enough to hold all requested data.
+ ///
+ /// @param[in] count
+ /// The number of uint64_t values to extract.
+ ///
+ /// @return
+ /// \a dst if all values were properly extracted and copied,
+ /// nullptr otherwise.
+ //------------------------------------------------------------------
+ void *GetU64(lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;
+
+ //------------------------------------------------------------------
+ /// Extract a signed LEB128 value from \a *offset_ptr.
+ ///
+ /// Extracts an signed LEB128 number from this object's data
+ /// starting at the offset pointed to by \a offset_ptr. The offset
+ /// pointed to by \a offset_ptr will be updated with the offset of
+ /// the byte following the last extracted byte.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// The extracted signed integer value.
+ //------------------------------------------------------------------
+ int64_t GetSLEB128(lldb::offset_t *offset_ptr) const;
+
+ //------------------------------------------------------------------
+ /// Extract a unsigned LEB128 value from \a *offset_ptr.
+ ///
+ /// Extracts an unsigned LEB128 number from this object's data
+ /// starting at the offset pointed to by \a offset_ptr. The offset
+ /// pointed to by \a offset_ptr will be updated with the offset of
+ /// the byte following the last extracted byte.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// The extracted unsigned integer value.
+ //------------------------------------------------------------------
+ uint64_t GetULEB128(lldb::offset_t *offset_ptr) const;
+
+ lldb::DataBufferSP &GetSharedDataBuffer() { return m_data_sp; }
+
+ //------------------------------------------------------------------
+ /// Peek at a C string at \a offset.
+ ///
+ /// Peeks at a string in the contained data. No verification is done
+ /// to make sure the entire string lies within the bounds of this
+ /// object's data, only \a offset is verified to be a valid offset.
+ ///
+ /// @param[in] offset
+ /// An offset into the data.
+ ///
+ /// @return
+ /// A non-nullptr C string pointer if \a offset is a valid offset,
+ /// nullptr otherwise.
+ //------------------------------------------------------------------
+ const char *PeekCStr(lldb::offset_t offset) const;
+
+ //------------------------------------------------------------------
+ /// Peek at a bytes at \a offset.
+ ///
+ /// Returns a pointer to \a length bytes at \a offset as long as
+ /// there are \a length bytes available starting at \a offset.
+ ///
+ /// @return
+ /// A non-nullptr data pointer if \a offset is a valid offset and
+ /// there are \a length bytes available at that offset, nullptr
+ /// otherwise.
+ //------------------------------------------------------------------
+ const uint8_t *PeekData(lldb::offset_t offset, lldb::offset_t length) const {
+ if (ValidOffsetForDataOfSize(offset, length))
+ return m_start + offset;
+ return nullptr;
+ }
+
+ //------------------------------------------------------------------
+ /// Set the address byte size.
+ ///
+ /// Set the size in bytes that will be used when extracting any
+ /// address and pointer values from data contained in this object.
+ ///
+ /// @param[in] addr_size
+ /// The size in bytes to use when extracting addresses.
+ //------------------------------------------------------------------
+ void SetAddressByteSize(uint32_t addr_size) {
#ifdef LLDB_CONFIGURATION_DEBUG
- assert (addr_size == 4 || addr_size == 8);
+ assert(addr_size == 4 || addr_size == 8);
#endif
- m_addr_size = addr_size;
- }
-
- //------------------------------------------------------------------
- /// Set data with a buffer that is caller owned.
- ///
- /// Use data that is owned by the caller when extracting values.
- /// The data must stay around as long as this object, or any object
- /// that copies a subset of this object's data, is valid. If \a
- /// bytes is nullptr, or \a length is zero, this object will contain
- /// no data.
- ///
- /// @param[in] bytes
- /// A pointer to caller owned data.
- ///
- /// @param[in] length
- /// The length in bytes of \a bytes.
- ///
- /// @param[in] byte_order
- /// A byte order of the data that we are extracting from.
- ///
- /// @return
- /// The number of bytes that this object now contains.
- //------------------------------------------------------------------
- lldb::offset_t
- SetData (const void *bytes, lldb::offset_t length, lldb::ByteOrder byte_order);
-
- //------------------------------------------------------------------
- /// Adopt a subset of \a data.
- ///
- /// Set this object's data to be a subset of the data bytes in \a
- /// data. If \a data contains shared data, then a reference to the
- /// shared data will be added to ensure the shared data stays around
- /// as long as any objects have references to the shared data. The
- /// byte order and the address size settings are copied from \a
- /// data. If \a offset is not a valid offset in \a data, then no
- /// reference to the shared data will be added. If there are not
- /// \a length bytes available in \a data starting at \a offset,
- /// the length will be truncated to contains as many bytes as
- /// possible.
- ///
- /// @param[in] data
- /// Another DataExtractor object that contains data.
- ///
- /// @param[in] offset
- /// The offset into \a data at which the subset starts.
- ///
- /// @param[in] length
- /// The length in bytes of the subset of \a data.
- ///
- /// @return
- /// The number of bytes that this object now contains.
- //------------------------------------------------------------------
- lldb::offset_t
- SetData (const DataExtractor& data, lldb::offset_t offset, lldb::offset_t length);
-
- //------------------------------------------------------------------
- /// Adopt a subset of shared data in \a data_sp.
- ///
- /// Copies the data shared pointer which adds a reference to the
- /// contained in \a data_sp. The shared data reference is reference
- /// counted to ensure the data lives as long as anyone still has a
- /// valid shared pointer to the data in \a data_sp. The byte order
- /// and address byte size settings remain the same. If
- /// \a offset is not a valid offset in \a data_sp, then no reference
- /// to the shared data will be added. If there are not \a length
- /// bytes available in \a data starting at \a offset, the length
- /// will be truncated to contains as many bytes as possible.
- ///
- /// @param[in] data_sp
- /// A shared pointer to data.
- ///
- /// @param[in] offset
- /// The offset into \a data_sp at which the subset starts.
- ///
- /// @param[in] length
- /// The length in bytes of the subset of \a data_sp.
- ///
- /// @return
- /// The number of bytes that this object now contains.
- //------------------------------------------------------------------
- lldb::offset_t
- SetData (const lldb::DataBufferSP& data_sp, lldb::offset_t offset = 0, lldb::offset_t length = LLDB_INVALID_OFFSET);
-
- //------------------------------------------------------------------
- /// Set the byte_order value.
- ///
- /// Sets the byte order of the data to extract. Extracted values
- /// will be swapped if necessary when decoding.
- ///
- /// @param[in] byte_order
- /// The byte order value to use when extracting data.
- //------------------------------------------------------------------
- void
- SetByteOrder (lldb::ByteOrder byte_order)
- {
- m_byte_order = byte_order;
- }
-
- //------------------------------------------------------------------
- /// Skip an LEB128 number at \a *offset_ptr.
- ///
- /// Skips a LEB128 number (signed or unsigned) from this object's
- /// data starting at the offset pointed to by \a offset_ptr. The
- /// offset pointed to by \a offset_ptr will be updated with the
- /// offset of the byte following the last extracted byte.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- // The number of bytes consumed during the extraction.
- //------------------------------------------------------------------
- uint32_t
- Skip_LEB128 (lldb::offset_t *offset_ptr) const;
-
- //------------------------------------------------------------------
- /// Test the validity of \a offset.
- ///
- /// @return
- /// \b true if \a offset is a valid offset into the data in this
- /// object, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ValidOffset (lldb::offset_t offset) const
- {
- return offset < GetByteSize();
- }
-
- //------------------------------------------------------------------
- /// Test the availability of \a length bytes of data from \a offset.
- ///
- /// @return
- /// \b true if \a offset is a valid offset and there are \a
- /// length bytes available at that offset, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ValidOffsetForDataOfSize (lldb::offset_t offset, lldb::offset_t length) const
- {
- return length <= BytesLeft (offset);
- }
-
- size_t
- Copy (DataExtractor& dest_data) const;
-
- bool
- Append (DataExtractor& rhs);
-
- bool
- Append (void* bytes, lldb::offset_t length);
-
- lldb::offset_t
- BytesLeft (lldb::offset_t offset) const
- {
- const lldb::offset_t size = GetByteSize();
- if (size > offset)
- return size - offset;
- return 0;
- }
-
- void
- Checksum (llvm::SmallVectorImpl<uint8_t> &dest,
- uint64_t max_data = 0);
+ m_addr_size = addr_size;
+ }
+
+ //------------------------------------------------------------------
+ /// Set data with a buffer that is caller owned.
+ ///
+ /// Use data that is owned by the caller when extracting values.
+ /// The data must stay around as long as this object, or any object
+ /// that copies a subset of this object's data, is valid. If \a
+ /// bytes is nullptr, or \a length is zero, this object will contain
+ /// no data.
+ ///
+ /// @param[in] bytes
+ /// A pointer to caller owned data.
+ ///
+ /// @param[in] length
+ /// The length in bytes of \a bytes.
+ ///
+ /// @param[in] byte_order
+ /// A byte order of the data that we are extracting from.
+ ///
+ /// @return
+ /// The number of bytes that this object now contains.
+ //------------------------------------------------------------------
+ lldb::offset_t SetData(const void *bytes, lldb::offset_t length,
+ lldb::ByteOrder byte_order);
+
+ //------------------------------------------------------------------
+ /// Adopt a subset of \a data.
+ ///
+ /// Set this object's data to be a subset of the data bytes in \a
+ /// data. If \a data contains shared data, then a reference to the
+ /// shared data will be added to ensure the shared data stays around
+ /// as long as any objects have references to the shared data. The
+ /// byte order and the address size settings are copied from \a
+ /// data. If \a offset is not a valid offset in \a data, then no
+ /// reference to the shared data will be added. If there are not
+ /// \a length bytes available in \a data starting at \a offset,
+ /// the length will be truncated to contains as many bytes as
+ /// possible.
+ ///
+ /// @param[in] data
+ /// Another DataExtractor object that contains data.
+ ///
+ /// @param[in] offset
+ /// The offset into \a data at which the subset starts.
+ ///
+ /// @param[in] length
+ /// The length in bytes of the subset of \a data.
+ ///
+ /// @return
+ /// The number of bytes that this object now contains.
+ //------------------------------------------------------------------
+ lldb::offset_t SetData(const DataExtractor &data, lldb::offset_t offset,
+ lldb::offset_t length);
+
+ //------------------------------------------------------------------
+ /// Adopt a subset of shared data in \a data_sp.
+ ///
+ /// Copies the data shared pointer which adds a reference to the
+ /// contained in \a data_sp. The shared data reference is reference
+ /// counted to ensure the data lives as long as anyone still has a
+ /// valid shared pointer to the data in \a data_sp. The byte order
+ /// and address byte size settings remain the same. If
+ /// \a offset is not a valid offset in \a data_sp, then no reference
+ /// to the shared data will be added. If there are not \a length
+ /// bytes available in \a data starting at \a offset, the length
+ /// will be truncated to contains as many bytes as possible.
+ ///
+ /// @param[in] data_sp
+ /// A shared pointer to data.
+ ///
+ /// @param[in] offset
+ /// The offset into \a data_sp at which the subset starts.
+ ///
+ /// @param[in] length
+ /// The length in bytes of the subset of \a data_sp.
+ ///
+ /// @return
+ /// The number of bytes that this object now contains.
+ //------------------------------------------------------------------
+ lldb::offset_t SetData(const lldb::DataBufferSP &data_sp,
+ lldb::offset_t offset = 0,
+ lldb::offset_t length = LLDB_INVALID_OFFSET);
+
+ //------------------------------------------------------------------
+ /// Set the byte_order value.
+ ///
+ /// Sets the byte order of the data to extract. Extracted values
+ /// will be swapped if necessary when decoding.
+ ///
+ /// @param[in] byte_order
+ /// The byte order value to use when extracting data.
+ //------------------------------------------------------------------
+ void SetByteOrder(lldb::ByteOrder byte_order) { m_byte_order = byte_order; }
+
+ //------------------------------------------------------------------
+ /// Skip an LEB128 number at \a *offset_ptr.
+ ///
+ /// Skips a LEB128 number (signed or unsigned) from this object's
+ /// data starting at the offset pointed to by \a offset_ptr. The
+ /// offset pointed to by \a offset_ptr will be updated with the
+ /// offset of the byte following the last extracted byte.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ // The number of bytes consumed during the extraction.
+ //------------------------------------------------------------------
+ uint32_t Skip_LEB128(lldb::offset_t *offset_ptr) const;
+
+ //------------------------------------------------------------------
+ /// Test the validity of \a offset.
+ ///
+ /// @return
+ /// \b true if \a offset is a valid offset into the data in this
+ /// object, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ValidOffset(lldb::offset_t offset) const {
+ return offset < GetByteSize();
+ }
+
+ //------------------------------------------------------------------
+ /// Test the availability of \a length bytes of data from \a offset.
+ ///
+ /// @return
+ /// \b true if \a offset is a valid offset and there are \a
+ /// length bytes available at that offset, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ValidOffsetForDataOfSize(lldb::offset_t offset,
+ lldb::offset_t length) const {
+ return length <= BytesLeft(offset);
+ }
+
+ size_t Copy(DataExtractor &dest_data) const;
+
+ bool Append(DataExtractor &rhs);
+
+ bool Append(void *bytes, lldb::offset_t length);
+
+ lldb::offset_t BytesLeft(lldb::offset_t offset) const {
+ const lldb::offset_t size = GetByteSize();
+ if (size > offset)
+ return size - offset;
+ return 0;
+ }
+
+ void Checksum(llvm::SmallVectorImpl<uint8_t> &dest, uint64_t max_data = 0);
protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- const uint8_t * m_start; ///< A pointer to the first byte of data.
- const uint8_t * m_end; ///< A pointer to the byte that is past the end of the data.
- lldb::ByteOrder m_byte_order; ///< The byte order of the data we are extracting from.
- uint32_t m_addr_size; ///< The address size to use when extracting pointers or addresses
- mutable lldb::DataBufferSP m_data_sp; ///< The shared pointer to data that can be shared among multiple instances
- const uint32_t m_target_byte_size;
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ const uint8_t *m_start; ///< A pointer to the first byte of data.
+ const uint8_t
+ *m_end; ///< A pointer to the byte that is past the end of the data.
+ lldb::ByteOrder
+ m_byte_order; ///< The byte order of the data we are extracting from.
+ uint32_t m_addr_size; ///< The address size to use when extracting pointers or
+ ///addresses
+ mutable lldb::DataBufferSP m_data_sp; ///< The shared pointer to data that can
+ ///be shared among multiple instances
+ const uint32_t m_target_byte_size;
};
} // namespace lldb_private
diff --git a/include/lldb/Core/Debugger.h b/include/lldb/Core/Debugger.h
index 7a969457eef6..ccc07b30f0c6 100644
--- a/include/lldb/Core/Debugger.h
+++ b/include/lldb/Core/Debugger.h
@@ -14,14 +14,13 @@
#include <stdint.h>
// C++ Includes
-#include <memory>
#include <map>
+#include <memory>
#include <mutex>
#include <vector>
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/FormatEntity.h"
#include "lldb/Core/IOHandler.h"
@@ -33,11 +32,10 @@
#include "lldb/Host/Terminal.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/TargetList.h"
+#include "lldb/lldb-public.h"
-namespace llvm
-{
-namespace sys
-{
+namespace llvm {
+namespace sys {
class DynamicLibrary;
} // namespace sys
} // namespace llvm
@@ -51,454 +49,346 @@ namespace lldb_private {
/// Provides a global root objects for the debugger core.
//----------------------------------------------------------------------
-class Debugger :
- public std::enable_shared_from_this<Debugger>,
- public UserID,
- public Properties
-{
-friend class SourceManager; // For GetSourceFileCache.
+class Debugger : public std::enable_shared_from_this<Debugger>,
+ public UserID,
+ public Properties {
+ friend class SourceManager; // For GetSourceFileCache.
public:
- ~Debugger() override;
-
- static lldb::DebuggerSP
- CreateInstance(lldb::LogOutputCallback log_callback = nullptr, void *baton = nullptr);
-
- static lldb::TargetSP
- FindTargetWithProcessID (lldb::pid_t pid);
-
- static lldb::TargetSP
- FindTargetWithProcess (Process *process);
-
- static void
- Initialize(LoadPluginCallbackType load_plugin_callback);
-
- static void
- Terminate();
-
- static void
- SettingsInitialize ();
-
- static void
- SettingsTerminate ();
-
- static void
- Destroy (lldb::DebuggerSP &debugger_sp);
-
- static lldb::DebuggerSP
- FindDebuggerWithID(lldb::user_id_t id);
-
- static lldb::DebuggerSP
- FindDebuggerWithInstanceName(const ConstString &instance_name);
-
- static size_t
- GetNumDebuggers();
-
- static lldb::DebuggerSP
- GetDebuggerAtIndex(size_t index);
-
- static bool
- FormatDisassemblerAddress(const FormatEntity::Entry *format,
- const SymbolContext *sc,
- const SymbolContext *prev_sc,
- const ExecutionContext *exe_ctx,
- const Address *addr,
- Stream &s);
-
- void Clear();
-
- bool
- GetAsyncExecution ();
-
- void
- SetAsyncExecution (bool async);
-
- lldb::StreamFileSP
- GetInputFile ()
- {
- return m_input_file_sp;
- }
-
- lldb::StreamFileSP
- GetOutputFile ()
- {
- return m_output_file_sp;
- }
-
- lldb::StreamFileSP
- GetErrorFile ()
- {
- return m_error_file_sp;
- }
-
- void
- SetInputFileHandle (FILE *fh, bool tranfer_ownership);
-
- void
- SetOutputFileHandle (FILE *fh, bool tranfer_ownership);
-
- void
- SetErrorFileHandle (FILE *fh, bool tranfer_ownership);
-
- void
- SaveInputTerminalState();
-
- void
- RestoreInputTerminalState();
-
- lldb::StreamSP
- GetAsyncOutputStream ();
-
- lldb::StreamSP
- GetAsyncErrorStream ();
-
- CommandInterpreter &
- GetCommandInterpreter ()
- {
- assert (m_command_interpreter_ap.get());
- return *m_command_interpreter_ap;
- }
-
- lldb::ListenerSP
- GetListener ()
- {
- return m_listener_sp;
- }
-
- // This returns the Debugger's scratch source manager. It won't be able to look up files in debug
- // information, but it can look up files by absolute path and display them to you.
- // To get the target's source manager, call GetSourceManager on the target instead.
- SourceManager &
- GetSourceManager ();
-
- lldb::TargetSP
- GetSelectedTarget ()
- {
- return m_target_list.GetSelectedTarget ();
- }
-
- ExecutionContext
- GetSelectedExecutionContext();
- //------------------------------------------------------------------
- /// Get accessor for the target list.
- ///
- /// The target list is part of the global debugger object. This
- /// the single debugger shared instance to control where targets
- /// get created and to allow for tracking and searching for targets
- /// based on certain criteria.
- ///
- /// @return
- /// A global shared target list.
- //------------------------------------------------------------------
- TargetList &
- GetTargetList ()
- {
- return m_target_list;
- }
-
- PlatformList &
- GetPlatformList ()
- {
- return m_platform_list;
- }
-
- void
- DispatchInputInterrupt ();
-
- void
- DispatchInputEndOfFile ();
-
- //------------------------------------------------------------------
- // If any of the streams are not set, set them to the in/out/err
- // stream of the top most input reader to ensure they at least have
- // something
- //------------------------------------------------------------------
- void
- AdoptTopIOHandlerFilesIfInvalid (lldb::StreamFileSP &in,
- lldb::StreamFileSP &out,
- lldb::StreamFileSP &err);
-
- void
- PushIOHandler (const lldb::IOHandlerSP& reader_sp);
-
- bool
- PopIOHandler (const lldb::IOHandlerSP& reader_sp);
-
- // Synchronously run an input reader until it is done
- void
- RunIOHandler (const lldb::IOHandlerSP& reader_sp);
-
- bool
- IsTopIOHandler (const lldb::IOHandlerSP& reader_sp);
-
- bool
- CheckTopIOHandlerTypes (IOHandler::Type top_type,
- IOHandler::Type second_top_type);
-
- void
- PrintAsync (const char *s, size_t len, bool is_stdout);
-
- ConstString
- GetTopIOHandlerControlSequence(char ch);
-
- const char *
- GetIOHandlerCommandPrefix();
-
- const char *
- GetIOHandlerHelpPrologue();
-
- void
- ClearIOHandlers ();
-
- bool
- GetCloseInputOnEOF () const;
-
- void
- SetCloseInputOnEOF (bool b);
-
- bool
- EnableLog (const char *channel, const char **categories, const char *log_file, uint32_t log_options, Stream &error_stream);
-
- void
- SetLoggingCallback (lldb::LogOutputCallback log_callback, void *baton);
-
- //----------------------------------------------------------------------
- // Properties Functions
- //----------------------------------------------------------------------
- enum StopDisassemblyType
- {
- eStopDisassemblyTypeNever = 0,
- eStopDisassemblyTypeNoDebugInfo,
- eStopDisassemblyTypeNoSource,
- eStopDisassemblyTypeAlways
- };
-
- Error
- SetPropertyValue(const ExecutionContext *exe_ctx,
- VarSetOperationType op,
- const char *property_path,
- const char *value) override;
-
- bool
- GetAutoConfirm () const;
-
- const FormatEntity::Entry *
- GetDisassemblyFormat() const;
-
- const FormatEntity::Entry *
- GetFrameFormat() const;
-
- const FormatEntity::Entry *
- GetThreadFormat() const;
-
- lldb::ScriptLanguage
- GetScriptLanguage() const;
-
- bool
- SetScriptLanguage (lldb::ScriptLanguage script_lang);
-
- uint32_t
- GetTerminalWidth () const;
-
- bool
- SetTerminalWidth (uint32_t term_width);
-
- const char *
- GetPrompt() const;
-
- void
- SetPrompt(const char *p);
-
- bool
- GetUseExternalEditor () const;
-
- bool
- SetUseExternalEditor (bool use_external_editor_p);
-
- bool
- GetUseColor () const;
-
- bool
- SetUseColor (bool use_color);
-
- uint32_t
- GetStopSourceLineCount (bool before) const;
-
- StopDisassemblyType
- GetStopDisassemblyDisplay () const;
-
- uint32_t
- GetDisassemblyLineCount () const;
-
- bool
- GetAutoOneLineSummaries () const;
-
- bool
- GetAutoIndent () const;
-
- bool
- SetAutoIndent (bool b);
-
- bool
- GetPrintDecls () const;
-
- bool
- SetPrintDecls (bool b);
-
- uint32_t
- GetTabSize () const;
-
- bool
- SetTabSize (uint32_t tab_size);
-
- bool
- GetEscapeNonPrintables () const;
-
- bool
- GetNotifyVoid () const;
-
- const ConstString &
- GetInstanceName()
- {
- return m_instance_name;
- }
-
- bool
- LoadPlugin (const FileSpec& spec, Error& error);
-
- void
- ExecuteIOHandlers();
-
- bool
- IsForwardingEvents ();
-
- void
- EnableForwardEvents (const lldb::ListenerSP &listener_sp);
-
- void
- CancelForwardEvents (const lldb::ListenerSP &listener_sp);
-
- bool
- IsHandlingEvents () const
- {
- return m_event_handler_thread.IsJoinable();
- }
-
- Error
- RunREPL (lldb::LanguageType language, const char *repl_options);
-
- // This is for use in the command interpreter, when you either want the selected target, or if no target
- // is present you want to prime the dummy target with entities that will be copied over to new targets.
- Target *GetSelectedOrDummyTarget(bool prefer_dummy = false);
- Target *GetDummyTarget();
-
- lldb::BroadcasterManagerSP
- GetBroadcasterManager()
- {
- return m_broadcaster_manager_sp;
- }
+ ~Debugger() override;
+
+ static lldb::DebuggerSP
+ CreateInstance(lldb::LogOutputCallback log_callback = nullptr,
+ void *baton = nullptr);
+
+ static lldb::TargetSP FindTargetWithProcessID(lldb::pid_t pid);
+
+ static lldb::TargetSP FindTargetWithProcess(Process *process);
+
+ static void Initialize(LoadPluginCallbackType load_plugin_callback);
+
+ static void Terminate();
+
+ static void SettingsInitialize();
+
+ static void SettingsTerminate();
+
+ static void Destroy(lldb::DebuggerSP &debugger_sp);
+
+ static lldb::DebuggerSP FindDebuggerWithID(lldb::user_id_t id);
+
+ static lldb::DebuggerSP
+ FindDebuggerWithInstanceName(const ConstString &instance_name);
+
+ static size_t GetNumDebuggers();
+
+ static lldb::DebuggerSP GetDebuggerAtIndex(size_t index);
+
+ static bool FormatDisassemblerAddress(const FormatEntity::Entry *format,
+ const SymbolContext *sc,
+ const SymbolContext *prev_sc,
+ const ExecutionContext *exe_ctx,
+ const Address *addr, Stream &s);
+
+ void Clear();
+
+ bool GetAsyncExecution();
+
+ void SetAsyncExecution(bool async);
+
+ lldb::StreamFileSP GetInputFile() { return m_input_file_sp; }
+
+ lldb::StreamFileSP GetOutputFile() { return m_output_file_sp; }
+
+ lldb::StreamFileSP GetErrorFile() { return m_error_file_sp; }
+
+ void SetInputFileHandle(FILE *fh, bool tranfer_ownership);
+
+ void SetOutputFileHandle(FILE *fh, bool tranfer_ownership);
+
+ void SetErrorFileHandle(FILE *fh, bool tranfer_ownership);
+
+ void SaveInputTerminalState();
+
+ void RestoreInputTerminalState();
+
+ lldb::StreamSP GetAsyncOutputStream();
+
+ lldb::StreamSP GetAsyncErrorStream();
+
+ CommandInterpreter &GetCommandInterpreter() {
+ assert(m_command_interpreter_ap.get());
+ return *m_command_interpreter_ap;
+ }
+
+ lldb::ListenerSP GetListener() { return m_listener_sp; }
+
+ // This returns the Debugger's scratch source manager. It won't be able to
+ // look up files in debug
+ // information, but it can look up files by absolute path and display them to
+ // you.
+ // To get the target's source manager, call GetSourceManager on the target
+ // instead.
+ SourceManager &GetSourceManager();
+
+ lldb::TargetSP GetSelectedTarget() {
+ return m_target_list.GetSelectedTarget();
+ }
+
+ ExecutionContext GetSelectedExecutionContext();
+ //------------------------------------------------------------------
+ /// Get accessor for the target list.
+ ///
+ /// The target list is part of the global debugger object. This
+ /// the single debugger shared instance to control where targets
+ /// get created and to allow for tracking and searching for targets
+ /// based on certain criteria.
+ ///
+ /// @return
+ /// A global shared target list.
+ //------------------------------------------------------------------
+ TargetList &GetTargetList() { return m_target_list; }
+
+ PlatformList &GetPlatformList() { return m_platform_list; }
+
+ void DispatchInputInterrupt();
+
+ void DispatchInputEndOfFile();
+
+ //------------------------------------------------------------------
+ // If any of the streams are not set, set them to the in/out/err
+ // stream of the top most input reader to ensure they at least have
+ // something
+ //------------------------------------------------------------------
+ void AdoptTopIOHandlerFilesIfInvalid(lldb::StreamFileSP &in,
+ lldb::StreamFileSP &out,
+ lldb::StreamFileSP &err);
+
+ void PushIOHandler(const lldb::IOHandlerSP &reader_sp);
+
+ bool PopIOHandler(const lldb::IOHandlerSP &reader_sp);
+
+ // Synchronously run an input reader until it is done
+ void RunIOHandler(const lldb::IOHandlerSP &reader_sp);
+
+ bool IsTopIOHandler(const lldb::IOHandlerSP &reader_sp);
+
+ bool CheckTopIOHandlerTypes(IOHandler::Type top_type,
+ IOHandler::Type second_top_type);
+
+ void PrintAsync(const char *s, size_t len, bool is_stdout);
+
+ ConstString GetTopIOHandlerControlSequence(char ch);
+
+ const char *GetIOHandlerCommandPrefix();
+
+ const char *GetIOHandlerHelpPrologue();
+
+ void ClearIOHandlers();
+
+ bool GetCloseInputOnEOF() const;
+
+ void SetCloseInputOnEOF(bool b);
+
+ bool EnableLog(const char *channel, const char **categories,
+ const char *log_file, uint32_t log_options,
+ Stream &error_stream);
+
+ void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton);
+
+ //----------------------------------------------------------------------
+ // Properties Functions
+ //----------------------------------------------------------------------
+ enum StopDisassemblyType {
+ eStopDisassemblyTypeNever = 0,
+ eStopDisassemblyTypeNoDebugInfo,
+ eStopDisassemblyTypeNoSource,
+ eStopDisassemblyTypeAlways
+ };
+
+ Error SetPropertyValue(const ExecutionContext *exe_ctx,
+ VarSetOperationType op, llvm::StringRef property_path,
+ llvm::StringRef value) override;
+
+ bool GetAutoConfirm() const;
+
+ const FormatEntity::Entry *GetDisassemblyFormat() const;
+
+ const FormatEntity::Entry *GetFrameFormat() const;
+
+ const FormatEntity::Entry *GetThreadFormat() const;
+
+ const FormatEntity::Entry *GetThreadStopFormat() const;
+
+ lldb::ScriptLanguage GetScriptLanguage() const;
+
+ bool SetScriptLanguage(lldb::ScriptLanguage script_lang);
+
+ uint32_t GetTerminalWidth() const;
+
+ bool SetTerminalWidth(uint32_t term_width);
+
+ llvm::StringRef GetPrompt() const;
+
+ void SetPrompt(llvm::StringRef p);
+ void SetPrompt(const char *) = delete;
+
+ bool GetUseExternalEditor() const;
+
+ bool SetUseExternalEditor(bool use_external_editor_p);
+
+ bool GetUseColor() const;
+
+ bool SetUseColor(bool use_color);
+
+ lldb::StopShowColumn GetStopShowColumn() const;
+
+ const FormatEntity::Entry *GetStopShowColumnAnsiPrefix() const;
+
+ const FormatEntity::Entry *GetStopShowColumnAnsiSuffix() const;
+
+ uint32_t GetStopSourceLineCount(bool before) const;
+
+ StopDisassemblyType GetStopDisassemblyDisplay() const;
+
+ uint32_t GetDisassemblyLineCount() const;
+
+ bool GetAutoOneLineSummaries() const;
+
+ bool GetAutoIndent() const;
+
+ bool SetAutoIndent(bool b);
+
+ bool GetPrintDecls() const;
+
+ bool SetPrintDecls(bool b);
+
+ uint32_t GetTabSize() const;
+
+ bool SetTabSize(uint32_t tab_size);
+
+ bool GetEscapeNonPrintables() const;
+
+ bool GetNotifyVoid() const;
+
+ const ConstString &GetInstanceName() { return m_instance_name; }
+
+ bool LoadPlugin(const FileSpec &spec, Error &error);
+
+ void ExecuteIOHandlers();
+
+ bool IsForwardingEvents();
+
+ void EnableForwardEvents(const lldb::ListenerSP &listener_sp);
+
+ void CancelForwardEvents(const lldb::ListenerSP &listener_sp);
+
+ bool IsHandlingEvents() const { return m_event_handler_thread.IsJoinable(); }
+
+ Error RunREPL(lldb::LanguageType language, const char *repl_options);
+
+ // This is for use in the command interpreter, when you either want the
+ // selected target, or if no target
+ // is present you want to prime the dummy target with entities that will be
+ // copied over to new targets.
+ Target *GetSelectedOrDummyTarget(bool prefer_dummy = false);
+ Target *GetDummyTarget();
+
+ lldb::BroadcasterManagerSP GetBroadcasterManager() {
+ return m_broadcaster_manager_sp;
+ }
protected:
- friend class CommandInterpreter;
- friend class REPL;
-
- bool
- StartEventHandlerThread();
-
- void
- StopEventHandlerThread();
-
- static lldb::thread_result_t
- EventHandlerThread (lldb::thread_arg_t arg);
-
- bool
- HasIOHandlerThread();
-
- bool
- StartIOHandlerThread();
-
- void
- StopIOHandlerThread();
-
- void
- JoinIOHandlerThread();
-
- static lldb::thread_result_t
- IOHandlerThread (lldb::thread_arg_t arg);
-
- void
- DefaultEventHandler();
-
- void
- HandleBreakpointEvent (const lldb::EventSP &event_sp);
-
- void
- HandleProcessEvent (const lldb::EventSP &event_sp);
-
- void
- HandleThreadEvent (const lldb::EventSP &event_sp);
-
- size_t
- GetProcessSTDOUT (Process *process, Stream *stream);
-
- size_t
- GetProcessSTDERR (Process *process, Stream *stream);
-
- SourceManager::SourceFileCache &
- GetSourceFileCache ()
- {
- return m_source_file_cache;
- }
-
- void
- InstanceInitialize ();
-
- lldb::StreamFileSP m_input_file_sp;
- lldb::StreamFileSP m_output_file_sp;
- lldb::StreamFileSP m_error_file_sp;
-
- lldb::BroadcasterManagerSP m_broadcaster_manager_sp; // The debugger acts as a broadcaster manager of last resort.
- // It needs to get constructed before the target_list or any other
- // member that might want to broadcast through the debugger.
-
- TerminalState m_terminal_state;
- TargetList m_target_list;
-
- PlatformList m_platform_list;
- lldb::ListenerSP m_listener_sp;
- std::unique_ptr<SourceManager> m_source_manager_ap; // This is a scratch source manager that we return if we have no targets.
- SourceManager::SourceFileCache m_source_file_cache; // All the source managers for targets created in this debugger used this shared
- // source file cache.
- std::unique_ptr<CommandInterpreter> m_command_interpreter_ap;
-
- IOHandlerStack m_input_reader_stack;
- typedef std::map<std::string, lldb::StreamWP> LogStreamMap;
- LogStreamMap m_log_streams;
- lldb::StreamSP m_log_callback_stream_sp;
- ConstString m_instance_name;
- static LoadPluginCallbackType g_load_plugin_callback;
- typedef std::vector<llvm::sys::DynamicLibrary> LoadedPluginsList;
- LoadedPluginsList m_loaded_plugins;
- HostThread m_event_handler_thread;
- HostThread m_io_handler_thread;
- Broadcaster m_sync_broadcaster;
- lldb::ListenerSP m_forward_listener_sp;
- std::once_flag m_clear_once;
-
- //----------------------------------------------------------------------
- // Events for m_sync_broadcaster
- //----------------------------------------------------------------------
- enum
- {
- eBroadcastBitEventThreadIsListening = (1 << 0),
- };
+ friend class CommandInterpreter;
+ friend class REPL;
+
+ bool StartEventHandlerThread();
+
+ void StopEventHandlerThread();
+
+ static lldb::thread_result_t EventHandlerThread(lldb::thread_arg_t arg);
+
+ bool HasIOHandlerThread();
+
+ bool StartIOHandlerThread();
+
+ void StopIOHandlerThread();
+
+ void JoinIOHandlerThread();
+
+ static lldb::thread_result_t IOHandlerThread(lldb::thread_arg_t arg);
+
+ void DefaultEventHandler();
+
+ void HandleBreakpointEvent(const lldb::EventSP &event_sp);
+
+ void HandleProcessEvent(const lldb::EventSP &event_sp);
+
+ void HandleThreadEvent(const lldb::EventSP &event_sp);
+
+ size_t GetProcessSTDOUT(Process *process, Stream *stream);
+
+ size_t GetProcessSTDERR(Process *process, Stream *stream);
+
+ SourceManager::SourceFileCache &GetSourceFileCache() {
+ return m_source_file_cache;
+ }
+
+ void InstanceInitialize();
+
+ lldb::StreamFileSP m_input_file_sp;
+ lldb::StreamFileSP m_output_file_sp;
+ lldb::StreamFileSP m_error_file_sp;
+
+ lldb::BroadcasterManagerSP m_broadcaster_manager_sp; // The debugger acts as a
+ // broadcaster manager of
+ // last resort.
+ // It needs to get constructed before the target_list or any other
+ // member that might want to broadcast through the debugger.
+
+ TerminalState m_terminal_state;
+ TargetList m_target_list;
+
+ PlatformList m_platform_list;
+ lldb::ListenerSP m_listener_sp;
+ std::unique_ptr<SourceManager> m_source_manager_ap; // This is a scratch
+ // source manager that we
+ // return if we have no
+ // targets.
+ SourceManager::SourceFileCache m_source_file_cache; // All the source managers
+ // for targets created in
+ // this debugger used this
+ // shared
+ // source file cache.
+ std::unique_ptr<CommandInterpreter> m_command_interpreter_ap;
+
+ IOHandlerStack m_input_reader_stack;
+ typedef std::map<std::string, lldb::StreamWP> LogStreamMap;
+ LogStreamMap m_log_streams;
+ lldb::StreamSP m_log_callback_stream_sp;
+ ConstString m_instance_name;
+ static LoadPluginCallbackType g_load_plugin_callback;
+ typedef std::vector<llvm::sys::DynamicLibrary> LoadedPluginsList;
+ LoadedPluginsList m_loaded_plugins;
+ HostThread m_event_handler_thread;
+ HostThread m_io_handler_thread;
+ Broadcaster m_sync_broadcaster;
+ lldb::ListenerSP m_forward_listener_sp;
+ std::once_flag m_clear_once;
+
+ //----------------------------------------------------------------------
+ // Events for m_sync_broadcaster
+ //----------------------------------------------------------------------
+ enum {
+ eBroadcastBitEventThreadIsListening = (1 << 0),
+ };
private:
- // Use Debugger::CreateInstance() to get a shared pointer to a new
- // debugger object
- Debugger (lldb::LogOutputCallback m_log_callback, void *baton);
+ // Use Debugger::CreateInstance() to get a shared pointer to a new
+ // debugger object
+ Debugger(lldb::LogOutputCallback m_log_callback, void *baton);
- DISALLOW_COPY_AND_ASSIGN (Debugger);
+ DISALLOW_COPY_AND_ASSIGN(Debugger);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/Disassembler.h b/include/lldb/Core/Disassembler.h
index bfa99de81ea4..c42074719b1a 100644
--- a/include/lldb/Core/Disassembler.h
+++ b/include/lldb/Core/Disassembler.h
@@ -12,472 +12,498 @@
// C Includes
// C++ Includes
-#include <vector>
#include <string>
+#include <vector>
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/EmulateInstruction.h"
#include "lldb/Core/Opcode.h"
#include "lldb/Core/PluginInterface.h"
+#include "lldb/Host/FileSpec.h"
#include "lldb/Interpreter/OptionValue.h"
+#include "lldb/Symbol/LineEntry.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class Instruction
-{
+class Instruction {
public:
- Instruction (const Address &address,
- lldb::AddressClass addr_class = lldb::eAddressClassInvalid);
-
- virtual
- ~Instruction();
-
- const Address &
- GetAddress () const
- {
- return m_address;
- }
-
- const char *
- GetMnemonic (const ExecutionContext* exe_ctx)
- {
- CalculateMnemonicOperandsAndCommentIfNeeded (exe_ctx);
- return m_opcode_name.c_str();
- }
-
- const char *
- GetOperands (const ExecutionContext* exe_ctx)
- {
- CalculateMnemonicOperandsAndCommentIfNeeded (exe_ctx);
- return m_mnemonics.c_str();
- }
-
- const char *
- GetComment (const ExecutionContext* exe_ctx)
- {
- CalculateMnemonicOperandsAndCommentIfNeeded (exe_ctx);
- return m_comment.c_str();
- }
-
- virtual void
- CalculateMnemonicOperandsAndComment (const ExecutionContext* exe_ctx) = 0;
-
- lldb::AddressClass
- GetAddressClass ();
-
- void
- SetAddress (const Address &addr)
- {
- // Invalidate the address class to lazily discover
- // it if we need to.
- m_address_class = lldb::eAddressClassInvalid;
- m_address = addr;
- }
-
- //------------------------------------------------------------------
- /// Dump the text representation of this Instruction to a Stream
- ///
- /// Print the (optional) address, (optional) bytes, opcode,
- /// operands, and instruction comments to a stream.
- ///
- /// @param[in] s
- /// The Stream to add the text to.
- ///
- /// @param[in] show_address
- /// Whether the address (using disassembly_addr_format_spec formatting)
- /// should be printed.
- ///
- /// @param[in] show_bytes
- /// Whether the bytes of the assembly instruction should be printed.
- ///
- /// @param[in] max_opcode_byte_size
- /// The size (in bytes) of the largest instruction in the list that
- /// we are printing (for text justification/alignment purposes)
- /// Only needed if show_bytes is true.
- ///
- /// @param[in] exe_ctx
- /// The current execution context, if available. May be used in
- /// the assembling of the operands+comments for this instruction.
- /// Pass NULL if not applicable.
- ///
- /// @param[in] sym_ctx
- /// The SymbolContext for this instruction.
- /// Pass NULL if not available/computed.
- /// Only needed if show_address is true.
- ///
- /// @param[in] prev_sym_ctx
- /// The SymbolContext for the previous instruction. Depending on
- /// the disassembly address format specification, a change in
- /// Symbol / Function may mean that a line is printed with the new
- /// symbol/function name.
- /// Pass NULL if unavailable, or if this is the first instruction of
- /// the InstructionList.
- /// Only needed if show_address is true.
- ///
- /// @param[in] disassembly_addr_format
- /// The format specification for how addresses are printed.
- /// Only needed if show_address is true.
- ///
- /// @param[in] max_address_text_size
- /// The length of the longest address string at the start of the
- /// disassembly line that will be printed (the Debugger::FormatDisassemblerAddress() string)
- /// so this method can properly align the instruction opcodes.
- /// May be 0 to indicate no indentation/alignment of the opcodes.
- //------------------------------------------------------------------
- virtual void
- Dump (Stream *s,
- uint32_t max_opcode_byte_size,
- bool show_address,
- bool show_bytes,
- const ExecutionContext* exe_ctx,
- const SymbolContext *sym_ctx,
- const SymbolContext *prev_sym_ctx,
- const FormatEntity::Entry *disassembly_addr_format,
- size_t max_address_text_size);
-
- virtual bool
- DoesBranch () = 0;
-
- virtual bool
- HasDelaySlot ();
-
- virtual size_t
- Decode (const Disassembler &disassembler,
- const DataExtractor& data,
- lldb::offset_t data_offset) = 0;
-
- virtual void
- SetDescription (const char *) {} // May be overridden in sub-classes that have descriptions.
-
- lldb::OptionValueSP
- ReadArray (FILE *in_file, Stream *out_stream, OptionValue::Type data_type);
-
- lldb::OptionValueSP
- ReadDictionary (FILE *in_file, Stream *out_stream);
-
- bool
- DumpEmulation (const ArchSpec &arch);
-
- virtual bool
- TestEmulation (Stream *stream, const char *test_file_name);
-
- bool
- Emulate (const ArchSpec &arch,
- uint32_t evaluate_options,
- void *baton,
- EmulateInstruction::ReadMemoryCallback read_mem_callback,
- EmulateInstruction::WriteMemoryCallback write_mem_calback,
- EmulateInstruction::ReadRegisterCallback read_reg_callback,
- EmulateInstruction::WriteRegisterCallback write_reg_callback);
-
- const Opcode &
- GetOpcode () const
- {
- return m_opcode;
- }
-
- uint32_t
- GetData (DataExtractor &data);
+ Instruction(const Address &address,
+ lldb::AddressClass addr_class = lldb::eAddressClassInvalid);
+
+ virtual ~Instruction();
+
+ const Address &GetAddress() const { return m_address; }
+
+ const char *GetMnemonic(const ExecutionContext *exe_ctx) {
+ CalculateMnemonicOperandsAndCommentIfNeeded(exe_ctx);
+ return m_opcode_name.c_str();
+ }
+
+ const char *GetOperands(const ExecutionContext *exe_ctx) {
+ CalculateMnemonicOperandsAndCommentIfNeeded(exe_ctx);
+ return m_mnemonics.c_str();
+ }
+
+ const char *GetComment(const ExecutionContext *exe_ctx) {
+ CalculateMnemonicOperandsAndCommentIfNeeded(exe_ctx);
+ return m_comment.c_str();
+ }
+
+ virtual void
+ CalculateMnemonicOperandsAndComment(const ExecutionContext *exe_ctx) = 0;
+
+ lldb::AddressClass GetAddressClass();
+
+ void SetAddress(const Address &addr) {
+ // Invalidate the address class to lazily discover
+ // it if we need to.
+ m_address_class = lldb::eAddressClassInvalid;
+ m_address = addr;
+ }
+
+ //------------------------------------------------------------------
+ /// Dump the text representation of this Instruction to a Stream
+ ///
+ /// Print the (optional) address, (optional) bytes, opcode,
+ /// operands, and instruction comments to a stream.
+ ///
+ /// @param[in] s
+ /// The Stream to add the text to.
+ ///
+ /// @param[in] show_address
+ /// Whether the address (using disassembly_addr_format_spec formatting)
+ /// should be printed.
+ ///
+ /// @param[in] show_bytes
+ /// Whether the bytes of the assembly instruction should be printed.
+ ///
+ /// @param[in] max_opcode_byte_size
+ /// The size (in bytes) of the largest instruction in the list that
+ /// we are printing (for text justification/alignment purposes)
+ /// Only needed if show_bytes is true.
+ ///
+ /// @param[in] exe_ctx
+ /// The current execution context, if available. May be used in
+ /// the assembling of the operands+comments for this instruction.
+ /// Pass NULL if not applicable.
+ ///
+ /// @param[in] sym_ctx
+ /// The SymbolContext for this instruction.
+ /// Pass NULL if not available/computed.
+ /// Only needed if show_address is true.
+ ///
+ /// @param[in] prev_sym_ctx
+ /// The SymbolContext for the previous instruction. Depending on
+ /// the disassembly address format specification, a change in
+ /// Symbol / Function may mean that a line is printed with the new
+ /// symbol/function name.
+ /// Pass NULL if unavailable, or if this is the first instruction of
+ /// the InstructionList.
+ /// Only needed if show_address is true.
+ ///
+ /// @param[in] disassembly_addr_format
+ /// The format specification for how addresses are printed.
+ /// Only needed if show_address is true.
+ ///
+ /// @param[in] max_address_text_size
+ /// The length of the longest address string at the start of the
+ /// disassembly line that will be printed (the
+ /// Debugger::FormatDisassemblerAddress() string)
+ /// so this method can properly align the instruction opcodes.
+ /// May be 0 to indicate no indentation/alignment of the opcodes.
+ //------------------------------------------------------------------
+ virtual void Dump(Stream *s, uint32_t max_opcode_byte_size, bool show_address,
+ bool show_bytes, const ExecutionContext *exe_ctx,
+ const SymbolContext *sym_ctx,
+ const SymbolContext *prev_sym_ctx,
+ const FormatEntity::Entry *disassembly_addr_format,
+ size_t max_address_text_size);
+
+ virtual bool DoesBranch() = 0;
+
+ virtual bool HasDelaySlot();
+
+ virtual size_t Decode(const Disassembler &disassembler,
+ const DataExtractor &data,
+ lldb::offset_t data_offset) = 0;
+
+ virtual void SetDescription(llvm::StringRef) {
+ } // May be overridden in sub-classes that have descriptions.
+
+ lldb::OptionValueSP ReadArray(FILE *in_file, Stream *out_stream,
+ OptionValue::Type data_type);
+
+ lldb::OptionValueSP ReadDictionary(FILE *in_file, Stream *out_stream);
+
+ bool DumpEmulation(const ArchSpec &arch);
+
+ virtual bool TestEmulation(Stream *stream, const char *test_file_name);
+
+ bool Emulate(const ArchSpec &arch, uint32_t evaluate_options, void *baton,
+ EmulateInstruction::ReadMemoryCallback read_mem_callback,
+ EmulateInstruction::WriteMemoryCallback write_mem_calback,
+ EmulateInstruction::ReadRegisterCallback read_reg_callback,
+ EmulateInstruction::WriteRegisterCallback write_reg_callback);
+
+ const Opcode &GetOpcode() const { return m_opcode; }
+
+ uint32_t GetData(DataExtractor &data);
+
+ struct Operand {
+ enum class Type {
+ Invalid = 0,
+ Register,
+ Immediate,
+ Dereference,
+ Sum,
+ Product
+ } m_type = Type::Invalid;
+ std::vector<Operand> m_children;
+ lldb::addr_t m_immediate = 0;
+ ConstString m_register;
+ bool m_negative = false;
+ bool m_clobbered = false;
+
+ bool IsValid() { return m_type != Type::Invalid; }
+
+ static Operand BuildRegister(ConstString &r);
+ static Operand BuildImmediate(lldb::addr_t imm, bool neg);
+ static Operand BuildImmediate(int64_t imm);
+ static Operand BuildDereference(const Operand &ref);
+ static Operand BuildSum(const Operand &lhs, const Operand &rhs);
+ static Operand BuildProduct(const Operand &lhs, const Operand &rhs);
+ };
+
+ virtual bool ParseOperands(llvm::SmallVectorImpl<Operand> &operands) {
+ return false;
+ }
+
+ virtual bool IsCall() { return false; }
protected:
- Address m_address; // The section offset address of this instruction
- // We include an address class in the Instruction class to
- // allow the instruction specify the eAddressClassCodeAlternateISA
- // (currently used for thumb), and also to specify data (eAddressClassData).
- // The usual value will be eAddressClassCode, but often when
- // disassembling memory, you might run into data. This can
- // help us to disassemble appropriately.
+ Address m_address; // The section offset address of this instruction
+ // We include an address class in the Instruction class to
+ // allow the instruction specify the eAddressClassCodeAlternateISA
+ // (currently used for thumb), and also to specify data (eAddressClassData).
+ // The usual value will be eAddressClassCode, but often when
+ // disassembling memory, you might run into data. This can
+ // help us to disassemble appropriately.
private:
- lldb::AddressClass m_address_class; // Use GetAddressClass () accessor function!
+ lldb::AddressClass
+ m_address_class; // Use GetAddressClass () accessor function!
protected:
- Opcode m_opcode; // The opcode for this instruction
- std::string m_opcode_name;
- std::string m_mnemonics;
- std::string m_comment;
- bool m_calculated_strings;
-
- void
- CalculateMnemonicOperandsAndCommentIfNeeded (const ExecutionContext* exe_ctx)
- {
- if (!m_calculated_strings)
- {
- m_calculated_strings = true;
- CalculateMnemonicOperandsAndComment(exe_ctx);
- }
+ Opcode m_opcode; // The opcode for this instruction
+ std::string m_opcode_name;
+ std::string m_mnemonics;
+ std::string m_comment;
+ bool m_calculated_strings;
+
+ void
+ CalculateMnemonicOperandsAndCommentIfNeeded(const ExecutionContext *exe_ctx) {
+ if (!m_calculated_strings) {
+ m_calculated_strings = true;
+ CalculateMnemonicOperandsAndComment(exe_ctx);
}
+ }
};
-class InstructionList
-{
+namespace OperandMatchers {
+std::function<bool(const Instruction::Operand &)>
+MatchBinaryOp(std::function<bool(const Instruction::Operand &)> base,
+ std::function<bool(const Instruction::Operand &)> left,
+ std::function<bool(const Instruction::Operand &)> right);
+
+std::function<bool(const Instruction::Operand &)>
+MatchUnaryOp(std::function<bool(const Instruction::Operand &)> base,
+ std::function<bool(const Instruction::Operand &)> child);
+
+std::function<bool(const Instruction::Operand &)>
+MatchRegOp(const RegisterInfo &info);
+
+std::function<bool(const Instruction::Operand &)> FetchRegOp(ConstString &reg);
+
+std::function<bool(const Instruction::Operand &)> MatchImmOp(int64_t imm);
+
+std::function<bool(const Instruction::Operand &)> FetchImmOp(int64_t &imm);
+
+std::function<bool(const Instruction::Operand &)>
+MatchOpType(Instruction::Operand::Type type);
+}
+
+class InstructionList {
public:
- InstructionList();
- ~InstructionList();
-
- size_t
- GetSize() const;
-
- uint32_t
- GetMaxOpcocdeByteSize () const;
-
- lldb::InstructionSP
- GetInstructionAtIndex (size_t idx) const;
-
- uint32_t
- GetIndexOfNextBranchInstruction(uint32_t start, Target &target) const;
-
- uint32_t
- GetIndexOfInstructionAtLoadAddress (lldb::addr_t load_addr, Target &target);
-
- uint32_t
- GetIndexOfInstructionAtAddress (const Address &addr);
-
- void
- Clear();
-
- void
- Append (lldb::InstructionSP &inst_sp);
-
- void
- Dump (Stream *s,
- bool show_address,
- bool show_bytes,
- const ExecutionContext* exe_ctx);
+ InstructionList();
+ ~InstructionList();
+
+ size_t GetSize() const;
+
+ uint32_t GetMaxOpcocdeByteSize() const;
+
+ lldb::InstructionSP GetInstructionAtIndex(size_t idx) const;
+
+ uint32_t GetIndexOfNextBranchInstruction(uint32_t start,
+ Target &target) const;
+
+ uint32_t GetIndexOfInstructionAtLoadAddress(lldb::addr_t load_addr,
+ Target &target);
+
+ uint32_t GetIndexOfInstructionAtAddress(const Address &addr);
+
+ void Clear();
+
+ void Append(lldb::InstructionSP &inst_sp);
+
+ void Dump(Stream *s, bool show_address, bool show_bytes,
+ const ExecutionContext *exe_ctx);
private:
- typedef std::vector<lldb::InstructionSP> collection;
- typedef collection::iterator iterator;
- typedef collection::const_iterator const_iterator;
+ typedef std::vector<lldb::InstructionSP> collection;
+ typedef collection::iterator iterator;
+ typedef collection::const_iterator const_iterator;
- collection m_instructions;
+ collection m_instructions;
};
-class PseudoInstruction :
- public Instruction
-{
+class PseudoInstruction : public Instruction {
public:
+ PseudoInstruction();
+
+ ~PseudoInstruction() override;
+
+ bool DoesBranch() override;
+
+ bool HasDelaySlot() override;
+
+ void CalculateMnemonicOperandsAndComment(
+ const ExecutionContext *exe_ctx) override {
+ // TODO: fill this in and put opcode name into Instruction::m_opcode_name,
+ // mnemonic into Instruction::m_mnemonics, and any comment into
+ // Instruction::m_comment
+ }
+
+ size_t Decode(const Disassembler &disassembler, const DataExtractor &data,
+ lldb::offset_t data_offset) override;
+
+ void SetOpcode(size_t opcode_size, void *opcode_data);
+
+ void SetDescription(llvm::StringRef description) override;
- PseudoInstruction ();
-
- ~PseudoInstruction() override;
-
- bool
- DoesBranch() override;
-
- bool
- HasDelaySlot() override;
-
- void
- CalculateMnemonicOperandsAndComment(const ExecutionContext* exe_ctx) override
- {
- // TODO: fill this in and put opcode name into Instruction::m_opcode_name,
- // mnemonic into Instruction::m_mnemonics, and any comment into
- // Instruction::m_comment
- }
-
- size_t
- Decode(const Disassembler &disassembler,
- const DataExtractor &data,
- lldb::offset_t data_offset) override;
-
- void
- SetOpcode (size_t opcode_size, void *opcode_data);
-
- void
- SetDescription(const char *description) override;
-
protected:
- std::string m_description;
-
- DISALLOW_COPY_AND_ASSIGN (PseudoInstruction);
+ std::string m_description;
+
+ DISALLOW_COPY_AND_ASSIGN(PseudoInstruction);
};
-class Disassembler :
- public std::enable_shared_from_this<Disassembler>,
- public PluginInterface
-{
+class Disassembler : public std::enable_shared_from_this<Disassembler>,
+ public PluginInterface {
public:
+ enum {
+ eOptionNone = 0u,
+ eOptionShowBytes = (1u << 0),
+ eOptionRawOuput = (1u << 1),
+ eOptionMarkPCSourceLine = (1u << 2), // Mark the source line that contains
+ // the current PC (mixed mode only)
+ eOptionMarkPCAddress =
+ (1u << 3) // Mark the disassembly line the contains the PC
+ };
+
+ enum HexImmediateStyle {
+ eHexStyleC,
+ eHexStyleAsm,
+ };
+
+ // FindPlugin should be lax about the flavor string (it is too annoying to
+ // have various internal uses of the
+ // disassembler fail because the global flavor string gets set wrong.
+ // Instead, if you get a flavor string you
+ // don't understand, use the default. Folks who care to check can use the
+ // FlavorValidForArchSpec method on the
+ // disassembler they got back.
+ static lldb::DisassemblerSP
+ FindPlugin(const ArchSpec &arch, const char *flavor, const char *plugin_name);
+
+ // This version will use the value in the Target settings if flavor is NULL;
+ static lldb::DisassemblerSP
+ FindPluginForTarget(const lldb::TargetSP target_sp, const ArchSpec &arch,
+ const char *flavor, const char *plugin_name);
+
+ static lldb::DisassemblerSP
+ DisassembleRange(const ArchSpec &arch, const char *plugin_name,
+ const char *flavor, const ExecutionContext &exe_ctx,
+ const AddressRange &disasm_range, bool prefer_file_cache);
+
+ static lldb::DisassemblerSP
+ DisassembleBytes(const ArchSpec &arch, const char *plugin_name,
+ const char *flavor, const Address &start, const void *bytes,
+ size_t length, uint32_t max_num_instructions,
+ bool data_from_file);
+
+ static bool Disassemble(Debugger &debugger, const ArchSpec &arch,
+ const char *plugin_name, const char *flavor,
+ const ExecutionContext &exe_ctx,
+ const AddressRange &range, uint32_t num_instructions,
+ bool mixed_source_and_assembly,
+ uint32_t num_mixed_context_lines, uint32_t options,
+ Stream &strm);
+
+ static bool Disassemble(Debugger &debugger, const ArchSpec &arch,
+ const char *plugin_name, const char *flavor,
+ const ExecutionContext &exe_ctx, const Address &start,
+ uint32_t num_instructions,
+ bool mixed_source_and_assembly,
+ uint32_t num_mixed_context_lines, uint32_t options,
+ Stream &strm);
+
+ static size_t
+ Disassemble(Debugger &debugger, const ArchSpec &arch, const char *plugin_name,
+ const char *flavor, const ExecutionContext &exe_ctx,
+ SymbolContextList &sc_list, uint32_t num_instructions,
+ bool mixed_source_and_assembly, uint32_t num_mixed_context_lines,
+ uint32_t options, Stream &strm);
+
+ static bool
+ Disassemble(Debugger &debugger, const ArchSpec &arch, const char *plugin_name,
+ const char *flavor, const ExecutionContext &exe_ctx,
+ const ConstString &name, Module *module,
+ uint32_t num_instructions, bool mixed_source_and_assembly,
+ uint32_t num_mixed_context_lines, uint32_t options, Stream &strm);
+
+ static bool
+ Disassemble(Debugger &debugger, const ArchSpec &arch, const char *plugin_name,
+ const char *flavor, const ExecutionContext &exe_ctx,
+ uint32_t num_instructions, bool mixed_source_and_assembly,
+ uint32_t num_mixed_context_lines, uint32_t options, Stream &strm);
+
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ Disassembler(const ArchSpec &arch, const char *flavor);
+ ~Disassembler() override;
+
+ typedef const char *(*SummaryCallback)(const Instruction &inst,
+ ExecutionContext *exe_context,
+ void *user_data);
+
+ static bool PrintInstructions(Disassembler *disasm_ptr, Debugger &debugger,
+ const ArchSpec &arch,
+ const ExecutionContext &exe_ctx,
+ uint32_t num_instructions,
+ bool mixed_source_and_assembly,
+ uint32_t num_mixed_context_lines,
+ uint32_t options, Stream &strm);
+
+ size_t ParseInstructions(const ExecutionContext *exe_ctx,
+ const AddressRange &range, Stream *error_strm_ptr,
+ bool prefer_file_cache);
+
+ size_t ParseInstructions(const ExecutionContext *exe_ctx,
+ const Address &range, uint32_t num_instructions,
+ bool prefer_file_cache);
+
+ virtual size_t DecodeInstructions(const Address &base_addr,
+ const DataExtractor &data,
+ lldb::offset_t data_offset,
+ size_t num_instructions, bool append,
+ bool data_from_file) = 0;
+
+ InstructionList &GetInstructionList();
+
+ const InstructionList &GetInstructionList() const;
+
+ const ArchSpec &GetArchitecture() const { return m_arch; }
+
+ const char *GetFlavor() const { return m_flavor.c_str(); }
+
+ virtual bool FlavorValidForArchSpec(const lldb_private::ArchSpec &arch,
+ const char *flavor) = 0;
+
+protected:
+ // SourceLine and SourceLinesToDisplay structures are only used in
+ // the mixed source and assembly display methods internal to this class.
- enum
- {
- eOptionNone = 0u,
- eOptionShowBytes = (1u << 0),
- eOptionRawOuput = (1u << 1),
- eOptionMarkPCSourceLine = (1u << 2), // Mark the source line that contains the current PC (mixed mode only)
- eOptionMarkPCAddress = (1u << 3) // Mark the disassembly line the contains the PC
- };
-
- enum HexImmediateStyle
- {
- eHexStyleC,
- eHexStyleAsm,
- };
-
- // FindPlugin should be lax about the flavor string (it is too annoying to have various internal uses of the
- // disassembler fail because the global flavor string gets set wrong. Instead, if you get a flavor string you
- // don't understand, use the default. Folks who care to check can use the FlavorValidForArchSpec method on the
- // disassembler they got back.
- static lldb::DisassemblerSP
- FindPlugin (const ArchSpec &arch, const char *flavor, const char *plugin_name);
-
- // This version will use the value in the Target settings if flavor is NULL;
- static lldb::DisassemblerSP
- FindPluginForTarget(const lldb::TargetSP target_sp, const ArchSpec &arch, const char *flavor, const char *plugin_name);
-
- static lldb::DisassemblerSP
- DisassembleRange (const ArchSpec &arch,
- const char *plugin_name,
- const char *flavor,
- const ExecutionContext &exe_ctx,
- const AddressRange &disasm_range,
- bool prefer_file_cache);
-
- static lldb::DisassemblerSP
- DisassembleBytes (const ArchSpec &arch,
- const char *plugin_name,
- const char *flavor,
- const Address &start,
- const void *bytes,
- size_t length,
- uint32_t max_num_instructions,
- bool data_from_file);
-
- static bool
- Disassemble (Debugger &debugger,
- const ArchSpec &arch,
- const char *plugin_name,
- const char *flavor,
- const ExecutionContext &exe_ctx,
- const AddressRange &range,
- uint32_t num_instructions,
- uint32_t num_mixed_context_lines,
- uint32_t options,
- Stream &strm);
-
- static bool
- Disassemble (Debugger &debugger,
- const ArchSpec &arch,
- const char *plugin_name,
- const char *flavor,
- const ExecutionContext &exe_ctx,
- const Address &start,
- uint32_t num_instructions,
- uint32_t num_mixed_context_lines,
- uint32_t options,
- Stream &strm);
-
- static size_t
- Disassemble (Debugger &debugger,
- const ArchSpec &arch,
- const char *plugin_name,
- const char *flavor,
- const ExecutionContext &exe_ctx,
- SymbolContextList &sc_list,
- uint32_t num_instructions,
- uint32_t num_mixed_context_lines,
- uint32_t options,
- Stream &strm);
-
- static bool
- Disassemble (Debugger &debugger,
- const ArchSpec &arch,
- const char *plugin_name,
- const char *flavor,
- const ExecutionContext &exe_ctx,
- const ConstString &name,
- Module *module,
- uint32_t num_instructions,
- uint32_t num_mixed_context_lines,
- uint32_t options,
- Stream &strm);
-
- static bool
- Disassemble (Debugger &debugger,
- const ArchSpec &arch,
- const char *plugin_name,
- const char *flavor,
- const ExecutionContext &exe_ctx,
- uint32_t num_instructions,
- uint32_t num_mixed_context_lines,
- uint32_t options,
- Stream &strm);
-
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- Disassembler(const ArchSpec &arch, const char *flavor);
- ~Disassembler() override;
-
- typedef const char * (*SummaryCallback)(const Instruction& inst, ExecutionContext *exe_context, void *user_data);
-
- static bool
- PrintInstructions (Disassembler *disasm_ptr,
- Debugger &debugger,
- const ArchSpec &arch,
- const ExecutionContext &exe_ctx,
- uint32_t num_instructions,
- uint32_t num_mixed_context_lines,
- uint32_t options,
- Stream &strm);
-
- size_t
- ParseInstructions (const ExecutionContext *exe_ctx,
- const AddressRange &range,
- Stream *error_strm_ptr,
- bool prefer_file_cache);
-
- size_t
- ParseInstructions (const ExecutionContext *exe_ctx,
- const Address &range,
- uint32_t num_instructions,
- bool prefer_file_cache);
-
- virtual size_t
- DecodeInstructions (const Address &base_addr,
- const DataExtractor& data,
- lldb::offset_t data_offset,
- size_t num_instructions,
- bool append,
- bool data_from_file) = 0;
-
- InstructionList &
- GetInstructionList ();
-
- const InstructionList &
- GetInstructionList () const;
-
- const ArchSpec &
- GetArchitecture () const
- {
- return m_arch;
+ struct SourceLine {
+ FileSpec file;
+ uint32_t line;
+ uint32_t column;
+
+ SourceLine() : file(), line(LLDB_INVALID_LINE_NUMBER), column(0) {}
+
+ bool operator==(const SourceLine &rhs) const {
+ return file == rhs.file && line == rhs.line && rhs.column == column;
}
-
- const char *
- GetFlavor () const
- {
- return m_flavor.c_str();
+
+ bool operator!=(const SourceLine &rhs) const {
+ return file != rhs.file || line != rhs.line || column != rhs.column;
}
-
- virtual bool
- FlavorValidForArchSpec (const lldb_private::ArchSpec &arch, const char *flavor) = 0;
-protected:
- //------------------------------------------------------------------
- // Classes that inherit from Disassembler can see and modify these
- //------------------------------------------------------------------
- ArchSpec m_arch;
- InstructionList m_instruction_list;
- lldb::addr_t m_base_addr;
- std::string m_flavor;
+ bool IsValid() const { return line != LLDB_INVALID_LINE_NUMBER; }
+ };
+
+ struct SourceLinesToDisplay {
+ std::vector<SourceLine> lines;
+
+ // index of the "current" source line, if we want to highlight that
+ // when displaying the source lines. (as opposed to the surrounding
+ // source lines provided to give context)
+ size_t current_source_line;
+
+ // Whether to print a blank line at the end of the source lines.
+ bool print_source_context_end_eol;
+
+ SourceLinesToDisplay()
+ : lines(), current_source_line(-1), print_source_context_end_eol(true) {
+ }
+ };
+
+ // Get the function's declaration line number, hopefully a line number earlier
+ // than the opening curly brace at the start of the function body.
+ static SourceLine GetFunctionDeclLineEntry(const SymbolContext &sc);
+
+ // Add the provided SourceLine to the map of filenames-to-source-lines-seen.
+ static void AddLineToSourceLineTables(
+ SourceLine &line,
+ std::map<FileSpec, std::set<uint32_t>> &source_lines_seen);
+
+ // Given a source line, determine if we should print it when we're doing
+ // mixed source & assembly output.
+ // We're currently using the target.process.thread.step-avoid-regexp setting
+ // (which is used for stepping over inlined STL functions by default) to
+ // determine what source lines to avoid showing.
+ //
+ // Returns true if this source line should be elided (if the source line
+ // should
+ // not be displayed).
+ static bool
+ ElideMixedSourceAndDisassemblyLine(const ExecutionContext &exe_ctx,
+ const SymbolContext &sc, SourceLine &line);
+
+ static bool
+ ElideMixedSourceAndDisassemblyLine(const ExecutionContext &exe_ctx,
+ const SymbolContext &sc, LineEntry &line) {
+ SourceLine sl;
+ sl.file = line.file;
+ sl.line = line.line;
+ sl.column = line.column;
+ return ElideMixedSourceAndDisassemblyLine(exe_ctx, sc, sl);
+ };
+
+ //------------------------------------------------------------------
+ // Classes that inherit from Disassembler can see and modify these
+ //------------------------------------------------------------------
+ ArchSpec m_arch;
+ InstructionList m_instruction_list;
+ lldb::addr_t m_base_addr;
+ std::string m_flavor;
private:
- //------------------------------------------------------------------
- // For Disassembler only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (Disassembler);
+ //------------------------------------------------------------------
+ // For Disassembler only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(Disassembler);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/EmulateInstruction.h b/include/lldb/Core/EmulateInstruction.h
index 36fff43bf6bc..90e66d668ca4 100644
--- a/include/lldb/Core/EmulateInstruction.h
+++ b/include/lldb/Core/EmulateInstruction.h
@@ -12,24 +12,25 @@
#include <string>
-#include "lldb/lldb-private.h"
-#include "lldb/lldb-public.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/Opcode.h"
+#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/RegisterValue.h"
+#include "lldb/lldb-private.h"
+#include "lldb/lldb-public.h"
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class EmulateInstruction EmulateInstruction.h "lldb/Core/EmulateInstruction.h"
+/// @class EmulateInstruction EmulateInstruction.h
+/// "lldb/Core/EmulateInstruction.h"
/// @brief A class that allows emulation of CPU opcodes.
///
-/// This class is a plug-in interface that is accessed through the
+/// This class is a plug-in interface that is accessed through the
/// standard static FindPlugin function call in the EmulateInstruction
/// class. The FindPlugin takes a target triple and returns a new object
/// if there is a plug-in that supports the architecture and OS. Four
-/// callbacks and a baton are provided. The four callbacks are read
+/// callbacks and a baton are provided. The four callbacks are read
/// register, write register, read memory and write memory.
///
/// This class is currently designed for these main use cases:
@@ -38,13 +39,13 @@ namespace lldb_private {
/// - Emulating instructions for breakpoint traps
///
/// Objects can be asked to read an instruction which will cause a call
-/// to the read register callback to get the PC, followed by a read
-/// memory call to read the opcode. If ReadInstruction () returns true,
-/// then a call to EmulateInstruction::EvaluateInstruction () can be
+/// to the read register callback to get the PC, followed by a read
+/// memory call to read the opcode. If ReadInstruction () returns true,
+/// then a call to EmulateInstruction::EvaluateInstruction () can be
/// made. At this point the EmulateInstruction subclass will use all of
/// the callbacks to emulate an instruction.
///
-/// Clients that provide the callbacks can either do the read/write
+/// Clients that provide the callbacks can either do the read/write
/// registers/memory to actually emulate the instruction on a real or
/// virtual CPU, or watch for the EmulateInstruction::Context which
/// is context for the read/write register/memory which explains why
@@ -54,15 +55,15 @@ namespace lldb_private {
/// CFI information from assembly code without having to actually do
/// the read/write register/memory.
///
-/// Clients must be prepared that not all instructions for an
-/// Instruction Set Architecture (ISA) will be emulated.
+/// Clients must be prepared that not all instructions for an
+/// Instruction Set Architecture (ISA) will be emulated.
///
/// Subclasses at the very least should implement the instructions that
/// save and restore registers onto the stack and adjustment to the stack
/// pointer. By just implementing a few instructions for an ISA that are
-/// the typical prologue opcodes, you can then generate CFI using a
+/// the typical prologue opcodes, you can then generate CFI using a
/// class that will soon be available.
-///
+///
/// Implementing all of the instructions that affect the PC can then
/// allow single step prediction support.
///
@@ -73,571 +74,435 @@ namespace lldb_private {
/// hitting software breakpoints we must disable the breakpoint by
/// restoring the original breakpoint opcode, single stepping and
/// restoring the breakpoint trap. If all threads were allowed to run
-/// then other threads could miss the breakpoint.
+/// then other threads could miss the breakpoint.
///
-/// This class centralizes the code that usually is done in separate
+/// This class centralizes the code that usually is done in separate
/// code paths in a debugger (single step prediction, finding save
/// restore locations of registers for unwinding stack frame variables)
/// and emulating the instruction is just a bonus.
//----------------------------------------------------------------------
-class EmulateInstruction :
- public PluginInterface
-{
+class EmulateInstruction : public PluginInterface {
public:
+ static EmulateInstruction *FindPlugin(const ArchSpec &arch,
+ InstructionType supported_inst_type,
+ const char *plugin_name);
+
+ enum ContextType {
+ eContextInvalid = 0,
+ // Read an instruction opcode from memory
+ eContextReadOpcode,
+
+ // Usually used for writing a register value whose source value is an
+ // immediate
+ eContextImmediate,
+
+ // Exclusively used when saving a register to the stack as part of the
+ // prologue
+ eContextPushRegisterOnStack,
+
+ // Exclusively used when restoring a register off the stack as part of
+ // the epilogue
+ eContextPopRegisterOffStack,
+
+ // Add or subtract a value from the stack
+ eContextAdjustStackPointer,
+
+ // Adjust the frame pointer for the current frame
+ eContextSetFramePointer,
+
+ // Typically in an epilogue sequence. Copy the frame pointer back
+ // into the stack pointer, use SP for CFA calculations again.
+ eContextRestoreStackPointer,
+
+ // Add or subtract a value from a base address register (other than SP)
+ eContextAdjustBaseRegister,
+
+ // Add or subtract a value from the PC or store a value to the PC.
+ eContextAdjustPC,
+
+ // Used in WriteRegister callbacks to indicate where the
+ eContextRegisterPlusOffset,
+
+ // Used in WriteMemory callback to indicate where the data came from
+ eContextRegisterStore,
+
+ eContextRegisterLoad,
+
+ // Used when performing a PC-relative branch where the
+ eContextRelativeBranchImmediate,
+
+ // Used when performing an absolute branch where the
+ eContextAbsoluteBranchRegister,
+
+ // Used when performing a supervisor call to an operating system to
+ // provide a service:
+ eContextSupervisorCall,
+
+ // Used when performing a MemU operation to read the PC-relative offset
+ // from an address.
+ eContextTableBranchReadMemory,
+
+ // Used when random bits are written into a register
+ eContextWriteRegisterRandomBits,
+
+ // Used when random bits are written to memory
+ eContextWriteMemoryRandomBits,
+
+ eContextArithmetic,
+
+ eContextAdvancePC,
+
+ eContextReturnFromException
+ };
+
+ enum InfoType {
+ eInfoTypeRegisterPlusOffset,
+ eInfoTypeRegisterPlusIndirectOffset,
+ eInfoTypeRegisterToRegisterPlusOffset,
+ eInfoTypeRegisterToRegisterPlusIndirectOffset,
+ eInfoTypeRegisterRegisterOperands,
+ eInfoTypeOffset,
+ eInfoTypeRegister,
+ eInfoTypeImmediate,
+ eInfoTypeImmediateSigned,
+ eInfoTypeAddress,
+ eInfoTypeISAAndImmediate,
+ eInfoTypeISAAndImmediateSigned,
+ eInfoTypeISA,
+ eInfoTypeNoArgs
+ } InfoType;
+
+ struct Context {
+ ContextType type;
+ enum InfoType info_type;
+ union {
+ struct RegisterPlusOffset {
+ RegisterInfo reg; // base register
+ int64_t signed_offset; // signed offset added to base register
+ } RegisterPlusOffset;
+
+ struct RegisterPlusIndirectOffset {
+ RegisterInfo base_reg; // base register number
+ RegisterInfo offset_reg; // offset register kind
+ } RegisterPlusIndirectOffset;
+
+ struct RegisterToRegisterPlusOffset {
+ RegisterInfo data_reg; // source/target register for data
+ RegisterInfo base_reg; // base register for address calculation
+ int64_t offset; // offset for address calculation
+ } RegisterToRegisterPlusOffset;
- static EmulateInstruction*
- FindPlugin (const ArchSpec &arch,
- InstructionType supported_inst_type,
- const char *plugin_name);
-
- enum ContextType
- {
- eContextInvalid = 0,
- // Read an instruction opcode from memory
- eContextReadOpcode,
-
- // Usually used for writing a register value whose source value is an
- // immediate
- eContextImmediate,
-
- // Exclusively used when saving a register to the stack as part of the
- // prologue
- eContextPushRegisterOnStack,
-
- // Exclusively used when restoring a register off the stack as part of
- // the epilogue
- eContextPopRegisterOffStack,
-
- // Add or subtract a value from the stack
- eContextAdjustStackPointer,
-
- // Adjust the frame pointer for the current frame
- eContextSetFramePointer,
-
- // Add or subtract a value from a base address register (other than SP)
- eContextAdjustBaseRegister,
-
- // Add or subtract a value from the PC or store a value to the PC.
- eContextAdjustPC,
-
- // Used in WriteRegister callbacks to indicate where the
- eContextRegisterPlusOffset,
-
- // Used in WriteMemory callback to indicate where the data came from
- eContextRegisterStore,
-
- eContextRegisterLoad,
-
- // Used when performing a PC-relative branch where the
- eContextRelativeBranchImmediate,
-
- // Used when performing an absolute branch where the
- eContextAbsoluteBranchRegister,
-
- // Used when performing a supervisor call to an operating system to
- // provide a service:
- eContextSupervisorCall,
-
- // Used when performing a MemU operation to read the PC-relative offset
- // from an address.
- eContextTableBranchReadMemory,
-
- // Used when random bits are written into a register
- eContextWriteRegisterRandomBits,
-
- // Used when random bits are written to memory
- eContextWriteMemoryRandomBits,
-
- eContextArithmetic,
-
- eContextAdvancePC,
-
- eContextReturnFromException
- };
-
- enum InfoType {
- eInfoTypeRegisterPlusOffset,
- eInfoTypeRegisterPlusIndirectOffset,
- eInfoTypeRegisterToRegisterPlusOffset,
- eInfoTypeRegisterToRegisterPlusIndirectOffset,
- eInfoTypeRegisterRegisterOperands,
- eInfoTypeOffset,
- eInfoTypeRegister,
- eInfoTypeImmediate,
- eInfoTypeImmediateSigned,
- eInfoTypeAddress,
- eInfoTypeISAAndImmediate,
- eInfoTypeISAAndImmediateSigned,
- eInfoTypeISA,
- eInfoTypeNoArgs
- } InfoType;
-
- struct Context
- {
- ContextType type;
- enum InfoType info_type;
- union
- {
- struct RegisterPlusOffset
- {
- RegisterInfo reg; // base register
- int64_t signed_offset; // signed offset added to base register
- } RegisterPlusOffset;
-
- struct RegisterPlusIndirectOffset
- {
- RegisterInfo base_reg; // base register number
- RegisterInfo offset_reg; // offset register kind
- } RegisterPlusIndirectOffset;
-
- struct RegisterToRegisterPlusOffset
- {
- RegisterInfo data_reg; // source/target register for data
- RegisterInfo base_reg; // base register for address calculation
- int64_t offset; // offset for address calculation
- } RegisterToRegisterPlusOffset;
-
- struct RegisterToRegisterPlusIndirectOffset
- {
- RegisterInfo base_reg; // base register for address calculation
- RegisterInfo offset_reg; // offset register for address calculation
- RegisterInfo data_reg; // source/target register for data
- } RegisterToRegisterPlusIndirectOffset;
-
- struct RegisterRegisterOperands
- {
- RegisterInfo operand1; // register containing first operand for binary op
- RegisterInfo operand2; // register containing second operand for binary op
- } RegisterRegisterOperands;
-
- int64_t signed_offset; // signed offset by which to adjust self (for registers only)
-
- RegisterInfo reg; // plain register
-
- uint64_t unsigned_immediate;// unsigned immediate value
- int64_t signed_immediate; // signed immediate value
-
- lldb::addr_t address; // direct address
-
- struct ISAAndImmediate
- {
- uint32_t isa;
- uint32_t unsigned_data32; // immediate data
- } ISAAndImmediate;
-
- struct ISAAndImmediateSigned
- {
- uint32_t isa;
- int32_t signed_data32; // signed immediate data
- } ISAAndImmediateSigned;
-
- uint32_t isa;
- } info;
-
- Context () :
- type (eContextInvalid),
- info_type (eInfoTypeNoArgs)
- {
- }
-
- void
- SetRegisterPlusOffset (RegisterInfo base_reg,
- int64_t signed_offset)
- {
- info_type = eInfoTypeRegisterPlusOffset;
- info.RegisterPlusOffset.reg = base_reg;
- info.RegisterPlusOffset.signed_offset = signed_offset;
- }
-
- void
- SetRegisterPlusIndirectOffset (RegisterInfo base_reg,
- RegisterInfo offset_reg)
- {
- info_type = eInfoTypeRegisterPlusIndirectOffset;
- info.RegisterPlusIndirectOffset.base_reg = base_reg;
- info.RegisterPlusIndirectOffset.offset_reg = offset_reg;
- }
-
- void
- SetRegisterToRegisterPlusOffset (RegisterInfo data_reg,
+ struct RegisterToRegisterPlusIndirectOffset {
+ RegisterInfo base_reg; // base register for address calculation
+ RegisterInfo offset_reg; // offset register for address calculation
+ RegisterInfo data_reg; // source/target register for data
+ } RegisterToRegisterPlusIndirectOffset;
+
+ struct RegisterRegisterOperands {
+ RegisterInfo
+ operand1; // register containing first operand for binary op
+ RegisterInfo
+ operand2; // register containing second operand for binary op
+ } RegisterRegisterOperands;
+
+ int64_t signed_offset; // signed offset by which to adjust self (for
+ // registers only)
+
+ RegisterInfo reg; // plain register
+
+ uint64_t unsigned_immediate; // unsigned immediate value
+ int64_t signed_immediate; // signed immediate value
+
+ lldb::addr_t address; // direct address
+
+ struct ISAAndImmediate {
+ uint32_t isa;
+ uint32_t unsigned_data32; // immediate data
+ } ISAAndImmediate;
+
+ struct ISAAndImmediateSigned {
+ uint32_t isa;
+ int32_t signed_data32; // signed immediate data
+ } ISAAndImmediateSigned;
+
+ uint32_t isa;
+ } info;
+
+ Context() : type(eContextInvalid), info_type(eInfoTypeNoArgs) {}
+
+ void SetRegisterPlusOffset(RegisterInfo base_reg, int64_t signed_offset) {
+ info_type = eInfoTypeRegisterPlusOffset;
+ info.RegisterPlusOffset.reg = base_reg;
+ info.RegisterPlusOffset.signed_offset = signed_offset;
+ }
+
+ void SetRegisterPlusIndirectOffset(RegisterInfo base_reg,
+ RegisterInfo offset_reg) {
+ info_type = eInfoTypeRegisterPlusIndirectOffset;
+ info.RegisterPlusIndirectOffset.base_reg = base_reg;
+ info.RegisterPlusIndirectOffset.offset_reg = offset_reg;
+ }
+
+ void SetRegisterToRegisterPlusOffset(RegisterInfo data_reg,
RegisterInfo base_reg,
- int64_t offset)
- {
- info_type = eInfoTypeRegisterToRegisterPlusOffset;
- info.RegisterToRegisterPlusOffset.data_reg = data_reg;
- info.RegisterToRegisterPlusOffset.base_reg = base_reg;
- info.RegisterToRegisterPlusOffset.offset = offset;
- }
-
- void
- SetRegisterToRegisterPlusIndirectOffset (RegisterInfo base_reg,
+ int64_t offset) {
+ info_type = eInfoTypeRegisterToRegisterPlusOffset;
+ info.RegisterToRegisterPlusOffset.data_reg = data_reg;
+ info.RegisterToRegisterPlusOffset.base_reg = base_reg;
+ info.RegisterToRegisterPlusOffset.offset = offset;
+ }
+
+ void SetRegisterToRegisterPlusIndirectOffset(RegisterInfo base_reg,
RegisterInfo offset_reg,
- RegisterInfo data_reg)
- {
- info_type = eInfoTypeRegisterToRegisterPlusIndirectOffset;
- info.RegisterToRegisterPlusIndirectOffset.base_reg = base_reg;
- info.RegisterToRegisterPlusIndirectOffset.offset_reg = offset_reg;
- info.RegisterToRegisterPlusIndirectOffset.data_reg = data_reg;
- }
-
- void
- SetRegisterRegisterOperands (RegisterInfo op1_reg,
- RegisterInfo op2_reg)
- {
- info_type = eInfoTypeRegisterRegisterOperands;
- info.RegisterRegisterOperands.operand1 = op1_reg;
- info.RegisterRegisterOperands.operand2 = op2_reg;
- }
-
- void
- SetOffset (int64_t signed_offset)
- {
- info_type = eInfoTypeOffset;
- info.signed_offset = signed_offset;
- }
-
- void
- SetRegister (RegisterInfo reg)
- {
- info_type = eInfoTypeRegister;
- info.reg = reg;
- }
-
- void
- SetImmediate (uint64_t immediate)
- {
- info_type = eInfoTypeImmediate;
- info.unsigned_immediate = immediate;
- }
-
- void
- SetImmediateSigned (int64_t signed_immediate)
- {
- info_type = eInfoTypeImmediateSigned;
- info.signed_immediate = signed_immediate;
- }
-
- void
- SetAddress (lldb::addr_t address)
- {
- info_type = eInfoTypeAddress;
- info.address = address;
- }
- void
- SetISAAndImmediate (uint32_t isa, uint32_t data)
- {
- info_type = eInfoTypeISAAndImmediate;
- info.ISAAndImmediate.isa = isa;
- info.ISAAndImmediate.unsigned_data32 = data;
- }
-
- void
- SetISAAndImmediateSigned (uint32_t isa, int32_t data)
- {
- info_type = eInfoTypeISAAndImmediateSigned;
- info.ISAAndImmediateSigned.isa = isa;
- info.ISAAndImmediateSigned.signed_data32 = data;
- }
-
- void
- SetISA (uint32_t isa)
- {
- info_type = eInfoTypeISA;
- info.isa = isa;
- }
-
- void
- SetNoArgs ()
- {
- info_type = eInfoTypeNoArgs;
- }
-
- void
- Dump (Stream &s,
- EmulateInstruction *instruction) const;
-
- };
-
- typedef size_t (*ReadMemoryCallback) (EmulateInstruction *instruction,
- void *baton,
- const Context &context,
- lldb::addr_t addr,
- void *dst,
- size_t length);
-
- typedef size_t (*WriteMemoryCallback) (EmulateInstruction *instruction,
- void *baton,
- const Context &context,
- lldb::addr_t addr,
- const void *dst,
- size_t length);
-
- typedef bool (*ReadRegisterCallback) (EmulateInstruction *instruction,
- void *baton,
- const RegisterInfo *reg_info,
- RegisterValue &reg_value);
-
- typedef bool (*WriteRegisterCallback) (EmulateInstruction *instruction,
- void *baton,
- const Context &context,
- const RegisterInfo *reg_info,
- const RegisterValue &reg_value);
-
- // Type to represent the condition of an instruction. The UINT32 value is reserved for the
- // unconditional case and all other value can be used in an architecture dependent way.
- typedef uint32_t InstructionCondition;
- static const InstructionCondition UnconditionalCondition = UINT32_MAX;
-
- EmulateInstruction (const ArchSpec &arch);
-
- ~EmulateInstruction() override = default;
-
- //----------------------------------------------------------------------
- // Mandatory overrides
- //----------------------------------------------------------------------
- virtual bool
- SupportsEmulatingInstructionsOfType (InstructionType inst_type) = 0;
-
- virtual bool
- SetTargetTriple (const ArchSpec &arch) = 0;
-
- virtual bool
- ReadInstruction () = 0;
-
- virtual bool
- EvaluateInstruction (uint32_t evaluate_options) = 0;
-
- virtual InstructionCondition
- GetInstructionCondition() { return UnconditionalCondition; }
-
- virtual bool
- TestEmulation (Stream *out_stream, ArchSpec &arch, OptionValueDictionary *test_data) = 0;
-
- virtual bool
- GetRegisterInfo (lldb::RegisterKind reg_kind, uint32_t reg_num, RegisterInfo &reg_info) = 0;
-
- //----------------------------------------------------------------------
- // Optional overrides
- //----------------------------------------------------------------------
- virtual bool
- SetInstruction (const Opcode &insn_opcode, const Address &inst_addr, Target *target);
-
- virtual bool
- CreateFunctionEntryUnwind (UnwindPlan &unwind_plan);
-
- static const char *
- TranslateRegister (lldb::RegisterKind reg_kind, uint32_t reg_num, std::string &reg_name);
-
- //----------------------------------------------------------------------
- // RegisterInfo variants
- //----------------------------------------------------------------------
- bool
- ReadRegister (const RegisterInfo *reg_info,
- RegisterValue& reg_value);
-
- uint64_t
- ReadRegisterUnsigned (const RegisterInfo *reg_info,
- uint64_t fail_value,
- bool *success_ptr);
-
- bool
- WriteRegister (const Context &context,
- const RegisterInfo *ref_info,
- const RegisterValue& reg_value);
-
- bool
- WriteRegisterUnsigned (const Context &context,
- const RegisterInfo *reg_info,
- uint64_t reg_value);
-
- //----------------------------------------------------------------------
- // Register kind and number variants
- //----------------------------------------------------------------------
- bool
- ReadRegister (lldb::RegisterKind reg_kind,
- uint32_t reg_num,
- RegisterValue& reg_value);
-
- bool
- WriteRegister (const Context &context,
- lldb::RegisterKind reg_kind,
- uint32_t reg_num,
- const RegisterValue& reg_value);
-
- uint64_t
- ReadRegisterUnsigned (lldb::RegisterKind reg_kind,
- uint32_t reg_num,
- uint64_t fail_value,
- bool *success_ptr);
-
- bool
- WriteRegisterUnsigned (const Context &context,
- lldb::RegisterKind reg_kind,
- uint32_t reg_num,
- uint64_t reg_value);
-
-
- size_t
- ReadMemory (const Context &context,
- lldb::addr_t addr,
- void *dst,
- size_t dst_len);
-
- uint64_t
- ReadMemoryUnsigned (const Context &context,
- lldb::addr_t addr,
- size_t byte_size,
- uint64_t fail_value,
- bool *success_ptr);
-
- bool
- WriteMemory (const Context &context,
- lldb::addr_t addr,
- const void *src,
- size_t src_len);
-
- bool
- WriteMemoryUnsigned (const Context &context,
- lldb::addr_t addr,
- uint64_t uval,
- size_t uval_byte_size);
-
- uint32_t
- GetAddressByteSize () const
- {
- return m_arch.GetAddressByteSize();
+ RegisterInfo data_reg) {
+ info_type = eInfoTypeRegisterToRegisterPlusIndirectOffset;
+ info.RegisterToRegisterPlusIndirectOffset.base_reg = base_reg;
+ info.RegisterToRegisterPlusIndirectOffset.offset_reg = offset_reg;
+ info.RegisterToRegisterPlusIndirectOffset.data_reg = data_reg;
+ }
+
+ void SetRegisterRegisterOperands(RegisterInfo op1_reg,
+ RegisterInfo op2_reg) {
+ info_type = eInfoTypeRegisterRegisterOperands;
+ info.RegisterRegisterOperands.operand1 = op1_reg;
+ info.RegisterRegisterOperands.operand2 = op2_reg;
+ }
+
+ void SetOffset(int64_t signed_offset) {
+ info_type = eInfoTypeOffset;
+ info.signed_offset = signed_offset;
+ }
+
+ void SetRegister(RegisterInfo reg) {
+ info_type = eInfoTypeRegister;
+ info.reg = reg;
}
- lldb::ByteOrder
- GetByteOrder () const
- {
- return m_arch.GetByteOrder();
+ void SetImmediate(uint64_t immediate) {
+ info_type = eInfoTypeImmediate;
+ info.unsigned_immediate = immediate;
}
- const Opcode &
- GetOpcode () const
- {
- return m_opcode;
+ void SetImmediateSigned(int64_t signed_immediate) {
+ info_type = eInfoTypeImmediateSigned;
+ info.signed_immediate = signed_immediate;
}
-
- lldb::addr_t
- GetAddress () const
- {
- return m_addr;
+
+ void SetAddress(lldb::addr_t address) {
+ info_type = eInfoTypeAddress;
+ info.address = address;
+ }
+ void SetISAAndImmediate(uint32_t isa, uint32_t data) {
+ info_type = eInfoTypeISAAndImmediate;
+ info.ISAAndImmediate.isa = isa;
+ info.ISAAndImmediate.unsigned_data32 = data;
}
-
- const ArchSpec &
- GetArchitecture () const
- {
- return m_arch;
+
+ void SetISAAndImmediateSigned(uint32_t isa, int32_t data) {
+ info_type = eInfoTypeISAAndImmediateSigned;
+ info.ISAAndImmediateSigned.isa = isa;
+ info.ISAAndImmediateSigned.signed_data32 = data;
+ }
+
+ void SetISA(uint32_t isa) {
+ info_type = eInfoTypeISA;
+ info.isa = isa;
}
- static size_t
- ReadMemoryFrame (EmulateInstruction *instruction,
- void *baton,
- const Context &context,
- lldb::addr_t addr,
- void *dst,
- size_t length);
-
- static size_t
- WriteMemoryFrame (EmulateInstruction *instruction,
- void *baton,
- const Context &context,
- lldb::addr_t addr,
- const void *dst,
- size_t length);
-
- static bool
- ReadRegisterFrame (EmulateInstruction *instruction,
- void *baton,
- const RegisterInfo *reg_info,
- RegisterValue &reg_value);
-
-
- static bool
- WriteRegisterFrame (EmulateInstruction *instruction,
- void *baton,
- const Context &context,
- const RegisterInfo *reg_info,
- const RegisterValue &reg_value);
-
- static size_t
- ReadMemoryDefault (EmulateInstruction *instruction,
- void *baton,
- const Context &context,
- lldb::addr_t addr,
- void *dst,
- size_t length);
-
- static size_t
- WriteMemoryDefault (EmulateInstruction *instruction,
- void *baton,
- const Context &context,
- lldb::addr_t addr,
- const void *dst,
- size_t length);
-
- static bool
- ReadRegisterDefault (EmulateInstruction *instruction,
- void *baton,
- const RegisterInfo *reg_info,
- RegisterValue &reg_value);
-
-
- static bool
- WriteRegisterDefault (EmulateInstruction *instruction,
- void *baton,
- const Context &context,
- const RegisterInfo *reg_info,
- const RegisterValue &reg_value);
-
- void
- SetBaton (void *baton);
-
- void
- SetCallbacks (ReadMemoryCallback read_mem_callback,
- WriteMemoryCallback write_mem_callback,
- ReadRegisterCallback read_reg_callback,
- WriteRegisterCallback write_reg_callback);
-
- void
- SetReadMemCallback (ReadMemoryCallback read_mem_callback);
-
- void
- SetWriteMemCallback (WriteMemoryCallback write_mem_callback);
-
- void
- SetReadRegCallback (ReadRegisterCallback read_reg_callback);
-
- void
- SetWriteRegCallback (WriteRegisterCallback write_reg_callback);
-
- static bool
- GetBestRegisterKindAndNumber (const RegisterInfo *reg_info,
- lldb::RegisterKind &reg_kind,
- uint32_t &reg_num);
-
- static uint32_t
- GetInternalRegisterNumber (RegisterContext *reg_ctx,
- const RegisterInfo &reg_info);
+ void SetNoArgs() { info_type = eInfoTypeNoArgs; }
+
+ void Dump(Stream &s, EmulateInstruction *instruction) const;
+ };
+
+ typedef size_t (*ReadMemoryCallback)(EmulateInstruction *instruction,
+ void *baton, const Context &context,
+ lldb::addr_t addr, void *dst,
+ size_t length);
+
+ typedef size_t (*WriteMemoryCallback)(EmulateInstruction *instruction,
+ void *baton, const Context &context,
+ lldb::addr_t addr, const void *dst,
+ size_t length);
+
+ typedef bool (*ReadRegisterCallback)(EmulateInstruction *instruction,
+ void *baton,
+ const RegisterInfo *reg_info,
+ RegisterValue &reg_value);
+
+ typedef bool (*WriteRegisterCallback)(EmulateInstruction *instruction,
+ void *baton, const Context &context,
+ const RegisterInfo *reg_info,
+ const RegisterValue &reg_value);
+
+ // Type to represent the condition of an instruction. The UINT32 value is
+ // reserved for the
+ // unconditional case and all other value can be used in an architecture
+ // dependent way.
+ typedef uint32_t InstructionCondition;
+ static const InstructionCondition UnconditionalCondition = UINT32_MAX;
+
+ EmulateInstruction(const ArchSpec &arch);
+
+ ~EmulateInstruction() override = default;
+
+ //----------------------------------------------------------------------
+ // Mandatory overrides
+ //----------------------------------------------------------------------
+ virtual bool
+ SupportsEmulatingInstructionsOfType(InstructionType inst_type) = 0;
+
+ virtual bool SetTargetTriple(const ArchSpec &arch) = 0;
+
+ virtual bool ReadInstruction() = 0;
+
+ virtual bool EvaluateInstruction(uint32_t evaluate_options) = 0;
+
+ virtual InstructionCondition GetInstructionCondition() {
+ return UnconditionalCondition;
+ }
+
+ virtual bool TestEmulation(Stream *out_stream, ArchSpec &arch,
+ OptionValueDictionary *test_data) = 0;
+
+ virtual bool GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num,
+ RegisterInfo &reg_info) = 0;
+
+ //----------------------------------------------------------------------
+ // Optional overrides
+ //----------------------------------------------------------------------
+ virtual bool SetInstruction(const Opcode &insn_opcode,
+ const Address &inst_addr, Target *target);
+
+ virtual bool CreateFunctionEntryUnwind(UnwindPlan &unwind_plan);
+
+ static const char *TranslateRegister(lldb::RegisterKind reg_kind,
+ uint32_t reg_num, std::string &reg_name);
+
+ //----------------------------------------------------------------------
+ // RegisterInfo variants
+ //----------------------------------------------------------------------
+ bool ReadRegister(const RegisterInfo *reg_info, RegisterValue &reg_value);
+
+ uint64_t ReadRegisterUnsigned(const RegisterInfo *reg_info,
+ uint64_t fail_value, bool *success_ptr);
+
+ bool WriteRegister(const Context &context, const RegisterInfo *ref_info,
+ const RegisterValue &reg_value);
+
+ bool WriteRegisterUnsigned(const Context &context,
+ const RegisterInfo *reg_info, uint64_t reg_value);
+
+ //----------------------------------------------------------------------
+ // Register kind and number variants
+ //----------------------------------------------------------------------
+ bool ReadRegister(lldb::RegisterKind reg_kind, uint32_t reg_num,
+ RegisterValue &reg_value);
+
+ bool WriteRegister(const Context &context, lldb::RegisterKind reg_kind,
+ uint32_t reg_num, const RegisterValue &reg_value);
+
+ uint64_t ReadRegisterUnsigned(lldb::RegisterKind reg_kind, uint32_t reg_num,
+ uint64_t fail_value, bool *success_ptr);
+
+ bool WriteRegisterUnsigned(const Context &context,
+ lldb::RegisterKind reg_kind, uint32_t reg_num,
+ uint64_t reg_value);
+
+ size_t ReadMemory(const Context &context, lldb::addr_t addr, void *dst,
+ size_t dst_len);
+
+ uint64_t ReadMemoryUnsigned(const Context &context, lldb::addr_t addr,
+ size_t byte_size, uint64_t fail_value,
+ bool *success_ptr);
+
+ bool WriteMemory(const Context &context, lldb::addr_t addr, const void *src,
+ size_t src_len);
+
+ bool WriteMemoryUnsigned(const Context &context, lldb::addr_t addr,
+ uint64_t uval, size_t uval_byte_size);
+
+ uint32_t GetAddressByteSize() const { return m_arch.GetAddressByteSize(); }
+
+ lldb::ByteOrder GetByteOrder() const { return m_arch.GetByteOrder(); }
+
+ const Opcode &GetOpcode() const { return m_opcode; }
+
+ lldb::addr_t GetAddress() const { return m_addr; }
+
+ const ArchSpec &GetArchitecture() const { return m_arch; }
+
+ static size_t ReadMemoryFrame(EmulateInstruction *instruction, void *baton,
+ const Context &context, lldb::addr_t addr,
+ void *dst, size_t length);
+
+ static size_t WriteMemoryFrame(EmulateInstruction *instruction, void *baton,
+ const Context &context, lldb::addr_t addr,
+ const void *dst, size_t length);
+
+ static bool ReadRegisterFrame(EmulateInstruction *instruction, void *baton,
+ const RegisterInfo *reg_info,
+ RegisterValue &reg_value);
+
+ static bool WriteRegisterFrame(EmulateInstruction *instruction, void *baton,
+ const Context &context,
+ const RegisterInfo *reg_info,
+ const RegisterValue &reg_value);
+
+ static size_t ReadMemoryDefault(EmulateInstruction *instruction, void *baton,
+ const Context &context, lldb::addr_t addr,
+ void *dst, size_t length);
+
+ static size_t WriteMemoryDefault(EmulateInstruction *instruction, void *baton,
+ const Context &context, lldb::addr_t addr,
+ const void *dst, size_t length);
+
+ static bool ReadRegisterDefault(EmulateInstruction *instruction, void *baton,
+ const RegisterInfo *reg_info,
+ RegisterValue &reg_value);
+
+ static bool WriteRegisterDefault(EmulateInstruction *instruction, void *baton,
+ const Context &context,
+ const RegisterInfo *reg_info,
+ const RegisterValue &reg_value);
+
+ void SetBaton(void *baton);
+
+ void SetCallbacks(ReadMemoryCallback read_mem_callback,
+ WriteMemoryCallback write_mem_callback,
+ ReadRegisterCallback read_reg_callback,
+ WriteRegisterCallback write_reg_callback);
+
+ void SetReadMemCallback(ReadMemoryCallback read_mem_callback);
+
+ void SetWriteMemCallback(WriteMemoryCallback write_mem_callback);
+
+ void SetReadRegCallback(ReadRegisterCallback read_reg_callback);
+
+ void SetWriteRegCallback(WriteRegisterCallback write_reg_callback);
+
+ static bool GetBestRegisterKindAndNumber(const RegisterInfo *reg_info,
+ lldb::RegisterKind &reg_kind,
+ uint32_t &reg_num);
+
+ static uint32_t GetInternalRegisterNumber(RegisterContext *reg_ctx,
+ const RegisterInfo &reg_info);
protected:
- ArchSpec m_arch;
- void * m_baton;
- ReadMemoryCallback m_read_mem_callback;
- WriteMemoryCallback m_write_mem_callback;
- ReadRegisterCallback m_read_reg_callback;
- WriteRegisterCallback m_write_reg_callback;
- lldb::addr_t m_addr;
- Opcode m_opcode;
-
+ ArchSpec m_arch;
+ void *m_baton;
+ ReadMemoryCallback m_read_mem_callback;
+ WriteMemoryCallback m_write_mem_callback;
+ ReadRegisterCallback m_read_reg_callback;
+ WriteRegisterCallback m_write_reg_callback;
+ lldb::addr_t m_addr;
+ Opcode m_opcode;
+
private:
- //------------------------------------------------------------------
- // For EmulateInstruction only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (EmulateInstruction);
+ //------------------------------------------------------------------
+ // For EmulateInstruction only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(EmulateInstruction);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/Error.h b/include/lldb/Core/Error.h
index a1687689fc3f..f33464816a16 100644
--- a/include/lldb/Core/Error.h
+++ b/include/lldb/Core/Error.h
@@ -19,6 +19,8 @@
#include "lldb/lldb-private.h"
+#include "llvm/Support/FormatVariadic.h"
+
namespace lldb_private {
class Log;
@@ -43,276 +45,260 @@ class Log;
/// be cached until the error is cleared of the value of the error
/// changes.
//----------------------------------------------------------------------
-class Error
-{
+class Error {
public:
- //------------------------------------------------------------------
- /// Every error value that this object can contain needs to be able
- /// to fit into ValueType.
- //------------------------------------------------------------------
- typedef uint32_t ValueType;
-
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Initialize the error object with a generic success value.
- ///
- /// @param[in] err
- /// An error code.
- ///
- /// @param[in] type
- /// The type for \a err.
- //------------------------------------------------------------------
- Error ();
-
- explicit
- Error (ValueType err, lldb::ErrorType type = lldb::eErrorTypeGeneric);
-
- explicit
- Error (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
-
- Error (const Error &rhs);
- //------------------------------------------------------------------
- /// Assignment operator.
- ///
- /// @param[in] err
- /// An error code.
- ///
- /// @return
- /// A const reference to this object.
- //------------------------------------------------------------------
- const Error&
- operator = (const Error& rhs);
-
-
- //------------------------------------------------------------------
- /// Assignment operator from a kern_return_t.
- ///
- /// Sets the type to \c MachKernel and the error code to \a err.
- ///
- /// @param[in] err
- /// A mach error code.
- ///
- /// @return
- /// A const reference to this object.
- //------------------------------------------------------------------
- const Error&
- operator = (uint32_t err);
-
- ~Error();
-
- //------------------------------------------------------------------
- /// Get the error string associated with the current error.
- //
- /// Gets the error value as a NULL terminated C string. The error
- /// string will be fetched and cached on demand. The error string
- /// will be retrieved from a callback that is appropriate for the
- /// type of the error and will be cached until the error value is
- /// changed or cleared.
- ///
- /// @return
- /// The error as a NULL terminated C string value if the error
- /// is valid and is able to be converted to a string value,
- /// NULL otherwise.
- //------------------------------------------------------------------
- const char *
- AsCString (const char *default_error_str = "unknown error") const;
-
- //------------------------------------------------------------------
- /// Clear the object state.
- ///
- /// Reverts the state of this object to contain a generic success
- /// value and frees any cached error string value.
- //------------------------------------------------------------------
- void
- Clear ();
-
- //------------------------------------------------------------------
- /// Test for error condition.
- ///
- /// @return
- /// \b true if this object contains an error, \b false
- /// otherwise.
- //------------------------------------------------------------------
- bool
- Fail () const;
-
- //------------------------------------------------------------------
- /// Access the error value.
- ///
- /// @return
- /// The error value.
- //------------------------------------------------------------------
- ValueType
- GetError () const;
-
- //------------------------------------------------------------------
- /// Access the error type.
- ///
- /// @return
- /// The error type enumeration value.
- //------------------------------------------------------------------
- lldb::ErrorType
- GetType () const;
-
- //------------------------------------------------------------------
- /// Log an error to Log().
- ///
- /// Log the error given a formatted string \a format. If the this
- /// object contains an error code, update the error string to
- /// contain the prefix "error: ", followed by the formatted string,
- /// followed by the error value and any string that describes the
- /// error value. This allows more context to be given to an error
- /// string that remains cached in this object. Logging always occurs
- /// even when the error code contains a non-error value.
- ///
- /// @param[in] format
- /// A printf style format string.
- ///
- /// @param[in] ...
- /// Variable arguments that are needed for the printf style
- /// format string \a format.
- //------------------------------------------------------------------
- void
- PutToLog (Log *log, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
-
- //------------------------------------------------------------------
- /// Log an error to Log() if the error value is an error.
- ///
- /// Log the error given a formatted string \a format only if the
- /// error value in this object describes an error condition. If the
- /// this object contains an error, update the error string to
- /// contain the prefix "error: " followed by the formatted string,
- /// followed by the error value and any string that describes the
- /// error value. This allows more context to be given to an error
- /// string that remains cached in this object.
- ///
- /// @param[in] format
- /// A printf style format string.
- ///
- /// @param[in] ...
- /// Variable arguments that are needed for the printf style
- /// format string \a format.
- //------------------------------------------------------------------
- void
- LogIfError (Log *log, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
-
- //------------------------------------------------------------------
- /// Set accessor from a kern_return_t.
- ///
- /// Set accesssor for the error value to \a err and the error type
- /// to \c MachKernel.
- ///
- /// @param[in] err
- /// A mach error code.
- //------------------------------------------------------------------
- void
- SetMachError (uint32_t err);
-
-
- void
- SetExpressionError (lldb::ExpressionResults, const char *mssg);
-
- int
- SetExpressionErrorWithFormat (lldb::ExpressionResults, const char *format, ...) __attribute__ ((format (printf, 3,4)));
-
- //------------------------------------------------------------------
- /// Set accesssor with an error value and type.
- ///
- /// Set accesssor for the error value to \a err and the error type
- /// to \a type.
- ///
- /// @param[in] err
- /// A mach error code.
- ///
- /// @param[in] type
- /// The type for \a err.
- //------------------------------------------------------------------
- void
- SetError (ValueType err, lldb::ErrorType type);
-
- //------------------------------------------------------------------
- /// Set the current error to errno.
- ///
- /// Update the error value to be \c errno and update the type to
- /// be \c Error::POSIX.
- //------------------------------------------------------------------
- void
- SetErrorToErrno ();
-
- //------------------------------------------------------------------
- /// Set the current error to a generic error.
- ///
- /// Update the error value to be \c LLDB_GENERIC_ERROR and update the
- /// type to be \c Error::Generic.
- //------------------------------------------------------------------
- void
- SetErrorToGenericError ();
-
- //------------------------------------------------------------------
- /// Set the current error string to \a err_str.
- ///
- /// Set accessor for the error string value for a generic errors,
- /// or to supply additional details above and beyond the standard
- /// error strings that the standard type callbacks typically
- /// provide. This allows custom strings to be supplied as an
- /// error explanation. The error string value will remain until the
- /// error value is cleared or a new error value/type is assigned.
- ///
- /// @param err_str
- /// The new custom error string to copy and cache.
- //------------------------------------------------------------------
- void
- SetErrorString (const char *err_str);
-
- //------------------------------------------------------------------
- /// Set the current error string to a formatted error string.
- ///
- /// @param format
- /// A printf style format string
- //------------------------------------------------------------------
- int
- SetErrorStringWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
-
- int
- SetErrorStringWithVarArg (const char *format, va_list args);
-
- //------------------------------------------------------------------
- /// Test for success condition.
- ///
- /// Returns true if the error code in this object is considered a
- /// successful return value.
- ///
- /// @return
- /// \b true if this object contains an value that describes
- /// success (non-erro), \b false otherwise.
- //------------------------------------------------------------------
- bool
- Success () const;
-
- //------------------------------------------------------------------
- /// Test for a failure due to a generic interrupt.
- ///
- /// Returns true if the error code in this object was caused by an interrupt.
- /// At present only supports Posix EINTR.
- ///
- /// @return
- /// \b true if this object contains an value that describes
- /// failure due to interrupt, \b false otherwise.
- //------------------------------------------------------------------
- bool
- WasInterrupted() const;
+ //------------------------------------------------------------------
+ /// Every error value that this object can contain needs to be able
+ /// to fit into ValueType.
+ //------------------------------------------------------------------
+ typedef uint32_t ValueType;
+
+ //------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// Initialize the error object with a generic success value.
+ ///
+ /// @param[in] err
+ /// An error code.
+ ///
+ /// @param[in] type
+ /// The type for \a err.
+ //------------------------------------------------------------------
+ Error();
+
+ explicit Error(ValueType err, lldb::ErrorType type = lldb::eErrorTypeGeneric);
+
+ explicit Error(const char *format, ...) __attribute__((format(printf, 2, 3)));
+
+ Error(const Error &rhs);
+ //------------------------------------------------------------------
+ /// Assignment operator.
+ ///
+ /// @param[in] err
+ /// An error code.
+ ///
+ /// @return
+ /// A const reference to this object.
+ //------------------------------------------------------------------
+ const Error &operator=(const Error &rhs);
+
+ //------------------------------------------------------------------
+ /// Assignment operator from a kern_return_t.
+ ///
+ /// Sets the type to \c MachKernel and the error code to \a err.
+ ///
+ /// @param[in] err
+ /// A mach error code.
+ ///
+ /// @return
+ /// A const reference to this object.
+ //------------------------------------------------------------------
+ const Error &operator=(uint32_t err);
+
+ ~Error();
+
+ //------------------------------------------------------------------
+ /// Get the error string associated with the current error.
+ //
+ /// Gets the error value as a NULL terminated C string. The error
+ /// string will be fetched and cached on demand. The error string
+ /// will be retrieved from a callback that is appropriate for the
+ /// type of the error and will be cached until the error value is
+ /// changed or cleared.
+ ///
+ /// @return
+ /// The error as a NULL terminated C string value if the error
+ /// is valid and is able to be converted to a string value,
+ /// NULL otherwise.
+ //------------------------------------------------------------------
+ const char *AsCString(const char *default_error_str = "unknown error") const;
+
+ //------------------------------------------------------------------
+ /// Clear the object state.
+ ///
+ /// Reverts the state of this object to contain a generic success
+ /// value and frees any cached error string value.
+ //------------------------------------------------------------------
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Test for error condition.
+ ///
+ /// @return
+ /// \b true if this object contains an error, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ bool Fail() const;
+
+ //------------------------------------------------------------------
+ /// Access the error value.
+ ///
+ /// @return
+ /// The error value.
+ //------------------------------------------------------------------
+ ValueType GetError() const;
+
+ //------------------------------------------------------------------
+ /// Access the error type.
+ ///
+ /// @return
+ /// The error type enumeration value.
+ //------------------------------------------------------------------
+ lldb::ErrorType GetType() const;
+
+ //------------------------------------------------------------------
+ /// Log an error to Log().
+ ///
+ /// Log the error given a formatted string \a format. If the this
+ /// object contains an error code, update the error string to
+ /// contain the prefix "error: ", followed by the formatted string,
+ /// followed by the error value and any string that describes the
+ /// error value. This allows more context to be given to an error
+ /// string that remains cached in this object. Logging always occurs
+ /// even when the error code contains a non-error value.
+ ///
+ /// @param[in] format
+ /// A printf style format string.
+ ///
+ /// @param[in] ...
+ /// Variable arguments that are needed for the printf style
+ /// format string \a format.
+ //------------------------------------------------------------------
+ void PutToLog(Log *log, const char *format, ...)
+ __attribute__((format(printf, 3, 4)));
+
+ //------------------------------------------------------------------
+ /// Log an error to Log() if the error value is an error.
+ ///
+ /// Log the error given a formatted string \a format only if the
+ /// error value in this object describes an error condition. If the
+ /// this object contains an error, update the error string to
+ /// contain the prefix "error: " followed by the formatted string,
+ /// followed by the error value and any string that describes the
+ /// error value. This allows more context to be given to an error
+ /// string that remains cached in this object.
+ ///
+ /// @param[in] format
+ /// A printf style format string.
+ ///
+ /// @param[in] ...
+ /// Variable arguments that are needed for the printf style
+ /// format string \a format.
+ //------------------------------------------------------------------
+ void LogIfError(Log *log, const char *format, ...)
+ __attribute__((format(printf, 3, 4)));
+
+ //------------------------------------------------------------------
+ /// Set accessor from a kern_return_t.
+ ///
+ /// Set accesssor for the error value to \a err and the error type
+ /// to \c MachKernel.
+ ///
+ /// @param[in] err
+ /// A mach error code.
+ //------------------------------------------------------------------
+ void SetMachError(uint32_t err);
+
+ void SetExpressionError(lldb::ExpressionResults, const char *mssg);
+
+ int SetExpressionErrorWithFormat(lldb::ExpressionResults, const char *format,
+ ...) __attribute__((format(printf, 3, 4)));
+
+ //------------------------------------------------------------------
+ /// Set accesssor with an error value and type.
+ ///
+ /// Set accesssor for the error value to \a err and the error type
+ /// to \a type.
+ ///
+ /// @param[in] err
+ /// A mach error code.
+ ///
+ /// @param[in] type
+ /// The type for \a err.
+ //------------------------------------------------------------------
+ void SetError(ValueType err, lldb::ErrorType type);
+
+ //------------------------------------------------------------------
+ /// Set the current error to errno.
+ ///
+ /// Update the error value to be \c errno and update the type to
+ /// be \c Error::POSIX.
+ //------------------------------------------------------------------
+ void SetErrorToErrno();
+
+ //------------------------------------------------------------------
+ /// Set the current error to a generic error.
+ ///
+ /// Update the error value to be \c LLDB_GENERIC_ERROR and update the
+ /// type to be \c Error::Generic.
+ //------------------------------------------------------------------
+ void SetErrorToGenericError();
+
+ //------------------------------------------------------------------
+ /// Set the current error string to \a err_str.
+ ///
+ /// Set accessor for the error string value for a generic errors,
+ /// or to supply additional details above and beyond the standard
+ /// error strings that the standard type callbacks typically
+ /// provide. This allows custom strings to be supplied as an
+ /// error explanation. The error string value will remain until the
+ /// error value is cleared or a new error value/type is assigned.
+ ///
+ /// @param err_str
+ /// The new custom error string to copy and cache.
+ //------------------------------------------------------------------
+ void SetErrorString(llvm::StringRef err_str);
+
+ //------------------------------------------------------------------
+ /// Set the current error string to a formatted error string.
+ ///
+ /// @param format
+ /// A printf style format string
+ //------------------------------------------------------------------
+ int SetErrorStringWithFormat(const char *format, ...)
+ __attribute__((format(printf, 2, 3)));
+
+ int SetErrorStringWithVarArg(const char *format, va_list args);
+
+ template <typename... Args>
+ void SetErrorStringWithFormatv(const char *format, Args &&... args) {
+ SetErrorString(llvm::formatv(format, std::forward<Args>(args)...).str());
+ }
+
+ //------------------------------------------------------------------
+ /// Test for success condition.
+ ///
+ /// Returns true if the error code in this object is considered a
+ /// successful return value.
+ ///
+ /// @return
+ /// \b true if this object contains an value that describes
+ /// success (non-erro), \b false otherwise.
+ //------------------------------------------------------------------
+ bool Success() const;
+
+ //------------------------------------------------------------------
+ /// Test for a failure due to a generic interrupt.
+ ///
+ /// Returns true if the error code in this object was caused by an interrupt.
+ /// At present only supports Posix EINTR.
+ ///
+ /// @return
+ /// \b true if this object contains an value that describes
+ /// failure due to interrupt, \b false otherwise.
+ //------------------------------------------------------------------
+ bool WasInterrupted() const;
protected:
- //------------------------------------------------------------------
- /// Member variables
- //------------------------------------------------------------------
- ValueType m_code; ///< Error code as an integer value.
- lldb::ErrorType m_type; ///< The type of the above error code.
- mutable std::string m_string; ///< A string representation of the error code.
+ //------------------------------------------------------------------
+ /// Member variables
+ //------------------------------------------------------------------
+ ValueType m_code; ///< Error code as an integer value.
+ lldb::ErrorType m_type; ///< The type of the above error code.
+ mutable std::string m_string; ///< A string representation of the error code.
};
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif // #ifndef __DCError_h__
+#endif // #if defined(__cplusplus)
+#endif // #ifndef __DCError_h__
diff --git a/include/lldb/Core/Event.h b/include/lldb/Core/Event.h
index 1ae0fc83b27e..049bb3cec224 100644
--- a/include/lldb/Core/Event.h
+++ b/include/lldb/Core/Event.h
@@ -12,253 +12,254 @@
// C Includes
// C++ Includes
+#include <chrono>
#include <memory>
#include <string>
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
+#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/ConstString.h"
+#include "lldb/Core/StructuredData.h"
#include "lldb/Host/Predicate.h"
-#include "lldb/Core/Broadcaster.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
// lldb::EventData
//----------------------------------------------------------------------
-class EventData
-{
- friend class Event;
+class EventData {
+ friend class Event;
public:
- EventData ();
+ EventData();
- virtual
- ~EventData();
+ virtual ~EventData();
- virtual const ConstString &
- GetFlavor () const = 0;
+ virtual const ConstString &GetFlavor() const = 0;
- virtual void
- Dump (Stream *s) const;
+ virtual void Dump(Stream *s) const;
private:
- virtual void
- DoOnRemoval (Event *event_ptr)
- {
- }
+ virtual void DoOnRemoval(Event *event_ptr) {}
- DISALLOW_COPY_AND_ASSIGN (EventData);
+ DISALLOW_COPY_AND_ASSIGN(EventData);
};
//----------------------------------------------------------------------
// lldb::EventDataBytes
//----------------------------------------------------------------------
-class EventDataBytes : public EventData
-{
+class EventDataBytes : public EventData {
public:
- //------------------------------------------------------------------
- // Constructors
- //------------------------------------------------------------------
- EventDataBytes ();
+ //------------------------------------------------------------------
+ // Constructors
+ //------------------------------------------------------------------
+ EventDataBytes();
+
+ EventDataBytes(const char *cstr);
+
+ EventDataBytes(llvm::StringRef str);
- EventDataBytes (const char *cstr);
+ EventDataBytes(const void *src, size_t src_len);
- EventDataBytes (const void *src, size_t src_len);
+ ~EventDataBytes() override;
- ~EventDataBytes() override;
+ //------------------------------------------------------------------
+ // Member functions
+ //------------------------------------------------------------------
+ const ConstString &GetFlavor() const override;
- //------------------------------------------------------------------
- // Member functions
- //------------------------------------------------------------------
- const ConstString &
- GetFlavor () const override;
+ void Dump(Stream *s) const override;
- void
- Dump (Stream *s) const override;
+ const void *GetBytes() const;
- const void *
- GetBytes() const;
+ size_t GetByteSize() const;
- size_t
- GetByteSize() const;
+ void SetBytes(const void *src, size_t src_len);
- void
- SetBytes (const void *src, size_t src_len);
-
- void
- SwapBytes (std::string &new_bytes);
+ void SwapBytes(std::string &new_bytes);
- void
- SetBytesFromCString (const char *cstr);
+ void SetBytesFromCString(const char *cstr);
- //------------------------------------------------------------------
- // Static functions
- //------------------------------------------------------------------
- static const EventDataBytes *
- GetEventDataFromEvent (const Event *event_ptr);
+ //------------------------------------------------------------------
+ // Static functions
+ //------------------------------------------------------------------
+ static const EventDataBytes *GetEventDataFromEvent(const Event *event_ptr);
- static const void *
- GetBytesFromEvent (const Event *event_ptr);
+ static const void *GetBytesFromEvent(const Event *event_ptr);
- static size_t
- GetByteSizeFromEvent (const Event *event_ptr);
+ static size_t GetByteSizeFromEvent(const Event *event_ptr);
- static const ConstString &
- GetFlavorString ();
+ static const ConstString &GetFlavorString();
private:
- std::string m_bytes;
+ std::string m_bytes;
- DISALLOW_COPY_AND_ASSIGN (EventDataBytes);
+ DISALLOW_COPY_AND_ASSIGN(EventDataBytes);
};
-class EventDataReceipt : public EventData
-{
+class EventDataReceipt : public EventData {
public:
- EventDataReceipt() :
- EventData(),
- m_predicate(false)
- {
- }
-
- ~EventDataReceipt() override
- {
- }
-
- static const ConstString &
- GetFlavorString ()
- {
- static ConstString g_flavor("Process::ProcessEventData");
- return g_flavor;
- }
-
- const ConstString &
- GetFlavor () const override
- {
- return GetFlavorString();
- }
-
- bool
- WaitForEventReceived (const TimeValue *abstime = nullptr, bool *timed_out = nullptr)
- {
- return m_predicate.WaitForValueEqualTo(true, abstime, timed_out);
- }
+ EventDataReceipt() : EventData(), m_predicate(false) {}
+
+ ~EventDataReceipt() override {}
+
+ static const ConstString &GetFlavorString() {
+ static ConstString g_flavor("Process::ProcessEventData");
+ return g_flavor;
+ }
+
+ const ConstString &GetFlavor() const override { return GetFlavorString(); }
+
+ bool WaitForEventReceived(
+ const std::chrono::microseconds &abstime = std::chrono::microseconds(0),
+ bool *timed_out = nullptr) {
+ return m_predicate.WaitForValueEqualTo(true, abstime, timed_out);
+ }
private:
- Predicate<bool> m_predicate;
-
- void
- DoOnRemoval (Event *event_ptr) override
- {
- m_predicate.SetValue(true, eBroadcastAlways);
- }
+ Predicate<bool> m_predicate;
+
+ void DoOnRemoval(Event *event_ptr) override {
+ m_predicate.SetValue(true, eBroadcastAlways);
+ }
};
//----------------------------------------------------------------------
-// lldb::Event
+/// This class handles one or more StructuredData::Dictionary entries
+/// that are raised for structured data events.
//----------------------------------------------------------------------
-class Event
-{
- friend class Listener;
- friend class EventData;
- friend class Broadcaster::BroadcasterImpl;
+class EventDataStructuredData : public EventData {
public:
- Event(Broadcaster *broadcaster, uint32_t event_type, EventData *data = nullptr);
-
- Event(Broadcaster *broadcaster, uint32_t event_type, const lldb::EventDataSP &event_data_sp);
-
- Event(uint32_t event_type, EventData *data = nullptr);
-
- Event(uint32_t event_type, const lldb::EventDataSP &event_data_sp);
-
- ~Event ();
-
- void
- Dump (Stream *s) const;
-
- EventData *
- GetData ()
- {
- return m_data_sp.get();
- }
-
- const EventData *
- GetData () const
- {
- return m_data_sp.get();
- }
-
- void
- SetData (EventData *new_data)
- {
- m_data_sp.reset (new_data);
- }
-
- uint32_t
- GetType () const
- {
- return m_type;
- }
-
- void
- SetType (uint32_t new_type)
- {
- m_type = new_type;
- }
-
- Broadcaster *
- GetBroadcaster () const
- {
- Broadcaster::BroadcasterImplSP broadcaster_impl_sp = m_broadcaster_wp.lock();
- if (broadcaster_impl_sp)
- return broadcaster_impl_sp->GetBroadcaster();
- else
- return nullptr;
- }
-
- bool
- BroadcasterIs (Broadcaster *broadcaster)
- {
- Broadcaster::BroadcasterImplSP broadcaster_impl_sp = m_broadcaster_wp.lock();
- if (broadcaster_impl_sp)
- return broadcaster_impl_sp->GetBroadcaster() == broadcaster;
- else
- return false;
- }
-
- void
- Clear()
- {
- m_data_sp.reset();
- }
+ //------------------------------------------------------------------
+ // Constructors
+ //------------------------------------------------------------------
+ EventDataStructuredData();
+
+ EventDataStructuredData(const lldb::ProcessSP &process_sp,
+ const StructuredData::ObjectSP &object_sp,
+ const lldb::StructuredDataPluginSP &plugin_sp);
+
+ ~EventDataStructuredData() override;
+
+ //------------------------------------------------------------------
+ // Member functions
+ //------------------------------------------------------------------
+ const ConstString &GetFlavor() const override;
+
+ void Dump(Stream *s) const override;
+
+ const lldb::ProcessSP &GetProcess() const;
+
+ const StructuredData::ObjectSP &GetObject() const;
+
+ const lldb::StructuredDataPluginSP &GetStructuredDataPlugin() const;
+
+ void SetProcess(const lldb::ProcessSP &process_sp);
+
+ void SetObject(const StructuredData::ObjectSP &object_sp);
+
+ void SetStructuredDataPlugin(const lldb::StructuredDataPluginSP &plugin_sp);
+
+ //------------------------------------------------------------------
+ // Static functions
+ //------------------------------------------------------------------
+ static const EventDataStructuredData *
+ GetEventDataFromEvent(const Event *event_ptr);
+
+ static lldb::ProcessSP GetProcessFromEvent(const Event *event_ptr);
+
+ static StructuredData::ObjectSP GetObjectFromEvent(const Event *event_ptr);
+
+ static lldb::StructuredDataPluginSP
+ GetPluginFromEvent(const Event *event_ptr);
+
+ static const ConstString &GetFlavorString();
private:
- // This is only called by Listener when it pops an event off the queue for
- // the listener. It calls the Event Data's DoOnRemoval() method, which is
- // virtual and can be overridden by the specific data classes.
+ lldb::ProcessSP m_process_sp;
+ StructuredData::ObjectSP m_object_sp;
+ lldb::StructuredDataPluginSP m_plugin_sp;
+
+ DISALLOW_COPY_AND_ASSIGN(EventDataStructuredData);
+};
+
+//----------------------------------------------------------------------
+// lldb::Event
+//----------------------------------------------------------------------
+class Event {
+ friend class Listener;
+ friend class EventData;
+ friend class Broadcaster::BroadcasterImpl;
+
+public:
+ Event(Broadcaster *broadcaster, uint32_t event_type,
+ EventData *data = nullptr);
+
+ Event(Broadcaster *broadcaster, uint32_t event_type,
+ const lldb::EventDataSP &event_data_sp);
+
+ Event(uint32_t event_type, EventData *data = nullptr);
+
+ Event(uint32_t event_type, const lldb::EventDataSP &event_data_sp);
+
+ ~Event();
+
+ void Dump(Stream *s) const;
- void
- DoOnRemoval ();
+ EventData *GetData() { return m_data_sp.get(); }
- // Called by Broadcaster::BroadcastEvent prior to letting all the listeners
- // know about it update the contained broadcaster so that events can be
- // popped off one queue and re-broadcast to others.
- void
- SetBroadcaster (Broadcaster *broadcaster)
- {
- m_broadcaster_wp = broadcaster->GetBroadcasterImpl();
- }
+ const EventData *GetData() const { return m_data_sp.get(); }
- Broadcaster::BroadcasterImplWP m_broadcaster_wp; // The broadcaster that sent this event
- uint32_t m_type; // The bit describing this event
- lldb::EventDataSP m_data_sp; // User specific data for this event
+ void SetData(EventData *new_data) { m_data_sp.reset(new_data); }
+ uint32_t GetType() const { return m_type; }
- DISALLOW_COPY_AND_ASSIGN (Event);
- Event(); // Disallow default constructor
+ void SetType(uint32_t new_type) { m_type = new_type; }
+
+ Broadcaster *GetBroadcaster() const {
+ Broadcaster::BroadcasterImplSP broadcaster_impl_sp =
+ m_broadcaster_wp.lock();
+ if (broadcaster_impl_sp)
+ return broadcaster_impl_sp->GetBroadcaster();
+ else
+ return nullptr;
+ }
+
+ bool BroadcasterIs(Broadcaster *broadcaster) {
+ Broadcaster::BroadcasterImplSP broadcaster_impl_sp =
+ m_broadcaster_wp.lock();
+ if (broadcaster_impl_sp)
+ return broadcaster_impl_sp->GetBroadcaster() == broadcaster;
+ else
+ return false;
+ }
+
+ void Clear() { m_data_sp.reset(); }
+
+private:
+ // This is only called by Listener when it pops an event off the queue for
+ // the listener. It calls the Event Data's DoOnRemoval() method, which is
+ // virtual and can be overridden by the specific data classes.
+
+ void DoOnRemoval();
+
+ // Called by Broadcaster::BroadcastEvent prior to letting all the listeners
+ // know about it update the contained broadcaster so that events can be
+ // popped off one queue and re-broadcast to others.
+ void SetBroadcaster(Broadcaster *broadcaster) {
+ m_broadcaster_wp = broadcaster->GetBroadcasterImpl();
+ }
+
+ Broadcaster::BroadcasterImplWP
+ m_broadcaster_wp; // The broadcaster that sent this event
+ uint32_t m_type; // The bit describing this event
+ lldb::EventDataSP m_data_sp; // User specific data for this event
+
+ DISALLOW_COPY_AND_ASSIGN(Event);
+ Event(); // Disallow default constructor
};
} // namespace lldb_private
diff --git a/include/lldb/Core/FastDemangle.h b/include/lldb/Core/FastDemangle.h
index cd6128c73038..f779aaa04606 100644
--- a/include/lldb/Core/FastDemangle.h
+++ b/include/lldb/Core/FastDemangle.h
@@ -10,15 +10,17 @@
#ifndef liblldb_FastDemangle_h_
#define liblldb_FastDemangle_h_
-namespace lldb_private
-{
+#include <cstddef>
- char *
- FastDemangle(const char *mangled_name);
+#include <functional>
- char *
- FastDemangle(const char *mangled_name, long mangled_name_length);
+namespace lldb_private {
+char *FastDemangle(const char *mangled_name);
+
+char *
+FastDemangle(const char *mangled_name, size_t mangled_name_length,
+ std::function<void(const char *s)> primitive_type_hook = nullptr);
}
#endif
diff --git a/include/lldb/Core/FileLineResolver.h b/include/lldb/Core/FileLineResolver.h
index f0f7fbdf756f..e9e20c59f93f 100644
--- a/include/lldb/Core/FileLineResolver.h
+++ b/include/lldb/Core/FileLineResolver.h
@@ -18,61 +18,46 @@ namespace lldb_private {
//----------------------------------------------------------------------
/// @class FileLineResolver FileLineResolver.h "lldb/Core/FileLineResolver.h"
-/// @brief This class finds address for source file and line. Optionally, it will look for inlined
+/// @brief This class finds address for source file and line. Optionally, it
+/// will look for inlined
/// instances of the file and line specification.
//----------------------------------------------------------------------
-class FileLineResolver :
- public Searcher
-{
+class FileLineResolver : public Searcher {
public:
- FileLineResolver () :
- m_file_spec(),
+ FileLineResolver()
+ : m_file_spec(),
m_line_number(UINT32_MAX), // Set this to zero for all lines in a file
- m_sc_list (),
- m_inlines (true)
- {
- }
-
- FileLineResolver (const FileSpec &resolver,
- uint32_t line_no,
- bool check_inlines);
-
- ~FileLineResolver () override;
-
- Searcher::CallbackReturn
- SearchCallback (SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool containing) override;
-
- Searcher::Depth
- GetDepth () override;
-
- void
- GetDescription (Stream *s) override;
-
- const SymbolContextList &
- GetFileLineMatches()
- {
- return m_sc_list;
- }
-
- void
- Clear();
-
- void
- Reset (const FileSpec &file_spec,
- uint32_t line,
- bool check_inlines);
-protected:
- FileSpec m_file_spec; // This is the file spec we are looking for.
- uint32_t m_line_number; // This is the line number that we are looking for.
- SymbolContextList m_sc_list;
- bool m_inlines; // This determines whether the resolver looks for inlined functions or not.
+ m_sc_list(), m_inlines(true) {}
+
+ FileLineResolver(const FileSpec &resolver, uint32_t line_no,
+ bool check_inlines);
+
+ ~FileLineResolver() override;
+
+ Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
+ SymbolContext &context, Address *addr,
+ bool containing) override;
+
+ Searcher::Depth GetDepth() override;
+
+ void GetDescription(Stream *s) override;
+
+ const SymbolContextList &GetFileLineMatches() { return m_sc_list; }
+
+ void Clear();
+
+ void Reset(const FileSpec &file_spec, uint32_t line, bool check_inlines);
+
+protected:
+ FileSpec m_file_spec; // This is the file spec we are looking for.
+ uint32_t m_line_number; // This is the line number that we are looking for.
+ SymbolContextList m_sc_list;
+ bool m_inlines; // This determines whether the resolver looks for inlined
+ // functions or not.
private:
- DISALLOW_COPY_AND_ASSIGN(FileLineResolver);
+ DISALLOW_COPY_AND_ASSIGN(FileLineResolver);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/FileSpecList.h b/include/lldb/Core/FileSpecList.h
index 7730690ca5b7..75995d1ca9fb 100644
--- a/include/lldb/Core/FileSpecList.h
+++ b/include/lldb/Core/FileSpecList.h
@@ -11,8 +11,8 @@
#define liblldb_FileSpecList_h_
#if defined(__cplusplus)
-#include "lldb/lldb-private.h"
#include "lldb/Host/FileSpec.h"
+#include "lldb/lldb-private.h"
#include <vector>
namespace lldb_private {
@@ -23,224 +23,201 @@ namespace lldb_private {
///
/// A class that contains a mutable list of FileSpec objects.
//----------------------------------------------------------------------
-class FileSpecList
-{
+class FileSpecList {
public:
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Initialize this object with an empty file list.
- //------------------------------------------------------------------
- FileSpecList ();
-
- //------------------------------------------------------------------
- /// Copy constructor.
- ///
- /// Initialize this object with a copy of the file list from \a rhs.
- ///
- /// @param[in] rhs
- /// A const reference to another file list object.
- //------------------------------------------------------------------
- FileSpecList (const FileSpecList &rhs);
-
- //------------------------------------------------------------------
- /// Destructor.
- //------------------------------------------------------------------
- ~FileSpecList ();
-
- //------------------------------------------------------------------
- /// Assignment operator.
- ///
- /// Replace the file list in this object with the file list from
- /// \a rhs.
- ///
- /// @param[in] rhs
- /// A file list object to copy.
- ///
- /// @return
- /// A const reference to this object.
- //------------------------------------------------------------------
- const FileSpecList&
- operator= (const FileSpecList &rhs);
-
- //------------------------------------------------------------------
- /// Append a FileSpec object to the list.
- ///
- /// Appends \a file to the end of the file list.
- ///
- /// @param[in] file
- /// A new file to append to this file list.
- //------------------------------------------------------------------
- void
- Append (const FileSpec &file);
-
- //------------------------------------------------------------------
- /// Append a FileSpec object if unique.
- ///
- /// Appends \a file to the end of the file list if it doesn't
- /// already exist in the file list.
- ///
- /// @param[in] file
- /// A new file to append to this file list.
- ///
- /// @return
- /// \b true if the file was appended, \b false otherwise.
- //------------------------------------------------------------------
- bool
- AppendIfUnique (const FileSpec &file);
-
- //------------------------------------------------------------------
- /// Clears the file list.
- //------------------------------------------------------------------
- void
- Clear ();
-
- //------------------------------------------------------------------
- /// Dumps the file list to the supplied stream pointer "s".
- ///
- /// @param[in] s
- /// The stream that will be used to dump the object description.
- //------------------------------------------------------------------
- void
- Dump (Stream *s, const char *separator_cstr = "\n") const;
-
- //------------------------------------------------------------------
- /// Find a file index.
- ///
- /// Find the index of the file in the file spec list that matches
- /// \a file starting \a idx entries into the file spec list.
- ///
- /// @param[in] idx
- /// An index into the file list.
- ///
- /// @param[in] file
- /// The file specification to search for.
- ///
- /// @param[in] full
- /// Should FileSpec::Equal be called with "full" true or false.
- ///
- /// @param[in] remove_backup_dots
- /// Should FileSpec::Equal be called with "remove_backup_dots" true or false.
- ///
- /// @return
- /// The index of the file that matches \a file if it is found,
- /// else UINT32_MAX is returned.
- //------------------------------------------------------------------
- size_t
- FindFileIndex (size_t idx, const FileSpec &file, bool full, bool remove_backup_dots = false) const;
-
- //------------------------------------------------------------------
- /// Get file at index.
- ///
- /// Gets a file from the file list. If \a idx is not a valid index,
- /// an empty FileSpec object will be returned. The file objects
- /// that are returned can be tested using
- /// FileSpec::operator void*().
- ///
- /// @param[in] idx
- /// An index into the file list.
- ///
- /// @return
- /// A copy of the FileSpec object at index \a idx. If \a idx
- /// is out of range, then an empty FileSpec object will be
- /// returned.
- //------------------------------------------------------------------
- const FileSpec &
- GetFileSpecAtIndex (size_t idx) const;
-
- //------------------------------------------------------------------
- /// Get file specification pointer at index.
- ///
- /// Gets a file from the file list. The file objects that are
- /// returned can be tested using FileSpec::operator void*().
- ///
- /// @param[in] idx
- /// An index into the file list.
- ///
- /// @return
- /// A pointer to a contained FileSpec object at index \a idx.
- /// If \a idx is out of range, then an NULL is returned.
- //------------------------------------------------------------------
- const FileSpec *
- GetFileSpecPointerAtIndex (size_t idx) const;
-
- //------------------------------------------------------------------
- /// Get the memory cost of this object.
- ///
- /// Return the size in bytes that this object takes in memory. This
- /// returns the size in bytes of this object, not any shared string
- /// values it may refer to.
- ///
- /// @return
- /// The number of bytes that this object occupies in memory.
- ///
- /// @see ConstString::StaticMemorySize ()
- //------------------------------------------------------------------
- size_t
- MemorySize () const;
-
- bool
- IsEmpty() const
- {
- return m_files.empty();
+ //------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// Initialize this object with an empty file list.
+ //------------------------------------------------------------------
+ FileSpecList();
+
+ //------------------------------------------------------------------
+ /// Copy constructor.
+ ///
+ /// Initialize this object with a copy of the file list from \a rhs.
+ ///
+ /// @param[in] rhs
+ /// A const reference to another file list object.
+ //------------------------------------------------------------------
+ FileSpecList(const FileSpecList &rhs);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ //------------------------------------------------------------------
+ ~FileSpecList();
+
+ //------------------------------------------------------------------
+ /// Assignment operator.
+ ///
+ /// Replace the file list in this object with the file list from
+ /// \a rhs.
+ ///
+ /// @param[in] rhs
+ /// A file list object to copy.
+ ///
+ /// @return
+ /// A const reference to this object.
+ //------------------------------------------------------------------
+ const FileSpecList &operator=(const FileSpecList &rhs);
+
+ //------------------------------------------------------------------
+ /// Append a FileSpec object to the list.
+ ///
+ /// Appends \a file to the end of the file list.
+ ///
+ /// @param[in] file
+ /// A new file to append to this file list.
+ //------------------------------------------------------------------
+ void Append(const FileSpec &file);
+
+ //------------------------------------------------------------------
+ /// Append a FileSpec object if unique.
+ ///
+ /// Appends \a file to the end of the file list if it doesn't
+ /// already exist in the file list.
+ ///
+ /// @param[in] file
+ /// A new file to append to this file list.
+ ///
+ /// @return
+ /// \b true if the file was appended, \b false otherwise.
+ //------------------------------------------------------------------
+ bool AppendIfUnique(const FileSpec &file);
+
+ //------------------------------------------------------------------
+ /// Clears the file list.
+ //------------------------------------------------------------------
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Dumps the file list to the supplied stream pointer "s".
+ ///
+ /// @param[in] s
+ /// The stream that will be used to dump the object description.
+ //------------------------------------------------------------------
+ void Dump(Stream *s, const char *separator_cstr = "\n") const;
+
+ //------------------------------------------------------------------
+ /// Find a file index.
+ ///
+ /// Find the index of the file in the file spec list that matches
+ /// \a file starting \a idx entries into the file spec list.
+ ///
+ /// @param[in] idx
+ /// An index into the file list.
+ ///
+ /// @param[in] file
+ /// The file specification to search for.
+ ///
+ /// @param[in] full
+ /// Should FileSpec::Equal be called with "full" true or false.
+ ///
+ /// @param[in] remove_backup_dots
+ /// Should FileSpec::Equal be called with "remove_backup_dots" true or
+ /// false.
+ ///
+ /// @return
+ /// The index of the file that matches \a file if it is found,
+ /// else UINT32_MAX is returned.
+ //------------------------------------------------------------------
+ size_t FindFileIndex(size_t idx, const FileSpec &file, bool full,
+ bool remove_backup_dots = false) const;
+
+ //------------------------------------------------------------------
+ /// Get file at index.
+ ///
+ /// Gets a file from the file list. If \a idx is not a valid index,
+ /// an empty FileSpec object will be returned. The file objects
+ /// that are returned can be tested using
+ /// FileSpec::operator void*().
+ ///
+ /// @param[in] idx
+ /// An index into the file list.
+ ///
+ /// @return
+ /// A copy of the FileSpec object at index \a idx. If \a idx
+ /// is out of range, then an empty FileSpec object will be
+ /// returned.
+ //------------------------------------------------------------------
+ const FileSpec &GetFileSpecAtIndex(size_t idx) const;
+
+ //------------------------------------------------------------------
+ /// Get file specification pointer at index.
+ ///
+ /// Gets a file from the file list. The file objects that are
+ /// returned can be tested using FileSpec::operator void*().
+ ///
+ /// @param[in] idx
+ /// An index into the file list.
+ ///
+ /// @return
+ /// A pointer to a contained FileSpec object at index \a idx.
+ /// If \a idx is out of range, then an NULL is returned.
+ //------------------------------------------------------------------
+ const FileSpec *GetFileSpecPointerAtIndex(size_t idx) const;
+
+ //------------------------------------------------------------------
+ /// Get the memory cost of this object.
+ ///
+ /// Return the size in bytes that this object takes in memory. This
+ /// returns the size in bytes of this object, not any shared string
+ /// values it may refer to.
+ ///
+ /// @return
+ /// The number of bytes that this object occupies in memory.
+ ///
+ /// @see ConstString::StaticMemorySize ()
+ //------------------------------------------------------------------
+ size_t MemorySize() const;
+
+ bool IsEmpty() const { return m_files.empty(); }
+
+ //------------------------------------------------------------------
+ /// Get the number of files in the file list.
+ ///
+ /// @return
+ /// The number of files in the file spec list.
+ //------------------------------------------------------------------
+ size_t GetSize() const;
+
+ bool Insert(size_t idx, const FileSpec &file) {
+ if (idx < m_files.size()) {
+ m_files.insert(m_files.begin() + idx, file);
+ return true;
+ } else if (idx == m_files.size()) {
+ m_files.push_back(file);
+ return true;
}
+ return false;
+ }
- //------------------------------------------------------------------
- /// Get the number of files in the file list.
- ///
- /// @return
- /// The number of files in the file spec list.
- //------------------------------------------------------------------
- size_t
- GetSize () const;
-
- bool
- Insert (size_t idx, const FileSpec &file)
- {
- if (idx < m_files.size())
- {
- m_files.insert(m_files.begin() + idx, file);
- return true;
- }
- else if (idx == m_files.size())
- {
- m_files.push_back(file);
- return true;
- }
- return false;
+ bool Replace(size_t idx, const FileSpec &file) {
+ if (idx < m_files.size()) {
+ m_files[idx] = file;
+ return true;
}
+ return false;
+ }
- bool
- Replace (size_t idx, const FileSpec &file)
- {
- if (idx < m_files.size())
- {
- m_files[idx] = file;
- return true;
- }
- return false;
+ bool Remove(size_t idx) {
+ if (idx < m_files.size()) {
+ m_files.erase(m_files.begin() + idx);
+ return true;
}
+ return false;
+ }
- bool
- Remove (size_t idx)
- {
- if (idx < m_files.size())
- {
- m_files.erase(m_files.begin() + idx);
- return true;
- }
- return false;
- }
-
- static size_t GetFilesMatchingPartialPath (const char *path, bool dir_okay, FileSpecList &matches);
+ static size_t GetFilesMatchingPartialPath(const char *path, bool dir_okay,
+ FileSpecList &matches);
protected:
- typedef std::vector<FileSpec> collection; ///< The collection type for the file list.
- collection m_files; ///< A collection of FileSpec objects.
+ typedef std::vector<FileSpec>
+ collection; ///< The collection type for the file list.
+ collection m_files; ///< A collection of FileSpec objects.
};
} // namespace lldb_private
-
-#endif // #if defined(__cplusplus)
-#endif // liblldb_FileSpecList_h_
+#endif // #if defined(__cplusplus)
+#endif // liblldb_FileSpecList_h_
diff --git a/include/lldb/Core/Flags.h b/include/lldb/Core/Flags.h
index 5f4f8830456b..d1bf685bced7 100644
--- a/include/lldb/Core/Flags.h
+++ b/include/lldb/Core/Flags.h
@@ -9,10 +9,9 @@
#ifndef liblldb_Flags_h_
#define liblldb_Flags_h_
-#if defined(__cplusplus)
-
-#include <stdint.h>
+#include <cstddef>
+#include <cstdint>
namespace lldb_private {
@@ -20,233 +19,175 @@ namespace lldb_private {
/// @class Flags Flags.h "lldb/Core/Flags.h"
/// @brief A class to manage flags.
///
-/// The Flags class managed flag bits and allows testing and
+/// The Flags class managed flag bits and allows testing and
/// modification of individual or multiple flag bits.
//----------------------------------------------------------------------
-class Flags
-{
+class Flags {
public:
- //----------------------------------------------------------------------
- /// The value type for flags is a 32 bit unsigned integer type.
- //----------------------------------------------------------------------
- typedef uint32_t ValueType;
-
- //----------------------------------------------------------------------
- /// Construct with initial flag bit values.
- ///
- /// Constructs this object with \a mask as the initial value for all
- /// of the flags.
- ///
- /// @param[in] mask
- /// The initial value for all flags.
- //----------------------------------------------------------------------
- Flags (ValueType flags = 0) :
- m_flags (flags)
- {
- }
-
- //----------------------------------------------------------------------
- /// Copy constructor.
- ///
- /// Construct and copy the flags from \a rhs.
- ///
- /// @param[in] rhs
- /// A const Flags object reference to copy.
- //----------------------------------------------------------------------
- Flags (const Flags& rhs) :
- m_flags(rhs.m_flags)
- {
- }
-
- //----------------------------------------------------------------------
- /// Destructor.
- //----------------------------------------------------------------------
- ~Flags ()
- {
- }
-
- //----------------------------------------------------------------------
- /// Get accessor for all flags.
- ///
- /// @return
- /// Returns all of the flags as a Flags::ValueType.
- //----------------------------------------------------------------------
- ValueType
- Get () const
- {
- return m_flags;
- }
-
- //----------------------------------------------------------------------
- /// Return the number of flags that can be represented in this
- /// object.
- ///
- /// @return
- /// The maximum number bits in this flag object.
- //----------------------------------------------------------------------
- size_t
- GetBitSize() const
- {
- return sizeof (ValueType) * 8;
- }
-
- //----------------------------------------------------------------------
- /// Set accessor for all flags.
- ///
- /// @param[in] flags
- /// The bits with which to replace all of the current flags.
- //----------------------------------------------------------------------
- void
- Reset (ValueType flags)
- {
- m_flags = flags;
- }
-
- //----------------------------------------------------------------------
- /// Clear one or more flags.
- ///
- /// @param[in] mask
- /// A bitfield containing one or more flags.
- ///
- /// @return
- /// The new flags after clearing all bits from \a mask.
- //----------------------------------------------------------------------
- ValueType
- Clear (ValueType mask = ~(ValueType)0)
- {
- m_flags &= ~mask;
- return m_flags;
- }
-
-
- //----------------------------------------------------------------------
- /// Set one or more flags by logical OR'ing \a mask with the current
- /// flags.
- ///
- /// @param[in] mask
- /// A bitfield containing one or more flags.
- ///
- /// @return
- /// The new flags after setting all bits from \a mask.
- //----------------------------------------------------------------------
- ValueType
- Set (ValueType mask)
- {
- m_flags |= mask;
- return m_flags;
- }
-
-
- //----------------------------------------------------------------------
- /// Test if all bits in \a mask are 1 in the current flags
- ///
- /// @return
- /// \b true if all flags in \a mask are 1, \b false
- /// otherwise.
- //----------------------------------------------------------------------
- bool
- AllSet (ValueType mask) const
- {
- return (m_flags & mask) == mask;
- }
-
- //----------------------------------------------------------------------
- /// Test one or more flags.
- ///
- /// @return
- /// \b true if any flags in \a mask are 1, \b false
- /// otherwise.
- //----------------------------------------------------------------------
- bool
- AnySet (ValueType mask) const
- {
- return (m_flags & mask) != 0;
- }
-
- //----------------------------------------------------------------------
- /// Test a single flag bit.
- ///
- /// @return
- /// \b true if \a bit is set, \b false otherwise.
- //----------------------------------------------------------------------
- bool
- Test (ValueType bit) const
- {
- return (m_flags & bit) != 0;
- }
-
- //----------------------------------------------------------------------
- /// Test if all bits in \a mask are clear.
- ///
- /// @return
- /// \b true if \b all flags in \a mask are clear, \b false
- /// otherwise.
- //----------------------------------------------------------------------
- bool
- AllClear (ValueType mask) const
- {
- return (m_flags & mask) == 0;
- }
-
- bool
- AnyClear (ValueType mask) const
- {
- return (m_flags & mask) != mask;
- }
-
- //----------------------------------------------------------------------
- /// Test a single flag bit to see if it is clear (zero).
- ///
- /// @return
- /// \b true if \a bit is 0, \b false otherwise.
- //----------------------------------------------------------------------
- bool
- IsClear (ValueType bit) const
- {
- return (m_flags & bit) == 0;
- }
-
- //----------------------------------------------------------------------
- /// Get the number of zero bits in \a m_flags.
- ///
- /// @return
- /// The number of bits that are set to 0 in the current flags.
- //----------------------------------------------------------------------
- size_t
- ClearCount () const
- {
- size_t count = 0;
- for (ValueType shift = 0; shift < sizeof(ValueType)*8; ++shift)
- {
- if ((m_flags & (1u << shift)) == 0)
- ++count;
- }
- return count;
- }
-
- //----------------------------------------------------------------------
- /// Get the number of one bits in \a m_flags.
- ///
- /// @return
- /// The number of bits that are set to 1 in the current flags.
- //----------------------------------------------------------------------
- size_t
- SetCount () const
- {
- size_t count = 0;
- for (ValueType mask = m_flags; mask; mask >>= 1)
- {
- if (mask & 1u)
- ++count;
- }
- return count;
- }
+ //----------------------------------------------------------------------
+ /// The value type for flags is a 32 bit unsigned integer type.
+ //----------------------------------------------------------------------
+ typedef uint32_t ValueType;
+
+ //----------------------------------------------------------------------
+ /// Construct with initial flag bit values.
+ ///
+ /// Constructs this object with \a mask as the initial value for all
+ /// of the flags.
+ ///
+ /// @param[in] mask
+ /// The initial value for all flags.
+ //----------------------------------------------------------------------
+ Flags(ValueType flags = 0) : m_flags(flags) {}
+
+ //----------------------------------------------------------------------
+ /// Copy constructor.
+ ///
+ /// Construct and copy the flags from \a rhs.
+ ///
+ /// @param[in] rhs
+ /// A const Flags object reference to copy.
+ //----------------------------------------------------------------------
+ Flags(const Flags &rhs) : m_flags(rhs.m_flags) {}
+
+ //----------------------------------------------------------------------
+ /// Destructor.
+ //----------------------------------------------------------------------
+ ~Flags() {}
+
+ //----------------------------------------------------------------------
+ /// Get accessor for all flags.
+ ///
+ /// @return
+ /// Returns all of the flags as a Flags::ValueType.
+ //----------------------------------------------------------------------
+ ValueType Get() const { return m_flags; }
+
+ //----------------------------------------------------------------------
+ /// Return the number of flags that can be represented in this
+ /// object.
+ ///
+ /// @return
+ /// The maximum number bits in this flag object.
+ //----------------------------------------------------------------------
+ size_t GetBitSize() const { return sizeof(ValueType) * 8; }
+
+ //----------------------------------------------------------------------
+ /// Set accessor for all flags.
+ ///
+ /// @param[in] flags
+ /// The bits with which to replace all of the current flags.
+ //----------------------------------------------------------------------
+ void Reset(ValueType flags) { m_flags = flags; }
+
+ //----------------------------------------------------------------------
+ /// Clear one or more flags.
+ ///
+ /// @param[in] mask
+ /// A bitfield containing one or more flags.
+ ///
+ /// @return
+ /// The new flags after clearing all bits from \a mask.
+ //----------------------------------------------------------------------
+ ValueType Clear(ValueType mask = ~(ValueType)0) {
+ m_flags &= ~mask;
+ return m_flags;
+ }
+
+ //----------------------------------------------------------------------
+ /// Set one or more flags by logical OR'ing \a mask with the current
+ /// flags.
+ ///
+ /// @param[in] mask
+ /// A bitfield containing one or more flags.
+ ///
+ /// @return
+ /// The new flags after setting all bits from \a mask.
+ //----------------------------------------------------------------------
+ ValueType Set(ValueType mask) {
+ m_flags |= mask;
+ return m_flags;
+ }
+
+ //----------------------------------------------------------------------
+ /// Test if all bits in \a mask are 1 in the current flags
+ ///
+ /// @return
+ /// \b true if all flags in \a mask are 1, \b false
+ /// otherwise.
+ //----------------------------------------------------------------------
+ bool AllSet(ValueType mask) const { return (m_flags & mask) == mask; }
+
+ //----------------------------------------------------------------------
+ /// Test one or more flags.
+ ///
+ /// @return
+ /// \b true if any flags in \a mask are 1, \b false
+ /// otherwise.
+ //----------------------------------------------------------------------
+ bool AnySet(ValueType mask) const { return (m_flags & mask) != 0; }
+
+ //----------------------------------------------------------------------
+ /// Test a single flag bit.
+ ///
+ /// @return
+ /// \b true if \a bit is set, \b false otherwise.
+ //----------------------------------------------------------------------
+ bool Test(ValueType bit) const { return (m_flags & bit) != 0; }
+
+ //----------------------------------------------------------------------
+ /// Test if all bits in \a mask are clear.
+ ///
+ /// @return
+ /// \b true if \b all flags in \a mask are clear, \b false
+ /// otherwise.
+ //----------------------------------------------------------------------
+ bool AllClear(ValueType mask) const { return (m_flags & mask) == 0; }
+
+ bool AnyClear(ValueType mask) const { return (m_flags & mask) != mask; }
+
+ //----------------------------------------------------------------------
+ /// Test a single flag bit to see if it is clear (zero).
+ ///
+ /// @return
+ /// \b true if \a bit is 0, \b false otherwise.
+ //----------------------------------------------------------------------
+ bool IsClear(ValueType bit) const { return (m_flags & bit) == 0; }
+
+ //----------------------------------------------------------------------
+ /// Get the number of zero bits in \a m_flags.
+ ///
+ /// @return
+ /// The number of bits that are set to 0 in the current flags.
+ //----------------------------------------------------------------------
+ size_t ClearCount() const {
+ size_t count = 0;
+ for (ValueType shift = 0; shift < sizeof(ValueType) * 8; ++shift) {
+ if ((m_flags & (1u << shift)) == 0)
+ ++count;
+ }
+ return count;
+ }
+
+ //----------------------------------------------------------------------
+ /// Get the number of one bits in \a m_flags.
+ ///
+ /// @return
+ /// The number of bits that are set to 1 in the current flags.
+ //----------------------------------------------------------------------
+ size_t SetCount() const {
+ size_t count = 0;
+ for (ValueType mask = m_flags; mask; mask >>= 1) {
+ if (mask & 1u)
+ ++count;
+ }
+ return count;
+ }
protected:
- ValueType m_flags; ///< The flags.
+ ValueType m_flags; ///< The flags.
};
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif // liblldb_Flags_h_
+#endif // liblldb_Flags_h_
diff --git a/include/lldb/Core/FormatEntity.h b/include/lldb/Core/FormatEntity.h
index 659b696e61fd..b6fe9ea46bfc 100644
--- a/include/lldb/Core/FormatEntity.h
+++ b/include/lldb/Core/FormatEntity.h
@@ -17,249 +17,201 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/Error.h"
+#include "lldb/lldb-private.h"
-namespace llvm
-{
- class StringRef;
+namespace llvm {
+class StringRef;
} // namespace llvm
-namespace lldb_private
-{
- class FormatEntity
- {
- public:
- struct Entry
- {
- enum class Type {
- Invalid,
- ParentNumber,
- ParentString,
- InsertString,
- Root,
- String,
- Scope,
- Variable,
- VariableSynthetic,
- ScriptVariable,
- ScriptVariableSynthetic,
- AddressLoad,
- AddressFile,
- AddressLoadOrFile,
- ProcessID,
- ProcessFile,
- ScriptProcess,
- ThreadID,
- ThreadProtocolID,
- ThreadIndexID,
- ThreadName,
- ThreadQueue,
- ThreadStopReason,
- ThreadReturnValue,
- ThreadCompletedExpression,
- ScriptThread,
- ThreadInfo,
- TargetArch,
- ScriptTarget,
- ModuleFile,
- File,
- Lang,
- FrameIndex,
- FrameRegisterPC,
- FrameRegisterSP,
- FrameRegisterFP,
- FrameRegisterFlags,
- FrameRegisterByName,
- ScriptFrame,
- FunctionID,
- FunctionDidChange,
- FunctionInitialFunction,
- FunctionName,
- FunctionNameWithArgs,
- FunctionNameNoArgs,
- FunctionAddrOffset,
- FunctionAddrOffsetConcrete,
- FunctionLineOffset,
- FunctionPCOffset,
- FunctionInitial,
- FunctionChanged,
- FunctionIsOptimized,
- LineEntryFile,
- LineEntryLineNumber,
- LineEntryStartAddress,
- LineEntryEndAddress,
- CurrentPCArrow
- };
-
- enum FormatType
- {
- None,
- UInt32,
- UInt64,
- CString
- };
-
- struct Definition
- {
- const char *name;
- const char *string; // Insert this exact string into the output
- Entry::Type type;
- FormatType format_type; // uint32_t, uint64_t, cstr, or anything that can be formatted by printf or lldb::Format
- uint64_t data;
- uint32_t num_children;
- Definition *children; // An array of "num_children" Definition entries,
- bool keep_separator;
- };
-
- Entry(Type t = Type::Invalid,
- const char *s = nullptr,
- const char *f = nullptr) :
- string (s ? s : ""),
- printf_format (f ? f : ""),
- children (),
- definition (nullptr),
- type (t),
- fmt (lldb::eFormatDefault),
- number (0),
- deref (false)
- {
- }
-
- Entry (llvm::StringRef s);
- Entry (char ch);
-
- void
- AppendChar (char ch);
-
- void
- AppendText (const llvm::StringRef &s);
-
- void
- AppendText (const char *cstr);
-
- void
- AppendEntry (const Entry &&entry)
- {
- children.push_back(entry);
- }
-
- void
- Clear ()
- {
- string.clear();
- printf_format.clear();
- children.clear();
- definition = nullptr;
- type = Type::Invalid;
- fmt = lldb::eFormatDefault;
- number = 0;
- deref = false;
- }
-
- static const char *
- TypeToCString (Type t);
-
- void
- Dump (Stream &s, int depth = 0) const;
-
- bool
- operator == (const Entry &rhs) const
- {
- if (string != rhs.string)
- return false;
- if (printf_format != rhs.printf_format)
- return false;
- const size_t n = children.size();
- const size_t m = rhs.children.size();
- for (size_t i=0; i < std::min<size_t>(n, m); ++i)
- {
- if (!(children[i] == rhs.children[i]))
- return false;
- }
- if (children != rhs.children)
- return false;
- if (definition != rhs.definition)
- return false;
- if (type != rhs.type)
- return false;
- if (fmt != rhs.fmt)
- return false;
- if (deref != rhs.deref)
- return false;
- return true;
- }
-
- std::string string;
- std::string printf_format;
- std::vector<Entry> children;
- Definition *definition;
- Type type;
- lldb::Format fmt;
- lldb::addr_t number;
- bool deref;
- };
-
- static bool
- Format (const Entry &entry,
- Stream &s,
- const SymbolContext *sc,
- const ExecutionContext *exe_ctx,
- const Address *addr,
- ValueObject* valobj,
- bool function_changed,
- bool initial_function);
-
- static bool
- FormatStringRef (const llvm::StringRef &format,
- Stream &s,
- const SymbolContext *sc,
- const ExecutionContext *exe_ctx,
- const Address *addr,
- ValueObject* valobj,
- bool function_changed,
- bool initial_function);
-
- static bool
- FormatCString (const char *format,
- Stream &s,
- const SymbolContext *sc,
- const ExecutionContext *exe_ctx,
- const Address *addr,
- ValueObject* valobj,
- bool function_changed,
- bool initial_function);
-
- static Error
- Parse (const llvm::StringRef &format, Entry &entry);
-
- static Error
- ExtractVariableInfo (llvm::StringRef &format_str,
- llvm::StringRef &variable_name,
- llvm::StringRef &variable_format);
-
- static size_t
- AutoComplete (const char *s,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches);
-
- //----------------------------------------------------------------------
- // Format the current elements into the stream \a s.
- //
- // The root element will be stripped off and the format str passed in
- // will be either an empty string (print a description of this object),
- // or contain a . separated series like a domain name that identifies
- // further sub elements to display.
- //----------------------------------------------------------------------
- static bool
- FormatFileSpec (const FileSpec &file, Stream &s, llvm::StringRef elements, llvm::StringRef element_format);
- protected:
- static Error
- ParseInternal (llvm::StringRef &format, Entry &parent_entry, uint32_t depth);
+namespace lldb_private {
+class FormatEntity {
+public:
+ struct Entry {
+ enum class Type {
+ Invalid,
+ ParentNumber,
+ ParentString,
+ InsertString,
+ Root,
+ String,
+ Scope,
+ Variable,
+ VariableSynthetic,
+ ScriptVariable,
+ ScriptVariableSynthetic,
+ AddressLoad,
+ AddressFile,
+ AddressLoadOrFile,
+ ProcessID,
+ ProcessFile,
+ ScriptProcess,
+ ThreadID,
+ ThreadProtocolID,
+ ThreadIndexID,
+ ThreadName,
+ ThreadQueue,
+ ThreadStopReason,
+ ThreadReturnValue,
+ ThreadCompletedExpression,
+ ScriptThread,
+ ThreadInfo,
+ TargetArch,
+ ScriptTarget,
+ ModuleFile,
+ File,
+ Lang,
+ FrameIndex,
+ FrameNoDebug,
+ FrameRegisterPC,
+ FrameRegisterSP,
+ FrameRegisterFP,
+ FrameRegisterFlags,
+ FrameRegisterByName,
+ ScriptFrame,
+ FunctionID,
+ FunctionDidChange,
+ FunctionInitialFunction,
+ FunctionName,
+ FunctionNameWithArgs,
+ FunctionNameNoArgs,
+ FunctionAddrOffset,
+ FunctionAddrOffsetConcrete,
+ FunctionLineOffset,
+ FunctionPCOffset,
+ FunctionInitial,
+ FunctionChanged,
+ FunctionIsOptimized,
+ LineEntryFile,
+ LineEntryLineNumber,
+ LineEntryStartAddress,
+ LineEntryEndAddress,
+ CurrentPCArrow
+ };
+ enum FormatType { None, UInt32, UInt64, CString };
+
+ struct Definition {
+ const char *name;
+ const char *string; // Insert this exact string into the output
+ Entry::Type type;
+ FormatType format_type; // uint32_t, uint64_t, cstr, or anything that can
+ // be formatted by printf or lldb::Format
+ uint64_t data;
+ uint32_t num_children;
+ Definition *children; // An array of "num_children" Definition entries,
+ bool keep_separator;
};
+
+ Entry(Type t = Type::Invalid, const char *s = nullptr,
+ const char *f = nullptr)
+ : string(s ? s : ""), printf_format(f ? f : ""), children(),
+ definition(nullptr), type(t), fmt(lldb::eFormatDefault), number(0),
+ deref(false) {}
+
+ Entry(llvm::StringRef s);
+ Entry(char ch);
+
+ void AppendChar(char ch);
+
+ void AppendText(const llvm::StringRef &s);
+
+ void AppendText(const char *cstr);
+
+ void AppendEntry(const Entry &&entry) { children.push_back(entry); }
+
+ void Clear() {
+ string.clear();
+ printf_format.clear();
+ children.clear();
+ definition = nullptr;
+ type = Type::Invalid;
+ fmt = lldb::eFormatDefault;
+ number = 0;
+ deref = false;
+ }
+
+ static const char *TypeToCString(Type t);
+
+ void Dump(Stream &s, int depth = 0) const;
+
+ bool operator==(const Entry &rhs) const {
+ if (string != rhs.string)
+ return false;
+ if (printf_format != rhs.printf_format)
+ return false;
+ const size_t n = children.size();
+ const size_t m = rhs.children.size();
+ for (size_t i = 0; i < std::min<size_t>(n, m); ++i) {
+ if (!(children[i] == rhs.children[i]))
+ return false;
+ }
+ if (children != rhs.children)
+ return false;
+ if (definition != rhs.definition)
+ return false;
+ if (type != rhs.type)
+ return false;
+ if (fmt != rhs.fmt)
+ return false;
+ if (deref != rhs.deref)
+ return false;
+ return true;
+ }
+
+ std::string string;
+ std::string printf_format;
+ std::vector<Entry> children;
+ Definition *definition;
+ Type type;
+ lldb::Format fmt;
+ lldb::addr_t number;
+ bool deref;
+ };
+
+ static bool Format(const Entry &entry, Stream &s, const SymbolContext *sc,
+ const ExecutionContext *exe_ctx, const Address *addr,
+ ValueObject *valobj, bool function_changed,
+ bool initial_function);
+
+ static bool FormatStringRef(const llvm::StringRef &format, Stream &s,
+ const SymbolContext *sc,
+ const ExecutionContext *exe_ctx,
+ const Address *addr, ValueObject *valobj,
+ bool function_changed, bool initial_function);
+
+ static bool FormatCString(const char *format, Stream &s,
+ const SymbolContext *sc,
+ const ExecutionContext *exe_ctx,
+ const Address *addr, ValueObject *valobj,
+ bool function_changed, bool initial_function);
+
+ static Error Parse(const llvm::StringRef &format, Entry &entry);
+
+ static Error ExtractVariableInfo(llvm::StringRef &format_str,
+ llvm::StringRef &variable_name,
+ llvm::StringRef &variable_format);
+
+ static size_t AutoComplete(llvm::StringRef s, int match_start_point,
+ int max_return_elements, bool &word_complete,
+ StringList &matches);
+
+ //----------------------------------------------------------------------
+ // Format the current elements into the stream \a s.
+ //
+ // The root element will be stripped off and the format str passed in
+ // will be either an empty string (print a description of this object),
+ // or contain a . separated series like a domain name that identifies
+ // further sub elements to display.
+ //----------------------------------------------------------------------
+ static bool FormatFileSpec(const FileSpec &file, Stream &s,
+ llvm::StringRef elements,
+ llvm::StringRef element_format);
+
+protected:
+ static Error ParseInternal(llvm::StringRef &format, Entry &parent_entry,
+ uint32_t depth);
+};
} // namespace lldb_private
#endif // liblldb_FormatEntity_h_
diff --git a/include/lldb/Core/History.h b/include/lldb/Core/History.h
index 164d1bfb651b..fcffcdd901bb 100644
--- a/include/lldb/Core/History.h
+++ b/include/lldb/Core/History.h
@@ -28,141 +28,105 @@ namespace lldb_private {
/// @class HistorySource History.h "lldb/Core/History.h"
/// @brief A class that defines history events.
//----------------------------------------------------------------------
-
-class HistorySource
-{
+
+class HistorySource {
public:
- typedef const void * HistoryEvent;
+ typedef const void *HistoryEvent;
- HistorySource() : m_mutex(), m_events() {}
+ HistorySource() : m_mutex(), m_events() {}
- virtual
- ~HistorySource()
- {
- }
+ virtual ~HistorySource() {}
- // Create a new history event. Subclasses should use any data or members
- // in the subclass of this class to produce a history event and push it
- // onto the end of the history stack.
+ // Create a new history event. Subclasses should use any data or members
+ // in the subclass of this class to produce a history event and push it
+ // onto the end of the history stack.
- virtual HistoryEvent
- CreateHistoryEvent () = 0;
+ virtual HistoryEvent CreateHistoryEvent() = 0;
- virtual void
- DeleteHistoryEvent (HistoryEvent event) = 0;
+ virtual void DeleteHistoryEvent(HistoryEvent event) = 0;
- virtual void
- DumpHistoryEvent (Stream &strm, HistoryEvent event) = 0;
+ virtual void DumpHistoryEvent(Stream &strm, HistoryEvent event) = 0;
- virtual size_t
- GetHistoryEventCount() = 0;
+ virtual size_t GetHistoryEventCount() = 0;
- virtual HistoryEvent
- GetHistoryEventAtIndex (uint32_t idx) = 0;
+ virtual HistoryEvent GetHistoryEventAtIndex(uint32_t idx) = 0;
- virtual HistoryEvent
- GetCurrentHistoryEvent () = 0;
+ virtual HistoryEvent GetCurrentHistoryEvent() = 0;
- // Return 0 when lhs == rhs, 1 if lhs > rhs, or -1 if lhs < rhs.
- virtual int
- CompareHistoryEvents (const HistoryEvent lhs,
- const HistoryEvent rhs) = 0;
+ // Return 0 when lhs == rhs, 1 if lhs > rhs, or -1 if lhs < rhs.
+ virtual int CompareHistoryEvents(const HistoryEvent lhs,
+ const HistoryEvent rhs) = 0;
- virtual bool
- IsCurrentHistoryEvent (const HistoryEvent event) = 0;
+ virtual bool IsCurrentHistoryEvent(const HistoryEvent event) = 0;
private:
- typedef std::stack<HistoryEvent> collection;
+ typedef std::stack<HistoryEvent> collection;
- std::recursive_mutex m_mutex;
- collection m_events;
+ std::recursive_mutex m_mutex;
+ collection m_events;
- DISALLOW_COPY_AND_ASSIGN (HistorySource);
+ DISALLOW_COPY_AND_ASSIGN(HistorySource);
};
-
+
//----------------------------------------------------------------------
/// @class HistorySourceUInt History.h "lldb/Core/History.h"
/// @brief A class that defines history events that are represented by
/// unsigned integers.
///
-/// Any history event that is defined by a unique monotonically
+/// Any history event that is defined by a unique monotonically
/// increasing unsigned integer
//----------------------------------------------------------------------
-class HistorySourceUInt : public HistorySource
-{
- HistorySourceUInt (const char *id_name, uintptr_t start_value = 0u) :
- HistorySource(),
- m_name (id_name),
- m_curr_id (start_value)
- {
- }
-
- ~HistorySourceUInt() override
- {
- }
-
- // Create a new history event. Subclasses should use any data or members
- // in the subclass of this class to produce a history event and push it
- // onto the end of the history stack.
-
- HistoryEvent
- CreateHistoryEvent () override
- {
- ++m_curr_id;
- return (HistoryEvent)m_curr_id;
- }
-
- void
- DeleteHistoryEvent (HistoryEvent event) override
- {
- // Nothing to delete, the event contains the integer
- }
-
- void
- DumpHistoryEvent (Stream &strm, HistoryEvent event) override;
-
- size_t
- GetHistoryEventCount() override
- {
- return m_curr_id;
- }
-
- HistoryEvent
- GetHistoryEventAtIndex (uint32_t idx) override
- {
- return (HistoryEvent)((uintptr_t)idx);
- }
-
- HistoryEvent
- GetCurrentHistoryEvent () override
- {
- return (HistoryEvent)m_curr_id;
- }
-
- // Return 0 when lhs == rhs, 1 if lhs > rhs, or -1 if lhs < rhs.
- int
- CompareHistoryEvents (const HistoryEvent lhs,
- const HistoryEvent rhs) override
- {
- uintptr_t lhs_uint = (uintptr_t)lhs;
- uintptr_t rhs_uint = (uintptr_t)rhs;
- if (lhs_uint < rhs_uint)
- return -1;
- if (lhs_uint > rhs_uint)
- return +1;
- return 0;
- }
-
- bool
- IsCurrentHistoryEvent (const HistoryEvent event) override
- {
- return (uintptr_t)event == m_curr_id;
- }
+class HistorySourceUInt : public HistorySource {
+ HistorySourceUInt(const char *id_name, uintptr_t start_value = 0u)
+ : HistorySource(), m_name(id_name), m_curr_id(start_value) {}
+
+ ~HistorySourceUInt() override {}
+
+ // Create a new history event. Subclasses should use any data or members
+ // in the subclass of this class to produce a history event and push it
+ // onto the end of the history stack.
+
+ HistoryEvent CreateHistoryEvent() override {
+ ++m_curr_id;
+ return (HistoryEvent)m_curr_id;
+ }
+
+ void DeleteHistoryEvent(HistoryEvent event) override {
+ // Nothing to delete, the event contains the integer
+ }
+
+ void DumpHistoryEvent(Stream &strm, HistoryEvent event) override;
+
+ size_t GetHistoryEventCount() override { return m_curr_id; }
+
+ HistoryEvent GetHistoryEventAtIndex(uint32_t idx) override {
+ return (HistoryEvent)((uintptr_t)idx);
+ }
+
+ HistoryEvent GetCurrentHistoryEvent() override {
+ return (HistoryEvent)m_curr_id;
+ }
+
+ // Return 0 when lhs == rhs, 1 if lhs > rhs, or -1 if lhs < rhs.
+ int CompareHistoryEvents(const HistoryEvent lhs,
+ const HistoryEvent rhs) override {
+ uintptr_t lhs_uint = (uintptr_t)lhs;
+ uintptr_t rhs_uint = (uintptr_t)rhs;
+ if (lhs_uint < rhs_uint)
+ return -1;
+ if (lhs_uint > rhs_uint)
+ return +1;
+ return 0;
+ }
+
+ bool IsCurrentHistoryEvent(const HistoryEvent event) override {
+ return (uintptr_t)event == m_curr_id;
+ }
protected:
- std::string m_name; // The name of the history unsigned integer
- uintptr_t m_curr_id; // The current value of the history unsigned unteger
+ std::string m_name; // The name of the history unsigned integer
+ uintptr_t m_curr_id; // The current value of the history unsigned unteger
};
} // namespace lldb_private
diff --git a/include/lldb/Core/IOHandler.h b/include/lldb/Core/IOHandler.h
index 1844df365158..2e6ff31ee687 100644
--- a/include/lldb/Core/IOHandler.h
+++ b/include/lldb/Core/IOHandler.h
@@ -21,8 +21,6 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
-#include "lldb/lldb-enumerations.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Flags.h"
@@ -30,794 +28,579 @@
#include "lldb/Core/StringList.h"
#include "lldb/Core/ValueObjectList.h"
#include "lldb/Host/Predicate.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-public.h"
-namespace curses
-{
- class Application;
- typedef std::unique_ptr<Application> ApplicationAP;
+namespace curses {
+class Application;
+typedef std::unique_ptr<Application> ApplicationAP;
} // namespace curses
namespace lldb_private {
- class IOHandler
- {
- public:
- enum class Type {
- CommandInterpreter,
- CommandList,
- Confirm,
- Curses,
- Expression,
- REPL,
- ProcessIO,
- PythonInterpreter,
- PythonCode,
- Other
- };
-
- IOHandler (Debugger &debugger,
- IOHandler::Type type);
-
- IOHandler (Debugger &debugger,
- IOHandler::Type type,
- const lldb::StreamFileSP &input_sp,
- const lldb::StreamFileSP &output_sp,
- const lldb::StreamFileSP &error_sp,
- uint32_t flags);
-
- virtual
- ~IOHandler ();
-
- // Each IOHandler gets to run until it is done. It should read data
- // from the "in" and place output into "out" and "err and return
- // when done.
- virtual void
- Run () = 0;
-
- // Called when an input reader should relinquish its control so another
- // can be pushed onto the IO handler stack, or so the current IO
- // handler can pop itself off the stack
-
- virtual void
- Cancel () = 0;
-
- // Called when CTRL+C is pressed which usually causes
- // Debugger::DispatchInputInterrupt to be called.
-
- virtual bool
- Interrupt () = 0;
-
- virtual void
- GotEOF() = 0;
-
- virtual bool
- IsActive ()
- {
- return m_active && !m_done;
- }
-
- virtual void
- SetIsDone (bool b)
- {
- m_done = b;
- }
-
- virtual bool
- GetIsDone ()
- {
- return m_done;
- }
-
- Type
- GetType () const
- {
- return m_type;
- }
-
- virtual void
- Activate ()
- {
- m_active = true;
- }
-
- virtual void
- Deactivate ()
- {
- m_active = false;
- }
-
- virtual const char *
- GetPrompt ()
- {
- // Prompt support isn't mandatory
- return nullptr;
- }
-
- virtual bool
- SetPrompt (const char *prompt)
- {
- // Prompt support isn't mandatory
- return false;
- }
-
- virtual ConstString
- GetControlSequence (char ch)
- {
- return ConstString();
- }
-
- virtual const char *
- GetCommandPrefix ()
- {
- return nullptr;
- }
-
- virtual const char *
- GetHelpPrologue()
- {
- return nullptr;
- }
-
- int
- GetInputFD();
-
- int
- GetOutputFD();
-
- int
- GetErrorFD();
-
- FILE *
- GetInputFILE();
-
- FILE *
- GetOutputFILE();
-
- FILE *
- GetErrorFILE();
-
- lldb::StreamFileSP &
- GetInputStreamFile();
-
- lldb::StreamFileSP &
- GetOutputStreamFile();
-
- lldb::StreamFileSP &
- GetErrorStreamFile();
-
- Debugger &
- GetDebugger()
- {
- return m_debugger;
- }
-
- void *
- GetUserData ()
- {
- return m_user_data;
- }
-
- void
- SetUserData (void *user_data)
- {
- m_user_data = user_data;
- }
-
- Flags &
- GetFlags ()
- {
- return m_flags;
- }
-
- const Flags &
- GetFlags () const
- {
- return m_flags;
- }
-
- //------------------------------------------------------------------
- /// Check if the input is being supplied interactively by a user
- ///
- /// This will return true if the input stream is a terminal (tty or
- /// pty) and can cause IO handlers to do different things (like
- /// for a confirmation when deleting all breakpoints).
- //------------------------------------------------------------------
- bool
- GetIsInteractive ();
-
- //------------------------------------------------------------------
- /// Check if the input is coming from a real terminal.
- ///
- /// A real terminal has a valid size with a certain number of rows
- /// and columns. If this function returns true, then terminal escape
- /// sequences are expected to work (cursor movement escape sequences,
- /// clearing lines, etc).
- //------------------------------------------------------------------
- bool
- GetIsRealTerminal ();
-
- void
- SetPopped (bool b);
-
- void
- WaitForPop ();
-
- virtual void
- PrintAsync (Stream *stream, const char *s, size_t len)
- {
- stream->Write (s, len);
- stream->Flush();
- }
-
- protected:
- Debugger &m_debugger;
- lldb::StreamFileSP m_input_sp;
- lldb::StreamFileSP m_output_sp;
- lldb::StreamFileSP m_error_sp;
- Predicate<bool> m_popped;
- Flags m_flags;
- Type m_type;
- void *m_user_data;
- bool m_done;
- bool m_active;
-
- private:
- DISALLOW_COPY_AND_ASSIGN (IOHandler);
- };
-
- //------------------------------------------------------------------
- /// A delegate class for use with IOHandler subclasses.
- ///
- /// The IOHandler delegate is designed to be mixed into classes so
- /// they can use an IOHandler subclass to fetch input and notify the
- /// object that inherits from this delegate class when a token is
- /// received.
- //------------------------------------------------------------------
- class IOHandlerDelegate
- {
- public:
- enum class Completion {
- None,
- LLDBCommand,
- Expression
- };
-
- IOHandlerDelegate (Completion completion = Completion::None) :
- m_completion(completion),
- m_io_handler_done (false)
- {
- }
-
- virtual
- ~IOHandlerDelegate() = default;
-
- virtual void
- IOHandlerActivated (IOHandler &io_handler)
- {
- }
-
- virtual void
- IOHandlerDeactivated (IOHandler &io_handler)
- {
- }
-
- virtual int
- IOHandlerComplete (IOHandler &io_handler,
- const char *current_line,
- const char *cursor,
- const char *last_char,
- int skip_first_n_matches,
- int max_matches,
- StringList &matches);
-
- virtual const char *
- IOHandlerGetFixIndentationCharacters ()
- {
- return nullptr;
- }
-
- //------------------------------------------------------------------
- /// Called when a new line is created or one of an identified set of
- /// indentation characters is typed.
- ///
- /// This function determines how much indentation should be added
- /// or removed to match the recommended amount for the final line.
- ///
- /// @param[in] io_handler
- /// The IOHandler that responsible for input.
- ///
- /// @param[in] lines
- /// The current input up to the line to be corrected. Lines
- /// following the line containing the cursor are not included.
- ///
- /// @param[in] cursor_position
- /// The number of characters preceding the cursor on the final
- /// line at the time.
- ///
- /// @return
- /// Returns an integer describing the number of spaces needed
- /// to correct the indentation level. Positive values indicate
- /// that spaces should be added, while negative values represent
- /// spaces that should be removed.
- //------------------------------------------------------------------
- virtual int
- IOHandlerFixIndentation (IOHandler &io_handler,
- const StringList &lines,
- int cursor_position)
- {
- return 0;
- }
-
- //------------------------------------------------------------------
- /// Called when a line or lines have been retrieved.
- ///
- /// This function can handle the current line and possibly call
- /// IOHandler::SetIsDone(true) when the IO handler is done like when
- /// "quit" is entered as a command, of when an empty line is
- /// received. It is up to the delegate to determine when a line
- /// should cause a IOHandler to exit.
- //------------------------------------------------------------------
- virtual void
- IOHandlerInputComplete (IOHandler &io_handler, std::string &data) = 0;
-
- virtual void
- IOHandlerInputInterrupted (IOHandler &io_handler, std::string &data)
- {
- }
-
- //------------------------------------------------------------------
- /// Called to determine whether typing enter after the last line in
- /// \a lines should end input. This function will not be called on
- /// IOHandler objects that are getting single lines.
- /// @param[in] io_handler
- /// The IOHandler that responsible for updating the lines.
- ///
- /// @param[in] lines
- /// The current multi-line content. May be altered to provide
- /// alternative input when complete.
- ///
- /// @return
- /// Return an boolean to indicate whether input is complete,
- /// true indicates that no additional input is necessary, while
- /// false indicates that more input is required.
- //------------------------------------------------------------------
- virtual bool
- IOHandlerIsInputComplete (IOHandler &io_handler,
- StringList &lines)
- {
- // Impose no requirements for input to be considered
- // complete. subclasses should do something more intelligent.
- return true;
- }
-
- virtual ConstString
- IOHandlerGetControlSequence (char ch)
- {
- return ConstString();
- }
-
- virtual const char *
- IOHandlerGetCommandPrefix ()
- {
- return nullptr;
- }
-
- virtual const char *
- IOHandlerGetHelpPrologue ()
- {
- return nullptr;
- }
-
- //------------------------------------------------------------------
- // Intercept the IOHandler::Interrupt() calls and do something.
- //
- // Return true if the interrupt was handled, false if the IOHandler
- // should continue to try handle the interrupt itself.
- //------------------------------------------------------------------
- virtual bool
- IOHandlerInterrupt (IOHandler &io_handler)
- {
- return false;
- }
-
- protected:
- Completion m_completion; // Support for common builtin completions
- bool m_io_handler_done;
- };
-
- //----------------------------------------------------------------------
- // IOHandlerDelegateMultiline
- //
- // A IOHandlerDelegate that handles terminating multi-line input when
- // the last line is equal to "end_line" which is specified in the
- // constructor.
- //----------------------------------------------------------------------
- class IOHandlerDelegateMultiline :
- public IOHandlerDelegate
- {
- public:
- IOHandlerDelegateMultiline (const char *end_line,
- Completion completion = Completion::None) :
- IOHandlerDelegate (completion),
- m_end_line((end_line && end_line[0]) ? end_line : "")
- {
- }
-
- ~IOHandlerDelegateMultiline() override = default;
-
- ConstString
- IOHandlerGetControlSequence (char ch) override
- {
- if (ch == 'd')
- return ConstString (m_end_line + "\n");
- return ConstString();
- }
-
- bool
- IOHandlerIsInputComplete (IOHandler &io_handler,
- StringList &lines) override
- {
- // Determine whether the end of input signal has been entered
- const size_t num_lines = lines.GetSize();
- if (num_lines > 0 && lines[num_lines - 1] == m_end_line)
- {
- // Remove the terminal line from "lines" so it doesn't appear in
- // the resulting input and return true to indicate we are done
- // getting lines
- lines.PopBack();
- return true;
- }
- return false;
- }
-
- protected:
- const std::string m_end_line;
- };
-
- class IOHandlerEditline : public IOHandler
- {
- public:
- IOHandlerEditline (Debugger &debugger,
- IOHandler::Type type,
- const char *editline_name, // Used for saving history files
- const char *prompt,
- const char *continuation_prompt,
- bool multi_line,
- bool color_prompts,
- uint32_t line_number_start, // If non-zero show line numbers starting at 'line_number_start'
- IOHandlerDelegate &delegate);
-
- IOHandlerEditline (Debugger &debugger,
- IOHandler::Type type,
- const lldb::StreamFileSP &input_sp,
- const lldb::StreamFileSP &output_sp,
- const lldb::StreamFileSP &error_sp,
- uint32_t flags,
- const char *editline_name, // Used for saving history files
- const char *prompt,
- const char *continuation_prompt,
- bool multi_line,
- bool color_prompts,
- uint32_t line_number_start, // If non-zero show line numbers starting at 'line_number_start'
- IOHandlerDelegate &delegate);
-
- ~IOHandlerEditline() override;
-
- void
- Run () override;
-
- void
- Cancel () override;
-
- bool
- Interrupt () override;
-
- void
- GotEOF() override;
-
- void
- Activate () override;
-
- void
- Deactivate () override;
-
- ConstString
- GetControlSequence (char ch) override
- {
- return m_delegate.IOHandlerGetControlSequence (ch);
- }
-
- const char *
- GetCommandPrefix () override
- {
- return m_delegate.IOHandlerGetCommandPrefix ();
- }
-
- const char *
- GetHelpPrologue () override
- {
- return m_delegate.IOHandlerGetHelpPrologue ();
- }
-
- const char *
- GetPrompt () override;
-
- bool
- SetPrompt (const char *prompt) override;
-
- const char *
- GetContinuationPrompt ();
-
- void
- SetContinuationPrompt (const char *prompt);
-
- bool
- GetLine (std::string &line, bool &interrupted);
-
- bool
- GetLines (StringList &lines, bool &interrupted);
-
- void
- SetBaseLineNumber (uint32_t line);
-
- bool
- GetInterruptExits ()
- {
- return m_interrupt_exits;
- }
-
- void
- SetInterruptExits (bool b)
- {
- m_interrupt_exits = b;
- }
-
- const StringList *
- GetCurrentLines () const
- {
- return m_current_lines_ptr;
- }
-
- uint32_t
- GetCurrentLineIndex () const;
-
- void
- PrintAsync (Stream *stream, const char *s, size_t len) override;
-
- private:
+class IOHandler {
+public:
+ enum class Type {
+ CommandInterpreter,
+ CommandList,
+ Confirm,
+ Curses,
+ Expression,
+ REPL,
+ ProcessIO,
+ PythonInterpreter,
+ PythonCode,
+ Other
+ };
+
+ IOHandler(Debugger &debugger, IOHandler::Type type);
+
+ IOHandler(Debugger &debugger, IOHandler::Type type,
+ const lldb::StreamFileSP &input_sp,
+ const lldb::StreamFileSP &output_sp,
+ const lldb::StreamFileSP &error_sp, uint32_t flags);
+
+ virtual ~IOHandler();
+
+ // Each IOHandler gets to run until it is done. It should read data
+ // from the "in" and place output into "out" and "err and return
+ // when done.
+ virtual void Run() = 0;
+
+ // Called when an input reader should relinquish its control so another
+ // can be pushed onto the IO handler stack, or so the current IO
+ // handler can pop itself off the stack
+
+ virtual void Cancel() = 0;
+
+ // Called when CTRL+C is pressed which usually causes
+ // Debugger::DispatchInputInterrupt to be called.
+
+ virtual bool Interrupt() = 0;
+
+ virtual void GotEOF() = 0;
+
+ virtual bool IsActive() { return m_active && !m_done; }
+
+ virtual void SetIsDone(bool b) { m_done = b; }
+
+ virtual bool GetIsDone() { return m_done; }
+
+ Type GetType() const { return m_type; }
+
+ virtual void Activate() { m_active = true; }
+
+ virtual void Deactivate() { m_active = false; }
+
+ virtual const char *GetPrompt() {
+ // Prompt support isn't mandatory
+ return nullptr;
+ }
+
+ virtual bool SetPrompt(llvm::StringRef prompt) {
+ // Prompt support isn't mandatory
+ return false;
+ }
+ bool SetPrompt(const char *) = delete;
+
+ virtual ConstString GetControlSequence(char ch) { return ConstString(); }
+
+ virtual const char *GetCommandPrefix() { return nullptr; }
+
+ virtual const char *GetHelpPrologue() { return nullptr; }
+
+ int GetInputFD();
+
+ int GetOutputFD();
+
+ int GetErrorFD();
+
+ FILE *GetInputFILE();
+
+ FILE *GetOutputFILE();
+
+ FILE *GetErrorFILE();
+
+ lldb::StreamFileSP &GetInputStreamFile();
+
+ lldb::StreamFileSP &GetOutputStreamFile();
+
+ lldb::StreamFileSP &GetErrorStreamFile();
+
+ Debugger &GetDebugger() { return m_debugger; }
+
+ void *GetUserData() { return m_user_data; }
+
+ void SetUserData(void *user_data) { m_user_data = user_data; }
+
+ Flags &GetFlags() { return m_flags; }
+
+ const Flags &GetFlags() const { return m_flags; }
+
+ //------------------------------------------------------------------
+ /// Check if the input is being supplied interactively by a user
+ ///
+ /// This will return true if the input stream is a terminal (tty or
+ /// pty) and can cause IO handlers to do different things (like
+ /// for a confirmation when deleting all breakpoints).
+ //------------------------------------------------------------------
+ bool GetIsInteractive();
+
+ //------------------------------------------------------------------
+ /// Check if the input is coming from a real terminal.
+ ///
+ /// A real terminal has a valid size with a certain number of rows
+ /// and columns. If this function returns true, then terminal escape
+ /// sequences are expected to work (cursor movement escape sequences,
+ /// clearing lines, etc).
+ //------------------------------------------------------------------
+ bool GetIsRealTerminal();
+
+ void SetPopped(bool b);
+
+ void WaitForPop();
+
+ virtual void PrintAsync(Stream *stream, const char *s, size_t len) {
+ stream->Write(s, len);
+ stream->Flush();
+ }
+
+protected:
+ Debugger &m_debugger;
+ lldb::StreamFileSP m_input_sp;
+ lldb::StreamFileSP m_output_sp;
+ lldb::StreamFileSP m_error_sp;
+ Predicate<bool> m_popped;
+ Flags m_flags;
+ Type m_type;
+ void *m_user_data;
+ bool m_done;
+ bool m_active;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(IOHandler);
+};
+
+//------------------------------------------------------------------
+/// A delegate class for use with IOHandler subclasses.
+///
+/// The IOHandler delegate is designed to be mixed into classes so
+/// they can use an IOHandler subclass to fetch input and notify the
+/// object that inherits from this delegate class when a token is
+/// received.
+//------------------------------------------------------------------
+class IOHandlerDelegate {
+public:
+ enum class Completion { None, LLDBCommand, Expression };
+
+ IOHandlerDelegate(Completion completion = Completion::None)
+ : m_completion(completion), m_io_handler_done(false) {}
+
+ virtual ~IOHandlerDelegate() = default;
+
+ virtual void IOHandlerActivated(IOHandler &io_handler) {}
+
+ virtual void IOHandlerDeactivated(IOHandler &io_handler) {}
+
+ virtual int IOHandlerComplete(IOHandler &io_handler, const char *current_line,
+ const char *cursor, const char *last_char,
+ int skip_first_n_matches, int max_matches,
+ StringList &matches);
+
+ virtual const char *IOHandlerGetFixIndentationCharacters() { return nullptr; }
+
+ //------------------------------------------------------------------
+ /// Called when a new line is created or one of an identified set of
+ /// indentation characters is typed.
+ ///
+ /// This function determines how much indentation should be added
+ /// or removed to match the recommended amount for the final line.
+ ///
+ /// @param[in] io_handler
+ /// The IOHandler that responsible for input.
+ ///
+ /// @param[in] lines
+ /// The current input up to the line to be corrected. Lines
+ /// following the line containing the cursor are not included.
+ ///
+ /// @param[in] cursor_position
+ /// The number of characters preceding the cursor on the final
+ /// line at the time.
+ ///
+ /// @return
+ /// Returns an integer describing the number of spaces needed
+ /// to correct the indentation level. Positive values indicate
+ /// that spaces should be added, while negative values represent
+ /// spaces that should be removed.
+ //------------------------------------------------------------------
+ virtual int IOHandlerFixIndentation(IOHandler &io_handler,
+ const StringList &lines,
+ int cursor_position) {
+ return 0;
+ }
+
+ //------------------------------------------------------------------
+ /// Called when a line or lines have been retrieved.
+ ///
+ /// This function can handle the current line and possibly call
+ /// IOHandler::SetIsDone(true) when the IO handler is done like when
+ /// "quit" is entered as a command, of when an empty line is
+ /// received. It is up to the delegate to determine when a line
+ /// should cause a IOHandler to exit.
+ //------------------------------------------------------------------
+ virtual void IOHandlerInputComplete(IOHandler &io_handler,
+ std::string &data) = 0;
+
+ virtual void IOHandlerInputInterrupted(IOHandler &io_handler,
+ std::string &data) {}
+
+ //------------------------------------------------------------------
+ /// Called to determine whether typing enter after the last line in
+ /// \a lines should end input. This function will not be called on
+ /// IOHandler objects that are getting single lines.
+ /// @param[in] io_handler
+ /// The IOHandler that responsible for updating the lines.
+ ///
+ /// @param[in] lines
+ /// The current multi-line content. May be altered to provide
+ /// alternative input when complete.
+ ///
+ /// @return
+ /// Return an boolean to indicate whether input is complete,
+ /// true indicates that no additional input is necessary, while
+ /// false indicates that more input is required.
+ //------------------------------------------------------------------
+ virtual bool IOHandlerIsInputComplete(IOHandler &io_handler,
+ StringList &lines) {
+ // Impose no requirements for input to be considered
+ // complete. subclasses should do something more intelligent.
+ return true;
+ }
+
+ virtual ConstString IOHandlerGetControlSequence(char ch) {
+ return ConstString();
+ }
+
+ virtual const char *IOHandlerGetCommandPrefix() { return nullptr; }
+
+ virtual const char *IOHandlerGetHelpPrologue() { return nullptr; }
+
+ //------------------------------------------------------------------
+ // Intercept the IOHandler::Interrupt() calls and do something.
+ //
+ // Return true if the interrupt was handled, false if the IOHandler
+ // should continue to try handle the interrupt itself.
+ //------------------------------------------------------------------
+ virtual bool IOHandlerInterrupt(IOHandler &io_handler) { return false; }
+
+protected:
+ Completion m_completion; // Support for common builtin completions
+ bool m_io_handler_done;
+};
+
+//----------------------------------------------------------------------
+// IOHandlerDelegateMultiline
+//
+// A IOHandlerDelegate that handles terminating multi-line input when
+// the last line is equal to "end_line" which is specified in the
+// constructor.
+//----------------------------------------------------------------------
+class IOHandlerDelegateMultiline : public IOHandlerDelegate {
+public:
+ IOHandlerDelegateMultiline(const char *end_line,
+ Completion completion = Completion::None)
+ : IOHandlerDelegate(completion),
+ m_end_line((end_line && end_line[0]) ? end_line : "") {}
+
+ ~IOHandlerDelegateMultiline() override = default;
+
+ ConstString IOHandlerGetControlSequence(char ch) override {
+ if (ch == 'd')
+ return ConstString(m_end_line + "\n");
+ return ConstString();
+ }
+
+ bool IOHandlerIsInputComplete(IOHandler &io_handler,
+ StringList &lines) override {
+ // Determine whether the end of input signal has been entered
+ const size_t num_lines = lines.GetSize();
+ if (num_lines > 0 && lines[num_lines - 1] == m_end_line) {
+ // Remove the terminal line from "lines" so it doesn't appear in
+ // the resulting input and return true to indicate we are done
+ // getting lines
+ lines.PopBack();
+ return true;
+ }
+ return false;
+ }
+
+protected:
+ const std::string m_end_line;
+};
+
+class IOHandlerEditline : public IOHandler {
+public:
+ IOHandlerEditline(Debugger &debugger, IOHandler::Type type,
+ const char *editline_name, // Used for saving history files
+ llvm::StringRef prompt, llvm::StringRef continuation_prompt,
+ bool multi_line, bool color_prompts,
+ uint32_t line_number_start, // If non-zero show line numbers
+ // starting at
+ // 'line_number_start'
+ IOHandlerDelegate &delegate);
+
+ IOHandlerEditline(Debugger &debugger, IOHandler::Type type,
+ const lldb::StreamFileSP &input_sp,
+ const lldb::StreamFileSP &output_sp,
+ const lldb::StreamFileSP &error_sp, uint32_t flags,
+ const char *editline_name, // Used for saving history files
+ llvm::StringRef prompt, llvm::StringRef continuation_prompt,
+ bool multi_line, bool color_prompts,
+ uint32_t line_number_start, // If non-zero show line numbers
+ // starting at
+ // 'line_number_start'
+ IOHandlerDelegate &delegate);
+
+ IOHandlerEditline(Debugger &, IOHandler::Type, const char *, const char *,
+ const char *, bool, bool, uint32_t,
+ IOHandlerDelegate &) = delete;
+
+ IOHandlerEditline(Debugger &, IOHandler::Type, const lldb::StreamFileSP &,
+ const lldb::StreamFileSP &, const lldb::StreamFileSP &,
+ uint32_t, const char *, const char *, const char *, bool,
+ bool, uint32_t, IOHandlerDelegate &) = delete;
+
+ ~IOHandlerEditline() override;
+
+ void Run() override;
+
+ void Cancel() override;
+
+ bool Interrupt() override;
+
+ void GotEOF() override;
+
+ void Activate() override;
+
+ void Deactivate() override;
+
+ ConstString GetControlSequence(char ch) override {
+ return m_delegate.IOHandlerGetControlSequence(ch);
+ }
+
+ const char *GetCommandPrefix() override {
+ return m_delegate.IOHandlerGetCommandPrefix();
+ }
+
+ const char *GetHelpPrologue() override {
+ return m_delegate.IOHandlerGetHelpPrologue();
+ }
+
+ const char *GetPrompt() override;
+
+ bool SetPrompt(llvm::StringRef prompt) override;
+ bool SetPrompt(const char *prompt) = delete;
+
+ const char *GetContinuationPrompt();
+
+ void SetContinuationPrompt(llvm::StringRef prompt);
+ void SetContinuationPrompt(const char *) = delete;
+
+ bool GetLine(std::string &line, bool &interrupted);
+
+ bool GetLines(StringList &lines, bool &interrupted);
+
+ void SetBaseLineNumber(uint32_t line);
+
+ bool GetInterruptExits() { return m_interrupt_exits; }
+
+ void SetInterruptExits(bool b) { m_interrupt_exits = b; }
+
+ const StringList *GetCurrentLines() const { return m_current_lines_ptr; }
+
+ uint32_t GetCurrentLineIndex() const;
+
+ void PrintAsync(Stream *stream, const char *s, size_t len) override;
+
+private:
#ifndef LLDB_DISABLE_LIBEDIT
- static bool
- IsInputCompleteCallback (Editline *editline,
- StringList &lines,
- void *baton);
-
- static int
- FixIndentationCallback (Editline *editline,
- const StringList &lines,
- int cursor_position,
- void *baton);
-
- static int AutoCompleteCallback (const char *current_line,
- const char *cursor,
- const char *last_char,
- int skip_first_n_matches,
- int max_matches,
- StringList &matches,
- void *baton);
+ static bool IsInputCompleteCallback(Editline *editline, StringList &lines,
+ void *baton);
+
+ static int FixIndentationCallback(Editline *editline, const StringList &lines,
+ int cursor_position, void *baton);
+
+ static int AutoCompleteCallback(const char *current_line, const char *cursor,
+ const char *last_char,
+ int skip_first_n_matches, int max_matches,
+ StringList &matches, void *baton);
#endif
- protected:
+protected:
#ifndef LLDB_DISABLE_LIBEDIT
- std::unique_ptr<Editline> m_editline_ap;
+ std::unique_ptr<Editline> m_editline_ap;
#endif
- IOHandlerDelegate &m_delegate;
- std::string m_prompt;
- std::string m_continuation_prompt;
- StringList *m_current_lines_ptr;
- uint32_t m_base_line_number; // If non-zero, then show line numbers in prompt
- uint32_t m_curr_line_idx;
- bool m_multi_line;
- bool m_color_prompts;
- bool m_interrupt_exits;
- bool m_editing; // Set to true when fetching a line manually (not using libedit)
- };
-
- // The order of base classes is important. Look at the constructor of IOHandlerConfirm
- // to see how.
- class IOHandlerConfirm :
- public IOHandlerDelegate,
- public IOHandlerEditline
- {
- public:
- IOHandlerConfirm (Debugger &debugger,
- const char *prompt,
- bool default_response);
-
- ~IOHandlerConfirm() override;
-
- bool
- GetResponse () const
- {
- return m_user_response;
- }
-
- int
- IOHandlerComplete (IOHandler &io_handler,
- const char *current_line,
- const char *cursor,
- const char *last_char,
- int skip_first_n_matches,
- int max_matches,
- StringList &matches) override;
-
- void
- IOHandlerInputComplete (IOHandler &io_handler, std::string &data) override;
-
- protected:
- const bool m_default_response;
- bool m_user_response;
- };
-
- class IOHandlerCursesGUI :
- public IOHandler
- {
- public:
- IOHandlerCursesGUI (Debugger &debugger);
-
- ~IOHandlerCursesGUI () override;
-
- void
- Run () override;
-
- void
- Cancel () override;
-
- bool
- Interrupt () override;
-
- void
- GotEOF() override;
-
- void
- Activate () override;
-
- void
- Deactivate () override;
-
- protected:
- curses::ApplicationAP m_app_ap;
- };
-
- class IOHandlerCursesValueObjectList :
- public IOHandler
- {
- public:
- IOHandlerCursesValueObjectList (Debugger &debugger, ValueObjectList &valobj_list);
-
- ~IOHandlerCursesValueObjectList() override;
-
- void
- Run () override;
-
- void
- GotEOF() override;
-
- protected:
- ValueObjectList m_valobj_list;
- };
-
- class IOHandlerStack
+ IOHandlerDelegate &m_delegate;
+ std::string m_prompt;
+ std::string m_continuation_prompt;
+ StringList *m_current_lines_ptr;
+ uint32_t m_base_line_number; // If non-zero, then show line numbers in prompt
+ uint32_t m_curr_line_idx;
+ bool m_multi_line;
+ bool m_color_prompts;
+ bool m_interrupt_exits;
+ bool m_editing; // Set to true when fetching a line manually (not using
+ // libedit)
+};
+
+// The order of base classes is important. Look at the constructor of
+// IOHandlerConfirm
+// to see how.
+class IOHandlerConfirm : public IOHandlerDelegate, public IOHandlerEditline {
+public:
+ IOHandlerConfirm(Debugger &debugger, llvm::StringRef prompt,
+ bool default_response);
+
+ ~IOHandlerConfirm() override;
+
+ bool GetResponse() const { return m_user_response; }
+
+ int IOHandlerComplete(IOHandler &io_handler, const char *current_line,
+ const char *cursor, const char *last_char,
+ int skip_first_n_matches, int max_matches,
+ StringList &matches) override;
+
+ void IOHandlerInputComplete(IOHandler &io_handler,
+ std::string &data) override;
+
+protected:
+ const bool m_default_response;
+ bool m_user_response;
+};
+
+class IOHandlerCursesGUI : public IOHandler {
+public:
+ IOHandlerCursesGUI(Debugger &debugger);
+
+ ~IOHandlerCursesGUI() override;
+
+ void Run() override;
+
+ void Cancel() override;
+
+ bool Interrupt() override;
+
+ void GotEOF() override;
+
+ void Activate() override;
+
+ void Deactivate() override;
+
+protected:
+ curses::ApplicationAP m_app_ap;
+};
+
+class IOHandlerCursesValueObjectList : public IOHandler {
+public:
+ IOHandlerCursesValueObjectList(Debugger &debugger,
+ ValueObjectList &valobj_list);
+
+ ~IOHandlerCursesValueObjectList() override;
+
+ void Run() override;
+
+ void GotEOF() override;
+
+protected:
+ ValueObjectList m_valobj_list;
+};
+
+class IOHandlerStack {
+public:
+ IOHandlerStack() : m_stack(), m_mutex(), m_top(nullptr) {}
+
+ ~IOHandlerStack() = default;
+
+ size_t GetSize() const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_stack.size();
+ }
+
+ void Push(const lldb::IOHandlerSP &sp) {
+ if (sp) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ sp->SetPopped(false);
+ m_stack.push_back(sp);
+ // Set m_top the non-locking IsTop() call
+ m_top = sp.get();
+ }
+ }
+
+ bool IsEmpty() const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_stack.empty();
+ }
+
+ lldb::IOHandlerSP Top() {
+ lldb::IOHandlerSP sp;
{
- public:
- IOHandlerStack() : m_stack(), m_mutex(), m_top(nullptr) {}
-
- ~IOHandlerStack() = default;
-
- size_t
- GetSize() const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_stack.size();
- }
-
- void
- Push(const lldb::IOHandlerSP &sp)
- {
- if (sp)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- sp->SetPopped(false);
- m_stack.push_back(sp);
- // Set m_top the non-locking IsTop() call
- m_top = sp.get();
- }
- }
-
- bool
- IsEmpty() const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_stack.empty();
- }
-
- lldb::IOHandlerSP
- Top()
- {
- lldb::IOHandlerSP sp;
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- if (!m_stack.empty())
- sp = m_stack.back();
- }
- return sp;
- }
-
- void
- Pop()
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- if (!m_stack.empty())
- {
- lldb::IOHandlerSP sp(m_stack.back());
- m_stack.pop_back();
- sp->SetPopped(true);
- }
- // Set m_top the non-locking IsTop() call
-
- m_top = (m_stack.empty() ? nullptr : m_stack.back().get());
- }
-
- std::recursive_mutex &
- GetMutex()
- {
- return m_mutex;
- }
-
- bool
- IsTop (const lldb::IOHandlerSP &io_handler_sp) const
- {
- return m_top == io_handler_sp.get();
- }
-
- bool
- CheckTopIOHandlerTypes(IOHandler::Type top_type, IOHandler::Type second_top_type)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- const size_t num_io_handlers = m_stack.size();
- return (num_io_handlers >= 2 && m_stack[num_io_handlers - 1]->GetType() == top_type &&
- m_stack[num_io_handlers - 2]->GetType() == second_top_type);
- }
-
- ConstString
- GetTopIOHandlerControlSequence (char ch)
- {
- return ((m_top != nullptr) ? m_top->GetControlSequence(ch) : ConstString());
- }
-
- const char *
- GetTopIOHandlerCommandPrefix()
- {
- return ((m_top != nullptr) ? m_top->GetCommandPrefix() : nullptr);
- }
-
- const char *
- GetTopIOHandlerHelpPrologue()
- {
- return ((m_top != nullptr) ? m_top->GetHelpPrologue() : nullptr);
- }
-
- void
- PrintAsync (Stream *stream, const char *s, size_t len);
-
- protected:
- typedef std::vector<lldb::IOHandlerSP> collection;
- collection m_stack;
- mutable std::recursive_mutex m_mutex;
- IOHandler *m_top;
-
- private:
- DISALLOW_COPY_AND_ASSIGN (IOHandlerStack);
- };
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ if (!m_stack.empty())
+ sp = m_stack.back();
+ }
+ return sp;
+ }
+
+ void Pop() {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ if (!m_stack.empty()) {
+ lldb::IOHandlerSP sp(m_stack.back());
+ m_stack.pop_back();
+ sp->SetPopped(true);
+ }
+ // Set m_top the non-locking IsTop() call
+
+ m_top = (m_stack.empty() ? nullptr : m_stack.back().get());
+ }
+
+ std::recursive_mutex &GetMutex() { return m_mutex; }
+
+ bool IsTop(const lldb::IOHandlerSP &io_handler_sp) const {
+ return m_top == io_handler_sp.get();
+ }
+
+ bool CheckTopIOHandlerTypes(IOHandler::Type top_type,
+ IOHandler::Type second_top_type) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ const size_t num_io_handlers = m_stack.size();
+ return (num_io_handlers >= 2 &&
+ m_stack[num_io_handlers - 1]->GetType() == top_type &&
+ m_stack[num_io_handlers - 2]->GetType() == second_top_type);
+ }
+
+ ConstString GetTopIOHandlerControlSequence(char ch) {
+ return ((m_top != nullptr) ? m_top->GetControlSequence(ch) : ConstString());
+ }
+
+ const char *GetTopIOHandlerCommandPrefix() {
+ return ((m_top != nullptr) ? m_top->GetCommandPrefix() : nullptr);
+ }
+
+ const char *GetTopIOHandlerHelpPrologue() {
+ return ((m_top != nullptr) ? m_top->GetHelpPrologue() : nullptr);
+ }
+
+ void PrintAsync(Stream *stream, const char *s, size_t len);
+
+protected:
+ typedef std::vector<lldb::IOHandlerSP> collection;
+ collection m_stack;
+ mutable std::recursive_mutex m_mutex;
+ IOHandler *m_top;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(IOHandlerStack);
+};
} // namespace lldb_private
diff --git a/include/lldb/Core/IOStreamMacros.h b/include/lldb/Core/IOStreamMacros.h
index cc4eeb0e050f..2562f179ca5d 100644
--- a/include/lldb/Core/IOStreamMacros.h
+++ b/include/lldb/Core/IOStreamMacros.h
@@ -13,26 +13,30 @@
#include <iomanip>
-#define RAW_HEXBASE std::setfill('0') << std::hex << std::right
-#define HEXBASE '0' << 'x' << RAW_HEXBASE
-#define RAWHEX8(x) RAW_HEXBASE << std::setw(2) << ((uint32_t)(x))
-#define RAWHEX16 RAW_HEXBASE << std::setw(4)
-#define RAWHEX32 RAW_HEXBASE << std::setw(8)
-#define RAWHEX64 RAW_HEXBASE << std::setw(16)
-#define HEX8(x) HEXBASE << std::setw(2) << ((uint32_t)(x))
-#define HEX16 HEXBASE << std::setw(4)
-#define HEX32 HEXBASE << std::setw(8)
-#define HEX64 HEXBASE << std::setw(16)
-#define RAW_HEX(x) RAW_HEXBASE << std::setw(sizeof(x)*2) << (x)
-#define HEX(x) HEXBASE << std::setw(sizeof(x)*2) << (x)
+#define RAW_HEXBASE std::setfill('0') << std::hex << std::right
+#define HEXBASE '0' << 'x' << RAW_HEXBASE
+#define RAWHEX8(x) RAW_HEXBASE << std::setw(2) << ((uint32_t)(x))
+#define RAWHEX16 RAW_HEXBASE << std::setw(4)
+#define RAWHEX32 RAW_HEXBASE << std::setw(8)
+#define RAWHEX64 RAW_HEXBASE << std::setw(16)
+#define HEX8(x) HEXBASE << std::setw(2) << ((uint32_t)(x))
+#define HEX16 HEXBASE << std::setw(4)
+#define HEX32 HEXBASE << std::setw(8)
+#define HEX64 HEXBASE << std::setw(16)
+#define RAW_HEX(x) RAW_HEXBASE << std::setw(sizeof(x) * 2) << (x)
+#define HEX(x) HEXBASE << std::setw(sizeof(x) * 2) << (x)
#define HEX_SIZE(x, sz) HEXBASE << std::setw((sz)) << (x)
#define STRING_WIDTH(w) std::setfill(' ') << std::setw(w)
-#define LEFT_STRING_WIDTH(s, w) std::left << std::setfill(' ') << std::setw(w) << (s) << std::right
-#define DECIMAL std::dec << std::setfill(' ')
+#define LEFT_STRING_WIDTH(s, w) \
+ std::left << std::setfill(' ') << std::setw(w) << (s) << std::right
+#define DECIMAL std::dec << std::setfill(' ')
#define DECIMAL_WIDTH(w) DECIMAL << std::setw(w)
-//#define FLOAT(n, d) std::setfill(' ') << std::setw((n)+(d)+1) << std::setprecision(d) << std::showpoint << std::fixed
-#define INDENT_WITH_SPACES(iword_idx) std::setfill(' ') << std::setw((iword_idx)) << ""
-#define INDENT_WITH_TABS(iword_idx) std::setfill('\t') << std::setw((iword_idx)) << ""
+//#define FLOAT(n, d) std::setfill(' ') << std::setw((n)+(d)+1) <<
+//std::setprecision(d) << std::showpoint << std::fixed
+#define INDENT_WITH_SPACES(iword_idx) \
+ std::setfill(' ') << std::setw((iword_idx)) << ""
+#define INDENT_WITH_TABS(iword_idx) \
+ std::setfill('\t') << std::setw((iword_idx)) << ""
-#endif // #if defined(__cplusplus)
-#endif // liblldb_IOStreamMacros_h_
+#endif // #if defined(__cplusplus)
+#endif // liblldb_IOStreamMacros_h_
diff --git a/include/lldb/Core/Listener.h b/include/lldb/Core/Listener.h
index 1057cf35c6db..b82844eabbb8 100644
--- a/include/lldb/Core/Listener.h
+++ b/include/lldb/Core/Listener.h
@@ -12,6 +12,7 @@
// C Includes
// C++ Includes
+#include <chrono>
#include <list>
#include <map>
#include <mutex>
@@ -20,184 +21,131 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
-#include "lldb/Core/Broadcaster.h"
-#include "lldb/Host/Condition.h"
#include "lldb/Core/Event.h"
+#include "lldb/Utility/Timeout.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class Listener :
- public std::enable_shared_from_this<Listener>
-{
+class Listener : public std::enable_shared_from_this<Listener> {
public:
- typedef bool (*HandleBroadcastCallback) (lldb::EventSP &event_sp, void *baton);
-
- friend class Broadcaster;
- friend class BroadcasterManager;
-
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- //
- // Listeners have to be constructed into shared pointers - at least if you want them to listen to
- // Broadcasters,
+ typedef bool (*HandleBroadcastCallback)(lldb::EventSP &event_sp, void *baton);
+
+ friend class Broadcaster;
+ friend class BroadcasterManager;
+
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ //
+ // Listeners have to be constructed into shared pointers - at least if you
+ // want them to listen to
+ // Broadcasters,
protected:
- Listener (const char *name);
+ Listener(const char *name);
public:
- static lldb::ListenerSP
- MakeListener(const char *name);
-
- ~Listener ();
+ static lldb::ListenerSP MakeListener(const char *name);
- void
- AddEvent (lldb::EventSP &event);
+ ~Listener();
- void
- Clear ();
+ void AddEvent(lldb::EventSP &event);
- const char *
- GetName ()
- {
- return m_name.c_str();
- }
+ void Clear();
- uint32_t
- StartListeningForEventSpec (lldb::BroadcasterManagerSP manager_sp,
- const BroadcastEventSpec &event_spec);
-
- bool
- StopListeningForEventSpec (lldb::BroadcasterManagerSP manager_sp,
+ const char *GetName() { return m_name.c_str(); }
+
+ uint32_t StartListeningForEventSpec(lldb::BroadcasterManagerSP manager_sp,
+ const BroadcastEventSpec &event_spec);
+
+ bool StopListeningForEventSpec(lldb::BroadcasterManagerSP manager_sp,
const BroadcastEventSpec &event_spec);
-
- uint32_t
- StartListeningForEvents (Broadcaster* broadcaster,
- uint32_t event_mask);
-
- uint32_t
- StartListeningForEvents (Broadcaster* broadcaster,
- uint32_t event_mask,
- HandleBroadcastCallback callback,
- void *callback_user_data);
-
- bool
- StopListeningForEvents (Broadcaster* broadcaster,
- uint32_t event_mask);
-
- // Returns true if an event was received, false if we timed out.
- bool
- WaitForEvent (const TimeValue *timeout,
- lldb::EventSP &event_sp);
-
- bool
- WaitForEventForBroadcaster (const TimeValue *timeout,
- Broadcaster *broadcaster,
- lldb::EventSP &event_sp);
-
- bool
- WaitForEventForBroadcasterWithType (const TimeValue *timeout,
- Broadcaster *broadcaster,
- uint32_t event_type_mask,
- lldb::EventSP &event_sp);
-
- Event *
- PeekAtNextEvent ();
-
- Event *
- PeekAtNextEventForBroadcaster (Broadcaster *broadcaster);
-
- Event *
- PeekAtNextEventForBroadcasterWithType (Broadcaster *broadcaster,
- uint32_t event_type_mask);
-
- bool
- GetNextEvent (lldb::EventSP &event_sp);
-
- bool
- GetNextEventForBroadcaster (Broadcaster *broadcaster,
- lldb::EventSP &event_sp);
-
- bool
- GetNextEventForBroadcasterWithType (Broadcaster *broadcaster,
- uint32_t event_type_mask,
- lldb::EventSP &event_sp);
-
- size_t
- HandleBroadcastEvent (lldb::EventSP &event_sp);
+
+ uint32_t StartListeningForEvents(Broadcaster *broadcaster,
+ uint32_t event_mask);
+
+ uint32_t StartListeningForEvents(Broadcaster *broadcaster,
+ uint32_t event_mask,
+ HandleBroadcastCallback callback,
+ void *callback_user_data);
+
+ bool StopListeningForEvents(Broadcaster *broadcaster, uint32_t event_mask);
+
+ Event *PeekAtNextEvent();
+
+ Event *PeekAtNextEventForBroadcaster(Broadcaster *broadcaster);
+
+ Event *PeekAtNextEventForBroadcasterWithType(Broadcaster *broadcaster,
+ uint32_t event_type_mask);
+
+ // Returns true if an event was received, false if we timed out.
+ bool GetEvent(lldb::EventSP &event_sp, const Timeout<std::micro> &timeout);
+
+ bool GetEventForBroadcaster(Broadcaster *broadcaster, lldb::EventSP &event_sp,
+ const Timeout<std::micro> &timeout);
+
+ bool GetEventForBroadcasterWithType(Broadcaster *broadcaster,
+ uint32_t event_type_mask,
+ lldb::EventSP &event_sp,
+ const Timeout<std::micro> &timeout);
+
+ size_t HandleBroadcastEvent(lldb::EventSP &event_sp);
private:
- //------------------------------------------------------------------
- // Classes that inherit from Listener can see and modify these
- //------------------------------------------------------------------
- struct BroadcasterInfo
- {
- BroadcasterInfo(uint32_t mask, HandleBroadcastCallback cb = nullptr, void *ud = nullptr) :
- event_mask (mask),
- callback (cb),
- callback_user_data (ud)
- {
- }
-
- uint32_t event_mask;
- HandleBroadcastCallback callback;
- void *callback_user_data;
- };
-
- typedef std::multimap<Broadcaster::BroadcasterImplWP,
- BroadcasterInfo,
- std::owner_less<Broadcaster::BroadcasterImplWP>> broadcaster_collection;
- typedef std::list<lldb::EventSP> event_collection;
- typedef std::vector<lldb::BroadcasterManagerWP> broadcaster_manager_collection;
-
- bool
- FindNextEventInternal(Mutex::Locker& lock,
- Broadcaster *broadcaster, // nullptr for any broadcaster
- const ConstString *sources, // nullptr for any event
- uint32_t num_sources,
- uint32_t event_type_mask,
- lldb::EventSP &event_sp,
- bool remove);
-
- bool
- GetNextEventInternal(Broadcaster *broadcaster, // nullptr for any broadcaster
- const ConstString *sources, // nullptr for any event
- uint32_t num_sources,
- uint32_t event_type_mask,
- lldb::EventSP &event_sp);
-
- bool
- WaitForEventsInternal(const TimeValue *timeout,
- Broadcaster *broadcaster, // nullptr for any broadcaster
- const ConstString *sources, // nullptr for any event
- uint32_t num_sources,
- uint32_t event_type_mask,
- lldb::EventSP &event_sp);
-
- std::string m_name;
- broadcaster_collection m_broadcasters;
- std::recursive_mutex m_broadcasters_mutex; // Protects m_broadcasters
- event_collection m_events;
- Mutex m_events_mutex; // Protects m_broadcasters and m_events
- Condition m_events_condition;
- broadcaster_manager_collection m_broadcaster_managers;
-
- void
- BroadcasterWillDestruct (Broadcaster *);
-
- void
- BroadcasterManagerWillDestruct (lldb::BroadcasterManagerSP manager_sp);
-
-
-// broadcaster_collection::iterator
-// FindBroadcasterWithMask (Broadcaster *broadcaster,
-// uint32_t event_mask,
-// bool exact);
-
- //------------------------------------------------------------------
- // For Listener only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (Listener);
+ //------------------------------------------------------------------
+ // Classes that inherit from Listener can see and modify these
+ //------------------------------------------------------------------
+ struct BroadcasterInfo {
+ BroadcasterInfo(uint32_t mask, HandleBroadcastCallback cb = nullptr,
+ void *ud = nullptr)
+ : event_mask(mask), callback(cb), callback_user_data(ud) {}
+
+ uint32_t event_mask;
+ HandleBroadcastCallback callback;
+ void *callback_user_data;
+ };
+
+ typedef std::multimap<Broadcaster::BroadcasterImplWP, BroadcasterInfo,
+ std::owner_less<Broadcaster::BroadcasterImplWP>>
+ broadcaster_collection;
+ typedef std::list<lldb::EventSP> event_collection;
+ typedef std::vector<lldb::BroadcasterManagerWP>
+ broadcaster_manager_collection;
+
+ bool
+ FindNextEventInternal(std::unique_lock<std::mutex> &lock,
+ Broadcaster *broadcaster, // nullptr for any broadcaster
+ const ConstString *sources, // nullptr for any event
+ uint32_t num_sources, uint32_t event_type_mask,
+ lldb::EventSP &event_sp, bool remove);
+
+ bool GetEventInternal(const Timeout<std::micro> &timeout,
+ Broadcaster *broadcaster, // nullptr for any broadcaster
+ const ConstString *sources, // nullptr for any event
+ uint32_t num_sources, uint32_t event_type_mask,
+ lldb::EventSP &event_sp);
+
+ std::string m_name;
+ broadcaster_collection m_broadcasters;
+ std::recursive_mutex m_broadcasters_mutex; // Protects m_broadcasters
+ event_collection m_events;
+ std::mutex m_events_mutex; // Protects m_broadcasters and m_events
+ std::condition_variable m_events_condition;
+ broadcaster_manager_collection m_broadcaster_managers;
+
+ void BroadcasterWillDestruct(Broadcaster *);
+
+ void BroadcasterManagerWillDestruct(lldb::BroadcasterManagerSP manager_sp);
+
+ // broadcaster_collection::iterator
+ // FindBroadcasterWithMask (Broadcaster *broadcaster,
+ // uint32_t event_mask,
+ // bool exact);
+
+ //------------------------------------------------------------------
+ // For Listener only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(Listener);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/LoadedModuleInfoList.h b/include/lldb/Core/LoadedModuleInfoList.h
index 6ba5c2813ec4..ecbe3548d687 100644
--- a/include/lldb/Core/LoadedModuleInfoList.h
+++ b/include/lldb/Core/LoadedModuleInfoList.h
@@ -19,134 +19,101 @@
#include "lldb/lldb-private-forward.h"
namespace lldb_private {
-class LoadedModuleInfoList
-{
+class LoadedModuleInfoList {
public:
+ class LoadedModuleInfo {
+ public:
+ enum e_data_point {
+ e_has_name = 0,
+ e_has_base,
+ e_has_dynamic,
+ e_has_link_map,
+ e_num
+ };
- class LoadedModuleInfo
- {
- public:
-
- enum e_data_point
- {
- e_has_name = 0,
- e_has_base ,
- e_has_dynamic ,
- e_has_link_map ,
- e_num
- };
-
- LoadedModuleInfo ()
- {
- for (uint32_t i = 0; i < e_num; ++i)
- m_has[i] = false;
- };
-
- void set_name (const std::string & name)
- {
- m_name = name;
- m_has[e_has_name] = true;
- }
- bool get_name (std::string & out) const
- {
- out = m_name;
- return m_has[e_has_name];
- }
-
- void set_base (const lldb::addr_t base)
- {
- m_base = base;
- m_has[e_has_base] = true;
- }
- bool get_base (lldb::addr_t & out) const
- {
- out = m_base;
- return m_has[e_has_base];
- }
-
- void set_base_is_offset (bool is_offset)
- {
- m_base_is_offset = is_offset;
- }
- bool get_base_is_offset(bool & out) const
- {
- out = m_base_is_offset;
- return m_has[e_has_base];
- }
-
- void set_link_map (const lldb::addr_t addr)
- {
- m_link_map = addr;
- m_has[e_has_link_map] = true;
- }
- bool get_link_map (lldb::addr_t & out) const
- {
- out = m_link_map;
- return m_has[e_has_link_map];
- }
-
- void set_dynamic (const lldb::addr_t addr)
- {
- m_dynamic = addr;
- m_has[e_has_dynamic] = true;
- }
- bool get_dynamic (lldb::addr_t & out) const
- {
- out = m_dynamic;
- return m_has[e_has_dynamic];
- }
-
- bool has_info (e_data_point datum) const
- {
- assert (datum < e_num);
- return m_has[datum];
- }
-
- bool
- operator == (LoadedModuleInfo const &rhs) const
- {
- if (e_num != rhs.e_num)
- return false;
-
- for (size_t i = 0; i < e_num; ++i)
- {
- if (m_has[i] != rhs.m_has[i])
- return false;
- }
-
- return (m_base == rhs.m_base) &&
- (m_link_map == rhs.m_link_map) &&
- (m_dynamic == rhs.m_dynamic) &&
- (m_name == rhs.m_name);
- }
- protected:
-
- bool m_has[e_num];
- std::string m_name;
- lldb::addr_t m_link_map;
- lldb::addr_t m_base;
- bool m_base_is_offset;
- lldb::addr_t m_dynamic;
+ LoadedModuleInfo() {
+ for (uint32_t i = 0; i < e_num; ++i)
+ m_has[i] = false;
};
- LoadedModuleInfoList ()
- : m_list ()
- , m_link_map (LLDB_INVALID_ADDRESS)
- {}
+ void set_name(const std::string &name) {
+ m_name = name;
+ m_has[e_has_name] = true;
+ }
+ bool get_name(std::string &out) const {
+ out = m_name;
+ return m_has[e_has_name];
+ }
+
+ void set_base(const lldb::addr_t base) {
+ m_base = base;
+ m_has[e_has_base] = true;
+ }
+ bool get_base(lldb::addr_t &out) const {
+ out = m_base;
+ return m_has[e_has_base];
+ }
+
+ void set_base_is_offset(bool is_offset) { m_base_is_offset = is_offset; }
+ bool get_base_is_offset(bool &out) const {
+ out = m_base_is_offset;
+ return m_has[e_has_base];
+ }
+
+ void set_link_map(const lldb::addr_t addr) {
+ m_link_map = addr;
+ m_has[e_has_link_map] = true;
+ }
+ bool get_link_map(lldb::addr_t &out) const {
+ out = m_link_map;
+ return m_has[e_has_link_map];
+ }
+
+ void set_dynamic(const lldb::addr_t addr) {
+ m_dynamic = addr;
+ m_has[e_has_dynamic] = true;
+ }
+ bool get_dynamic(lldb::addr_t &out) const {
+ out = m_dynamic;
+ return m_has[e_has_dynamic];
+ }
- void add (const LoadedModuleInfo & mod)
- {
- m_list.push_back (mod);
+ bool has_info(e_data_point datum) const {
+ assert(datum < e_num);
+ return m_has[datum];
}
- void clear ()
- {
- m_list.clear ();
+ bool operator==(LoadedModuleInfo const &rhs) const {
+ if (e_num != rhs.e_num)
+ return false;
+
+ for (size_t i = 0; i < e_num; ++i) {
+ if (m_has[i] != rhs.m_has[i])
+ return false;
+ }
+
+ return (m_base == rhs.m_base) && (m_link_map == rhs.m_link_map) &&
+ (m_dynamic == rhs.m_dynamic) && (m_name == rhs.m_name);
}
- std::vector<LoadedModuleInfo> m_list;
+ protected:
+ bool m_has[e_num];
+ std::string m_name;
lldb::addr_t m_link_map;
+ lldb::addr_t m_base;
+ bool m_base_is_offset;
+ lldb::addr_t m_dynamic;
+ };
+
+ LoadedModuleInfoList() : m_list(), m_link_map(LLDB_INVALID_ADDRESS) {}
+
+ void add(const LoadedModuleInfo &mod) { m_list.push_back(mod); }
+
+ void clear() { m_list.clear(); }
+
+ std::vector<LoadedModuleInfo> m_list;
+ lldb::addr_t m_link_map;
};
} // namespace lldb_private
-#endif // liblldb_LoadedModuleInfoList_h_
+#endif // liblldb_LoadedModuleInfoList_h_
diff --git a/include/lldb/Core/Log.h b/include/lldb/Core/Log.h
index 674fdfdfc0b2..d87c263a427c 100644
--- a/include/lldb/Core/Log.h
+++ b/include/lldb/Core/Log.h
@@ -11,179 +11,153 @@
#define liblldb_Log_h_
// C Includes
+#include <signal.h>
#include <stdarg.h>
#include <stdint.h>
-#include <signal.h>
#include <stdio.h>
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Flags.h"
#include "lldb/Core/Logging.h"
#include "lldb/Core/PluginInterface.h"
+#include "lldb/lldb-private.h"
+
+#include "llvm/Support/FormatVariadic.h"
//----------------------------------------------------------------------
// Logging Options
//----------------------------------------------------------------------
-#define LLDB_LOG_OPTION_THREADSAFE (1u << 0)
-#define LLDB_LOG_OPTION_VERBOSE (1u << 1)
-#define LLDB_LOG_OPTION_DEBUG (1u << 2)
-#define LLDB_LOG_OPTION_PREPEND_SEQUENCE (1u << 3)
-#define LLDB_LOG_OPTION_PREPEND_TIMESTAMP (1u << 4)
+#define LLDB_LOG_OPTION_THREADSAFE (1u << 0)
+#define LLDB_LOG_OPTION_VERBOSE (1u << 1)
+#define LLDB_LOG_OPTION_DEBUG (1u << 2)
+#define LLDB_LOG_OPTION_PREPEND_SEQUENCE (1u << 3)
+#define LLDB_LOG_OPTION_PREPEND_TIMESTAMP (1u << 4)
#define LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD (1u << 5)
-#define LLDB_LOG_OPTION_PREPEND_THREAD_NAME (1U << 6)
-#define LLDB_LOG_OPTION_BACKTRACE (1U << 7)
-#define LLDB_LOG_OPTION_APPEND (1U << 8)
+#define LLDB_LOG_OPTION_PREPEND_THREAD_NAME (1U << 6)
+#define LLDB_LOG_OPTION_BACKTRACE (1U << 7)
+#define LLDB_LOG_OPTION_APPEND (1U << 8)
//----------------------------------------------------------------------
// Logging Functions
//----------------------------------------------------------------------
namespace lldb_private {
-class Log
-{
+class Log final {
public:
-
- //------------------------------------------------------------------
- // Callback definitions for abstracted plug-in log access.
- //------------------------------------------------------------------
- typedef void (*DisableCallback)(const char **categories, Stream *feedback_strm);
- typedef Log *(*EnableCallback)(lldb::StreamSP &log_stream_sp, uint32_t log_options, const char **categories,
+ //------------------------------------------------------------------
+ // Callback definitions for abstracted plug-in log access.
+ //------------------------------------------------------------------
+ typedef void (*DisableCallback)(const char **categories,
+ Stream *feedback_strm);
+ typedef Log *(*EnableCallback)(lldb::StreamSP &log_stream_sp,
+ uint32_t log_options, const char **categories,
Stream *feedback_strm);
typedef void (*ListCategoriesCallback)(Stream *strm);
- struct Callbacks
- {
- DisableCallback disable;
- EnableCallback enable;
- ListCategoriesCallback list_categories;
- };
-
- //------------------------------------------------------------------
- // Static accessors for logging channels
- //------------------------------------------------------------------
- static void
- RegisterLogChannel(const ConstString &channel, const Log::Callbacks &log_callbacks);
-
- static bool
- UnregisterLogChannel(const ConstString &channel);
+ struct Callbacks {
+ DisableCallback disable;
+ EnableCallback enable;
+ ListCategoriesCallback list_categories;
+ };
- static bool
- GetLogChannelCallbacks(const ConstString &channel, Log::Callbacks &log_callbacks);
+ //------------------------------------------------------------------
+ // Static accessors for logging channels
+ //------------------------------------------------------------------
+ static void RegisterLogChannel(const ConstString &channel,
+ const Log::Callbacks &log_callbacks);
- static bool
- EnableLogChannel(lldb::StreamSP &log_stream_sp, uint32_t log_options, const char *channel,
- const char **categories, Stream &error_stream);
+ static bool UnregisterLogChannel(const ConstString &channel);
- static void
- EnableAllLogChannels(lldb::StreamSP &log_stream_sp, uint32_t log_options, const char **categories,
- Stream *feedback_strm);
+ static bool GetLogChannelCallbacks(const ConstString &channel,
+ Log::Callbacks &log_callbacks);
- static void
- DisableAllLogChannels(Stream *feedback_strm);
+ static bool EnableLogChannel(lldb::StreamSP &log_stream_sp,
+ uint32_t log_options, const char *channel,
+ const char **categories, Stream &error_stream);
- static void
- ListAllLogChannels(Stream *strm);
+ static void EnableAllLogChannels(lldb::StreamSP &log_stream_sp,
+ uint32_t log_options,
+ const char **categories,
+ Stream *feedback_strm);
- static void
- Initialize();
+ static void DisableAllLogChannels(Stream *feedback_strm);
- static void
- Terminate();
+ static void ListAllLogChannels(Stream *strm);
- //------------------------------------------------------------------
- // Auto completion
- //------------------------------------------------------------------
- static void
- AutoCompleteChannelName(const char *channel_name, StringList &matches);
+ static void Initialize();
- //------------------------------------------------------------------
- // Member functions
- //------------------------------------------------------------------
- Log();
+ static void Terminate();
- Log(const lldb::StreamSP &stream_sp);
+ //------------------------------------------------------------------
+ // Auto completion
+ //------------------------------------------------------------------
+ static void AutoCompleteChannelName(const char *channel_name,
+ StringList &matches);
- virtual
- ~Log();
+ //------------------------------------------------------------------
+ // Member functions
+ //------------------------------------------------------------------
+ Log();
- virtual void
- PutCString(const char *cstr);
+ Log(const lldb::StreamSP &stream_sp);
- virtual void
- Printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
+ ~Log();
- virtual void
- VAPrintf(const char *format, va_list args);
+ void PutCString(const char *cstr);
+ void PutString(llvm::StringRef str);
- virtual void
- LogIf(uint32_t mask, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
+ template <typename... Args> void Format(const char *fmt, Args &&... args) {
+ PutString(llvm::formatv(fmt, std::forward<Args>(args)...).str());
+ }
- virtual void
- Debug(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
+ // CLEANUP: Add llvm::raw_ostream &Stream() function.
+ void Printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
- virtual void
- DebugVerbose(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
+ void VAPrintf(const char *format, va_list args);
- virtual void
- Error(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
+ void LogIf(uint32_t mask, const char *fmt, ...)
+ __attribute__((format(printf, 3, 4)));
- virtual void
- VAError(const char *format, va_list args);
+ void Debug(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
- virtual void
- FatalError(int err, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
+ void Error(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
- virtual void
- Verbose(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
+ void VAError(const char *format, va_list args);
- virtual void
- Warning(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
+ void Verbose(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
- virtual void
- WarningVerbose(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
+ void Warning(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
- Flags &
- GetOptions();
+ Flags &GetOptions();
- const Flags &
- GetOptions() const;
+ const Flags &GetOptions() const;
- Flags &
- GetMask();
+ Flags &GetMask();
- const Flags &
- GetMask() const;
+ const Flags &GetMask() const;
- bool
- GetVerbose() const;
+ bool GetVerbose() const;
- bool
- GetDebug() const;
+ bool GetDebug() const;
- void
- SetStream(const lldb::StreamSP &stream_sp)
- {
- m_stream_sp = stream_sp;
- }
+ void SetStream(const lldb::StreamSP &stream_sp) { m_stream_sp = stream_sp; }
protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- lldb::StreamSP m_stream_sp;
- Flags m_options;
- Flags m_mask_bits;
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ lldb::StreamSP m_stream_sp;
+ Flags m_options;
+ Flags m_mask_bits;
private:
DISALLOW_COPY_AND_ASSIGN(Log);
};
-class LogChannel : public PluginInterface
-{
+class LogChannel : public PluginInterface {
public:
LogChannel();
@@ -191,18 +165,20 @@ public:
static lldb::LogChannelSP FindPlugin(const char *plugin_name);
- // categories is an array of chars that ends with a NULL element.
+ // categories is an array of chars that ends with a NULL element.
virtual void Disable(const char **categories, Stream *feedback_strm) = 0;
- virtual bool Enable(
- lldb::StreamSP &log_stream_sp, uint32_t log_options,
- Stream *feedback_strm, // Feedback stream for argument errors etc
- const char **categories) = 0; // The categories to enable within this logging stream, if empty, enable default set
+ virtual bool
+ Enable(lldb::StreamSP &log_stream_sp, uint32_t log_options,
+ Stream *feedback_strm, // Feedback stream for argument errors etc
+ const char **categories) = 0; // The categories to enable within this
+ // logging stream, if empty, enable
+ // default set
virtual void ListCategories(Stream *strm) = 0;
protected:
- std::unique_ptr<Log> m_log_ap;
+ std::unique_ptr<Log> m_log_ap;
private:
DISALLOW_COPY_AND_ASSIGN(LogChannel);
diff --git a/include/lldb/Core/Logging.h b/include/lldb/Core/Logging.h
index da8c0d8f5bb6..d93fa05af125 100644
--- a/include/lldb/Core/Logging.h
+++ b/include/lldb/Core/Logging.h
@@ -19,78 +19,65 @@
//----------------------------------------------------------------------
// Log Bits specific to logging in lldb
//----------------------------------------------------------------------
-#define LIBLLDB_LOG_VERBOSE (1u << 0)
-#define LIBLLDB_LOG_PROCESS (1u << 1)
-#define LIBLLDB_LOG_THREAD (1u << 2)
-#define LIBLLDB_LOG_DYNAMIC_LOADER (1u << 3)
-#define LIBLLDB_LOG_EVENTS (1u << 4)
-#define LIBLLDB_LOG_BREAKPOINTS (1u << 5)
-#define LIBLLDB_LOG_WATCHPOINTS (1u << 6)
-#define LIBLLDB_LOG_STEP (1u << 7)
-#define LIBLLDB_LOG_EXPRESSIONS (1u << 8)
-#define LIBLLDB_LOG_TEMPORARY (1u << 9)
-#define LIBLLDB_LOG_STATE (1u << 10)
-#define LIBLLDB_LOG_OBJECT (1u << 11)
-#define LIBLLDB_LOG_COMMUNICATION (1u << 12)
-#define LIBLLDB_LOG_CONNECTION (1u << 13)
-#define LIBLLDB_LOG_HOST (1u << 14)
-#define LIBLLDB_LOG_UNWIND (1u << 15)
-#define LIBLLDB_LOG_API (1u << 16)
-#define LIBLLDB_LOG_SCRIPT (1u << 17)
-#define LIBLLDB_LOG_COMMANDS (1U << 18)
-#define LIBLLDB_LOG_TYPES (1u << 19)
-#define LIBLLDB_LOG_SYMBOLS (1u << 20)
-#define LIBLLDB_LOG_MODULES (1u << 21)
-#define LIBLLDB_LOG_TARGET (1u << 22)
-#define LIBLLDB_LOG_MMAP (1u << 23)
-#define LIBLLDB_LOG_OS (1u << 24)
-#define LIBLLDB_LOG_PLATFORM (1u << 25)
-#define LIBLLDB_LOG_SYSTEM_RUNTIME (1u << 26)
-#define LIBLLDB_LOG_JIT_LOADER (1u << 27)
-#define LIBLLDB_LOG_LANGUAGE (1u << 28)
-#define LIBLLDB_LOG_DATAFORMATTERS (1u << 29)
-#define LIBLLDB_LOG_DEMANGLE (1u << 30)
-#define LIBLLDB_LOG_ALL (UINT32_MAX)
-#define LIBLLDB_LOG_DEFAULT (LIBLLDB_LOG_PROCESS |\
- LIBLLDB_LOG_THREAD |\
- LIBLLDB_LOG_DYNAMIC_LOADER |\
- LIBLLDB_LOG_BREAKPOINTS |\
- LIBLLDB_LOG_WATCHPOINTS |\
- LIBLLDB_LOG_STEP |\
- LIBLLDB_LOG_STATE |\
- LIBLLDB_LOG_SYMBOLS |\
- LIBLLDB_LOG_TARGET |\
- LIBLLDB_LOG_COMMANDS)
+#define LIBLLDB_LOG_VERBOSE (1u << 0)
+#define LIBLLDB_LOG_PROCESS (1u << 1)
+#define LIBLLDB_LOG_THREAD (1u << 2)
+#define LIBLLDB_LOG_DYNAMIC_LOADER (1u << 3)
+#define LIBLLDB_LOG_EVENTS (1u << 4)
+#define LIBLLDB_LOG_BREAKPOINTS (1u << 5)
+#define LIBLLDB_LOG_WATCHPOINTS (1u << 6)
+#define LIBLLDB_LOG_STEP (1u << 7)
+#define LIBLLDB_LOG_EXPRESSIONS (1u << 8)
+#define LIBLLDB_LOG_TEMPORARY (1u << 9)
+#define LIBLLDB_LOG_STATE (1u << 10)
+#define LIBLLDB_LOG_OBJECT (1u << 11)
+#define LIBLLDB_LOG_COMMUNICATION (1u << 12)
+#define LIBLLDB_LOG_CONNECTION (1u << 13)
+#define LIBLLDB_LOG_HOST (1u << 14)
+#define LIBLLDB_LOG_UNWIND (1u << 15)
+#define LIBLLDB_LOG_API (1u << 16)
+#define LIBLLDB_LOG_SCRIPT (1u << 17)
+#define LIBLLDB_LOG_COMMANDS (1U << 18)
+#define LIBLLDB_LOG_TYPES (1u << 19)
+#define LIBLLDB_LOG_SYMBOLS (1u << 20)
+#define LIBLLDB_LOG_MODULES (1u << 21)
+#define LIBLLDB_LOG_TARGET (1u << 22)
+#define LIBLLDB_LOG_MMAP (1u << 23)
+#define LIBLLDB_LOG_OS (1u << 24)
+#define LIBLLDB_LOG_PLATFORM (1u << 25)
+#define LIBLLDB_LOG_SYSTEM_RUNTIME (1u << 26)
+#define LIBLLDB_LOG_JIT_LOADER (1u << 27)
+#define LIBLLDB_LOG_LANGUAGE (1u << 28)
+#define LIBLLDB_LOG_DATAFORMATTERS (1u << 29)
+#define LIBLLDB_LOG_DEMANGLE (1u << 30)
+#define LIBLLDB_LOG_ALL (UINT32_MAX)
+#define LIBLLDB_LOG_DEFAULT \
+ (LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD | LIBLLDB_LOG_DYNAMIC_LOADER | \
+ LIBLLDB_LOG_BREAKPOINTS | LIBLLDB_LOG_WATCHPOINTS | LIBLLDB_LOG_STEP | \
+ LIBLLDB_LOG_STATE | LIBLLDB_LOG_SYMBOLS | LIBLLDB_LOG_TARGET | \
+ LIBLLDB_LOG_COMMANDS)
namespace lldb_private {
-void
-LogIfAllCategoriesSet (uint32_t mask, const char *format, ...);
+void LogIfAllCategoriesSet(uint32_t mask, const char *format, ...);
-void
-LogIfAnyCategoriesSet (uint32_t mask, const char *format, ...);
+void LogIfAnyCategoriesSet(uint32_t mask, const char *format, ...);
-Log *
-GetLogIfAllCategoriesSet (uint32_t mask);
+Log *GetLogIfAllCategoriesSet(uint32_t mask);
-Log *
-GetLogIfAnyCategoriesSet (uint32_t mask);
+Log *GetLogIfAnyCategoriesSet(uint32_t mask);
-uint32_t
-GetLogMask ();
+uint32_t GetLogMask();
-bool
-IsLogVerbose ();
+bool IsLogVerbose();
-void
-DisableLog (const char **categories, Stream *feedback_strm);
+void DisableLog(const char **categories, Stream *feedback_strm);
-Log *
-EnableLog (lldb::StreamSP &log_stream_sp, uint32_t log_options, const char **categories, Stream *feedback_strm);
+Log *EnableLog(lldb::StreamSP &log_stream_sp, uint32_t log_options,
+ const char **categories, Stream *feedback_strm);
-void
-ListLogCategories (Stream *strm);
+void ListLogCategories(Stream *strm);
} // namespace lldb_private
-#endif // liblldb_Core_Logging_h_
+#endif // liblldb_Core_Logging_h_
diff --git a/include/lldb/Core/Mangled.h b/include/lldb/Core/Mangled.h
index 6d8d8c4a0da7..4170b708013e 100644
--- a/include/lldb/Core/Mangled.h
+++ b/include/lldb/Core/Mangled.h
@@ -11,9 +11,8 @@
#define liblldb_Mangled_h_
#if defined(__cplusplus)
-
-#include "lldb/lldb-private.h"
#include "lldb/Core/ConstString.h"
+#include "lldb/lldb-private.h"
#include <vector>
namespace lldb_private {
@@ -30,313 +29,280 @@ namespace lldb_private {
/// string pools are used for the mangled, demangled, and token string
/// values to allow for faster comparisons and for efficient memory use.
//----------------------------------------------------------------------
-class Mangled
-{
+class Mangled {
public:
-
- enum NamePreference
- {
- ePreferMangled,
- ePreferDemangled,
- ePreferDemangledWithoutArguments
- };
-
- enum ManglingScheme
- {
- eManglingSchemeNone = 0,
- eManglingSchemeMSVC,
- eManglingSchemeItanium
- };
-
- //----------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Initialize with both mangled and demangled names empty.
- //----------------------------------------------------------------------
- Mangled ();
-
- //----------------------------------------------------------------------
- /// Construct with name.
- ///
- /// Constructor with an optional string and a boolean indicating if it is
- /// the mangled version.
- ///
- /// @param[in] name
- /// The already const name to copy into this object.
- ///
- /// @param[in] is_mangled
- /// If \b true then \a name is a mangled name, if \b false then
- /// \a name is demangled.
- //----------------------------------------------------------------------
- explicit
- Mangled (const ConstString &name, bool is_mangled);
-
- //----------------------------------------------------------------------
- /// Construct with name.
- ///
- /// Constructor with an optional string and auto-detect if \a name is
- /// mangled or not.
- ///
- /// @param[in] name
- /// The already const name to copy into this object.
- //----------------------------------------------------------------------
- explicit
- Mangled (const ConstString &name);
-
- //----------------------------------------------------------------------
- /// Destructor
- ///
- /// Releases its ref counts on the mangled and demangled strings that
- /// live in the global string pool.
- //----------------------------------------------------------------------
- ~Mangled ();
-
- //----------------------------------------------------------------------
- /// Convert to pointer operator.
- ///
- /// This allows code to check a Mangled object to see if it contains
- /// a valid mangled name using code such as:
- ///
- /// @code
- /// Mangled mangled(...);
- /// if (mangled)
- /// { ...
- /// @endcode
- ///
- /// @return
- /// A pointer to this object if either the mangled or unmangled
- /// name is set, NULL otherwise.
- //----------------------------------------------------------------------
- operator
- void*() const;
-
- //----------------------------------------------------------------------
- /// Logical NOT operator.
- ///
- /// This allows code to check a Mangled object to see if it contains
- /// an empty mangled name using code such as:
- ///
- /// @code
- /// Mangled mangled(...);
- /// if (!mangled)
- /// { ...
- /// @endcode
- ///
- /// @return
- /// Returns \b true if the object has an empty mangled and
- /// unmangled name, \b false otherwise.
- //----------------------------------------------------------------------
- bool
- operator!() const;
-
- //----------------------------------------------------------------------
- /// Clear the mangled and demangled values.
- //----------------------------------------------------------------------
- void
- Clear ();
-
- //----------------------------------------------------------------------
- /// Compare the mangled string values
- ///
- /// Compares the Mangled::GetName() string in \a lhs and \a rhs.
- ///
- /// @param[in] lhs
- /// A const reference to the Left Hand Side object to compare.
- ///
- /// @param[in] rhs
- /// A const reference to the Right Hand Side object to compare.
- ///
- /// @return
- /// @li -1 if \a lhs is less than \a rhs
- /// @li 0 if \a lhs is equal to \a rhs
- /// @li 1 if \a lhs is greater than \a rhs
- //----------------------------------------------------------------------
- static int
- Compare (const Mangled& lhs, const Mangled& rhs);
-
- //----------------------------------------------------------------------
- /// Dump a description of this object to a Stream \a s.
- ///
- /// Dump a Mangled object to stream \a s. We don't force our
- /// demangled name to be computed currently (we don't use the accessor).
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- //----------------------------------------------------------------------
- void
- Dump (Stream *s) const;
-
- //----------------------------------------------------------------------
- /// Dump a debug description of this object to a Stream \a s.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- //----------------------------------------------------------------------
- void
- DumpDebug (Stream *s) const;
-
- //----------------------------------------------------------------------
- /// Demangled name get accessor.
- ///
- /// @return
- /// A const reference to the demangled name string object.
- //----------------------------------------------------------------------
- const ConstString&
- GetDemangledName (lldb::LanguageType language) const;
-
- //----------------------------------------------------------------------
- /// Display demangled name get accessor.
- ///
- /// @return
- /// A const reference to the display demangled name string object.
- //----------------------------------------------------------------------
- ConstString
- GetDisplayDemangledName (lldb::LanguageType language) const;
-
- void
- SetDemangledName (const ConstString &name)
- {
- m_demangled = name;
- }
-
- void
- SetMangledName (const ConstString &name)
- {
- m_mangled = name;
- }
-
- //----------------------------------------------------------------------
- /// Mangled name get accessor.
- ///
- /// @return
- /// A reference to the mangled name string object.
- //----------------------------------------------------------------------
- ConstString&
- GetMangledName ()
- {
- return m_mangled;
- }
-
- //----------------------------------------------------------------------
- /// Mangled name get accessor.
- ///
- /// @return
- /// A const reference to the mangled name string object.
- //----------------------------------------------------------------------
- const ConstString&
- GetMangledName () const
- {
- return m_mangled;
- }
-
- //----------------------------------------------------------------------
- /// Best name get accessor.
- ///
- /// @param[in] preference
- /// Which name would you prefer to get?
- ///
- /// @return
- /// A const reference to the preferred name string object if this
- /// object has a valid name of that kind, else a const reference to the
- /// other name is returned.
- //----------------------------------------------------------------------
- ConstString
- GetName (lldb::LanguageType language, NamePreference preference = ePreferDemangled) const;
-
- //----------------------------------------------------------------------
- /// Check if "name" matches either the mangled or demangled name.
- ///
- /// @param[in] name
- /// A name to match against both strings.
- ///
- /// @return
- /// \b True if \a name matches either name, \b false otherwise.
- //----------------------------------------------------------------------
- bool
- NameMatches (const ConstString &name, lldb::LanguageType language) const
- {
- if (m_mangled == name)
- return true;
- return GetDemangledName (language) == name;
- }
-
- bool
- NameMatches (const RegularExpression& regex, lldb::LanguageType language) const;
-
- //----------------------------------------------------------------------
- /// Get the memory cost of this object.
- ///
- /// Return the size in bytes that this object takes in memory. This
- /// returns the size in bytes of this object, not any shared string
- /// values it may refer to.
- ///
- /// @return
- /// The number of bytes that this object occupies in memory.
- ///
- /// @see ConstString::StaticMemorySize ()
- //----------------------------------------------------------------------
- size_t
- MemorySize () const;
-
- //----------------------------------------------------------------------
- /// Set the string value in this object.
- ///
- /// If \a is_mangled is \b true, then the mangled named is set to \a
- /// name, else the demangled name is set to \a name.
- ///
- /// @param[in] name
- /// The already const version of the name for this object.
- ///
- /// @param[in] is_mangled
- /// If \b true then \a name is a mangled name, if \b false then
- /// \a name is demangled.
- //----------------------------------------------------------------------
- void
- SetValue (const ConstString &name, bool is_mangled);
-
- //----------------------------------------------------------------------
- /// Set the string value in this object.
- ///
- /// This version auto detects if the string is mangled by inspecting the
- /// string value and looking for common mangling prefixes.
- ///
- /// @param[in] name
- /// The already const version of the name for this object.
- //----------------------------------------------------------------------
- void
- SetValue (const ConstString &name);
-
- //----------------------------------------------------------------------
- /// Try to guess the language from the mangling.
- ///
- /// For a mangled name to have a language it must have both a mangled
- /// and a demangled name and it can be guessed from the mangling what
- /// the language is. Note: this will return C++ for any language that
- /// uses Itanium ABI mangling.
- ///
- /// Standard C function names will return eLanguageTypeUnknown because
- /// they aren't mangled and it isn't clear what language the name
- /// represents (there will be no mangled name).
- ///
- /// @return
- /// The language for the mangled/demangled name, eLanguageTypeUnknown
- /// if there is no mangled or demangled counterpart.
- //----------------------------------------------------------------------
- lldb::LanguageType
- GuessLanguage () const;
+ enum NamePreference {
+ ePreferMangled,
+ ePreferDemangled,
+ ePreferDemangledWithoutArguments
+ };
+
+ enum ManglingScheme {
+ eManglingSchemeNone = 0,
+ eManglingSchemeMSVC,
+ eManglingSchemeItanium
+ };
+
+ //----------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// Initialize with both mangled and demangled names empty.
+ //----------------------------------------------------------------------
+ Mangled();
+
+ //----------------------------------------------------------------------
+ /// Construct with name.
+ ///
+ /// Constructor with an optional string and a boolean indicating if it is
+ /// the mangled version.
+ ///
+ /// @param[in] name
+ /// The already const name to copy into this object.
+ ///
+ /// @param[in] is_mangled
+ /// If \b true then \a name is a mangled name, if \b false then
+ /// \a name is demangled.
+ //----------------------------------------------------------------------
+ Mangled(const ConstString &name, bool is_mangled);
+ Mangled(llvm::StringRef name, bool is_mangled);
+
+ //----------------------------------------------------------------------
+ /// Construct with name.
+ ///
+ /// Constructor with an optional string and auto-detect if \a name is
+ /// mangled or not.
+ ///
+ /// @param[in] name
+ /// The already const name to copy into this object.
+ //----------------------------------------------------------------------
+ explicit Mangled(const ConstString &name);
+
+ explicit Mangled(llvm::StringRef name);
+
+ //----------------------------------------------------------------------
+ /// Destructor
+ ///
+ /// Releases its ref counts on the mangled and demangled strings that
+ /// live in the global string pool.
+ //----------------------------------------------------------------------
+ ~Mangled();
+
+ //----------------------------------------------------------------------
+ /// Convert to pointer operator.
+ ///
+ /// This allows code to check a Mangled object to see if it contains
+ /// a valid mangled name using code such as:
+ ///
+ /// @code
+ /// Mangled mangled(...);
+ /// if (mangled)
+ /// { ...
+ /// @endcode
+ ///
+ /// @return
+ /// A pointer to this object if either the mangled or unmangled
+ /// name is set, NULL otherwise.
+ //----------------------------------------------------------------------
+ operator void *() const;
+
+ //----------------------------------------------------------------------
+ /// Logical NOT operator.
+ ///
+ /// This allows code to check a Mangled object to see if it contains
+ /// an empty mangled name using code such as:
+ ///
+ /// @code
+ /// Mangled mangled(...);
+ /// if (!mangled)
+ /// { ...
+ /// @endcode
+ ///
+ /// @return
+ /// Returns \b true if the object has an empty mangled and
+ /// unmangled name, \b false otherwise.
+ //----------------------------------------------------------------------
+ bool operator!() const;
+
+ //----------------------------------------------------------------------
+ /// Clear the mangled and demangled values.
+ //----------------------------------------------------------------------
+ void Clear();
+
+ //----------------------------------------------------------------------
+ /// Compare the mangled string values
+ ///
+ /// Compares the Mangled::GetName() string in \a lhs and \a rhs.
+ ///
+ /// @param[in] lhs
+ /// A const reference to the Left Hand Side object to compare.
+ ///
+ /// @param[in] rhs
+ /// A const reference to the Right Hand Side object to compare.
+ ///
+ /// @return
+ /// @li -1 if \a lhs is less than \a rhs
+ /// @li 0 if \a lhs is equal to \a rhs
+ /// @li 1 if \a lhs is greater than \a rhs
+ //----------------------------------------------------------------------
+ static int Compare(const Mangled &lhs, const Mangled &rhs);
+
+ //----------------------------------------------------------------------
+ /// Dump a description of this object to a Stream \a s.
+ ///
+ /// Dump a Mangled object to stream \a s. We don't force our
+ /// demangled name to be computed currently (we don't use the accessor).
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ //----------------------------------------------------------------------
+ void Dump(Stream *s) const;
+
+ //----------------------------------------------------------------------
+ /// Dump a debug description of this object to a Stream \a s.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ //----------------------------------------------------------------------
+ void DumpDebug(Stream *s) const;
+
+ //----------------------------------------------------------------------
+ /// Demangled name get accessor.
+ ///
+ /// @return
+ /// A const reference to the demangled name string object.
+ //----------------------------------------------------------------------
+ const ConstString &GetDemangledName(lldb::LanguageType language) const;
+
+ //----------------------------------------------------------------------
+ /// Display demangled name get accessor.
+ ///
+ /// @return
+ /// A const reference to the display demangled name string object.
+ //----------------------------------------------------------------------
+ ConstString GetDisplayDemangledName(lldb::LanguageType language) const;
+
+ void SetDemangledName(const ConstString &name) { m_demangled = name; }
+
+ void SetMangledName(const ConstString &name) { m_mangled = name; }
+
+ //----------------------------------------------------------------------
+ /// Mangled name get accessor.
+ ///
+ /// @return
+ /// A reference to the mangled name string object.
+ //----------------------------------------------------------------------
+ ConstString &GetMangledName() { return m_mangled; }
+
+ //----------------------------------------------------------------------
+ /// Mangled name get accessor.
+ ///
+ /// @return
+ /// A const reference to the mangled name string object.
+ //----------------------------------------------------------------------
+ const ConstString &GetMangledName() const { return m_mangled; }
+
+ //----------------------------------------------------------------------
+ /// Best name get accessor.
+ ///
+ /// @param[in] preference
+ /// Which name would you prefer to get?
+ ///
+ /// @return
+ /// A const reference to the preferred name string object if this
+ /// object has a valid name of that kind, else a const reference to the
+ /// other name is returned.
+ //----------------------------------------------------------------------
+ ConstString GetName(lldb::LanguageType language,
+ NamePreference preference = ePreferDemangled) const;
+
+ //----------------------------------------------------------------------
+ /// Check if "name" matches either the mangled or demangled name.
+ ///
+ /// @param[in] name
+ /// A name to match against both strings.
+ ///
+ /// @return
+ /// \b True if \a name matches either name, \b false otherwise.
+ //----------------------------------------------------------------------
+ bool NameMatches(const ConstString &name, lldb::LanguageType language) const {
+ if (m_mangled == name)
+ return true;
+ return GetDemangledName(language) == name;
+ }
+
+ bool NameMatches(const RegularExpression &regex,
+ lldb::LanguageType language) const;
+
+ //----------------------------------------------------------------------
+ /// Get the memory cost of this object.
+ ///
+ /// Return the size in bytes that this object takes in memory. This
+ /// returns the size in bytes of this object, not any shared string
+ /// values it may refer to.
+ ///
+ /// @return
+ /// The number of bytes that this object occupies in memory.
+ ///
+ /// @see ConstString::StaticMemorySize ()
+ //----------------------------------------------------------------------
+ size_t MemorySize() const;
+
+ //----------------------------------------------------------------------
+ /// Set the string value in this object.
+ ///
+ /// If \a is_mangled is \b true, then the mangled named is set to \a
+ /// name, else the demangled name is set to \a name.
+ ///
+ /// @param[in] name
+ /// The already const version of the name for this object.
+ ///
+ /// @param[in] is_mangled
+ /// If \b true then \a name is a mangled name, if \b false then
+ /// \a name is demangled.
+ //----------------------------------------------------------------------
+ void SetValue(const ConstString &name, bool is_mangled);
+
+ //----------------------------------------------------------------------
+ /// Set the string value in this object.
+ ///
+ /// This version auto detects if the string is mangled by inspecting the
+ /// string value and looking for common mangling prefixes.
+ ///
+ /// @param[in] name
+ /// The already const version of the name for this object.
+ //----------------------------------------------------------------------
+ void SetValue(const ConstString &name);
+
+ //----------------------------------------------------------------------
+ /// Try to guess the language from the mangling.
+ ///
+ /// For a mangled name to have a language it must have both a mangled
+ /// and a demangled name and it can be guessed from the mangling what
+ /// the language is. Note: this will return C++ for any language that
+ /// uses Itanium ABI mangling.
+ ///
+ /// Standard C function names will return eLanguageTypeUnknown because
+ /// they aren't mangled and it isn't clear what language the name
+ /// represents (there will be no mangled name).
+ ///
+ /// @return
+ /// The language for the mangled/demangled name, eLanguageTypeUnknown
+ /// if there is no mangled or demangled counterpart.
+ //----------------------------------------------------------------------
+ lldb::LanguageType GuessLanguage() const;
private:
- //----------------------------------------------------------------------
- /// Mangled member variables.
- //----------------------------------------------------------------------
- ConstString m_mangled; ///< The mangled version of the name
- mutable ConstString m_demangled; ///< Mutable so we can get it on demand with a const version of this object
+ //----------------------------------------------------------------------
+ /// Mangled member variables.
+ //----------------------------------------------------------------------
+ ConstString m_mangled; ///< The mangled version of the name
+ mutable ConstString m_demangled; ///< Mutable so we can get it on demand with
+ ///a const version of this object
};
-
-Stream& operator << (Stream& s, const Mangled& obj);
+Stream &operator<<(Stream &s, const Mangled &obj);
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif // liblldb_Mangled_h_
+#endif // #if defined(__cplusplus)
+#endif // liblldb_Mangled_h_
diff --git a/include/lldb/Core/MappedHash.h b/include/lldb/Core/MappedHash.h
index b7cf3b02e01e..44fe63216165 100644
--- a/include/lldb/Core/MappedHash.h
+++ b/include/lldb/Core/MappedHash.h
@@ -25,535 +25,460 @@
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Stream.h"
-class MappedHash
-{
+class MappedHash {
public:
- enum HashFunctionType
- {
- eHashFunctionDJB = 0u // Daniel J Bernstein hash function that is also used by the ELF GNU_HASH sections
- };
+ enum HashFunctionType {
+ eHashFunctionDJB = 0u // Daniel J Bernstein hash function that is also used
+ // by the ELF GNU_HASH sections
+ };
+
+ static uint32_t HashStringUsingDJB(const char *s) {
+ uint32_t h = 5381;
+
+ for (unsigned char c = *s; c; c = *++s)
+ h = ((h << 5) + h) + c;
+
+ return h;
+ }
- static uint32_t
- HashStringUsingDJB (const char *s)
- {
- uint32_t h = 5381;
-
- for (unsigned char c = *s; c; c = *++s)
- h = ((h << 5) + h) + c;
-
- return h;
+ static uint32_t HashString(uint32_t hash_function, const char *s) {
+ if (!s)
+ return 0;
+
+ switch (hash_function) {
+ case MappedHash::eHashFunctionDJB:
+ return HashStringUsingDJB(s);
+
+ default:
+ break;
}
-
- static uint32_t
- HashString (uint32_t hash_function, const char *s)
- {
- if (!s)
- return 0;
-
- switch (hash_function)
- {
- case MappedHash::eHashFunctionDJB:
- return HashStringUsingDJB (s);
-
- default:
- break;
- }
- assert (!"Invalid hash function index");
- return 0;
+ assert(!"Invalid hash function index");
+ return 0;
+ }
+
+ static const uint32_t HASH_MAGIC = 0x48415348u;
+ static const uint32_t HASH_CIGAM = 0x48534148u;
+
+ template <typename T> struct Header {
+ typedef T HeaderData;
+
+ uint32_t
+ magic; // HASH_MAGIC or HASH_CIGAM magic value to allow endian detection
+ uint16_t version; // Version number
+ uint16_t hash_function; // The hash function enumeration that was used
+ uint32_t bucket_count; // The number of buckets in this hash table
+ uint32_t hashes_count; // The total number of unique hash values and hash
+ // data offsets in this table
+ uint32_t header_data_len; // The size in bytes of the "header_data" template
+ // member below
+ HeaderData header_data; //
+
+ Header()
+ : magic(HASH_MAGIC), version(1), hash_function(eHashFunctionDJB),
+ bucket_count(0), hashes_count(0), header_data_len(sizeof(T)),
+ header_data() {}
+
+ virtual ~Header() = default;
+
+ size_t GetByteSize() const {
+ return sizeof(magic) + sizeof(version) + sizeof(hash_function) +
+ sizeof(bucket_count) + sizeof(hashes_count) +
+ sizeof(header_data_len) + header_data_len;
}
- static const uint32_t HASH_MAGIC = 0x48415348u;
- static const uint32_t HASH_CIGAM = 0x48534148u;
-
- template <typename T>
- struct Header
- {
- typedef T HeaderData;
-
- uint32_t magic; // HASH_MAGIC or HASH_CIGAM magic value to allow endian detection
- uint16_t version; // Version number
- uint16_t hash_function; // The hash function enumeration that was used
- uint32_t bucket_count; // The number of buckets in this hash table
- uint32_t hashes_count; // The total number of unique hash values and hash data offsets in this table
- uint32_t header_data_len; // The size in bytes of the "header_data" template member below
- HeaderData header_data; //
-
- Header () :
- magic (HASH_MAGIC),
- version (1),
- hash_function (eHashFunctionDJB),
- bucket_count (0),
- hashes_count (0),
- header_data_len (sizeof(T)),
- header_data ()
- {
- }
-
- virtual
- ~Header() = default;
-
- size_t
- GetByteSize() const
- {
- return sizeof(magic) +
- sizeof(version) +
- sizeof(hash_function) +
- sizeof(bucket_count) +
- sizeof(hashes_count) +
- sizeof(header_data_len) +
- header_data_len;
- }
-
- virtual size_t
- GetByteSize (const HeaderData &header_data) = 0;
-
- void
- SetHeaderDataByteSize (uint32_t header_data_byte_size)
- {
- header_data_len = header_data_byte_size;
- }
+ virtual size_t GetByteSize(const HeaderData &header_data) = 0;
- void
- Dump (lldb_private::Stream &s)
- {
- s.Printf ("header.magic = 0x%8.8x\n", magic);
- s.Printf ("header.version = 0x%4.4x\n", version);
- s.Printf ("header.hash_function = 0x%4.4x\n", hash_function);
- s.Printf ("header.bucket_count = 0x%8.8x %u\n", bucket_count, bucket_count);
- s.Printf ("header.hashes_count = 0x%8.8x %u\n", hashes_count, hashes_count);
- s.Printf ("header.header_data_len = 0x%8.8x %u\n", header_data_len, header_data_len);
- }
-
- virtual lldb::offset_t
- Read (lldb_private::DataExtractor &data, lldb::offset_t offset)
- {
- if (data.ValidOffsetForDataOfSize (offset,
- sizeof (magic) +
- sizeof (version) +
- sizeof (hash_function) +
- sizeof (bucket_count) +
- sizeof (hashes_count) +
- sizeof (header_data_len)))
- {
- magic = data.GetU32 (&offset);
- if (magic != HASH_MAGIC)
- {
- if (magic == HASH_CIGAM)
- {
- switch (data.GetByteOrder())
- {
- case lldb::eByteOrderBig:
- data.SetByteOrder(lldb::eByteOrderLittle);
- break;
- case lldb::eByteOrderLittle:
- data.SetByteOrder(lldb::eByteOrderBig);
- break;
- default:
- return LLDB_INVALID_OFFSET;
- }
- }
- else
- {
- // Magic bytes didn't match
- version = 0;
- return LLDB_INVALID_OFFSET;
- }
- }
-
- version = data.GetU16 (&offset);
- if (version != 1)
- {
- // Unsupported version
- return LLDB_INVALID_OFFSET;
- }
- hash_function = data.GetU16 (&offset);
- if (hash_function == 4)
- hash_function = 0; // Deal with pre-release version of this table...
- bucket_count = data.GetU32 (&offset);
- hashes_count = data.GetU32 (&offset);
- header_data_len = data.GetU32 (&offset);
- return offset;
+ void SetHeaderDataByteSize(uint32_t header_data_byte_size) {
+ header_data_len = header_data_byte_size;
+ }
+
+ void Dump(lldb_private::Stream &s) {
+ s.Printf("header.magic = 0x%8.8x\n", magic);
+ s.Printf("header.version = 0x%4.4x\n", version);
+ s.Printf("header.hash_function = 0x%4.4x\n", hash_function);
+ s.Printf("header.bucket_count = 0x%8.8x %u\n", bucket_count,
+ bucket_count);
+ s.Printf("header.hashes_count = 0x%8.8x %u\n", hashes_count,
+ hashes_count);
+ s.Printf("header.header_data_len = 0x%8.8x %u\n", header_data_len,
+ header_data_len);
+ }
+
+ virtual lldb::offset_t Read(lldb_private::DataExtractor &data,
+ lldb::offset_t offset) {
+ if (data.ValidOffsetForDataOfSize(
+ offset, sizeof(magic) + sizeof(version) + sizeof(hash_function) +
+ sizeof(bucket_count) + sizeof(hashes_count) +
+ sizeof(header_data_len))) {
+ magic = data.GetU32(&offset);
+ if (magic != HASH_MAGIC) {
+ if (magic == HASH_CIGAM) {
+ switch (data.GetByteOrder()) {
+ case lldb::eByteOrderBig:
+ data.SetByteOrder(lldb::eByteOrderLittle);
+ break;
+ case lldb::eByteOrderLittle:
+ data.SetByteOrder(lldb::eByteOrderBig);
+ break;
+ default:
+ return LLDB_INVALID_OFFSET;
}
+ } else {
+ // Magic bytes didn't match
+ version = 0;
return LLDB_INVALID_OFFSET;
+ }
}
-//
-// // Returns a buffer that contains a serialized version of this table
-// // that must be freed with free().
-// virtual void *
-// Write (int fd);
- };
-
- template <typename __KeyType, class __HeaderDataType, class __ValueType>
- class ExportTable
- {
- public:
- typedef __HeaderDataType HeaderDataType;
- typedef Header<HeaderDataType> HeaderType;
- typedef __KeyType KeyType;
- typedef __ValueType ValueType;
-
- struct Entry
- {
- uint32_t hash;
- KeyType key;
- ValueType value;
- };
-
- typedef std::vector<ValueType> ValueArrayType;
-
- typedef std::map<KeyType, ValueArrayType> HashData;
- // Map a name hash to one or more name infos
- typedef std::map<uint32_t, HashData> HashToHashData;
-
- virtual KeyType
- GetKeyForStringType (const char *cstr) const = 0;
-
- virtual size_t
- GetByteSize (const HashData &key_to_key_values) = 0;
-
- virtual bool
- WriteHashData (const HashData &hash_data,
- lldb_private::Stream &ostrm) = 0;
-//
- void
- AddEntry (const char *cstr, const ValueType &value)
- {
- Entry entry;
- entry.hash = MappedHash::HashString (eHashFunctionDJB, cstr);
- entry.key = GetKeyForStringType (cstr);
- entry.value = value;
- m_entries.push_back (entry);
+
+ version = data.GetU16(&offset);
+ if (version != 1) {
+ // Unsupported version
+ return LLDB_INVALID_OFFSET;
}
+ hash_function = data.GetU16(&offset);
+ if (hash_function == 4)
+ hash_function = 0; // Deal with pre-release version of this table...
+ bucket_count = data.GetU32(&offset);
+ hashes_count = data.GetU32(&offset);
+ header_data_len = data.GetU32(&offset);
+ return offset;
+ }
+ return LLDB_INVALID_OFFSET;
+ }
+ //
+ // // Returns a buffer that contains a serialized version of this
+ // table
+ // // that must be freed with free().
+ // virtual void *
+ // Write (int fd);
+ };
+
+ template <typename __KeyType, class __HeaderDataType, class __ValueType>
+ class ExportTable {
+ public:
+ typedef __HeaderDataType HeaderDataType;
+ typedef Header<HeaderDataType> HeaderType;
+ typedef __KeyType KeyType;
+ typedef __ValueType ValueType;
+
+ struct Entry {
+ uint32_t hash;
+ KeyType key;
+ ValueType value;
+ };
- void
- Save (const HeaderDataType &header_data,
- lldb_private::Stream &ostrm)
- {
- if (m_entries.empty())
- return;
-
- const uint32_t num_entries = m_entries.size();
- uint32_t i = 0;
-
- HeaderType header;
-
- header.magic = HASH_MAGIC;
- header.version = 1;
- header.hash_function = eHashFunctionDJB;
- header.bucket_count = 0;
- header.hashes_count = 0;
- header.prologue_length = header_data.GetByteSize();
-
- // We need to figure out the number of unique hashes first before we can
- // calculate the number of buckets we want to use.
- typedef std::vector<uint32_t> hash_coll;
- hash_coll unique_hashes;
- unique_hashes.resize (num_entries);
- for (i=0; i<num_entries; ++i)
- unique_hashes[i] = m_entries[i].hash;
- std::sort (unique_hashes.begin(), unique_hashes.end());
- hash_coll::iterator pos = std::unique (unique_hashes.begin(), unique_hashes.end());
- const size_t num_unique_hashes = std::distance (unique_hashes.begin(), pos);
-
- if (num_unique_hashes > 1024)
- header.bucket_count = num_unique_hashes/4;
- else if (num_unique_hashes > 16)
- header.bucket_count = num_unique_hashes/2;
- else
- header.bucket_count = num_unique_hashes;
- if (header.bucket_count == 0)
- header.bucket_count = 1;
-
- std::vector<HashToHashData> hash_buckets;
- std::vector<uint32_t> hash_indexes (header.bucket_count, 0);
- std::vector<uint32_t> hash_values;
- std::vector<uint32_t> hash_offsets;
- hash_buckets.resize (header.bucket_count);
- uint32_t bucket_entry_empties = 0;
- //StreamString hash_file_data(Stream::eBinary, dwarf->GetObjectFile()->GetAddressByteSize(), dwarf->GetObjectFile()->GetByteSize());
-
- // Push all of the hashes into their buckets and create all bucket
- // entries all populated with data.
- for (i=0; i<num_entries; ++i)
- {
- const uint32_t hash = m_entries[i].hash;
- const uint32_t bucket_idx = hash % header.bucket_count;
- const uint32_t strp_offset = m_entries[i].str_offset;
- const uint32_t die_offset = m_entries[i].die_offset;
- hash_buckets[bucket_idx][hash][strp_offset].push_back(die_offset);
- }
-
- // Now for each bucket we write the bucket value which is the
- // number of hashes and the hash index encoded into a single
- // 32 bit unsigned integer.
- for (i=0; i<header.bucket_count; ++i)
- {
- HashToHashData &bucket_entry = hash_buckets[i];
-
- if (bucket_entry.empty())
- {
- // Empty bucket
- ++bucket_entry_empties;
- hash_indexes[i] = UINT32_MAX;
- }
- else
- {
- const uint32_t hash_value_index = hash_values.size();
- uint32_t hash_count = 0;
- typename HashToHashData::const_iterator pos, end = bucket_entry.end();
- for (pos = bucket_entry.begin(); pos != end; ++pos)
- {
- hash_values.push_back (pos->first);
- hash_offsets.push_back (GetByteSize (pos->second));
- ++hash_count;
- }
-
- hash_indexes[i] = hash_value_index;
- }
- }
- header.hashes_count = hash_values.size();
-
- // Write the header out now that we have the hash_count
- header.Write (ostrm);
-
- // Now for each bucket we write the start index of the hashes
- // for the current bucket, or UINT32_MAX if the bucket is empty
- for (i=0; i<header.bucket_count; ++i)
- {
- ostrm.PutHex32(hash_indexes[i]);
- }
-
- // Now we need to write out all of the hash values
- for (i=0; i<header.hashes_count; ++i)
- {
- ostrm.PutHex32(hash_values[i]);
- }
+ typedef std::vector<ValueType> ValueArrayType;
- // Now we need to write out all of the hash data offsets,
- // there is an offset for each hash in the hashes array
- // that was written out above
- for (i=0; i<header.hashes_count; ++i)
- {
- ostrm.PutHex32(hash_offsets[i]);
- }
+ typedef std::map<KeyType, ValueArrayType> HashData;
+ // Map a name hash to one or more name infos
+ typedef std::map<uint32_t, HashData> HashToHashData;
- // Now we write the data for each hash and verify we got the offset
- // correct above...
- for (i=0; i<header.bucket_count; ++i)
- {
- HashToHashData &bucket_entry = hash_buckets[i];
-
- typename HashToHashData::const_iterator pos, end = bucket_entry.end();
- for (pos = bucket_entry.begin(); pos != end; ++pos)
- {
- if (!bucket_entry.empty())
- {
- WriteHashData (pos->second);
- }
- }
- }
+ virtual KeyType GetKeyForStringType(const char *cstr) const = 0;
+
+ virtual size_t GetByteSize(const HashData &key_to_key_values) = 0;
+
+ virtual bool WriteHashData(const HashData &hash_data,
+ lldb_private::Stream &ostrm) = 0;
+ //
+ void AddEntry(const char *cstr, const ValueType &value) {
+ Entry entry;
+ entry.hash = MappedHash::HashString(eHashFunctionDJB, cstr);
+ entry.key = GetKeyForStringType(cstr);
+ entry.value = value;
+ m_entries.push_back(entry);
+ }
+
+ void Save(const HeaderDataType &header_data, lldb_private::Stream &ostrm) {
+ if (m_entries.empty())
+ return;
+
+ const uint32_t num_entries = m_entries.size();
+ uint32_t i = 0;
+
+ HeaderType header;
+
+ header.magic = HASH_MAGIC;
+ header.version = 1;
+ header.hash_function = eHashFunctionDJB;
+ header.bucket_count = 0;
+ header.hashes_count = 0;
+ header.prologue_length = header_data.GetByteSize();
+
+ // We need to figure out the number of unique hashes first before we can
+ // calculate the number of buckets we want to use.
+ typedef std::vector<uint32_t> hash_coll;
+ hash_coll unique_hashes;
+ unique_hashes.resize(num_entries);
+ for (i = 0; i < num_entries; ++i)
+ unique_hashes[i] = m_entries[i].hash;
+ std::sort(unique_hashes.begin(), unique_hashes.end());
+ hash_coll::iterator pos =
+ std::unique(unique_hashes.begin(), unique_hashes.end());
+ const size_t num_unique_hashes =
+ std::distance(unique_hashes.begin(), pos);
+
+ if (num_unique_hashes > 1024)
+ header.bucket_count = num_unique_hashes / 4;
+ else if (num_unique_hashes > 16)
+ header.bucket_count = num_unique_hashes / 2;
+ else
+ header.bucket_count = num_unique_hashes;
+ if (header.bucket_count == 0)
+ header.bucket_count = 1;
+
+ std::vector<HashToHashData> hash_buckets;
+ std::vector<uint32_t> hash_indexes(header.bucket_count, 0);
+ std::vector<uint32_t> hash_values;
+ std::vector<uint32_t> hash_offsets;
+ hash_buckets.resize(header.bucket_count);
+ uint32_t bucket_entry_empties = 0;
+ // StreamString hash_file_data(Stream::eBinary,
+ // dwarf->GetObjectFile()->GetAddressByteSize(),
+ // dwarf->GetObjectFile()->GetByteSize());
+
+ // Push all of the hashes into their buckets and create all bucket
+ // entries all populated with data.
+ for (i = 0; i < num_entries; ++i) {
+ const uint32_t hash = m_entries[i].hash;
+ const uint32_t bucket_idx = hash % header.bucket_count;
+ const uint32_t strp_offset = m_entries[i].str_offset;
+ const uint32_t die_offset = m_entries[i].die_offset;
+ hash_buckets[bucket_idx][hash][strp_offset].push_back(die_offset);
+ }
+
+ // Now for each bucket we write the bucket value which is the
+ // number of hashes and the hash index encoded into a single
+ // 32 bit unsigned integer.
+ for (i = 0; i < header.bucket_count; ++i) {
+ HashToHashData &bucket_entry = hash_buckets[i];
+
+ if (bucket_entry.empty()) {
+ // Empty bucket
+ ++bucket_entry_empties;
+ hash_indexes[i] = UINT32_MAX;
+ } else {
+ const uint32_t hash_value_index = hash_values.size();
+ uint32_t hash_count = 0;
+ typename HashToHashData::const_iterator pos, end = bucket_entry.end();
+ for (pos = bucket_entry.begin(); pos != end; ++pos) {
+ hash_values.push_back(pos->first);
+ hash_offsets.push_back(GetByteSize(pos->second));
+ ++hash_count;
+ }
+
+ hash_indexes[i] = hash_value_index;
}
+ }
+ header.hashes_count = hash_values.size();
+
+ // Write the header out now that we have the hash_count
+ header.Write(ostrm);
+
+ // Now for each bucket we write the start index of the hashes
+ // for the current bucket, or UINT32_MAX if the bucket is empty
+ for (i = 0; i < header.bucket_count; ++i) {
+ ostrm.PutHex32(hash_indexes[i]);
+ }
+
+ // Now we need to write out all of the hash values
+ for (i = 0; i < header.hashes_count; ++i) {
+ ostrm.PutHex32(hash_values[i]);
+ }
+
+ // Now we need to write out all of the hash data offsets,
+ // there is an offset for each hash in the hashes array
+ // that was written out above
+ for (i = 0; i < header.hashes_count; ++i) {
+ ostrm.PutHex32(hash_offsets[i]);
+ }
+
+ // Now we write the data for each hash and verify we got the offset
+ // correct above...
+ for (i = 0; i < header.bucket_count; ++i) {
+ HashToHashData &bucket_entry = hash_buckets[i];
+
+ typename HashToHashData::const_iterator pos, end = bucket_entry.end();
+ for (pos = bucket_entry.begin(); pos != end; ++pos) {
+ if (!bucket_entry.empty()) {
+ WriteHashData(pos->second);
+ }
+ }
+ }
+ }
- protected:
- typedef std::vector<Entry> collection;
- collection m_entries;
+ protected:
+ typedef std::vector<Entry> collection;
+ collection m_entries;
+ };
+
+ // A class for reading and using a saved hash table from a block of data
+ // in memory
+ template <typename __KeyType, class __HeaderType, class __HashData>
+ class MemoryTable {
+ public:
+ typedef __HeaderType HeaderType;
+ typedef __KeyType KeyType;
+ typedef __HashData HashData;
+
+ enum Result {
+ eResultKeyMatch = 0u, // The entry was found, key matched and "pair" was
+ // filled in successfully
+ eResultKeyMismatch =
+ 1u, // Bucket hash data collision, but key didn't match
+ eResultEndOfHashData = 2u, // The chain of items for this hash data in
+ // this bucket is terminated, search no more
+ eResultError = 3u // Error parsing the hash data, abort
};
- // A class for reading and using a saved hash table from a block of data
- // in memory
- template <typename __KeyType, class __HeaderType, class __HashData>
- class MemoryTable
- {
- public:
- typedef __HeaderType HeaderType;
- typedef __KeyType KeyType;
- typedef __HashData HashData;
-
- enum Result
- {
- eResultKeyMatch = 0u, // The entry was found, key matched and "pair" was filled in successfully
- eResultKeyMismatch = 1u, // Bucket hash data collision, but key didn't match
- eResultEndOfHashData = 2u, // The chain of items for this hash data in this bucket is terminated, search no more
- eResultError = 3u // Error parsing the hash data, abort
- };
-
- struct Pair
- {
- KeyType key;
- HashData value;
- };
-
- MemoryTable (lldb_private::DataExtractor &data) :
- m_header (),
- m_hash_indexes (nullptr),
- m_hash_values (nullptr),
- m_hash_offsets (nullptr)
- {
- lldb::offset_t offset = m_header.Read (data, 0);
- if (offset != LLDB_INVALID_OFFSET && IsValid ())
- {
- m_hash_indexes = (const uint32_t *)data.GetData (&offset, m_header.bucket_count * sizeof(uint32_t));
- m_hash_values = (const uint32_t *)data.GetData (&offset, m_header.hashes_count * sizeof(uint32_t));
- m_hash_offsets = (const uint32_t *)data.GetData (&offset, m_header.hashes_count * sizeof(uint32_t));
- }
- }
+ struct Pair {
+ KeyType key;
+ HashData value;
+ };
- virtual
- ~MemoryTable() = default;
+ MemoryTable(lldb_private::DataExtractor &data)
+ : m_header(), m_hash_indexes(nullptr), m_hash_values(nullptr),
+ m_hash_offsets(nullptr) {
+ lldb::offset_t offset = m_header.Read(data, 0);
+ if (offset != LLDB_INVALID_OFFSET && IsValid()) {
+ m_hash_indexes = (const uint32_t *)data.GetData(
+ &offset, m_header.bucket_count * sizeof(uint32_t));
+ m_hash_values = (const uint32_t *)data.GetData(
+ &offset, m_header.hashes_count * sizeof(uint32_t));
+ m_hash_offsets = (const uint32_t *)data.GetData(
+ &offset, m_header.hashes_count * sizeof(uint32_t));
+ }
+ }
- bool
- IsValid () const
- {
- return m_header.version == 1 &&
- m_header.hash_function == eHashFunctionDJB &&
- m_header.bucket_count > 0 &&
- m_header.hashes_count > 0;
- }
-
- uint32_t
- GetHashIndex (uint32_t bucket_idx) const
- {
- if (m_hash_indexes && bucket_idx < m_header.bucket_count)
- return m_hash_indexes[bucket_idx];
- return UINT32_MAX;
- }
-
- uint32_t
- GetHashValue (uint32_t hash_idx) const
- {
- if (m_hash_values && hash_idx < m_header.hashes_count)
- return m_hash_values[hash_idx];
- return UINT32_MAX;
- }
-
- uint32_t
- GetHashDataOffset (uint32_t hash_idx) const
- {
- if (m_hash_offsets && hash_idx < m_header.hashes_count)
- return m_hash_offsets[hash_idx];
- return UINT32_MAX;
- }
-
- bool
- Find (const char *name, Pair &pair) const
- {
- if (!name || !name[0])
- return false;
-
- if (IsValid ())
- {
- const uint32_t bucket_count = m_header.bucket_count;
- const uint32_t hash_count = m_header.hashes_count;
- const uint32_t hash_value = MappedHash::HashString (m_header.hash_function, name);
- const uint32_t bucket_idx = hash_value % bucket_count;
- uint32_t hash_idx = GetHashIndex (bucket_idx);
- if (hash_idx < hash_count)
- {
- for (; hash_idx < hash_count; ++hash_idx)
- {
- const uint32_t curr_hash_value = GetHashValue (hash_idx);
- if (curr_hash_value == hash_value)
- {
- lldb::offset_t hash_data_offset = GetHashDataOffset (hash_idx);
- while (hash_data_offset != UINT32_MAX)
- {
- const lldb::offset_t prev_hash_data_offset = hash_data_offset;
- Result hash_result = GetHashDataForName (name, &hash_data_offset, pair);
- // Check the result of getting our hash data
- switch (hash_result)
- {
- case eResultKeyMatch:
- return true;
-
- case eResultKeyMismatch:
- if (prev_hash_data_offset == hash_data_offset)
- return false;
- break;
-
- case eResultEndOfHashData:
- // The last HashData for this key has been reached, stop searching
- return false;
- case eResultError:
- // Error parsing the hash data, abort
- return false;
- }
- }
- }
- if ((curr_hash_value % bucket_count) != bucket_idx)
- break;
- }
- }
- }
- return false;
- }
+ virtual ~MemoryTable() = default;
- // This method must be implemented in any subclasses.
- // The KeyType is user specified and must somehow result in a string
- // value. For example, the KeyType might be a string offset in a string
- // table and subclasses can store their string table as a member of the
- // subclass and return a valie "const char *" given a "key". The value
- // could also be a C string pointer, in which case just returning "key"
- // will suffice.
- virtual const char *
- GetStringForKeyType (KeyType key) const = 0;
-
- virtual bool
- ReadHashData (uint32_t hash_data_offset,
- HashData &hash_data) const = 0;
-
- // This method must be implemented in any subclasses and it must try to
- // read one "Pair" at the offset pointed to by the "hash_data_offset_ptr"
- // parameter. This offset should be updated as bytes are consumed and
- // a value "Result" enum should be returned. If the "name" matches the
- // full name for the "pair.key" (which must be filled in by this call),
- // then the HashData in the pair ("pair.value") should be extracted and
- // filled in and "eResultKeyMatch" should be returned. If "name" doesn't
- // match this string for the key, then "eResultKeyMismatch" should be
- // returned and all data for the current HashData must be consumed or
- // skipped and the "hash_data_offset_ptr" offset needs to be updated to
- // point to the next HashData. If the end of the HashData objects for
- // a given hash value have been reached, then "eResultEndOfHashData"
- // should be returned. If anything else goes wrong during parsing,
- // return "eResultError" and the corresponding "Find()" function will
- // be canceled and return false.
- virtual Result
- GetHashDataForName (const char *name,
- lldb::offset_t* hash_data_offset_ptr,
- Pair &pair) const = 0;
-
- const HeaderType &
- GetHeader()
- {
- return m_header;
- }
+ bool IsValid() const {
+ return m_header.version == 1 &&
+ m_header.hash_function == eHashFunctionDJB &&
+ m_header.bucket_count > 0 && m_header.hashes_count > 0;
+ }
+
+ uint32_t GetHashIndex(uint32_t bucket_idx) const {
+ if (m_hash_indexes && bucket_idx < m_header.bucket_count)
+ return m_hash_indexes[bucket_idx];
+ return UINT32_MAX;
+ }
+
+ uint32_t GetHashValue(uint32_t hash_idx) const {
+ if (m_hash_values && hash_idx < m_header.hashes_count)
+ return m_hash_values[hash_idx];
+ return UINT32_MAX;
+ }
- void
- ForEach (std::function <bool(const HashData &hash_data)> const &callback) const
- {
- const size_t num_hash_offsets = m_header.hashes_count;
- for (size_t i=0; i<num_hash_offsets; ++i)
- {
- uint32_t hash_data_offset = GetHashDataOffset (i);
- if (hash_data_offset != UINT32_MAX)
- {
- HashData hash_data;
- if (ReadHashData (hash_data_offset, hash_data))
- {
- // If the callback returns false, then we are done and should stop
- if (callback(hash_data) == false)
- return;
- }
+ uint32_t GetHashDataOffset(uint32_t hash_idx) const {
+ if (m_hash_offsets && hash_idx < m_header.hashes_count)
+ return m_hash_offsets[hash_idx];
+ return UINT32_MAX;
+ }
+
+ bool Find(const char *name, Pair &pair) const {
+ if (!name || !name[0])
+ return false;
+
+ if (IsValid()) {
+ const uint32_t bucket_count = m_header.bucket_count;
+ const uint32_t hash_count = m_header.hashes_count;
+ const uint32_t hash_value =
+ MappedHash::HashString(m_header.hash_function, name);
+ const uint32_t bucket_idx = hash_value % bucket_count;
+ uint32_t hash_idx = GetHashIndex(bucket_idx);
+ if (hash_idx < hash_count) {
+ for (; hash_idx < hash_count; ++hash_idx) {
+ const uint32_t curr_hash_value = GetHashValue(hash_idx);
+ if (curr_hash_value == hash_value) {
+ lldb::offset_t hash_data_offset = GetHashDataOffset(hash_idx);
+ while (hash_data_offset != UINT32_MAX) {
+ const lldb::offset_t prev_hash_data_offset = hash_data_offset;
+ Result hash_result =
+ GetHashDataForName(name, &hash_data_offset, pair);
+ // Check the result of getting our hash data
+ switch (hash_result) {
+ case eResultKeyMatch:
+ return true;
+
+ case eResultKeyMismatch:
+ if (prev_hash_data_offset == hash_data_offset)
+ return false;
+ break;
+
+ case eResultEndOfHashData:
+ // The last HashData for this key has been reached, stop
+ // searching
+ return false;
+ case eResultError:
+ // Error parsing the hash data, abort
+ return false;
}
+ }
}
+ if ((curr_hash_value % bucket_count) != bucket_idx)
+ break;
+ }
}
+ }
+ return false;
+ }
- protected:
- // Implementation agnostic information
- HeaderType m_header;
- const uint32_t *m_hash_indexes;
- const uint32_t *m_hash_values;
- const uint32_t *m_hash_offsets;
- };
+ // This method must be implemented in any subclasses.
+ // The KeyType is user specified and must somehow result in a string
+ // value. For example, the KeyType might be a string offset in a string
+ // table and subclasses can store their string table as a member of the
+ // subclass and return a valie "const char *" given a "key". The value
+ // could also be a C string pointer, in which case just returning "key"
+ // will suffice.
+ virtual const char *GetStringForKeyType(KeyType key) const = 0;
+
+ virtual bool ReadHashData(uint32_t hash_data_offset,
+ HashData &hash_data) const = 0;
+
+ // This method must be implemented in any subclasses and it must try to
+ // read one "Pair" at the offset pointed to by the "hash_data_offset_ptr"
+ // parameter. This offset should be updated as bytes are consumed and
+ // a value "Result" enum should be returned. If the "name" matches the
+ // full name for the "pair.key" (which must be filled in by this call),
+ // then the HashData in the pair ("pair.value") should be extracted and
+ // filled in and "eResultKeyMatch" should be returned. If "name" doesn't
+ // match this string for the key, then "eResultKeyMismatch" should be
+ // returned and all data for the current HashData must be consumed or
+ // skipped and the "hash_data_offset_ptr" offset needs to be updated to
+ // point to the next HashData. If the end of the HashData objects for
+ // a given hash value have been reached, then "eResultEndOfHashData"
+ // should be returned. If anything else goes wrong during parsing,
+ // return "eResultError" and the corresponding "Find()" function will
+ // be canceled and return false.
+ virtual Result GetHashDataForName(const char *name,
+ lldb::offset_t *hash_data_offset_ptr,
+ Pair &pair) const = 0;
+
+ const HeaderType &GetHeader() { return m_header; }
+
+ void ForEach(
+ std::function<bool(const HashData &hash_data)> const &callback) const {
+ const size_t num_hash_offsets = m_header.hashes_count;
+ for (size_t i = 0; i < num_hash_offsets; ++i) {
+ uint32_t hash_data_offset = GetHashDataOffset(i);
+ if (hash_data_offset != UINT32_MAX) {
+ HashData hash_data;
+ if (ReadHashData(hash_data_offset, hash_data)) {
+ // If the callback returns false, then we are done and should stop
+ if (callback(hash_data) == false)
+ return;
+ }
+ }
+ }
+ }
+
+ protected:
+ // Implementation agnostic information
+ HeaderType m_header;
+ const uint32_t *m_hash_indexes;
+ const uint32_t *m_hash_values;
+ const uint32_t *m_hash_offsets;
+ };
};
#endif // liblldb_MappedHash_h_
diff --git a/include/lldb/Core/Module.h b/include/lldb/Core/Module.h
index 46fa330fb19c..90d75b623732 100644
--- a/include/lldb/Core/Module.h
+++ b/include/lldb/Core/Module.h
@@ -10,24 +10,27 @@
#ifndef liblldb_Module_h_
#define liblldb_Module_h_
-// C Includes
-// C++ Includes
-#include <atomic>
-#include <mutex>
-#include <string>
-#include <vector>
+#include "lldb/Symbol/SymbolContextScope.h"
-// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-forward.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/UUID.h"
#include "lldb/Host/FileSpec.h"
-#include "lldb/Host/TimeValue.h"
-#include "lldb/Symbol/SymbolContextScope.h"
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/PathMappingList.h"
+#include "lldb/lldb-forward.h"
+
+// Other libraries and framework includes
#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Chrono.h"
+
+// C Includes
+// C++ Includes
+#include <atomic>
+#include <mutex>
+#include <string>
+#include <vector>
namespace lldb_private {
@@ -50,1187 +53,1093 @@ namespace lldb_private {
/// The module will parse more detailed information as more queries are
/// made.
//----------------------------------------------------------------------
-class Module :
- public std::enable_shared_from_this<Module>,
- public SymbolContextScope
-{
+class Module : public std::enable_shared_from_this<Module>,
+ public SymbolContextScope {
public:
- // Static functions that can track the lifetime of module objects.
- // This is handy because we might have Module objects that are in
- // shared pointers that aren't in the global module list (from
- // ModuleList). If this is the case we need to know about it.
- // The modules in the global list maintained by these functions
- // can be viewed using the "target modules list" command using the
- // "--global" (-g for short).
- static size_t
- GetNumberAllocatedModules ();
-
- static Module *
- GetAllocatedModuleAtIndex (size_t idx);
-
- static std::recursive_mutex &
- GetAllocationModuleCollectionMutex();
-
- //------------------------------------------------------------------
- /// Construct with file specification and architecture.
- ///
- /// Clients that wish to share modules with other targets should
- /// use ModuleList::GetSharedModule().
- ///
- /// @param[in] file_spec
- /// The file specification for the on disk representation of
- /// this executable image.
- ///
- /// @param[in] arch
- /// The architecture to set as the current architecture in
- /// this module.
- ///
- /// @param[in] object_name
- /// The name of an object in a module used to extract a module
- /// within a module (.a files and modules that contain multiple
- /// architectures).
- ///
- /// @param[in] object_offset
- /// The offset within an existing module used to extract a
- /// module within a module (.a files and modules that contain
- /// multiple architectures).
- //------------------------------------------------------------------
- Module(const FileSpec& file_spec,
- const ArchSpec& arch,
- const ConstString *object_name = nullptr,
- lldb::offset_t object_offset = 0,
- const TimeValue *object_mod_time_ptr = nullptr);
-
- Module (const ModuleSpec &module_spec);
-
- static lldb::ModuleSP
- CreateJITModule (const lldb::ObjectFileJITDelegateSP &delegate_sp);
-
- //------------------------------------------------------------------
- /// Destructor.
- //------------------------------------------------------------------
- ~Module() override;
-
- bool
- MatchesModuleSpec (const ModuleSpec &module_ref);
-
- //------------------------------------------------------------------
- /// Set the load address for all sections in a module to be the
- /// file address plus \a slide.
- ///
- /// Many times a module will be loaded in a target with a constant
- /// offset applied to all top level sections. This function can
- /// set the load address for all top level sections to be the
- /// section file address + offset.
- ///
- /// @param[in] target
- /// The target in which to apply the section load addresses.
- ///
- /// @param[in] value
- /// if \a value_is_offset is true, then value is the offset to
- /// apply to all file addresses for all top level sections in
- /// the object file as each section load address is being set.
- /// If \a value_is_offset is false, then "value" is the new
- /// absolute base address for the image.
- ///
- /// @param[in] value_is_offset
- /// If \b true, then \a value is an offset to apply to each
- /// file address of each top level section.
- /// If \b false, then \a value is the image base address that
- /// will be used to rigidly slide all loadable sections.
- ///
- /// @param[out] changed
- /// If any section load addresses were changed in \a target,
- /// then \a changed will be set to \b true. Else \a changed
- /// will be set to false. This allows this function to be
- /// called multiple times on the same module for the same
- /// target. If the module hasn't moved, then \a changed will
- /// be false and no module updated notification will need to
- /// be sent out.
- ///
- /// @return
- /// /b True if any sections were successfully loaded in \a target,
- /// /b false otherwise.
- //------------------------------------------------------------------
- bool
- SetLoadAddress (Target &target,
- lldb::addr_t value,
- bool value_is_offset,
- bool &changed);
-
- //------------------------------------------------------------------
- /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
- ///
- /// @see SymbolContextScope
- //------------------------------------------------------------------
- void
- CalculateSymbolContext(SymbolContext* sc) override;
-
- lldb::ModuleSP
- CalculateSymbolContextModule() override;
-
- void
- GetDescription (Stream *s,
- lldb::DescriptionLevel level = lldb::eDescriptionLevelFull);
-
- //------------------------------------------------------------------
- /// Get the module path and object name.
- ///
- /// Modules can refer to object files. In this case the specification
- /// is simple and would return the path to the file:
- ///
- /// "/usr/lib/foo.dylib"
- ///
- /// Modules can be .o files inside of a BSD archive (.a file). In
- /// this case, the object specification will look like:
- ///
- /// "/usr/lib/foo.a(bar.o)"
- ///
- /// There are many places where logging wants to log this fully
- /// qualified specification, so we centralize this functionality
- /// here.
- ///
- /// @return
- /// The object path + object name if there is one.
- //------------------------------------------------------------------
- std::string
- GetSpecificationDescription () const;
-
- //------------------------------------------------------------------
- /// Dump a description of this object to a Stream.
- ///
- /// Dump a description of the contents of this object to the
- /// supplied stream \a s. The dumped content will be only what has
- /// been loaded or parsed up to this point at which this function
- /// is called, so this is a good way to see what has been parsed
- /// in a module.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- //------------------------------------------------------------------
- void
- Dump (Stream *s);
-
- //------------------------------------------------------------------
- /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
- ///
- /// @see SymbolContextScope
- //------------------------------------------------------------------
- void
- DumpSymbolContext(Stream *s) override;
-
- //------------------------------------------------------------------
- /// Find a symbol in the object file's symbol table.
- ///
- /// @param[in] name
- /// The name of the symbol that we are looking for.
- ///
- /// @param[in] symbol_type
- /// If set to eSymbolTypeAny, find a symbol of any type that
- /// has a name that matches \a name. If set to any other valid
- /// SymbolType enumeration value, then search only for
- /// symbols that match \a symbol_type.
- ///
- /// @return
- /// Returns a valid symbol pointer if a symbol was found,
- /// nullptr otherwise.
- //------------------------------------------------------------------
- const Symbol *
- FindFirstSymbolWithNameAndType (const ConstString &name,
- lldb::SymbolType symbol_type = lldb::eSymbolTypeAny);
-
- size_t
- FindSymbolsWithNameAndType (const ConstString &name,
- lldb::SymbolType symbol_type,
- SymbolContextList &sc_list);
-
- size_t
- FindSymbolsMatchingRegExAndType (const RegularExpression &regex,
- lldb::SymbolType symbol_type,
- SymbolContextList &sc_list);
-
- //------------------------------------------------------------------
- /// Find a funciton symbols in the object file's symbol table.
- ///
- /// @param[in] name
- /// The name of the symbol that we are looking for.
- ///
- /// @param[in] name_type_mask
- /// A mask that has one or more bitwise OR'ed values from the
- /// lldb::FunctionNameType enumeration type that indicate what
- /// kind of names we are looking for.
- ///
- /// @param[out] sc_list
- /// A list to append any matching symbol contexts to.
- ///
- /// @return
- /// The number of symbol contexts that were added to \a sc_list
- //------------------------------------------------------------------
- size_t
- FindFunctionSymbols (const ConstString &name,
- uint32_t name_type_mask,
- SymbolContextList& sc_list);
-
- //------------------------------------------------------------------
- /// Find compile units by partial or full path.
- ///
- /// Finds all compile units that match \a path in all of the modules
- /// and returns the results in \a sc_list.
- ///
- /// @param[in] path
- /// The name of the function we are looking for.
- ///
- /// @param[in] append
- /// If \b true, then append any compile units that were found
- /// to \a sc_list. If \b false, then the \a sc_list is cleared
- /// and the contents of \a sc_list are replaced.
- ///
- /// @param[out] sc_list
- /// A symbol context list that gets filled in with all of the
- /// matches.
- ///
- /// @return
- /// The number of matches added to \a sc_list.
- //------------------------------------------------------------------
- size_t
- FindCompileUnits (const FileSpec &path,
- bool append,
- SymbolContextList &sc_list);
-
- //------------------------------------------------------------------
- /// Find functions by name.
- ///
- /// If the function is an inlined function, it will have a block,
- /// representing the inlined function, and the function will be the
- /// containing function. If it is not inlined, then the block will
- /// be NULL.
- ///
- /// @param[in] name
- /// The name of the compile unit we are looking for.
- ///
- /// @param[in] namespace_decl
- /// If valid, a namespace to search in.
- ///
- /// @param[in] name_type_mask
- /// A bit mask of bits that indicate what kind of names should
- /// be used when doing the lookup. Bits include fully qualified
- /// names, base names, C++ methods, or ObjC selectors.
- /// See FunctionNameType for more details.
- ///
- /// @param[in] append
- /// If \b true, any matches will be appended to \a sc_list, else
- /// matches replace the contents of \a sc_list.
- ///
- /// @param[out] sc_list
- /// A symbol context list that gets filled in with all of the
- /// matches.
- ///
- /// @return
- /// The number of matches added to \a sc_list.
- //------------------------------------------------------------------
- size_t
- FindFunctions (const ConstString &name,
- const CompilerDeclContext *parent_decl_ctx,
- uint32_t name_type_mask,
- bool symbols_ok,
- bool inlines_ok,
- bool append,
- SymbolContextList& sc_list);
-
- //------------------------------------------------------------------
- /// Find functions by name.
- ///
- /// If the function is an inlined function, it will have a block,
- /// representing the inlined function, and the function will be the
- /// containing function. If it is not inlined, then the block will
- /// be NULL.
- ///
- /// @param[in] regex
- /// A regular expression to use when matching the name.
- ///
- /// @param[in] append
- /// If \b true, any matches will be appended to \a sc_list, else
- /// matches replace the contents of \a sc_list.
- ///
- /// @param[out] sc_list
- /// A symbol context list that gets filled in with all of the
- /// matches.
- ///
- /// @return
- /// The number of matches added to \a sc_list.
- //------------------------------------------------------------------
- size_t
- FindFunctions (const RegularExpression& regex,
- bool symbols_ok,
- bool inlines_ok,
- bool append,
- SymbolContextList& sc_list);
-
- //------------------------------------------------------------------
- /// Find addresses by file/line
- ///
- /// @param[in] target_sp
- /// The target the addresses are desired for.
- ///
- /// @param[in] file
- /// Source file to locate.
- ///
- /// @param[in] line
- /// Source line to locate.
- ///
- /// @param[in] function
- /// Optional filter function. Addresses within this function will be
- /// added to the 'local' list. All others will be added to the 'extern' list.
- ///
- /// @param[out] output_local
- /// All matching addresses within 'function'
- ///
- /// @param[out] output_extern
- /// All matching addresses not within 'function'
- void FindAddressesForLine (const lldb::TargetSP target_sp,
- const FileSpec &file, uint32_t line,
- Function *function,
- std::vector<Address> &output_local, std::vector<Address> &output_extern);
-
- //------------------------------------------------------------------
- /// Find global and static variables by name.
- ///
- /// @param[in] name
- /// The name of the global or static variable we are looking
- /// for.
- ///
- /// @param[in] parent_decl_ctx
- /// If valid, a decl context that results must exist within
- ///
- /// @param[in] append
- /// If \b true, any matches will be appended to \a
- /// variable_list, else matches replace the contents of
- /// \a variable_list.
- ///
- /// @param[in] max_matches
- /// Allow the number of matches to be limited to \a
- /// max_matches. Specify UINT32_MAX to get all possible matches.
- ///
- /// @param[in] variable_list
- /// A list of variables that gets the matches appended to (if
- /// \a append it \b true), or replace (if \a append is \b false).
- ///
- /// @return
- /// The number of matches added to \a variable_list.
- //------------------------------------------------------------------
- size_t
- FindGlobalVariables (const ConstString &name,
- const CompilerDeclContext *parent_decl_ctx,
- bool append,
- size_t max_matches,
- VariableList& variable_list);
-
- //------------------------------------------------------------------
- /// Find global and static variables by regular expression.
- ///
- /// @param[in] regex
- /// A regular expression to use when matching the name.
- ///
- /// @param[in] append
- /// If \b true, any matches will be appended to \a
- /// variable_list, else matches replace the contents of
- /// \a variable_list.
- ///
- /// @param[in] max_matches
- /// Allow the number of matches to be limited to \a
- /// max_matches. Specify UINT32_MAX to get all possible matches.
- ///
- /// @param[in] variable_list
- /// A list of variables that gets the matches appended to (if
- /// \a append it \b true), or replace (if \a append is \b false).
- ///
- /// @return
- /// The number of matches added to \a variable_list.
- //------------------------------------------------------------------
- size_t
- FindGlobalVariables (const RegularExpression& regex,
- bool append,
- size_t max_matches,
- VariableList& variable_list);
-
- //------------------------------------------------------------------
- /// Find types by name.
- ///
- /// Type lookups in modules go through the SymbolVendor (which will
- /// use one or more SymbolFile subclasses). The SymbolFile needs to
- /// be able to lookup types by basename and not the fully qualified
- /// typename. This allows the type accelerator tables to stay small,
- /// even with heavily templatized C++. The type search will then
- /// narrow down the search results. If "exact_match" is true, then
- /// the type search will only match exact type name matches. If
- /// "exact_match" is false, the type will match as long as the base
- /// typename matches and as long as any immediate containing
- /// namespaces/class scopes that are specified match. So to search
- /// for a type "d" in "b::c", the name "b::c::d" can be specified
- /// and it will match any class/namespace "b" which contains a
- /// class/namespace "c" which contains type "d". We do this to
- /// allow users to not always have to specify complete scoping on
- /// all expressions, but it also allows for exact matching when
- /// required.
- ///
- /// @param[in] sc
- /// A symbol context that scopes where to extract a type list
- /// from.
- ///
- /// @param[in] type_name
- /// The name of the type we are looking for that is a fully
- /// or partially qualified type name.
- ///
- /// @param[in] exact_match
- /// If \b true, \a type_name is fully qualified and must match
- /// exactly. If \b false, \a type_name is a partially qualified
- /// name where the leading namespaces or classes can be
- /// omitted to make finding types that a user may type
- /// easier.
- ///
- /// @param[out] type_list
- /// A type list gets populated with any matches.
- ///
- /// @return
- /// The number of matches added to \a type_list.
- //------------------------------------------------------------------
- size_t
- FindTypes (const SymbolContext& sc,
- const ConstString &type_name,
- bool exact_match,
- size_t max_matches,
- llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
- TypeList& types);
-
- lldb::TypeSP
- FindFirstType (const SymbolContext& sc,
- const ConstString &type_name,
- bool exact_match);
-
- //------------------------------------------------------------------
- /// Find types by name that are in a namespace. This function is
- /// used by the expression parser when searches need to happen in
- /// an exact namespace scope.
- ///
- /// @param[in] sc
- /// A symbol context that scopes where to extract a type list
- /// from.
- ///
- /// @param[in] type_name
- /// The name of a type within a namespace that should not include
- /// any qualifying namespaces (just a type basename).
- ///
- /// @param[in] namespace_decl
- /// The namespace declaration that this type must exist in.
- ///
- /// @param[out] type_list
- /// A type list gets populated with any matches.
- ///
- /// @return
- /// The number of matches added to \a type_list.
- //------------------------------------------------------------------
- size_t
- FindTypesInNamespace (const SymbolContext& sc,
- const ConstString &type_name,
- const CompilerDeclContext *parent_decl_ctx,
- size_t max_matches,
- TypeList& type_list);
-
- //------------------------------------------------------------------
- /// Get const accessor for the module architecture.
- ///
- /// @return
- /// A const reference to the architecture object.
- //------------------------------------------------------------------
- const ArchSpec&
- GetArchitecture () const;
-
- //------------------------------------------------------------------
- /// Get const accessor for the module file specification.
- ///
- /// This function returns the file for the module on the host system
- /// that is running LLDB. This can differ from the path on the
- /// platform since we might be doing remote debugging.
- ///
- /// @return
- /// A const reference to the file specification object.
- //------------------------------------------------------------------
- const FileSpec &
- GetFileSpec () const
- {
- return m_file;
- }
-
- //------------------------------------------------------------------
- /// Get accessor for the module platform file specification.
- ///
- /// Platform file refers to the path of the module as it is known on
- /// the remote system on which it is being debugged. For local
- /// debugging this is always the same as Module::GetFileSpec(). But
- /// remote debugging might mention a file "/usr/lib/liba.dylib"
- /// which might be locally downloaded and cached. In this case the
- /// platform file could be something like:
- /// "/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib"
- /// The file could also be cached in a local developer kit directory.
- ///
- /// @return
- /// A const reference to the file specification object.
- //------------------------------------------------------------------
- const FileSpec &
- GetPlatformFileSpec () const
- {
- if (m_platform_file)
- return m_platform_file;
- return m_file;
- }
-
- void
- SetPlatformFileSpec (const FileSpec &file)
- {
- m_platform_file = file;
- }
-
- const FileSpec &
- GetRemoteInstallFileSpec () const
- {
- return m_remote_install_file;
- }
-
- void
- SetRemoteInstallFileSpec (const FileSpec &file)
- {
- m_remote_install_file = file;
- }
-
- const FileSpec &
- GetSymbolFileFileSpec () const
- {
- return m_symfile_spec;
- }
-
- void
- SetSymbolFileFileSpec (const FileSpec &file);
-
- const TimeValue &
- GetModificationTime () const
- {
- return m_mod_time;
- }
-
- const TimeValue &
- GetObjectModificationTime () const
- {
- return m_object_mod_time;
- }
-
- void
- SetObjectModificationTime (const TimeValue &mod_time)
- {
- m_mod_time = mod_time;
- }
-
- //------------------------------------------------------------------
- /// Tells whether this module is capable of being the main executable
- /// for a process.
- ///
- /// @return
- /// \b true if it is, \b false otherwise.
- //------------------------------------------------------------------
- bool
- IsExecutable ();
-
- //------------------------------------------------------------------
- /// Tells whether this module has been loaded in the target passed in.
- /// This call doesn't distinguish between whether the module is loaded
- /// by the dynamic loader, or by a "target module add" type call.
- ///
- /// @param[in] target
- /// The target to check whether this is loaded in.
- ///
- /// @return
- /// \b true if it is, \b false otherwise.
- //------------------------------------------------------------------
- bool
- IsLoadedInTarget (Target *target);
-
- bool
- LoadScriptingResourceInTarget(Target *target,
- Error& error,
- Stream* feedback_stream = nullptr);
-
- //------------------------------------------------------------------
- /// Get the number of compile units for this module.
- ///
- /// @return
- /// The number of compile units that the symbol vendor plug-in
- /// finds.
- //------------------------------------------------------------------
- size_t
- GetNumCompileUnits();
-
- lldb::CompUnitSP
- GetCompileUnitAtIndex (size_t idx);
-
- const ConstString &
- GetObjectName() const;
-
- uint64_t
- GetObjectOffset() const
- {
- return m_object_offset;
- }
-
- //------------------------------------------------------------------
- /// Get the object file representation for the current architecture.
- ///
- /// If the object file has not been located or parsed yet, this
- /// function will find the best ObjectFile plug-in that can parse
- /// Module::m_file.
- ///
- /// @return
- /// If Module::m_file does not exist, or no plug-in was found
- /// that can parse the file, or the object file doesn't contain
- /// the current architecture in Module::m_arch, nullptr will be
- /// returned, else a valid object file interface will be
- /// returned. The returned pointer is owned by this object and
- /// remains valid as long as the object is around.
- //------------------------------------------------------------------
- virtual ObjectFile *
- GetObjectFile ();
-
- //------------------------------------------------------------------
- /// Get the unified section list for the module. This is the section
- /// list created by the module's object file and any debug info and
- /// symbol files created by the symbol vendor.
- ///
- /// If the symbol vendor has not been loaded yet, this function
- /// will return the section list for the object file.
- ///
- /// @return
- /// Unified module section list.
- //------------------------------------------------------------------
- virtual SectionList *
- GetSectionList ();
-
- //------------------------------------------------------------------
- /// Notify the module that the file addresses for the Sections have
- /// been updated.
- ///
- /// If the Section file addresses for a module are updated, this
- /// method should be called. Any parts of the module, object file,
- /// or symbol file that has cached those file addresses must invalidate
- /// or update its cache.
- //------------------------------------------------------------------
- virtual void
- SectionFileAddressesChanged ();
-
- uint32_t
- GetVersion (uint32_t *versions, uint32_t num_versions);
-
- //------------------------------------------------------------------
- /// Load an object file from memory.
- ///
- /// If available, the size of the object file in memory may be
- /// passed to avoid additional round trips to process memory.
- /// If the size is not provided, a default value is used. This
- /// value should be large enough to enable the ObjectFile plugins
- /// to read the header of the object file without going back to the
- /// process.
- ///
- /// @return
- /// The object file loaded from memory or nullptr, if the operation
- /// failed (see the `error` for more information in that case).
- //------------------------------------------------------------------
- ObjectFile *
- GetMemoryObjectFile (const lldb::ProcessSP &process_sp,
- lldb::addr_t header_addr,
- Error &error,
- size_t size_to_read = 512);
- //------------------------------------------------------------------
- /// Get the symbol vendor interface for the current architecture.
- ///
- /// If the symbol vendor file has not been located yet, this
- /// function will find the best SymbolVendor plug-in that can
- /// use the current object file.
- ///
- /// @return
- /// If this module does not have a valid object file, or no
- /// plug-in can be found that can use the object file, nullptr will
- /// be returned, else a valid symbol vendor plug-in interface
- /// will be returned. The returned pointer is owned by this
- /// object and remains valid as long as the object is around.
- //------------------------------------------------------------------
- virtual SymbolVendor*
- GetSymbolVendor(bool can_create = true,
- lldb_private::Stream *feedback_strm = nullptr);
-
- //------------------------------------------------------------------
- /// Get accessor the type list for this module.
- ///
- /// @return
- /// A valid type list pointer, or nullptr if there is no valid
- /// symbol vendor for this module.
- //------------------------------------------------------------------
- TypeList*
- GetTypeList ();
-
- //------------------------------------------------------------------
- /// Get a pointer to the UUID value contained in this object.
- ///
- /// If the executable image file doesn't not have a UUID value built
- /// into the file format, an MD5 checksum of the entire file, or
- /// slice of the file for the current architecture should be used.
- ///
- /// @return
- /// A const pointer to the internal copy of the UUID value in
- /// this module if this module has a valid UUID value, NULL
- /// otherwise.
- //------------------------------------------------------------------
- const lldb_private::UUID &
- GetUUID ();
-
- //------------------------------------------------------------------
- /// A debugging function that will cause everything in a module to
- /// be parsed.
- ///
- /// All compile units will be parsed, along with all globals and
- /// static variables and all functions for those compile units.
- /// All types, scopes, local variables, static variables, global
- /// variables, and line tables will be parsed. This can be used
- /// prior to dumping a module to see a complete list of the
- /// resulting debug information that gets parsed, or as a debug
- /// function to ensure that the module can consume all of the
- /// debug data the symbol vendor provides.
- //------------------------------------------------------------------
- void
- ParseAllDebugSymbols();
-
- bool
- ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr);
-
- //------------------------------------------------------------------
- /// Resolve the symbol context for the given address.
- ///
- /// Tries to resolve the matching symbol context based on a lookup
- /// from the current symbol vendor. If the lazy lookup fails,
- /// an attempt is made to parse the eh_frame section to handle
- /// stripped symbols. If this fails, an attempt is made to resolve
- /// the symbol to the previous address to handle the case of a
- /// function with a tail call.
- ///
- /// Use properties of the modified SymbolContext to inspect any
- /// resolved target, module, compilation unit, symbol, function,
- /// function block or line entry. Use the return value to determine
- /// which of these properties have been modified.
- ///
- /// @param[in] so_addr
- /// A load address to resolve.
- ///
- /// @param[in] resolve_scope
- /// The scope that should be resolved (see SymbolContext::Scope).
- /// A combination of flags from the enumeration SymbolContextItem
- /// requesting a resolution depth. Note that the flags that are
- /// actually resolved may be a superset of the requested flags.
- /// For instance, eSymbolContextSymbol requires resolution of
- /// eSymbolContextModule, and eSymbolContextFunction requires
- /// eSymbolContextSymbol.
- ///
- /// @param[out] sc
- /// The SymbolContext that is modified based on symbol resolution.
- ///
- /// @param[in] resolve_tail_call_address
- /// Determines if so_addr should resolve to a symbol in the case
- /// of a function whose last instruction is a call. In this case,
- /// the PC can be one past the address range of the function.
- ///
- /// @return
- /// The scope that has been resolved (see SymbolContext::Scope).
- ///
- /// @see SymbolContext::Scope
- //------------------------------------------------------------------
- uint32_t
- ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve_scope,
- SymbolContext& sc, bool resolve_tail_call_address = false);
-
- //------------------------------------------------------------------
- /// Resolve items in the symbol context for a given file and line.
- ///
- /// Tries to resolve \a file_path and \a line to a list of matching
- /// symbol contexts.
- ///
- /// The line table entries contains addresses that can be used to
- /// further resolve the values in each match: the function, block,
- /// symbol. Care should be taken to minimize the amount of
- /// information that is requested to only what is needed --
- /// typically the module, compile unit, line table and line table
- /// entry are sufficient.
- ///
- /// @param[in] file_path
- /// A path to a source file to match. If \a file_path does not
- /// specify a directory, then this query will match all files
- /// whose base filename matches. If \a file_path does specify
- /// a directory, the fullpath to the file must match.
- ///
- /// @param[in] line
- /// The source line to match, or zero if just the compile unit
- /// should be resolved.
- ///
- /// @param[in] check_inlines
- /// Check for inline file and line number matches. This option
- /// should be used sparingly as it will cause all line tables
- /// for every compile unit to be parsed and searched for
- /// matching inline file entries.
- ///
- /// @param[in] resolve_scope
- /// The scope that should be resolved (see
- /// SymbolContext::Scope).
- ///
- /// @param[out] sc_list
- /// A symbol context list that gets matching symbols contexts
- /// appended to.
- ///
- /// @return
- /// The number of matches that were added to \a sc_list.
- ///
- /// @see SymbolContext::Scope
- //------------------------------------------------------------------
- uint32_t
- ResolveSymbolContextForFilePath (const char *file_path, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list);
-
- //------------------------------------------------------------------
- /// Resolve items in the symbol context for a given file and line.
- ///
- /// Tries to resolve \a file_spec and \a line to a list of matching
- /// symbol contexts.
- ///
- /// The line table entries contains addresses that can be used to
- /// further resolve the values in each match: the function, block,
- /// symbol. Care should be taken to minimize the amount of
- /// information that is requested to only what is needed --
- /// typically the module, compile unit, line table and line table
- /// entry are sufficient.
- ///
- /// @param[in] file_spec
- /// A file spec to a source file to match. If \a file_path does
- /// not specify a directory, then this query will match all
- /// files whose base filename matches. If \a file_path does
- /// specify a directory, the fullpath to the file must match.
- ///
- /// @param[in] line
- /// The source line to match, or zero if just the compile unit
- /// should be resolved.
- ///
- /// @param[in] check_inlines
- /// Check for inline file and line number matches. This option
- /// should be used sparingly as it will cause all line tables
- /// for every compile unit to be parsed and searched for
- /// matching inline file entries.
- ///
- /// @param[in] resolve_scope
- /// The scope that should be resolved (see
- /// SymbolContext::Scope).
- ///
- /// @param[out] sc_list
- /// A symbol context list that gets filled in with all of the
- /// matches.
- ///
- /// @return
- /// A integer that contains SymbolContext::Scope bits set for
- /// each item that was successfully resolved.
- ///
- /// @see SymbolContext::Scope
- //------------------------------------------------------------------
- uint32_t
- ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list);
-
- void
- SetFileSpecAndObjectName (const FileSpec &file,
- const ConstString &object_name);
-
- bool
- GetIsDynamicLinkEditor ();
-
- TypeSystem *
- GetTypeSystemForLanguage (lldb::LanguageType language);
-
- // Special error functions that can do printf style formatting that will prepend the message with
- // something appropriate for this module (like the architecture, path and object name (if any)).
- // This centralizes code so that everyone doesn't need to format their error and log messages on
- // their own and keeps the output a bit more consistent.
- void
- LogMessage (Log *log, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
-
- void
- LogMessageVerboseBacktrace (Log *log, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
-
- void
- ReportWarning (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
-
- void
- ReportError (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
-
- // Only report an error once when the module is first detected to be modified
- // so we don't spam the console with many messages.
- void
- ReportErrorIfModifyDetected (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
-
- //------------------------------------------------------------------
- // Return true if the file backing this module has changed since the
- // module was originally created since we saved the initial file
- // modification time when the module first gets created.
- //------------------------------------------------------------------
- bool
- FileHasChanged () const;
-
- //------------------------------------------------------------------
- // SymbolVendor, SymbolFile and ObjectFile member objects should
- // lock the module mutex to avoid deadlocks.
- //------------------------------------------------------------------
- std::recursive_mutex &
- GetMutex() const
- {
- return m_mutex;
- }
-
- PathMappingList &
- GetSourceMappingList ()
- {
- return m_source_mappings;
- }
-
- const PathMappingList &
- GetSourceMappingList () const
- {
- return m_source_mappings;
- }
-
- //------------------------------------------------------------------
- /// Finds a source file given a file spec using the module source
- /// path remappings (if any).
- ///
- /// Tries to resolve \a orig_spec by checking the module source path
- /// remappings. It makes sure the file exists, so this call can be
- /// expensive if the remappings are on a network file system, so
- /// use this function sparingly (not in a tight debug info parsing
- /// loop).
- ///
- /// @param[in] orig_spec
- /// The original source file path to try and remap.
- ///
- /// @param[out] new_spec
- /// The newly remapped filespec that is guaranteed to exist.
- ///
- /// @return
- /// /b true if \a orig_spec was successfully located and
- /// \a new_spec is filled in with an existing file spec,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool
- FindSourceFile (const FileSpec &orig_spec, FileSpec &new_spec) const;
-
- //------------------------------------------------------------------
- /// Remaps a source file given \a path into \a new_path.
- ///
- /// Remaps \a path if any source remappings match. This function
- /// does NOT stat the file system so it can be used in tight loops
- /// where debug info is being parsed.
- ///
- /// @param[in] path
- /// The original source file path to try and remap.
- ///
- /// @param[out] new_path
- /// The newly remapped filespec that is may or may not exist.
- ///
- /// @return
- /// /b true if \a path was successfully located and \a new_path
- /// is filled in with a new source path, \b false otherwise.
- //------------------------------------------------------------------
- bool
- RemapSourceFile (const char *path, std::string &new_path) const;
-
- //----------------------------------------------------------------------
- /// @class LookupInfo Module.h "lldb/Core/Module.h"
- /// @brief A class that encapsulates name lookup information.
- ///
- /// Users can type a wide variety of partial names when setting
- /// breakpoints by name or when looking for functions by name.
- /// SymbolVendor and SymbolFile objects are only required to implement
- /// name lookup for function basenames and for fully mangled names.
- /// This means if the user types in a partial name, we must reduce this
- /// to a name lookup that will work with all SymbolFile objects. So we
- /// might reduce a name lookup to look for a basename, and then prune
- /// out any results that don't match.
- ///
- /// The "m_name" member variable represents the name as it was typed
- /// by the user. "m_lookup_name" will be the name we actually search
- /// for through the symbol or objects files. Lanaguage is included in
- /// case we need to filter results by language at a later date. The
- /// "m_name_type_mask" member variable tells us what kinds of names we
- /// are looking for and can help us prune out unwanted results.
- ///
- /// Function lookups are done in Module.cpp, ModuleList.cpp and in
- /// BreakpointResolverName.cpp and they all now use this class to do
- /// lookups correctly.
- //----------------------------------------------------------------------
- class LookupInfo
- {
- public:
- LookupInfo() :
- m_name(),
- m_lookup_name(),
- m_language(lldb::eLanguageTypeUnknown),
- m_name_type_mask(0),
- m_match_name_after_lookup(false)
- {
- }
-
- LookupInfo(const ConstString &name, uint32_t name_type_mask, lldb::LanguageType language);
-
- const ConstString &
- GetName() const
- {
- return m_name;
- }
-
- void
- SetName(const ConstString &name)
- {
- m_name = name;
- }
-
- const ConstString &
- GetLookupName() const
- {
- return m_lookup_name;
- }
-
- void
- SetLookupName(const ConstString &name)
- {
- m_lookup_name = name;
- }
-
- uint32_t
- GetNameTypeMask() const
- {
- return m_name_type_mask;
- }
-
- void
- SetNameTypeMask(uint32_t mask)
- {
- m_name_type_mask = mask;
- }
-
- void
- Prune(SymbolContextList &sc_list, size_t start_idx) const;
-
- protected:
- ConstString m_name; ///< What the user originally typed
- ConstString m_lookup_name; ///< The actual name will lookup when calling in the object or symbol file
- lldb::LanguageType m_language; ///< Limit matches to only be for this language
- uint32_t m_name_type_mask; ///< One or more bits from lldb::FunctionNameType that indicate what kind of names we are looking for
- bool m_match_name_after_lookup; ///< If \b true, then demangled names that match will need to contain "m_name" in order to be considered a match
- };
+ // Static functions that can track the lifetime of module objects.
+ // This is handy because we might have Module objects that are in
+ // shared pointers that aren't in the global module list (from
+ // ModuleList). If this is the case we need to know about it.
+ // The modules in the global list maintained by these functions
+ // can be viewed using the "target modules list" command using the
+ // "--global" (-g for short).
+ static size_t GetNumberAllocatedModules();
+
+ static Module *GetAllocatedModuleAtIndex(size_t idx);
+
+ static std::recursive_mutex &GetAllocationModuleCollectionMutex();
+
+ //------------------------------------------------------------------
+ /// Construct with file specification and architecture.
+ ///
+ /// Clients that wish to share modules with other targets should
+ /// use ModuleList::GetSharedModule().
+ ///
+ /// @param[in] file_spec
+ /// The file specification for the on disk representation of
+ /// this executable image.
+ ///
+ /// @param[in] arch
+ /// The architecture to set as the current architecture in
+ /// this module.
+ ///
+ /// @param[in] object_name
+ /// The name of an object in a module used to extract a module
+ /// within a module (.a files and modules that contain multiple
+ /// architectures).
+ ///
+ /// @param[in] object_offset
+ /// The offset within an existing module used to extract a
+ /// module within a module (.a files and modules that contain
+ /// multiple architectures).
+ //------------------------------------------------------------------
+ Module(
+ const FileSpec &file_spec, const ArchSpec &arch,
+ const ConstString *object_name = nullptr,
+ lldb::offset_t object_offset = 0,
+ const llvm::sys::TimePoint<> &object_mod_time = llvm::sys::TimePoint<>());
+
+ Module(const ModuleSpec &module_spec);
+
+ static lldb::ModuleSP
+ CreateJITModule(const lldb::ObjectFileJITDelegateSP &delegate_sp);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ //------------------------------------------------------------------
+ ~Module() override;
+
+ bool MatchesModuleSpec(const ModuleSpec &module_ref);
+
+ //------------------------------------------------------------------
+ /// Set the load address for all sections in a module to be the
+ /// file address plus \a slide.
+ ///
+ /// Many times a module will be loaded in a target with a constant
+ /// offset applied to all top level sections. This function can
+ /// set the load address for all top level sections to be the
+ /// section file address + offset.
+ ///
+ /// @param[in] target
+ /// The target in which to apply the section load addresses.
+ ///
+ /// @param[in] value
+ /// if \a value_is_offset is true, then value is the offset to
+ /// apply to all file addresses for all top level sections in
+ /// the object file as each section load address is being set.
+ /// If \a value_is_offset is false, then "value" is the new
+ /// absolute base address for the image.
+ ///
+ /// @param[in] value_is_offset
+ /// If \b true, then \a value is an offset to apply to each
+ /// file address of each top level section.
+ /// If \b false, then \a value is the image base address that
+ /// will be used to rigidly slide all loadable sections.
+ ///
+ /// @param[out] changed
+ /// If any section load addresses were changed in \a target,
+ /// then \a changed will be set to \b true. Else \a changed
+ /// will be set to false. This allows this function to be
+ /// called multiple times on the same module for the same
+ /// target. If the module hasn't moved, then \a changed will
+ /// be false and no module updated notification will need to
+ /// be sent out.
+ ///
+ /// @return
+ /// /b True if any sections were successfully loaded in \a target,
+ /// /b false otherwise.
+ //------------------------------------------------------------------
+ bool SetLoadAddress(Target &target, lldb::addr_t value, bool value_is_offset,
+ bool &changed);
+
+ //------------------------------------------------------------------
+ /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
+ ///
+ /// @see SymbolContextScope
+ //------------------------------------------------------------------
+ void CalculateSymbolContext(SymbolContext *sc) override;
+
+ lldb::ModuleSP CalculateSymbolContextModule() override;
+
+ void
+ GetDescription(Stream *s,
+ lldb::DescriptionLevel level = lldb::eDescriptionLevelFull);
+
+ //------------------------------------------------------------------
+ /// Get the module path and object name.
+ ///
+ /// Modules can refer to object files. In this case the specification
+ /// is simple and would return the path to the file:
+ ///
+ /// "/usr/lib/foo.dylib"
+ ///
+ /// Modules can be .o files inside of a BSD archive (.a file). In
+ /// this case, the object specification will look like:
+ ///
+ /// "/usr/lib/foo.a(bar.o)"
+ ///
+ /// There are many places where logging wants to log this fully
+ /// qualified specification, so we centralize this functionality
+ /// here.
+ ///
+ /// @return
+ /// The object path + object name if there is one.
+ //------------------------------------------------------------------
+ std::string GetSpecificationDescription() const;
+
+ //------------------------------------------------------------------
+ /// Dump a description of this object to a Stream.
+ ///
+ /// Dump a description of the contents of this object to the
+ /// supplied stream \a s. The dumped content will be only what has
+ /// been loaded or parsed up to this point at which this function
+ /// is called, so this is a good way to see what has been parsed
+ /// in a module.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ //------------------------------------------------------------------
+ void Dump(Stream *s);
+
+ //------------------------------------------------------------------
+ /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
+ ///
+ /// @see SymbolContextScope
+ //------------------------------------------------------------------
+ void DumpSymbolContext(Stream *s) override;
+
+ //------------------------------------------------------------------
+ /// Find a symbol in the object file's symbol table.
+ ///
+ /// @param[in] name
+ /// The name of the symbol that we are looking for.
+ ///
+ /// @param[in] symbol_type
+ /// If set to eSymbolTypeAny, find a symbol of any type that
+ /// has a name that matches \a name. If set to any other valid
+ /// SymbolType enumeration value, then search only for
+ /// symbols that match \a symbol_type.
+ ///
+ /// @return
+ /// Returns a valid symbol pointer if a symbol was found,
+ /// nullptr otherwise.
+ //------------------------------------------------------------------
+ const Symbol *FindFirstSymbolWithNameAndType(
+ const ConstString &name,
+ lldb::SymbolType symbol_type = lldb::eSymbolTypeAny);
+
+ size_t FindSymbolsWithNameAndType(const ConstString &name,
+ lldb::SymbolType symbol_type,
+ SymbolContextList &sc_list);
+
+ size_t FindSymbolsMatchingRegExAndType(const RegularExpression &regex,
+ lldb::SymbolType symbol_type,
+ SymbolContextList &sc_list);
+
+ //------------------------------------------------------------------
+ /// Find a function symbols in the object file's symbol table.
+ ///
+ /// @param[in] name
+ /// The name of the symbol that we are looking for.
+ ///
+ /// @param[in] name_type_mask
+ /// A mask that has one or more bitwise OR'ed values from the
+ /// lldb::FunctionNameType enumeration type that indicate what
+ /// kind of names we are looking for.
+ ///
+ /// @param[out] sc_list
+ /// A list to append any matching symbol contexts to.
+ ///
+ /// @return
+ /// The number of symbol contexts that were added to \a sc_list
+ //------------------------------------------------------------------
+ size_t FindFunctionSymbols(const ConstString &name, uint32_t name_type_mask,
+ SymbolContextList &sc_list);
+
+ //------------------------------------------------------------------
+ /// Find compile units by partial or full path.
+ ///
+ /// Finds all compile units that match \a path in all of the modules
+ /// and returns the results in \a sc_list.
+ ///
+ /// @param[in] path
+ /// The name of the function we are looking for.
+ ///
+ /// @param[in] append
+ /// If \b true, then append any compile units that were found
+ /// to \a sc_list. If \b false, then the \a sc_list is cleared
+ /// and the contents of \a sc_list are replaced.
+ ///
+ /// @param[out] sc_list
+ /// A symbol context list that gets filled in with all of the
+ /// matches.
+ ///
+ /// @return
+ /// The number of matches added to \a sc_list.
+ //------------------------------------------------------------------
+ size_t FindCompileUnits(const FileSpec &path, bool append,
+ SymbolContextList &sc_list);
+
+ //------------------------------------------------------------------
+ /// Find functions by name.
+ ///
+ /// If the function is an inlined function, it will have a block,
+ /// representing the inlined function, and the function will be the
+ /// containing function. If it is not inlined, then the block will
+ /// be NULL.
+ ///
+ /// @param[in] name
+ /// The name of the compile unit we are looking for.
+ ///
+ /// @param[in] namespace_decl
+ /// If valid, a namespace to search in.
+ ///
+ /// @param[in] name_type_mask
+ /// A bit mask of bits that indicate what kind of names should
+ /// be used when doing the lookup. Bits include fully qualified
+ /// names, base names, C++ methods, or ObjC selectors.
+ /// See FunctionNameType for more details.
+ ///
+ /// @param[in] append
+ /// If \b true, any matches will be appended to \a sc_list, else
+ /// matches replace the contents of \a sc_list.
+ ///
+ /// @param[out] sc_list
+ /// A symbol context list that gets filled in with all of the
+ /// matches.
+ ///
+ /// @return
+ /// The number of matches added to \a sc_list.
+ //------------------------------------------------------------------
+ size_t FindFunctions(const ConstString &name,
+ const CompilerDeclContext *parent_decl_ctx,
+ uint32_t name_type_mask, bool symbols_ok,
+ bool inlines_ok, bool append,
+ SymbolContextList &sc_list);
+
+ //------------------------------------------------------------------
+ /// Find functions by name.
+ ///
+ /// If the function is an inlined function, it will have a block,
+ /// representing the inlined function, and the function will be the
+ /// containing function. If it is not inlined, then the block will
+ /// be NULL.
+ ///
+ /// @param[in] regex
+ /// A regular expression to use when matching the name.
+ ///
+ /// @param[in] append
+ /// If \b true, any matches will be appended to \a sc_list, else
+ /// matches replace the contents of \a sc_list.
+ ///
+ /// @param[out] sc_list
+ /// A symbol context list that gets filled in with all of the
+ /// matches.
+ ///
+ /// @return
+ /// The number of matches added to \a sc_list.
+ //------------------------------------------------------------------
+ size_t FindFunctions(const RegularExpression &regex, bool symbols_ok,
+ bool inlines_ok, bool append,
+ SymbolContextList &sc_list);
+
+ //------------------------------------------------------------------
+ /// Find addresses by file/line
+ ///
+ /// @param[in] target_sp
+ /// The target the addresses are desired for.
+ ///
+ /// @param[in] file
+ /// Source file to locate.
+ ///
+ /// @param[in] line
+ /// Source line to locate.
+ ///
+ /// @param[in] function
+ /// Optional filter function. Addresses within this function will be
+ /// added to the 'local' list. All others will be added to the 'extern'
+ /// list.
+ ///
+ /// @param[out] output_local
+ /// All matching addresses within 'function'
+ ///
+ /// @param[out] output_extern
+ /// All matching addresses not within 'function'
+ void FindAddressesForLine(const lldb::TargetSP target_sp,
+ const FileSpec &file, uint32_t line,
+ Function *function,
+ std::vector<Address> &output_local,
+ std::vector<Address> &output_extern);
+
+ //------------------------------------------------------------------
+ /// Find global and static variables by name.
+ ///
+ /// @param[in] name
+ /// The name of the global or static variable we are looking
+ /// for.
+ ///
+ /// @param[in] parent_decl_ctx
+ /// If valid, a decl context that results must exist within
+ ///
+ /// @param[in] append
+ /// If \b true, any matches will be appended to \a
+ /// variable_list, else matches replace the contents of
+ /// \a variable_list.
+ ///
+ /// @param[in] max_matches
+ /// Allow the number of matches to be limited to \a
+ /// max_matches. Specify UINT32_MAX to get all possible matches.
+ ///
+ /// @param[in] variable_list
+ /// A list of variables that gets the matches appended to (if
+ /// \a append it \b true), or replace (if \a append is \b false).
+ ///
+ /// @return
+ /// The number of matches added to \a variable_list.
+ //------------------------------------------------------------------
+ size_t FindGlobalVariables(const ConstString &name,
+ const CompilerDeclContext *parent_decl_ctx,
+ bool append, size_t max_matches,
+ VariableList &variable_list);
+
+ //------------------------------------------------------------------
+ /// Find global and static variables by regular expression.
+ ///
+ /// @param[in] regex
+ /// A regular expression to use when matching the name.
+ ///
+ /// @param[in] append
+ /// If \b true, any matches will be appended to \a
+ /// variable_list, else matches replace the contents of
+ /// \a variable_list.
+ ///
+ /// @param[in] max_matches
+ /// Allow the number of matches to be limited to \a
+ /// max_matches. Specify UINT32_MAX to get all possible matches.
+ ///
+ /// @param[in] variable_list
+ /// A list of variables that gets the matches appended to (if
+ /// \a append it \b true), or replace (if \a append is \b false).
+ ///
+ /// @return
+ /// The number of matches added to \a variable_list.
+ //------------------------------------------------------------------
+ size_t FindGlobalVariables(const RegularExpression &regex, bool append,
+ size_t max_matches, VariableList &variable_list);
+
+ //------------------------------------------------------------------
+ /// Find types by name.
+ ///
+ /// Type lookups in modules go through the SymbolVendor (which will
+ /// use one or more SymbolFile subclasses). The SymbolFile needs to
+ /// be able to lookup types by basename and not the fully qualified
+ /// typename. This allows the type accelerator tables to stay small,
+ /// even with heavily templatized C++. The type search will then
+ /// narrow down the search results. If "exact_match" is true, then
+ /// the type search will only match exact type name matches. If
+ /// "exact_match" is false, the type will match as long as the base
+ /// typename matches and as long as any immediate containing
+ /// namespaces/class scopes that are specified match. So to search
+ /// for a type "d" in "b::c", the name "b::c::d" can be specified
+ /// and it will match any class/namespace "b" which contains a
+ /// class/namespace "c" which contains type "d". We do this to
+ /// allow users to not always have to specify complete scoping on
+ /// all expressions, but it also allows for exact matching when
+ /// required.
+ ///
+ /// @param[in] sc
+ /// A symbol context that scopes where to extract a type list
+ /// from.
+ ///
+ /// @param[in] type_name
+ /// The name of the type we are looking for that is a fully
+ /// or partially qualified type name.
+ ///
+ /// @param[in] exact_match
+ /// If \b true, \a type_name is fully qualified and must match
+ /// exactly. If \b false, \a type_name is a partially qualified
+ /// name where the leading namespaces or classes can be
+ /// omitted to make finding types that a user may type
+ /// easier.
+ ///
+ /// @param[out] type_list
+ /// A type list gets populated with any matches.
+ ///
+ /// @return
+ /// The number of matches added to \a type_list.
+ //------------------------------------------------------------------
+ size_t
+ FindTypes(const SymbolContext &sc, const ConstString &type_name,
+ bool exact_match, size_t max_matches,
+ llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
+ TypeList &types);
+
+ lldb::TypeSP FindFirstType(const SymbolContext &sc,
+ const ConstString &type_name, bool exact_match);
+
+ //------------------------------------------------------------------
+ /// Find types by name that are in a namespace. This function is
+ /// used by the expression parser when searches need to happen in
+ /// an exact namespace scope.
+ ///
+ /// @param[in] sc
+ /// A symbol context that scopes where to extract a type list
+ /// from.
+ ///
+ /// @param[in] type_name
+ /// The name of a type within a namespace that should not include
+ /// any qualifying namespaces (just a type basename).
+ ///
+ /// @param[in] namespace_decl
+ /// The namespace declaration that this type must exist in.
+ ///
+ /// @param[out] type_list
+ /// A type list gets populated with any matches.
+ ///
+ /// @return
+ /// The number of matches added to \a type_list.
+ //------------------------------------------------------------------
+ size_t FindTypesInNamespace(const SymbolContext &sc,
+ const ConstString &type_name,
+ const CompilerDeclContext *parent_decl_ctx,
+ size_t max_matches, TypeList &type_list);
+
+ //------------------------------------------------------------------
+ /// Get const accessor for the module architecture.
+ ///
+ /// @return
+ /// A const reference to the architecture object.
+ //------------------------------------------------------------------
+ const ArchSpec &GetArchitecture() const;
+
+ //------------------------------------------------------------------
+ /// Get const accessor for the module file specification.
+ ///
+ /// This function returns the file for the module on the host system
+ /// that is running LLDB. This can differ from the path on the
+ /// platform since we might be doing remote debugging.
+ ///
+ /// @return
+ /// A const reference to the file specification object.
+ //------------------------------------------------------------------
+ const FileSpec &GetFileSpec() const { return m_file; }
+
+ //------------------------------------------------------------------
+ /// Get accessor for the module platform file specification.
+ ///
+ /// Platform file refers to the path of the module as it is known on
+ /// the remote system on which it is being debugged. For local
+ /// debugging this is always the same as Module::GetFileSpec(). But
+ /// remote debugging might mention a file "/usr/lib/liba.dylib"
+ /// which might be locally downloaded and cached. In this case the
+ /// platform file could be something like:
+ /// "/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib"
+ /// The file could also be cached in a local developer kit directory.
+ ///
+ /// @return
+ /// A const reference to the file specification object.
+ //------------------------------------------------------------------
+ const FileSpec &GetPlatformFileSpec() const {
+ if (m_platform_file)
+ return m_platform_file;
+ return m_file;
+ }
+
+ void SetPlatformFileSpec(const FileSpec &file) { m_platform_file = file; }
+
+ const FileSpec &GetRemoteInstallFileSpec() const {
+ return m_remote_install_file;
+ }
+
+ void SetRemoteInstallFileSpec(const FileSpec &file) {
+ m_remote_install_file = file;
+ }
+
+ const FileSpec &GetSymbolFileFileSpec() const { return m_symfile_spec; }
+
+ void SetSymbolFileFileSpec(const FileSpec &file);
+
+ const llvm::sys::TimePoint<> &GetModificationTime() const {
+ return m_mod_time;
+ }
+
+ const llvm::sys::TimePoint<> &GetObjectModificationTime() const {
+ return m_object_mod_time;
+ }
+
+ void SetObjectModificationTime(const llvm::sys::TimePoint<> &mod_time) {
+ m_mod_time = mod_time;
+ }
+
+ //------------------------------------------------------------------
+ /// Tells whether this module is capable of being the main executable
+ /// for a process.
+ ///
+ /// @return
+ /// \b true if it is, \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsExecutable();
+
+ //------------------------------------------------------------------
+ /// Tells whether this module has been loaded in the target passed in.
+ /// This call doesn't distinguish between whether the module is loaded
+ /// by the dynamic loader, or by a "target module add" type call.
+ ///
+ /// @param[in] target
+ /// The target to check whether this is loaded in.
+ ///
+ /// @return
+ /// \b true if it is, \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsLoadedInTarget(Target *target);
+
+ bool LoadScriptingResourceInTarget(Target *target, Error &error,
+ Stream *feedback_stream = nullptr);
+
+ //------------------------------------------------------------------
+ /// Get the number of compile units for this module.
+ ///
+ /// @return
+ /// The number of compile units that the symbol vendor plug-in
+ /// finds.
+ //------------------------------------------------------------------
+ size_t GetNumCompileUnits();
+
+ lldb::CompUnitSP GetCompileUnitAtIndex(size_t idx);
+
+ const ConstString &GetObjectName() const;
+
+ uint64_t GetObjectOffset() const { return m_object_offset; }
+
+ //------------------------------------------------------------------
+ /// Get the object file representation for the current architecture.
+ ///
+ /// If the object file has not been located or parsed yet, this
+ /// function will find the best ObjectFile plug-in that can parse
+ /// Module::m_file.
+ ///
+ /// @return
+ /// If Module::m_file does not exist, or no plug-in was found
+ /// that can parse the file, or the object file doesn't contain
+ /// the current architecture in Module::m_arch, nullptr will be
+ /// returned, else a valid object file interface will be
+ /// returned. The returned pointer is owned by this object and
+ /// remains valid as long as the object is around.
+ //------------------------------------------------------------------
+ virtual ObjectFile *GetObjectFile();
+
+ //------------------------------------------------------------------
+ /// Get the unified section list for the module. This is the section
+ /// list created by the module's object file and any debug info and
+ /// symbol files created by the symbol vendor.
+ ///
+ /// If the symbol vendor has not been loaded yet, this function
+ /// will return the section list for the object file.
+ ///
+ /// @return
+ /// Unified module section list.
+ //------------------------------------------------------------------
+ virtual SectionList *GetSectionList();
+
+ //------------------------------------------------------------------
+ /// Notify the module that the file addresses for the Sections have
+ /// been updated.
+ ///
+ /// If the Section file addresses for a module are updated, this
+ /// method should be called. Any parts of the module, object file,
+ /// or symbol file that has cached those file addresses must invalidate
+ /// or update its cache.
+ //------------------------------------------------------------------
+ virtual void SectionFileAddressesChanged();
+
+ uint32_t GetVersion(uint32_t *versions, uint32_t num_versions);
+
+ //------------------------------------------------------------------
+ /// Load an object file from memory.
+ ///
+ /// If available, the size of the object file in memory may be
+ /// passed to avoid additional round trips to process memory.
+ /// If the size is not provided, a default value is used. This
+ /// value should be large enough to enable the ObjectFile plugins
+ /// to read the header of the object file without going back to the
+ /// process.
+ ///
+ /// @return
+ /// The object file loaded from memory or nullptr, if the operation
+ /// failed (see the `error` for more information in that case).
+ //------------------------------------------------------------------
+ ObjectFile *GetMemoryObjectFile(const lldb::ProcessSP &process_sp,
+ lldb::addr_t header_addr, Error &error,
+ size_t size_to_read = 512);
+ //------------------------------------------------------------------
+ /// Get the symbol vendor interface for the current architecture.
+ ///
+ /// If the symbol vendor file has not been located yet, this
+ /// function will find the best SymbolVendor plug-in that can
+ /// use the current object file.
+ ///
+ /// @return
+ /// If this module does not have a valid object file, or no
+ /// plug-in can be found that can use the object file, nullptr will
+ /// be returned, else a valid symbol vendor plug-in interface
+ /// will be returned. The returned pointer is owned by this
+ /// object and remains valid as long as the object is around.
+ //------------------------------------------------------------------
+ virtual SymbolVendor *
+ GetSymbolVendor(bool can_create = true,
+ lldb_private::Stream *feedback_strm = nullptr);
+
+ //------------------------------------------------------------------
+ /// Get accessor the type list for this module.
+ ///
+ /// @return
+ /// A valid type list pointer, or nullptr if there is no valid
+ /// symbol vendor for this module.
+ //------------------------------------------------------------------
+ TypeList *GetTypeList();
+
+ //------------------------------------------------------------------
+ /// Get a pointer to the UUID value contained in this object.
+ ///
+ /// If the executable image file doesn't not have a UUID value built
+ /// into the file format, an MD5 checksum of the entire file, or
+ /// slice of the file for the current architecture should be used.
+ ///
+ /// @return
+ /// A const pointer to the internal copy of the UUID value in
+ /// this module if this module has a valid UUID value, NULL
+ /// otherwise.
+ //------------------------------------------------------------------
+ const lldb_private::UUID &GetUUID();
+
+ //------------------------------------------------------------------
+ /// A debugging function that will cause everything in a module to
+ /// be parsed.
+ ///
+ /// All compile units will be parsed, along with all globals and
+ /// static variables and all functions for those compile units.
+ /// All types, scopes, local variables, static variables, global
+ /// variables, and line tables will be parsed. This can be used
+ /// prior to dumping a module to see a complete list of the
+ /// resulting debug information that gets parsed, or as a debug
+ /// function to ensure that the module can consume all of the
+ /// debug data the symbol vendor provides.
+ //------------------------------------------------------------------
+ void ParseAllDebugSymbols();
+
+ bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr);
+
+ //------------------------------------------------------------------
+ /// Resolve the symbol context for the given address.
+ ///
+ /// Tries to resolve the matching symbol context based on a lookup
+ /// from the current symbol vendor. If the lazy lookup fails,
+ /// an attempt is made to parse the eh_frame section to handle
+ /// stripped symbols. If this fails, an attempt is made to resolve
+ /// the symbol to the previous address to handle the case of a
+ /// function with a tail call.
+ ///
+ /// Use properties of the modified SymbolContext to inspect any
+ /// resolved target, module, compilation unit, symbol, function,
+ /// function block or line entry. Use the return value to determine
+ /// which of these properties have been modified.
+ ///
+ /// @param[in] so_addr
+ /// A load address to resolve.
+ ///
+ /// @param[in] resolve_scope
+ /// The scope that should be resolved (see SymbolContext::Scope).
+ /// A combination of flags from the enumeration SymbolContextItem
+ /// requesting a resolution depth. Note that the flags that are
+ /// actually resolved may be a superset of the requested flags.
+ /// For instance, eSymbolContextSymbol requires resolution of
+ /// eSymbolContextModule, and eSymbolContextFunction requires
+ /// eSymbolContextSymbol.
+ ///
+ /// @param[out] sc
+ /// The SymbolContext that is modified based on symbol resolution.
+ ///
+ /// @param[in] resolve_tail_call_address
+ /// Determines if so_addr should resolve to a symbol in the case
+ /// of a function whose last instruction is a call. In this case,
+ /// the PC can be one past the address range of the function.
+ ///
+ /// @return
+ /// The scope that has been resolved (see SymbolContext::Scope).
+ ///
+ /// @see SymbolContext::Scope
+ //------------------------------------------------------------------
+ uint32_t
+ ResolveSymbolContextForAddress(const Address &so_addr, uint32_t resolve_scope,
+ SymbolContext &sc,
+ bool resolve_tail_call_address = false);
+
+ //------------------------------------------------------------------
+ /// Resolve items in the symbol context for a given file and line.
+ ///
+ /// Tries to resolve \a file_path and \a line to a list of matching
+ /// symbol contexts.
+ ///
+ /// The line table entries contains addresses that can be used to
+ /// further resolve the values in each match: the function, block,
+ /// symbol. Care should be taken to minimize the amount of
+ /// information that is requested to only what is needed --
+ /// typically the module, compile unit, line table and line table
+ /// entry are sufficient.
+ ///
+ /// @param[in] file_path
+ /// A path to a source file to match. If \a file_path does not
+ /// specify a directory, then this query will match all files
+ /// whose base filename matches. If \a file_path does specify
+ /// a directory, the fullpath to the file must match.
+ ///
+ /// @param[in] line
+ /// The source line to match, or zero if just the compile unit
+ /// should be resolved.
+ ///
+ /// @param[in] check_inlines
+ /// Check for inline file and line number matches. This option
+ /// should be used sparingly as it will cause all line tables
+ /// for every compile unit to be parsed and searched for
+ /// matching inline file entries.
+ ///
+ /// @param[in] resolve_scope
+ /// The scope that should be resolved (see
+ /// SymbolContext::Scope).
+ ///
+ /// @param[out] sc_list
+ /// A symbol context list that gets matching symbols contexts
+ /// appended to.
+ ///
+ /// @return
+ /// The number of matches that were added to \a sc_list.
+ ///
+ /// @see SymbolContext::Scope
+ //------------------------------------------------------------------
+ uint32_t ResolveSymbolContextForFilePath(const char *file_path, uint32_t line,
+ bool check_inlines,
+ uint32_t resolve_scope,
+ SymbolContextList &sc_list);
+
+ //------------------------------------------------------------------
+ /// Resolve items in the symbol context for a given file and line.
+ ///
+ /// Tries to resolve \a file_spec and \a line to a list of matching
+ /// symbol contexts.
+ ///
+ /// The line table entries contains addresses that can be used to
+ /// further resolve the values in each match: the function, block,
+ /// symbol. Care should be taken to minimize the amount of
+ /// information that is requested to only what is needed --
+ /// typically the module, compile unit, line table and line table
+ /// entry are sufficient.
+ ///
+ /// @param[in] file_spec
+ /// A file spec to a source file to match. If \a file_path does
+ /// not specify a directory, then this query will match all
+ /// files whose base filename matches. If \a file_path does
+ /// specify a directory, the fullpath to the file must match.
+ ///
+ /// @param[in] line
+ /// The source line to match, or zero if just the compile unit
+ /// should be resolved.
+ ///
+ /// @param[in] check_inlines
+ /// Check for inline file and line number matches. This option
+ /// should be used sparingly as it will cause all line tables
+ /// for every compile unit to be parsed and searched for
+ /// matching inline file entries.
+ ///
+ /// @param[in] resolve_scope
+ /// The scope that should be resolved (see
+ /// SymbolContext::Scope).
+ ///
+ /// @param[out] sc_list
+ /// A symbol context list that gets filled in with all of the
+ /// matches.
+ ///
+ /// @return
+ /// A integer that contains SymbolContext::Scope bits set for
+ /// each item that was successfully resolved.
+ ///
+ /// @see SymbolContext::Scope
+ //------------------------------------------------------------------
+ uint32_t ResolveSymbolContextsForFileSpec(const FileSpec &file_spec,
+ uint32_t line, bool check_inlines,
+ uint32_t resolve_scope,
+ SymbolContextList &sc_list);
+
+ void SetFileSpecAndObjectName(const FileSpec &file,
+ const ConstString &object_name);
+
+ bool GetIsDynamicLinkEditor();
+
+ TypeSystem *GetTypeSystemForLanguage(lldb::LanguageType language);
+
+ // Special error functions that can do printf style formatting that will
+ // prepend the message with
+ // something appropriate for this module (like the architecture, path and
+ // object name (if any)).
+ // This centralizes code so that everyone doesn't need to format their error
+ // and log messages on
+ // their own and keeps the output a bit more consistent.
+ void LogMessage(Log *log, const char *format, ...)
+ __attribute__((format(printf, 3, 4)));
+
+ void LogMessageVerboseBacktrace(Log *log, const char *format, ...)
+ __attribute__((format(printf, 3, 4)));
+
+ void ReportWarning(const char *format, ...)
+ __attribute__((format(printf, 2, 3)));
+
+ void ReportError(const char *format, ...)
+ __attribute__((format(printf, 2, 3)));
+
+ // Only report an error once when the module is first detected to be modified
+ // so we don't spam the console with many messages.
+ void ReportErrorIfModifyDetected(const char *format, ...)
+ __attribute__((format(printf, 2, 3)));
+
+ //------------------------------------------------------------------
+ // Return true if the file backing this module has changed since the
+ // module was originally created since we saved the initial file
+ // modification time when the module first gets created.
+ //------------------------------------------------------------------
+ bool FileHasChanged() const;
+
+ //------------------------------------------------------------------
+ // SymbolVendor, SymbolFile and ObjectFile member objects should
+ // lock the module mutex to avoid deadlocks.
+ //------------------------------------------------------------------
+ std::recursive_mutex &GetMutex() const { return m_mutex; }
+
+ PathMappingList &GetSourceMappingList() { return m_source_mappings; }
+
+ const PathMappingList &GetSourceMappingList() const {
+ return m_source_mappings;
+ }
+
+ //------------------------------------------------------------------
+ /// Finds a source file given a file spec using the module source
+ /// path remappings (if any).
+ ///
+ /// Tries to resolve \a orig_spec by checking the module source path
+ /// remappings. It makes sure the file exists, so this call can be
+ /// expensive if the remappings are on a network file system, so
+ /// use this function sparingly (not in a tight debug info parsing
+ /// loop).
+ ///
+ /// @param[in] orig_spec
+ /// The original source file path to try and remap.
+ ///
+ /// @param[out] new_spec
+ /// The newly remapped filespec that is guaranteed to exist.
+ ///
+ /// @return
+ /// /b true if \a orig_spec was successfully located and
+ /// \a new_spec is filled in with an existing file spec,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool FindSourceFile(const FileSpec &orig_spec, FileSpec &new_spec) const;
+
+ //------------------------------------------------------------------
+ /// Remaps a source file given \a path into \a new_path.
+ ///
+ /// Remaps \a path if any source remappings match. This function
+ /// does NOT stat the file system so it can be used in tight loops
+ /// where debug info is being parsed.
+ ///
+ /// @param[in] path
+ /// The original source file path to try and remap.
+ ///
+ /// @param[out] new_path
+ /// The newly remapped filespec that is may or may not exist.
+ ///
+ /// @return
+ /// /b true if \a path was successfully located and \a new_path
+ /// is filled in with a new source path, \b false otherwise.
+ //------------------------------------------------------------------
+ bool RemapSourceFile(llvm::StringRef path, std::string &new_path) const;
+ bool RemapSourceFile(const char *, std::string &) const = delete;
+
+ //----------------------------------------------------------------------
+ /// @class LookupInfo Module.h "lldb/Core/Module.h"
+ /// @brief A class that encapsulates name lookup information.
+ ///
+ /// Users can type a wide variety of partial names when setting
+ /// breakpoints by name or when looking for functions by name.
+ /// SymbolVendor and SymbolFile objects are only required to implement
+ /// name lookup for function basenames and for fully mangled names.
+ /// This means if the user types in a partial name, we must reduce this
+ /// to a name lookup that will work with all SymbolFile objects. So we
+ /// might reduce a name lookup to look for a basename, and then prune
+ /// out any results that don't match.
+ ///
+ /// The "m_name" member variable represents the name as it was typed
+ /// by the user. "m_lookup_name" will be the name we actually search
+ /// for through the symbol or objects files. Lanaguage is included in
+ /// case we need to filter results by language at a later date. The
+ /// "m_name_type_mask" member variable tells us what kinds of names we
+ /// are looking for and can help us prune out unwanted results.
+ ///
+ /// Function lookups are done in Module.cpp, ModuleList.cpp and in
+ /// BreakpointResolverName.cpp and they all now use this class to do
+ /// lookups correctly.
+ //----------------------------------------------------------------------
+ class LookupInfo {
+ public:
+ LookupInfo()
+ : m_name(), m_lookup_name(), m_language(lldb::eLanguageTypeUnknown),
+ m_name_type_mask(0), m_match_name_after_lookup(false) {}
+
+ LookupInfo(const ConstString &name, uint32_t name_type_mask,
+ lldb::LanguageType language);
+
+ const ConstString &GetName() const { return m_name; }
+
+ void SetName(const ConstString &name) { m_name = name; }
+
+ const ConstString &GetLookupName() const { return m_lookup_name; }
+
+ void SetLookupName(const ConstString &name) { m_lookup_name = name; }
+
+ uint32_t GetNameTypeMask() const { return m_name_type_mask; }
+
+ void SetNameTypeMask(uint32_t mask) { m_name_type_mask = mask; }
+
+ void Prune(SymbolContextList &sc_list, size_t start_idx) const;
+
+ protected:
+ ConstString m_name; ///< What the user originally typed
+ ConstString m_lookup_name; ///< The actual name will lookup when calling in
+ ///the object or symbol file
+ lldb::LanguageType
+ m_language; ///< Limit matches to only be for this language
+ uint32_t m_name_type_mask; ///< One or more bits from lldb::FunctionNameType
+ ///that indicate what kind of names we are
+ ///looking for
+ bool m_match_name_after_lookup; ///< If \b true, then demangled names that
+ ///match will need to contain "m_name" in
+ ///order to be considered a match
+ };
protected:
- //------------------------------------------------------------------
- // Member Variables
- //------------------------------------------------------------------
- mutable std::recursive_mutex m_mutex; ///< A mutex to keep this object happy in multi-threaded environments.
- TimeValue m_mod_time; ///< The modification time for this module when it was created.
- ArchSpec m_arch; ///< The architecture for this module.
- UUID m_uuid; ///< Each module is assumed to have a unique identifier to help match it up to debug symbols.
- FileSpec m_file; ///< The file representation on disk for this module (if there is one).
- FileSpec m_platform_file;///< The path to the module on the platform on which it is being debugged
- FileSpec m_remote_install_file; ///< If set when debugging on remote platforms, this module will be installed at this location
- FileSpec m_symfile_spec; ///< If this path is valid, then this is the file that _will_ be used as the symbol file for this module
- ConstString m_object_name; ///< The name an object within this module that is selected, or empty of the module is represented by \a m_file.
- uint64_t m_object_offset;
- TimeValue m_object_mod_time;
- lldb::ObjectFileSP m_objfile_sp; ///< A shared pointer to the object file parser for this module as it may or may not be shared with the SymbolFile
- lldb::SymbolVendorUP m_symfile_ap; ///< A pointer to the symbol vendor for this module.
- std::vector<lldb::SymbolVendorUP> m_old_symfiles; ///< If anyone calls Module::SetSymbolFileFileSpec() and changes the symbol file,
- ///< we need to keep all old symbol files around in case anyone has type references to them
- TypeSystemMap m_type_system_map; ///< A map of any type systems associated with this module
- PathMappingList m_source_mappings; ///< Module specific source remappings for when you have debug info for a module that doesn't match where the sources currently are
- lldb::SectionListUP m_sections_ap; ///< Unified section list for module that is used by the ObjectFile and and ObjectFile instances for the debug info
-
- std::atomic<bool> m_did_load_objfile;
- std::atomic<bool> m_did_load_symbol_vendor;
- std::atomic<bool> m_did_parse_uuid;
- mutable bool m_file_has_changed:1,
- m_first_file_changed_log:1; /// See if the module was modified after it was initially opened.
-
- //------------------------------------------------------------------
- /// Resolve a file or load virtual address.
- ///
- /// Tries to resolve \a vm_addr as a file address (if \a
- /// vm_addr_is_file_addr is true) or as a load address if \a
- /// vm_addr_is_file_addr is false) in the symbol vendor.
- /// \a resolve_scope indicates what clients wish to resolve
- /// and can be used to limit the scope of what is parsed.
- ///
- /// @param[in] vm_addr
- /// The load virtual address to resolve.
- ///
- /// @param[in] vm_addr_is_file_addr
- /// If \b true, \a vm_addr is a file address, else \a vm_addr
- /// if a load address.
- ///
- /// @param[in] resolve_scope
- /// The scope that should be resolved (see
- /// SymbolContext::Scope).
- ///
- /// @param[out] so_addr
- /// The section offset based address that got resolved if
- /// any bits are returned.
- ///
- /// @param[out] sc
- // The symbol context that has objects filled in. Each bit
- /// in the \a resolve_scope pertains to a member in the \a sc.
- ///
- /// @return
- /// A integer that contains SymbolContext::Scope bits set for
- /// each item that was successfully resolved.
- ///
- /// @see SymbolContext::Scope
- //------------------------------------------------------------------
- uint32_t
- ResolveSymbolContextForAddress (lldb::addr_t vm_addr,
- bool vm_addr_is_file_addr,
- uint32_t resolve_scope,
- Address& so_addr,
- SymbolContext& sc);
-
- void
- SymbolIndicesToSymbolContextList (Symtab *symtab,
- std::vector<uint32_t> &symbol_indexes,
- SymbolContextList &sc_list);
-
- bool
- SetArchitecture (const ArchSpec &new_arch);
-
- SectionList *
- GetUnifiedSectionList();
-
- friend class ModuleList;
- friend class ObjectFile;
- friend class SymbolFile;
+ //------------------------------------------------------------------
+ // Member Variables
+ //------------------------------------------------------------------
+ mutable std::recursive_mutex m_mutex; ///< A mutex to keep this object happy
+ ///in multi-threaded environments.
+
+ /// The modification time for this module when it was created.
+ llvm::sys::TimePoint<> m_mod_time;
+
+ ArchSpec m_arch; ///< The architecture for this module.
+ UUID m_uuid; ///< Each module is assumed to have a unique identifier to help
+ ///match it up to debug symbols.
+ FileSpec m_file; ///< The file representation on disk for this module (if
+ ///there is one).
+ FileSpec m_platform_file; ///< The path to the module on the platform on which
+ ///it is being debugged
+ FileSpec m_remote_install_file; ///< If set when debugging on remote
+ ///platforms, this module will be installed at
+ ///this location
+ FileSpec m_symfile_spec; ///< If this path is valid, then this is the file
+ ///that _will_ be used as the symbol file for this
+ ///module
+ ConstString m_object_name; ///< The name an object within this module that is
+ ///selected, or empty of the module is represented
+ ///by \a m_file.
+ uint64_t m_object_offset;
+ llvm::sys::TimePoint<> m_object_mod_time;
+ lldb::ObjectFileSP m_objfile_sp; ///< A shared pointer to the object file
+ ///parser for this module as it may or may
+ ///not be shared with the SymbolFile
+ lldb::SymbolVendorUP
+ m_symfile_ap; ///< A pointer to the symbol vendor for this module.
+ std::vector<lldb::SymbolVendorUP>
+ m_old_symfiles; ///< If anyone calls Module::SetSymbolFileFileSpec() and
+ ///changes the symbol file,
+ ///< we need to keep all old symbol files around in case anyone has type
+ ///references to them
+ TypeSystemMap m_type_system_map; ///< A map of any type systems associated
+ ///with this module
+ PathMappingList m_source_mappings; ///< Module specific source remappings for
+ ///when you have debug info for a module
+ ///that doesn't match where the sources
+ ///currently are
+ lldb::SectionListUP m_sections_ap; ///< Unified section list for module that
+ ///is used by the ObjectFile and and
+ ///ObjectFile instances for the debug info
+
+ std::atomic<bool> m_did_load_objfile{false};
+ std::atomic<bool> m_did_load_symbol_vendor{false};
+ std::atomic<bool> m_did_parse_uuid{false};
+ mutable bool m_file_has_changed : 1,
+ m_first_file_changed_log : 1; /// See if the module was modified after it
+ /// was initially opened.
+
+ //------------------------------------------------------------------
+ /// Resolve a file or load virtual address.
+ ///
+ /// Tries to resolve \a vm_addr as a file address (if \a
+ /// vm_addr_is_file_addr is true) or as a load address if \a
+ /// vm_addr_is_file_addr is false) in the symbol vendor.
+ /// \a resolve_scope indicates what clients wish to resolve
+ /// and can be used to limit the scope of what is parsed.
+ ///
+ /// @param[in] vm_addr
+ /// The load virtual address to resolve.
+ ///
+ /// @param[in] vm_addr_is_file_addr
+ /// If \b true, \a vm_addr is a file address, else \a vm_addr
+ /// if a load address.
+ ///
+ /// @param[in] resolve_scope
+ /// The scope that should be resolved (see
+ /// SymbolContext::Scope).
+ ///
+ /// @param[out] so_addr
+ /// The section offset based address that got resolved if
+ /// any bits are returned.
+ ///
+ /// @param[out] sc
+ // The symbol context that has objects filled in. Each bit
+ /// in the \a resolve_scope pertains to a member in the \a sc.
+ ///
+ /// @return
+ /// A integer that contains SymbolContext::Scope bits set for
+ /// each item that was successfully resolved.
+ ///
+ /// @see SymbolContext::Scope
+ //------------------------------------------------------------------
+ uint32_t ResolveSymbolContextForAddress(lldb::addr_t vm_addr,
+ bool vm_addr_is_file_addr,
+ uint32_t resolve_scope,
+ Address &so_addr, SymbolContext &sc);
+
+ void SymbolIndicesToSymbolContextList(Symtab *symtab,
+ std::vector<uint32_t> &symbol_indexes,
+ SymbolContextList &sc_list);
+
+ bool SetArchitecture(const ArchSpec &new_arch);
+
+ SectionList *GetUnifiedSectionList();
+
+ friend class ModuleList;
+ friend class ObjectFile;
+ friend class SymbolFile;
private:
- Module (); // Only used internally by CreateJITModule ()
-
- size_t
- FindTypes_Impl (const SymbolContext& sc,
- const ConstString &name,
- const CompilerDeclContext *parent_decl_ctx,
- bool append,
- size_t max_matches,
- llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
- TypeMap& types);
-
- DISALLOW_COPY_AND_ASSIGN (Module);
+ Module(); // Only used internally by CreateJITModule ()
+
+ size_t FindTypes_Impl(
+ const SymbolContext &sc, const ConstString &name,
+ const CompilerDeclContext *parent_decl_ctx, bool append,
+ size_t max_matches,
+ llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
+ TypeMap &types);
+
+ DISALLOW_COPY_AND_ASSIGN(Module);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/ModuleChild.h b/include/lldb/Core/ModuleChild.h
index d2a6fb0c3bc1..f47c5ca135e6 100644
--- a/include/lldb/Core/ModuleChild.h
+++ b/include/lldb/Core/ModuleChild.h
@@ -19,72 +19,67 @@ namespace lldb_private {
/// @brief A mix in class that contains a pointer back to the module
/// that owns the object which inherits from it.
//----------------------------------------------------------------------
-class ModuleChild
-{
+class ModuleChild {
public:
- //------------------------------------------------------------------
- /// Construct with owning module.
- ///
- /// @param[in] module
- /// The module that owns the object that inherits from this
- /// class.
- //------------------------------------------------------------------
- ModuleChild (const lldb::ModuleSP &module_sp);
+ //------------------------------------------------------------------
+ /// Construct with owning module.
+ ///
+ /// @param[in] module
+ /// The module that owns the object that inherits from this
+ /// class.
+ //------------------------------------------------------------------
+ ModuleChild(const lldb::ModuleSP &module_sp);
- //------------------------------------------------------------------
- /// Copy constructor.
- ///
- /// @param[in] rhs
- /// A const ModuleChild class reference to copy.
- //------------------------------------------------------------------
- ModuleChild (const ModuleChild& rhs);
+ //------------------------------------------------------------------
+ /// Copy constructor.
+ ///
+ /// @param[in] rhs
+ /// A const ModuleChild class reference to copy.
+ //------------------------------------------------------------------
+ ModuleChild(const ModuleChild &rhs);
- //------------------------------------------------------------------
- /// Destructor.
- //------------------------------------------------------------------
- ~ModuleChild();
+ //------------------------------------------------------------------
+ /// Destructor.
+ //------------------------------------------------------------------
+ ~ModuleChild();
- //------------------------------------------------------------------
- /// Assignment operator.
- ///
- /// @param[in] rhs
- /// A const ModuleChild class reference to copy.
- ///
- /// @return
- /// A const reference to this object.
- //------------------------------------------------------------------
- const ModuleChild&
- operator= (const ModuleChild& rhs);
+ //------------------------------------------------------------------
+ /// Assignment operator.
+ ///
+ /// @param[in] rhs
+ /// A const ModuleChild class reference to copy.
+ ///
+ /// @return
+ /// A const reference to this object.
+ //------------------------------------------------------------------
+ const ModuleChild &operator=(const ModuleChild &rhs);
- //------------------------------------------------------------------
- /// Get const accessor for the module pointer.
- ///
- /// @return
- /// A const pointer to the module that owns the object that
- /// inherits from this class.
- //------------------------------------------------------------------
- lldb::ModuleSP
- GetModule () const;
+ //------------------------------------------------------------------
+ /// Get const accessor for the module pointer.
+ ///
+ /// @return
+ /// A const pointer to the module that owns the object that
+ /// inherits from this class.
+ //------------------------------------------------------------------
+ lldb::ModuleSP GetModule() const;
- //------------------------------------------------------------------
- /// Set accessor for the module pointer.
- ///
- /// @param[in] module
- /// A new module that owns the object that inherits from this
- /// class.
- //------------------------------------------------------------------
- void
- SetModule (const lldb::ModuleSP &module_sp);
+ //------------------------------------------------------------------
+ /// Set accessor for the module pointer.
+ ///
+ /// @param[in] module
+ /// A new module that owns the object that inherits from this
+ /// class.
+ //------------------------------------------------------------------
+ void SetModule(const lldb::ModuleSP &module_sp);
protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- lldb::ModuleWP m_module_wp; ///< The Module that owns the object that inherits
- ///< from this class.
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ lldb::ModuleWP m_module_wp; ///< The Module that owns the object that inherits
+ ///< from this class.
};
} // namespace lldb_private
-
-#endif // liblldb_ModuleChild_h_
+#endif // liblldb_ModuleChild_h_
diff --git a/include/lldb/Core/ModuleList.h b/include/lldb/Core/ModuleList.h
index 38a91b0bf0ee..4aa16740bd74 100644
--- a/include/lldb/Core/ModuleList.h
+++ b/include/lldb/Core/ModuleList.h
@@ -19,8 +19,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Utility/Iterable.h"
+#include "lldb/lldb-private.h"
#include "llvm/ADT/DenseSet.h"
namespace lldb_private {
@@ -32,585 +32,515 @@ namespace lldb_private {
/// Modules in the module collection class are stored as reference
/// counted shared pointers to Module objects.
//----------------------------------------------------------------------
-class ModuleList
-{
+class ModuleList {
public:
- class Notifier
- {
- public:
- virtual
- ~Notifier() = default;
-
- virtual void
- ModuleAdded (const ModuleList& module_list, const lldb::ModuleSP& module_sp) = 0;
- virtual void
- ModuleRemoved (const ModuleList& module_list, const lldb::ModuleSP& module_sp) = 0;
- virtual void
- ModuleUpdated (const ModuleList& module_list, const lldb::ModuleSP& old_module_sp,
- const lldb::ModuleSP& new_module_sp) = 0;
- virtual void
- WillClearList (const ModuleList& module_list) = 0;
- };
-
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Creates an empty list of Module objects.
- //------------------------------------------------------------------
- ModuleList ();
-
- //------------------------------------------------------------------
- /// Copy Constructor.
- ///
- /// Creates a new module list object with a copy of the modules from
- /// \a rhs.
- ///
- /// @param[in] rhs
- /// Another module list object.
- //------------------------------------------------------------------
- ModuleList (const ModuleList& rhs);
-
- ModuleList (ModuleList::Notifier* notifier);
-
- //------------------------------------------------------------------
- /// Destructor.
- //------------------------------------------------------------------
- ~ModuleList ();
-
- //------------------------------------------------------------------
- /// Assignment operator.
- ///
- /// Copies the module list from \a rhs into this list.
- ///
- /// @param[in] rhs
- /// Another module list object.
- ///
- /// @return
- /// A const reference to this object.
- //------------------------------------------------------------------
- const ModuleList&
- operator= (const ModuleList& rhs);
-
- //------------------------------------------------------------------
- /// Append a module to the module list.
- ///
- /// Appends the module to the collection.
- ///
- /// @param[in] module_sp
- /// A shared pointer to a module to add to this collection.
- //------------------------------------------------------------------
- void
- Append (const lldb::ModuleSP &module_sp);
-
- //------------------------------------------------------------------
- /// Append a module to the module list and remove any equivalent
- /// modules. Equivalent modules are ones whose file, platform file
- /// and architecture matches.
- ///
- /// Replaces the module to the collection.
- ///
- /// @param[in] module_sp
- /// A shared pointer to a module to replace in this collection.
- //------------------------------------------------------------------
- void
- ReplaceEquivalent (const lldb::ModuleSP &module_sp);
-
- bool
- AppendIfNeeded (const lldb::ModuleSP &module_sp);
-
- void
- Append (const ModuleList& module_list);
-
- bool
- AppendIfNeeded (const ModuleList& module_list);
-
- bool
- ReplaceModule (const lldb::ModuleSP &old_module_sp, const lldb::ModuleSP &new_module_sp);
-
- //------------------------------------------------------------------
- /// Clear the object's state.
- ///
- /// Clears the list of modules and releases a reference to each
- /// module object and if the reference count goes to zero, the
- /// module will be deleted.
- //------------------------------------------------------------------
- void
- Clear ();
-
- //------------------------------------------------------------------
- /// Clear the object's state.
- ///
- /// Clears the list of modules and releases a reference to each
- /// module object and if the reference count goes to zero, the
- /// module will be deleted. Also release all memory that might be
- /// held by any collection classes (like std::vector)
- //------------------------------------------------------------------
- void
- Destroy();
-
- //------------------------------------------------------------------
- /// Dump the description of each module contained in this list.
- ///
- /// Dump the description of each module contained in this list to
- /// the supplied stream \a s.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- ///
- /// @see Module::Dump(Stream *) const
- //------------------------------------------------------------------
- void
- Dump (Stream *s) const;
-
- void
- LogUUIDAndPaths (Log *log, const char *prefix_cstr);
-
- std::recursive_mutex &
- GetMutex() const
- {
- return m_modules_mutex;
- }
-
- size_t
- GetIndexForModule (const Module *module) const;
-
- //------------------------------------------------------------------
- /// Get the module shared pointer for the module at index \a idx.
- ///
- /// @param[in] idx
- /// An index into this module collection.
- ///
- /// @return
- /// A shared pointer to a Module which can contain NULL if
- /// \a idx is out of range.
- ///
- /// @see ModuleList::GetSize()
- //------------------------------------------------------------------
- lldb::ModuleSP
- GetModuleAtIndex (size_t idx) const;
-
- //------------------------------------------------------------------
- /// Get the module shared pointer for the module at index \a idx without
- /// acquiring the ModuleList mutex. This MUST already have been
- /// acquired with ModuleList::GetMutex and locked for this call to be safe.
- ///
- /// @param[in] idx
- /// An index into this module collection.
- ///
- /// @return
- /// A shared pointer to a Module which can contain NULL if
- /// \a idx is out of range.
- ///
- /// @see ModuleList::GetSize()
- //------------------------------------------------------------------
- lldb::ModuleSP
- GetModuleAtIndexUnlocked (size_t idx) const;
-
- //------------------------------------------------------------------
- /// Get the module pointer for the module at index \a idx.
- ///
- /// @param[in] idx
- /// An index into this module collection.
- ///
- /// @return
- /// A pointer to a Module which can by nullptr if \a idx is out
- /// of range.
- ///
- /// @see ModuleList::GetSize()
- //------------------------------------------------------------------
- Module*
- GetModulePointerAtIndex (size_t idx) const;
-
- //------------------------------------------------------------------
- /// Get the module pointer for the module at index \a idx without
- /// acquiring the ModuleList mutex. This MUST already have been
- /// acquired with ModuleList::GetMutex and locked for this call to be safe.
- ///
- /// @param[in] idx
- /// An index into this module collection.
- ///
- /// @return
- /// A pointer to a Module which can by nullptr if \a idx is out
- /// of range.
- ///
- /// @see ModuleList::GetSize()
- //------------------------------------------------------------------
- Module*
- GetModulePointerAtIndexUnlocked (size_t idx) const;
-
- //------------------------------------------------------------------
- /// Find compile units by partial or full path.
- ///
- /// Finds all compile units that match \a path in all of the modules
- /// and returns the results in \a sc_list.
- ///
- /// @param[in] path
- /// The name of the compile unit we are looking for.
- ///
- /// @param[in] append
- /// If \b true, then append any compile units that were found
- /// to \a sc_list. If \b false, then the \a sc_list is cleared
- /// and the contents of \a sc_list are replaced.
- ///
- /// @param[out] sc_list
- /// A symbol context list that gets filled in with all of the
- /// matches.
- ///
- /// @return
- /// The number of matches added to \a sc_list.
- //------------------------------------------------------------------
- size_t
- FindCompileUnits (const FileSpec &path,
- bool append,
- SymbolContextList &sc_list) const;
-
- //------------------------------------------------------------------
- /// @see Module::FindFunctions ()
- //------------------------------------------------------------------
- size_t
- FindFunctions (const ConstString &name,
- uint32_t name_type_mask,
- bool include_symbols,
- bool include_inlines,
- bool append,
- SymbolContextList &sc_list) const;
-
- //------------------------------------------------------------------
- /// @see Module::FindFunctionSymbols ()
- //------------------------------------------------------------------
- size_t
- FindFunctionSymbols (const ConstString &name,
- uint32_t name_type_mask,
- SymbolContextList& sc_list);
-
- //------------------------------------------------------------------
- /// @see Module::FindFunctions ()
- //------------------------------------------------------------------
- size_t
- FindFunctions(const RegularExpression &name,
- bool include_symbols,
- bool include_inlines,
- bool append,
- SymbolContextList& sc_list);
-
- //------------------------------------------------------------------
- /// Find global and static variables by name.
- ///
- /// @param[in] name
- /// The name of the global or static variable we are looking
- /// for.
- ///
- /// @param[in] append
- /// If \b true, any matches will be appended to \a
- /// variable_list, else matches replace the contents of
- /// \a variable_list.
- ///
- /// @param[in] max_matches
- /// Allow the number of matches to be limited to \a
- /// max_matches. Specify UINT32_MAX to get all possible matches.
- ///
- /// @param[in] variable_list
- /// A list of variables that gets the matches appended to (if
- /// \a append it \b true), or replace (if \a append is \b false).
- ///
- /// @return
- /// The number of matches added to \a variable_list.
- //------------------------------------------------------------------
- size_t
- FindGlobalVariables (const ConstString &name,
- bool append,
- size_t max_matches,
- VariableList& variable_list) const;
-
- //------------------------------------------------------------------
- /// Find global and static variables by regular expression.
- ///
- /// @param[in] regex
- /// A regular expression to use when matching the name.
- ///
- /// @param[in] append
- /// If \b true, any matches will be appended to \a
- /// variable_list, else matches replace the contents of
- /// \a variable_list.
- ///
- /// @param[in] max_matches
- /// Allow the number of matches to be limited to \a
- /// max_matches. Specify UINT32_MAX to get all possible matches.
- ///
- /// @param[in] variable_list
- /// A list of variables that gets the matches appended to (if
- /// \a append it \b true), or replace (if \a append is \b false).
- ///
- /// @return
- /// The number of matches added to \a variable_list.
- //------------------------------------------------------------------
- size_t
- FindGlobalVariables (const RegularExpression& regex,
- bool append,
- size_t max_matches,
- VariableList& variable_list) const;
-
- //------------------------------------------------------------------
- /// Finds the first module whose file specification matches \a
- /// file_spec.
- ///
- /// @param[in] file_spec_ptr
- /// A file specification object to match against the Module's
- /// file specifications. If \a file_spec does not have
- /// directory information, matches will occur by matching only
- /// the basename of any modules in this list. If this value is
- /// NULL, then file specifications won't be compared when
- /// searching for matching modules.
- ///
- /// @param[in] arch_ptr
- /// The architecture to search for if non-NULL. If this value
- /// is NULL no architecture matching will be performed.
- ///
- /// @param[in] uuid_ptr
- /// The uuid to search for if non-NULL. If this value is NULL
- /// no uuid matching will be performed.
- ///
- /// @param[in] object_name
- /// An optional object name that must match as well. This value
- /// can be NULL.
- ///
- /// @param[out] matching_module_list
- /// A module list that gets filled in with any modules that
- /// match the search criteria.
- ///
- /// @return
- /// The number of matching modules found by the search.
- //------------------------------------------------------------------
- size_t
- FindModules (const ModuleSpec &module_spec,
- ModuleList& matching_module_list) const;
-
- lldb::ModuleSP
- FindModule (const Module *module_ptr) const;
-
- //------------------------------------------------------------------
- // Find a module by UUID
- //
- // The UUID value for a module is extracted from the ObjectFile and
- // is the MD5 checksum, or a smarter object file equivalent, so
- // finding modules by UUID values is very efficient and accurate.
- //------------------------------------------------------------------
- lldb::ModuleSP
- FindModule (const UUID &uuid) const;
-
- lldb::ModuleSP
- FindFirstModule (const ModuleSpec &module_spec) const;
-
- size_t
- FindSymbolsWithNameAndType (const ConstString &name,
- lldb::SymbolType symbol_type,
- SymbolContextList &sc_list,
- bool append = false) const;
-
- size_t
- FindSymbolsMatchingRegExAndType (const RegularExpression &regex,
- lldb::SymbolType symbol_type,
- SymbolContextList &sc_list,
- bool append = false) const;
-
- //------------------------------------------------------------------
- /// Find types by name.
- ///
- /// @param[in] sc
- /// A symbol context that scopes where to extract a type list
- /// from.
- ///
- /// @param[in] name
- /// The name of the type we are looking for.
- ///
- /// @param[in] append
- /// If \b true, any matches will be appended to \a
- /// variable_list, else matches replace the contents of
- /// \a variable_list.
- ///
- /// @param[in] max_matches
- /// Allow the number of matches to be limited to \a
- /// max_matches. Specify UINT32_MAX to get all possible matches.
- ///
- /// @param[in] encoding
- /// Limit the search to specific types, or get all types if
- /// set to Type::invalid.
- ///
- /// @param[in] udt_name
- /// If the encoding is a user defined type, specify the name
- /// of the user defined type ("struct", "union", "class", etc).
- ///
- /// @param[out] type_list
- /// A type list gets populated with any matches.
- ///
- /// @return
- /// The number of matches added to \a type_list.
- //------------------------------------------------------------------
- size_t
- FindTypes (const SymbolContext& sc,
- const ConstString &name,
- bool name_is_fully_qualified,
- size_t max_matches,
- llvm::DenseSet<SymbolFile *> &searched_symbol_files,
- TypeList& types) const;
-
- bool
- FindSourceFile (const FileSpec &orig_spec, FileSpec &new_spec) const;
-
-
- //------------------------------------------------------------------
- /// Find addresses by file/line
- ///
- /// @param[in] target_sp
- /// The target the addresses are desired for.
- ///
- /// @param[in] file
- /// Source file to locate.
- ///
- /// @param[in] line
- /// Source line to locate.
- ///
- /// @param[in] function
- /// Optional filter function. Addresses within this function will be
- /// added to the 'local' list. All others will be added to the 'extern' list.
- ///
- /// @param[out] output_local
- /// All matching addresses within 'function'
- ///
- /// @param[out] output_extern
- /// All matching addresses not within 'function'
- void FindAddressesForLine (const lldb::TargetSP target_sp,
- const FileSpec &file, uint32_t line,
- Function *function,
- std::vector<Address> &output_local, std::vector<Address> &output_extern);
-
-
- bool
- Remove (const lldb::ModuleSP &module_sp);
-
- size_t
- Remove (ModuleList &module_list);
-
- bool
- RemoveIfOrphaned (const Module *module_ptr);
-
- size_t
- RemoveOrphans (bool mandatory);
-
- bool
- ResolveFileAddress (lldb::addr_t vm_addr,
- Address& so_addr) const;
-
- //------------------------------------------------------------------
- /// @copydoc Module::ResolveSymbolContextForAddress (const Address &,uint32_t,SymbolContext&)
- //------------------------------------------------------------------
- uint32_t
- ResolveSymbolContextForAddress (const Address& so_addr,
- uint32_t resolve_scope,
- SymbolContext& sc) const;
-
- //------------------------------------------------------------------
- /// @copydoc Module::ResolveSymbolContextForFilePath (const char *,uint32_t,bool,uint32_t,SymbolContextList&)
- //------------------------------------------------------------------
- uint32_t
- ResolveSymbolContextForFilePath (const char *file_path,
- uint32_t line,
- bool check_inlines,
- uint32_t resolve_scope,
- SymbolContextList& sc_list) const;
-
- //------------------------------------------------------------------
- /// @copydoc Module::ResolveSymbolContextsForFileSpec (const FileSpec &,uint32_t,bool,uint32_t,SymbolContextList&)
- //------------------------------------------------------------------
- uint32_t
- ResolveSymbolContextsForFileSpec (const FileSpec &file_spec,
- uint32_t line,
- bool check_inlines,
- uint32_t resolve_scope,
- SymbolContextList& sc_list) const;
-
- //------------------------------------------------------------------
- /// Gets the size of the module list.
- ///
- /// @return
- /// The number of modules in the module list.
- //------------------------------------------------------------------
- size_t
- GetSize () const;
-
- bool
- LoadScriptingResourcesInTarget(Target *target,
- std::list<Error>& errors,
- Stream* feedback_stream = nullptr,
- bool continue_on_error = true);
-
- static bool
- ModuleIsInCache (const Module *module_ptr);
-
- static Error
- GetSharedModule (const ModuleSpec &module_spec,
- lldb::ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr,
- lldb::ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr,
- bool always_create = false);
-
- static bool
- RemoveSharedModule (lldb::ModuleSP &module_sp);
-
- static size_t
- FindSharedModules (const ModuleSpec &module_spec,
- ModuleList &matching_module_list);
-
- static size_t
- RemoveOrphanSharedModules (bool mandatory);
-
- static bool
- RemoveSharedModuleIfOrphaned (const Module *module_ptr);
-
- void
- ForEach (std::function <bool (const lldb::ModuleSP &module_sp)> const &callback) const;
+ class Notifier {
+ public:
+ virtual ~Notifier() = default;
+
+ virtual void ModuleAdded(const ModuleList &module_list,
+ const lldb::ModuleSP &module_sp) = 0;
+ virtual void ModuleRemoved(const ModuleList &module_list,
+ const lldb::ModuleSP &module_sp) = 0;
+ virtual void ModuleUpdated(const ModuleList &module_list,
+ const lldb::ModuleSP &old_module_sp,
+ const lldb::ModuleSP &new_module_sp) = 0;
+ virtual void WillClearList(const ModuleList &module_list) = 0;
+ };
+
+ //------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// Creates an empty list of Module objects.
+ //------------------------------------------------------------------
+ ModuleList();
+
+ //------------------------------------------------------------------
+ /// Copy Constructor.
+ ///
+ /// Creates a new module list object with a copy of the modules from
+ /// \a rhs.
+ ///
+ /// @param[in] rhs
+ /// Another module list object.
+ //------------------------------------------------------------------
+ ModuleList(const ModuleList &rhs);
+
+ ModuleList(ModuleList::Notifier *notifier);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ //------------------------------------------------------------------
+ ~ModuleList();
+
+ //------------------------------------------------------------------
+ /// Assignment operator.
+ ///
+ /// Copies the module list from \a rhs into this list.
+ ///
+ /// @param[in] rhs
+ /// Another module list object.
+ ///
+ /// @return
+ /// A const reference to this object.
+ //------------------------------------------------------------------
+ const ModuleList &operator=(const ModuleList &rhs);
+
+ //------------------------------------------------------------------
+ /// Append a module to the module list.
+ ///
+ /// Appends the module to the collection.
+ ///
+ /// @param[in] module_sp
+ /// A shared pointer to a module to add to this collection.
+ //------------------------------------------------------------------
+ void Append(const lldb::ModuleSP &module_sp);
+
+ //------------------------------------------------------------------
+ /// Append a module to the module list and remove any equivalent
+ /// modules. Equivalent modules are ones whose file, platform file
+ /// and architecture matches.
+ ///
+ /// Replaces the module to the collection.
+ ///
+ /// @param[in] module_sp
+ /// A shared pointer to a module to replace in this collection.
+ //------------------------------------------------------------------
+ void ReplaceEquivalent(const lldb::ModuleSP &module_sp);
+
+ bool AppendIfNeeded(const lldb::ModuleSP &module_sp);
+
+ void Append(const ModuleList &module_list);
+
+ bool AppendIfNeeded(const ModuleList &module_list);
+
+ bool ReplaceModule(const lldb::ModuleSP &old_module_sp,
+ const lldb::ModuleSP &new_module_sp);
+
+ //------------------------------------------------------------------
+ /// Clear the object's state.
+ ///
+ /// Clears the list of modules and releases a reference to each
+ /// module object and if the reference count goes to zero, the
+ /// module will be deleted.
+ //------------------------------------------------------------------
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Clear the object's state.
+ ///
+ /// Clears the list of modules and releases a reference to each
+ /// module object and if the reference count goes to zero, the
+ /// module will be deleted. Also release all memory that might be
+ /// held by any collection classes (like std::vector)
+ //------------------------------------------------------------------
+ void Destroy();
+
+ //------------------------------------------------------------------
+ /// Dump the description of each module contained in this list.
+ ///
+ /// Dump the description of each module contained in this list to
+ /// the supplied stream \a s.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ ///
+ /// @see Module::Dump(Stream *) const
+ //------------------------------------------------------------------
+ void Dump(Stream *s) const;
+
+ void LogUUIDAndPaths(Log *log, const char *prefix_cstr);
+
+ std::recursive_mutex &GetMutex() const { return m_modules_mutex; }
+
+ size_t GetIndexForModule(const Module *module) const;
+
+ //------------------------------------------------------------------
+ /// Get the module shared pointer for the module at index \a idx.
+ ///
+ /// @param[in] idx
+ /// An index into this module collection.
+ ///
+ /// @return
+ /// A shared pointer to a Module which can contain NULL if
+ /// \a idx is out of range.
+ ///
+ /// @see ModuleList::GetSize()
+ //------------------------------------------------------------------
+ lldb::ModuleSP GetModuleAtIndex(size_t idx) const;
+
+ //------------------------------------------------------------------
+ /// Get the module shared pointer for the module at index \a idx without
+ /// acquiring the ModuleList mutex. This MUST already have been
+ /// acquired with ModuleList::GetMutex and locked for this call to be safe.
+ ///
+ /// @param[in] idx
+ /// An index into this module collection.
+ ///
+ /// @return
+ /// A shared pointer to a Module which can contain NULL if
+ /// \a idx is out of range.
+ ///
+ /// @see ModuleList::GetSize()
+ //------------------------------------------------------------------
+ lldb::ModuleSP GetModuleAtIndexUnlocked(size_t idx) const;
+
+ //------------------------------------------------------------------
+ /// Get the module pointer for the module at index \a idx.
+ ///
+ /// @param[in] idx
+ /// An index into this module collection.
+ ///
+ /// @return
+ /// A pointer to a Module which can by nullptr if \a idx is out
+ /// of range.
+ ///
+ /// @see ModuleList::GetSize()
+ //------------------------------------------------------------------
+ Module *GetModulePointerAtIndex(size_t idx) const;
+
+ //------------------------------------------------------------------
+ /// Get the module pointer for the module at index \a idx without
+ /// acquiring the ModuleList mutex. This MUST already have been
+ /// acquired with ModuleList::GetMutex and locked for this call to be safe.
+ ///
+ /// @param[in] idx
+ /// An index into this module collection.
+ ///
+ /// @return
+ /// A pointer to a Module which can by nullptr if \a idx is out
+ /// of range.
+ ///
+ /// @see ModuleList::GetSize()
+ //------------------------------------------------------------------
+ Module *GetModulePointerAtIndexUnlocked(size_t idx) const;
+
+ //------------------------------------------------------------------
+ /// Find compile units by partial or full path.
+ ///
+ /// Finds all compile units that match \a path in all of the modules
+ /// and returns the results in \a sc_list.
+ ///
+ /// @param[in] path
+ /// The name of the compile unit we are looking for.
+ ///
+ /// @param[in] append
+ /// If \b true, then append any compile units that were found
+ /// to \a sc_list. If \b false, then the \a sc_list is cleared
+ /// and the contents of \a sc_list are replaced.
+ ///
+ /// @param[out] sc_list
+ /// A symbol context list that gets filled in with all of the
+ /// matches.
+ ///
+ /// @return
+ /// The number of matches added to \a sc_list.
+ //------------------------------------------------------------------
+ size_t FindCompileUnits(const FileSpec &path, bool append,
+ SymbolContextList &sc_list) const;
+
+ //------------------------------------------------------------------
+ /// @see Module::FindFunctions ()
+ //------------------------------------------------------------------
+ size_t FindFunctions(const ConstString &name, uint32_t name_type_mask,
+ bool include_symbols, bool include_inlines, bool append,
+ SymbolContextList &sc_list) const;
+
+ //------------------------------------------------------------------
+ /// @see Module::FindFunctionSymbols ()
+ //------------------------------------------------------------------
+ size_t FindFunctionSymbols(const ConstString &name, uint32_t name_type_mask,
+ SymbolContextList &sc_list);
+
+ //------------------------------------------------------------------
+ /// @see Module::FindFunctions ()
+ //------------------------------------------------------------------
+ size_t FindFunctions(const RegularExpression &name, bool include_symbols,
+ bool include_inlines, bool append,
+ SymbolContextList &sc_list);
+
+ //------------------------------------------------------------------
+ /// Find global and static variables by name.
+ ///
+ /// @param[in] name
+ /// The name of the global or static variable we are looking
+ /// for.
+ ///
+ /// @param[in] append
+ /// If \b true, any matches will be appended to \a
+ /// variable_list, else matches replace the contents of
+ /// \a variable_list.
+ ///
+ /// @param[in] max_matches
+ /// Allow the number of matches to be limited to \a
+ /// max_matches. Specify UINT32_MAX to get all possible matches.
+ ///
+ /// @param[in] variable_list
+ /// A list of variables that gets the matches appended to (if
+ /// \a append it \b true), or replace (if \a append is \b false).
+ ///
+ /// @return
+ /// The number of matches added to \a variable_list.
+ //------------------------------------------------------------------
+ size_t FindGlobalVariables(const ConstString &name, bool append,
+ size_t max_matches,
+ VariableList &variable_list) const;
+
+ //------------------------------------------------------------------
+ /// Find global and static variables by regular expression.
+ ///
+ /// @param[in] regex
+ /// A regular expression to use when matching the name.
+ ///
+ /// @param[in] append
+ /// If \b true, any matches will be appended to \a
+ /// variable_list, else matches replace the contents of
+ /// \a variable_list.
+ ///
+ /// @param[in] max_matches
+ /// Allow the number of matches to be limited to \a
+ /// max_matches. Specify UINT32_MAX to get all possible matches.
+ ///
+ /// @param[in] variable_list
+ /// A list of variables that gets the matches appended to (if
+ /// \a append it \b true), or replace (if \a append is \b false).
+ ///
+ /// @return
+ /// The number of matches added to \a variable_list.
+ //------------------------------------------------------------------
+ size_t FindGlobalVariables(const RegularExpression &regex, bool append,
+ size_t max_matches,
+ VariableList &variable_list) const;
+
+ //------------------------------------------------------------------
+ /// Finds the first module whose file specification matches \a
+ /// file_spec.
+ ///
+ /// @param[in] file_spec_ptr
+ /// A file specification object to match against the Module's
+ /// file specifications. If \a file_spec does not have
+ /// directory information, matches will occur by matching only
+ /// the basename of any modules in this list. If this value is
+ /// NULL, then file specifications won't be compared when
+ /// searching for matching modules.
+ ///
+ /// @param[in] arch_ptr
+ /// The architecture to search for if non-NULL. If this value
+ /// is NULL no architecture matching will be performed.
+ ///
+ /// @param[in] uuid_ptr
+ /// The uuid to search for if non-NULL. If this value is NULL
+ /// no uuid matching will be performed.
+ ///
+ /// @param[in] object_name
+ /// An optional object name that must match as well. This value
+ /// can be NULL.
+ ///
+ /// @param[out] matching_module_list
+ /// A module list that gets filled in with any modules that
+ /// match the search criteria.
+ ///
+ /// @return
+ /// The number of matching modules found by the search.
+ //------------------------------------------------------------------
+ size_t FindModules(const ModuleSpec &module_spec,
+ ModuleList &matching_module_list) const;
+
+ lldb::ModuleSP FindModule(const Module *module_ptr) const;
+
+ //------------------------------------------------------------------
+ // Find a module by UUID
+ //
+ // The UUID value for a module is extracted from the ObjectFile and
+ // is the MD5 checksum, or a smarter object file equivalent, so
+ // finding modules by UUID values is very efficient and accurate.
+ //------------------------------------------------------------------
+ lldb::ModuleSP FindModule(const UUID &uuid) const;
+
+ lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const;
+
+ size_t FindSymbolsWithNameAndType(const ConstString &name,
+ lldb::SymbolType symbol_type,
+ SymbolContextList &sc_list,
+ bool append = false) const;
+
+ size_t FindSymbolsMatchingRegExAndType(const RegularExpression &regex,
+ lldb::SymbolType symbol_type,
+ SymbolContextList &sc_list,
+ bool append = false) const;
+
+ //------------------------------------------------------------------
+ /// Find types by name.
+ ///
+ /// @param[in] sc
+ /// A symbol context that scopes where to extract a type list
+ /// from.
+ ///
+ /// @param[in] name
+ /// The name of the type we are looking for.
+ ///
+ /// @param[in] append
+ /// If \b true, any matches will be appended to \a
+ /// variable_list, else matches replace the contents of
+ /// \a variable_list.
+ ///
+ /// @param[in] max_matches
+ /// Allow the number of matches to be limited to \a
+ /// max_matches. Specify UINT32_MAX to get all possible matches.
+ ///
+ /// @param[in] encoding
+ /// Limit the search to specific types, or get all types if
+ /// set to Type::invalid.
+ ///
+ /// @param[in] udt_name
+ /// If the encoding is a user defined type, specify the name
+ /// of the user defined type ("struct", "union", "class", etc).
+ ///
+ /// @param[out] type_list
+ /// A type list gets populated with any matches.
+ ///
+ /// @return
+ /// The number of matches added to \a type_list.
+ //------------------------------------------------------------------
+ size_t FindTypes(const SymbolContext &sc, const ConstString &name,
+ bool name_is_fully_qualified, size_t max_matches,
+ llvm::DenseSet<SymbolFile *> &searched_symbol_files,
+ TypeList &types) const;
+
+ bool FindSourceFile(const FileSpec &orig_spec, FileSpec &new_spec) const;
+
+ //------------------------------------------------------------------
+ /// Find addresses by file/line
+ ///
+ /// @param[in] target_sp
+ /// The target the addresses are desired for.
+ ///
+ /// @param[in] file
+ /// Source file to locate.
+ ///
+ /// @param[in] line
+ /// Source line to locate.
+ ///
+ /// @param[in] function
+ /// Optional filter function. Addresses within this function will be
+ /// added to the 'local' list. All others will be added to the 'extern'
+ /// list.
+ ///
+ /// @param[out] output_local
+ /// All matching addresses within 'function'
+ ///
+ /// @param[out] output_extern
+ /// All matching addresses not within 'function'
+ void FindAddressesForLine(const lldb::TargetSP target_sp,
+ const FileSpec &file, uint32_t line,
+ Function *function,
+ std::vector<Address> &output_local,
+ std::vector<Address> &output_extern);
+
+ bool Remove(const lldb::ModuleSP &module_sp);
+
+ size_t Remove(ModuleList &module_list);
+
+ bool RemoveIfOrphaned(const Module *module_ptr);
+
+ size_t RemoveOrphans(bool mandatory);
+
+ bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr) const;
+
+ //------------------------------------------------------------------
+ /// @copydoc Module::ResolveSymbolContextForAddress (const Address
+ /// &,uint32_t,SymbolContext&)
+ //------------------------------------------------------------------
+ uint32_t ResolveSymbolContextForAddress(const Address &so_addr,
+ uint32_t resolve_scope,
+ SymbolContext &sc) const;
+
+ //------------------------------------------------------------------
+ /// @copydoc Module::ResolveSymbolContextForFilePath (const char
+ /// *,uint32_t,bool,uint32_t,SymbolContextList&)
+ //------------------------------------------------------------------
+ uint32_t ResolveSymbolContextForFilePath(const char *file_path, uint32_t line,
+ bool check_inlines,
+ uint32_t resolve_scope,
+ SymbolContextList &sc_list) const;
+
+ //------------------------------------------------------------------
+ /// @copydoc Module::ResolveSymbolContextsForFileSpec (const FileSpec
+ /// &,uint32_t,bool,uint32_t,SymbolContextList&)
+ //------------------------------------------------------------------
+ uint32_t ResolveSymbolContextsForFileSpec(const FileSpec &file_spec,
+ uint32_t line, bool check_inlines,
+ uint32_t resolve_scope,
+ SymbolContextList &sc_list) const;
+
+ //------------------------------------------------------------------
+ /// Gets the size of the module list.
+ ///
+ /// @return
+ /// The number of modules in the module list.
+ //------------------------------------------------------------------
+ size_t GetSize() const;
+
+ bool LoadScriptingResourcesInTarget(Target *target, std::list<Error> &errors,
+ Stream *feedback_stream = nullptr,
+ bool continue_on_error = true);
+
+ static bool ModuleIsInCache(const Module *module_ptr);
+
+ static Error GetSharedModule(const ModuleSpec &module_spec,
+ lldb::ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr,
+ lldb::ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr,
+ bool always_create = false);
+
+ static bool RemoveSharedModule(lldb::ModuleSP &module_sp);
+
+ static size_t FindSharedModules(const ModuleSpec &module_spec,
+ ModuleList &matching_module_list);
+
+ static size_t RemoveOrphanSharedModules(bool mandatory);
+
+ static bool RemoveSharedModuleIfOrphaned(const Module *module_ptr);
+
+ void ForEach(std::function<bool(const lldb::ModuleSP &module_sp)> const
+ &callback) const;
protected:
- //------------------------------------------------------------------
- // Class typedefs.
- //------------------------------------------------------------------
- typedef std::vector<lldb::ModuleSP> collection; ///< The module collection type.
-
- void
- AppendImpl (const lldb::ModuleSP &module_sp, bool use_notifier = true);
-
- bool
- RemoveImpl (const lldb::ModuleSP &module_sp, bool use_notifier = true);
-
- collection::iterator
- RemoveImpl (collection::iterator pos, bool use_notifier = true);
-
- void
- ClearImpl (bool use_notifier = true);
-
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- collection m_modules; ///< The collection of modules.
- mutable std::recursive_mutex m_modules_mutex;
-
- Notifier* m_notifier;
-
+ //------------------------------------------------------------------
+ // Class typedefs.
+ //------------------------------------------------------------------
+ typedef std::vector<lldb::ModuleSP>
+ collection; ///< The module collection type.
+
+ void AppendImpl(const lldb::ModuleSP &module_sp, bool use_notifier = true);
+
+ bool RemoveImpl(const lldb::ModuleSP &module_sp, bool use_notifier = true);
+
+ collection::iterator RemoveImpl(collection::iterator pos,
+ bool use_notifier = true);
+
+ void ClearImpl(bool use_notifier = true);
+
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ collection m_modules; ///< The collection of modules.
+ mutable std::recursive_mutex m_modules_mutex;
+
+ Notifier *m_notifier;
+
public:
- typedef LockingAdaptedIterable<collection, lldb::ModuleSP, vector_adapter, std::recursive_mutex> ModuleIterable;
- ModuleIterable
- Modules()
- {
- return ModuleIterable(m_modules, GetMutex());
- }
-
- typedef AdaptedIterable<collection, lldb::ModuleSP, vector_adapter> ModuleIterableNoLocking;
- ModuleIterableNoLocking
- ModulesNoLocking ()
- {
- return ModuleIterableNoLocking(m_modules);
- }
+ typedef LockingAdaptedIterable<collection, lldb::ModuleSP, vector_adapter,
+ std::recursive_mutex>
+ ModuleIterable;
+ ModuleIterable Modules() { return ModuleIterable(m_modules, GetMutex()); }
+
+ typedef AdaptedIterable<collection, lldb::ModuleSP, vector_adapter>
+ ModuleIterableNoLocking;
+ ModuleIterableNoLocking ModulesNoLocking() {
+ return ModuleIterableNoLocking(m_modules);
+ }
};
} // namespace lldb_private
diff --git a/include/lldb/Core/ModuleSpec.h b/include/lldb/Core/ModuleSpec.h
index 245cb2365b2e..6a9e60482b91 100644
--- a/include/lldb/Core/ModuleSpec.h
+++ b/include/lldb/Core/ModuleSpec.h
@@ -10,12 +10,6 @@
#ifndef liblldb_ModuleSpec_h_
#define liblldb_ModuleSpec_h_
-// C Includes
-// C++ Includes
-#include <mutex>
-#include <vector>
-
-// Other libraries and framework includes
// Project includes
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Stream.h"
@@ -23,577 +17,407 @@
#include "lldb/Host/FileSpec.h"
#include "lldb/Target/PathMappingList.h"
-namespace lldb_private {
-
-class ModuleSpec
-{
-public:
- ModuleSpec () :
- m_file (),
- m_platform_file (),
- m_symbol_file (),
- m_arch (),
- m_uuid (),
- m_object_name (),
- m_object_offset (0),
- m_object_size (0),
- m_object_mod_time (),
- m_source_mappings ()
- {
- }
-
- ModuleSpec (const FileSpec &file_spec) :
- m_file (file_spec),
- m_platform_file (),
- m_symbol_file (),
- m_arch (),
- m_uuid (),
- m_object_name (),
- m_object_offset (0),
- m_object_size (file_spec.GetByteSize ()),
- m_object_mod_time (),
- m_source_mappings ()
- {
- }
-
- ModuleSpec (const FileSpec &file_spec, const ArchSpec &arch) :
- m_file (file_spec),
- m_platform_file (),
- m_symbol_file (),
- m_arch (arch),
- m_uuid (),
- m_object_name (),
- m_object_offset (0),
- m_object_size (file_spec.GetByteSize ()),
- m_object_mod_time (),
- m_source_mappings ()
- {
- }
-
- ModuleSpec (const ModuleSpec &rhs) :
- m_file (rhs.m_file),
- m_platform_file (rhs.m_platform_file),
- m_symbol_file (rhs.m_symbol_file),
- m_arch (rhs.m_arch),
- m_uuid (rhs.m_uuid),
- m_object_name (rhs.m_object_name),
- m_object_offset (rhs.m_object_offset),
- m_object_size (rhs.m_object_size),
- m_object_mod_time (rhs.m_object_mod_time),
- m_source_mappings (rhs.m_source_mappings)
- {
- }
-
- ModuleSpec &
- operator = (const ModuleSpec &rhs)
- {
- if (this != &rhs)
- {
- m_file = rhs.m_file;
- m_platform_file = rhs.m_platform_file;
- m_symbol_file = rhs.m_symbol_file;
- m_arch = rhs.m_arch;
- m_uuid = rhs.m_uuid;
- m_object_name = rhs.m_object_name;
- m_object_offset = rhs.m_object_offset;
- m_object_size = rhs.m_object_size;
- m_object_mod_time = rhs.m_object_mod_time;
- m_source_mappings = rhs.m_source_mappings;
- }
- return *this;
- }
-
- FileSpec *
- GetFileSpecPtr ()
- {
- return (m_file ? &m_file : nullptr);
- }
-
- const FileSpec *
- GetFileSpecPtr () const
- {
- return (m_file ? &m_file : nullptr);
- }
-
- FileSpec &
- GetFileSpec ()
- {
- return m_file;
- }
-
- const FileSpec &
- GetFileSpec () const
- {
- return m_file;
- }
-
- FileSpec *
- GetPlatformFileSpecPtr ()
- {
- return (m_platform_file ? &m_platform_file : nullptr);
- }
-
- const FileSpec *
- GetPlatformFileSpecPtr () const
- {
- return (m_platform_file ? &m_platform_file : nullptr);
- }
-
- FileSpec &
- GetPlatformFileSpec ()
- {
- return m_platform_file;
- }
-
- const FileSpec &
- GetPlatformFileSpec () const
- {
- return m_platform_file;
- }
-
- FileSpec *
- GetSymbolFileSpecPtr ()
- {
- return (m_symbol_file ? &m_symbol_file : nullptr);
- }
-
- const FileSpec *
- GetSymbolFileSpecPtr () const
- {
- return (m_symbol_file ? &m_symbol_file : nullptr);
- }
-
- FileSpec &
- GetSymbolFileSpec ()
- {
- return m_symbol_file;
- }
-
- const FileSpec &
- GetSymbolFileSpec () const
- {
- return m_symbol_file;
- }
+// Other libraries and framework includes
+#include "llvm/Support/Chrono.h"
- ArchSpec *
- GetArchitecturePtr ()
- {
- return (m_arch.IsValid() ? &m_arch : nullptr);
- }
-
- const ArchSpec *
- GetArchitecturePtr () const
- {
- return (m_arch.IsValid() ? &m_arch : nullptr);
- }
-
- ArchSpec &
- GetArchitecture ()
- {
- return m_arch;
- }
-
- const ArchSpec &
- GetArchitecture () const
- {
- return m_arch;
- }
+// C Includes
+// C++ Includes
+#include <mutex>
+#include <vector>
- UUID *
- GetUUIDPtr ()
- {
- return (m_uuid.IsValid() ? &m_uuid : nullptr);
- }
-
- const UUID *
- GetUUIDPtr () const
- {
- return (m_uuid.IsValid() ? &m_uuid : nullptr);
- }
-
- UUID &
- GetUUID ()
- {
- return m_uuid;
- }
-
- const UUID &
- GetUUID () const
- {
- return m_uuid;
- }
+namespace lldb_private {
- ConstString &
- GetObjectName ()
- {
- return m_object_name;
- }
+class ModuleSpec {
+public:
+ ModuleSpec()
+ : m_file(), m_platform_file(), m_symbol_file(), m_arch(), m_uuid(),
+ m_object_name(), m_object_offset(0), m_object_size(0),
+ m_source_mappings() {}
- const ConstString &
- GetObjectName () const
- {
- return m_object_name;
- }
+ ModuleSpec(const FileSpec &file_spec)
+ : m_file(file_spec), m_platform_file(), m_symbol_file(), m_arch(),
+ m_uuid(), m_object_name(), m_object_offset(0),
+ m_object_size(file_spec.GetByteSize()), m_source_mappings() {}
- uint64_t
- GetObjectOffset () const
- {
- return m_object_offset;
- }
+ ModuleSpec(const FileSpec &file_spec, const ArchSpec &arch)
+ : m_file(file_spec), m_platform_file(), m_symbol_file(), m_arch(arch),
+ m_uuid(), m_object_name(), m_object_offset(0),
+ m_object_size(file_spec.GetByteSize()), m_source_mappings() {}
- void
- SetObjectOffset (uint64_t object_offset)
- {
- m_object_offset = object_offset;
- }
+ ModuleSpec(const ModuleSpec &rhs)
+ : m_file(rhs.m_file), m_platform_file(rhs.m_platform_file),
+ m_symbol_file(rhs.m_symbol_file), m_arch(rhs.m_arch),
+ m_uuid(rhs.m_uuid), m_object_name(rhs.m_object_name),
+ m_object_offset(rhs.m_object_offset), m_object_size(rhs.m_object_size),
+ m_object_mod_time(rhs.m_object_mod_time),
+ m_source_mappings(rhs.m_source_mappings) {}
- uint64_t
- GetObjectSize () const
- {
- return m_object_size;
+ ModuleSpec &operator=(const ModuleSpec &rhs) {
+ if (this != &rhs) {
+ m_file = rhs.m_file;
+ m_platform_file = rhs.m_platform_file;
+ m_symbol_file = rhs.m_symbol_file;
+ m_arch = rhs.m_arch;
+ m_uuid = rhs.m_uuid;
+ m_object_name = rhs.m_object_name;
+ m_object_offset = rhs.m_object_offset;
+ m_object_size = rhs.m_object_size;
+ m_object_mod_time = rhs.m_object_mod_time;
+ m_source_mappings = rhs.m_source_mappings;
}
+ return *this;
+ }
- void
- SetObjectSize (uint64_t object_size)
- {
- m_object_size = object_size;
- }
+ FileSpec *GetFileSpecPtr() { return (m_file ? &m_file : nullptr); }
- TimeValue &
- GetObjectModificationTime ()
- {
- return m_object_mod_time;
- }
-
- const TimeValue &
- GetObjectModificationTime () const
- {
- return m_object_mod_time;
- }
+ const FileSpec *GetFileSpecPtr() const {
+ return (m_file ? &m_file : nullptr);
+ }
- PathMappingList &
- GetSourceMappingList () const
- {
- return m_source_mappings;
- }
+ FileSpec &GetFileSpec() { return m_file; }
- void
- Clear ()
- {
- m_file.Clear();
- m_platform_file.Clear();
- m_symbol_file.Clear();
- m_arch.Clear();
- m_uuid.Clear();
- m_object_name.Clear();
- m_object_offset = 0;
- m_object_size = 0;
- m_source_mappings.Clear(false);
- m_object_mod_time.Clear();
+ const FileSpec &GetFileSpec() const { return m_file; }
+
+ FileSpec *GetPlatformFileSpecPtr() {
+ return (m_platform_file ? &m_platform_file : nullptr);
+ }
+
+ const FileSpec *GetPlatformFileSpecPtr() const {
+ return (m_platform_file ? &m_platform_file : nullptr);
+ }
+
+ FileSpec &GetPlatformFileSpec() { return m_platform_file; }
+
+ const FileSpec &GetPlatformFileSpec() const { return m_platform_file; }
+
+ FileSpec *GetSymbolFileSpecPtr() {
+ return (m_symbol_file ? &m_symbol_file : nullptr);
+ }
+
+ const FileSpec *GetSymbolFileSpecPtr() const {
+ return (m_symbol_file ? &m_symbol_file : nullptr);
+ }
+
+ FileSpec &GetSymbolFileSpec() { return m_symbol_file; }
+
+ const FileSpec &GetSymbolFileSpec() const { return m_symbol_file; }
+
+ ArchSpec *GetArchitecturePtr() {
+ return (m_arch.IsValid() ? &m_arch : nullptr);
+ }
+
+ const ArchSpec *GetArchitecturePtr() const {
+ return (m_arch.IsValid() ? &m_arch : nullptr);
+ }
+
+ ArchSpec &GetArchitecture() { return m_arch; }
+
+ const ArchSpec &GetArchitecture() const { return m_arch; }
+
+ UUID *GetUUIDPtr() { return (m_uuid.IsValid() ? &m_uuid : nullptr); }
+
+ const UUID *GetUUIDPtr() const {
+ return (m_uuid.IsValid() ? &m_uuid : nullptr);
+ }
+
+ UUID &GetUUID() { return m_uuid; }
+
+ const UUID &GetUUID() const { return m_uuid; }
+
+ ConstString &GetObjectName() { return m_object_name; }
+
+ const ConstString &GetObjectName() const { return m_object_name; }
+
+ uint64_t GetObjectOffset() const { return m_object_offset; }
+
+ void SetObjectOffset(uint64_t object_offset) {
+ m_object_offset = object_offset;
+ }
+
+ uint64_t GetObjectSize() const { return m_object_size; }
+
+ void SetObjectSize(uint64_t object_size) { m_object_size = object_size; }
+
+ llvm::sys::TimePoint<> &GetObjectModificationTime() {
+ return m_object_mod_time;
+ }
+
+ const llvm::sys::TimePoint<> &GetObjectModificationTime() const {
+ return m_object_mod_time;
+ }
+
+ PathMappingList &GetSourceMappingList() const { return m_source_mappings; }
+
+ void Clear() {
+ m_file.Clear();
+ m_platform_file.Clear();
+ m_symbol_file.Clear();
+ m_arch.Clear();
+ m_uuid.Clear();
+ m_object_name.Clear();
+ m_object_offset = 0;
+ m_object_size = 0;
+ m_source_mappings.Clear(false);
+ m_object_mod_time = llvm::sys::TimePoint<>();
+ }
+
+ explicit operator bool() const {
+ if (m_file)
+ return true;
+ if (m_platform_file)
+ return true;
+ if (m_symbol_file)
+ return true;
+ if (m_arch.IsValid())
+ return true;
+ if (m_uuid.IsValid())
+ return true;
+ if (m_object_name)
+ return true;
+ if (m_object_size)
+ return true;
+ if (m_object_mod_time != llvm::sys::TimePoint<>())
+ return true;
+ return false;
+ }
+
+ void Dump(Stream &strm) const {
+ bool dumped_something = false;
+ if (m_file) {
+ strm.PutCString("file = '");
+ strm << m_file;
+ strm.PutCString("'");
+ dumped_something = true;
+ }
+ if (m_platform_file) {
+ if (dumped_something)
+ strm.PutCString(", ");
+ strm.PutCString("platform_file = '");
+ strm << m_platform_file;
+ strm.PutCString("'");
+ dumped_something = true;
+ }
+ if (m_symbol_file) {
+ if (dumped_something)
+ strm.PutCString(", ");
+ strm.PutCString("symbol_file = '");
+ strm << m_symbol_file;
+ strm.PutCString("'");
+ dumped_something = true;
+ }
+ if (m_arch.IsValid()) {
+ if (dumped_something)
+ strm.PutCString(", ");
+ strm.Printf("arch = ");
+ m_arch.DumpTriple(strm);
+ dumped_something = true;
+ }
+ if (m_uuid.IsValid()) {
+ if (dumped_something)
+ strm.PutCString(", ");
+ strm.PutCString("uuid = ");
+ m_uuid.Dump(&strm);
+ dumped_something = true;
+ }
+ if (m_object_name) {
+ if (dumped_something)
+ strm.PutCString(", ");
+ strm.Printf("object_name = %s", m_object_name.GetCString());
+ dumped_something = true;
+ }
+ if (m_object_offset > 0) {
+ if (dumped_something)
+ strm.PutCString(", ");
+ strm.Printf("object_offset = %" PRIu64, m_object_offset);
+ dumped_something = true;
+ }
+ if (m_object_size > 0) {
+ if (dumped_something)
+ strm.PutCString(", ");
+ strm.Printf("object size = %" PRIu64, m_object_size);
+ dumped_something = true;
+ }
+ if (m_object_mod_time != llvm::sys::TimePoint<>()) {
+ if (dumped_something)
+ strm.PutCString(", ");
+ strm.Format("object_mod_time = {0:x+}",
+ uint64_t(llvm::sys::toTimeT(m_object_mod_time)));
+ }
+ }
+
+ bool Matches(const ModuleSpec &match_module_spec,
+ bool exact_arch_match) const {
+ if (match_module_spec.GetUUIDPtr() &&
+ match_module_spec.GetUUID() != GetUUID())
+ return false;
+ if (match_module_spec.GetObjectName() &&
+ match_module_spec.GetObjectName() != GetObjectName())
+ return false;
+ if (match_module_spec.GetFileSpecPtr()) {
+ const FileSpec &fspec = match_module_spec.GetFileSpec();
+ if (!FileSpec::Equal(fspec, GetFileSpec(),
+ fspec.GetDirectory().IsEmpty() == false))
+ return false;
}
-
- explicit operator bool () const
- {
- if (m_file)
- return true;
- if (m_platform_file)
- return true;
- if (m_symbol_file)
- return true;
- if (m_arch.IsValid())
- return true;
- if (m_uuid.IsValid())
- return true;
- if (m_object_name)
- return true;
- if (m_object_size)
- return true;
- if (m_object_mod_time.IsValid())
- return true;
+ if (GetPlatformFileSpec() && match_module_spec.GetPlatformFileSpecPtr()) {
+ const FileSpec &fspec = match_module_spec.GetPlatformFileSpec();
+ if (!FileSpec::Equal(fspec, GetPlatformFileSpec(),
+ fspec.GetDirectory().IsEmpty() == false))
return false;
}
-
- void
- Dump (Stream &strm) const
- {
- bool dumped_something = false;
- if (m_file)
- {
- strm.PutCString("file = '");
- strm << m_file;
- strm.PutCString("'");
- dumped_something = true;
- }
- if (m_platform_file)
- {
- if (dumped_something)
- strm.PutCString(", ");
- strm.PutCString("platform_file = '");
- strm << m_platform_file;
- strm.PutCString("'");
- dumped_something = true;
- }
- if (m_symbol_file)
- {
- if (dumped_something)
- strm.PutCString(", ");
- strm.PutCString("symbol_file = '");
- strm << m_symbol_file;
- strm.PutCString("'");
- dumped_something = true;
- }
- if (m_arch.IsValid())
- {
- if (dumped_something)
- strm.PutCString(", ");
- strm.Printf("arch = ");
- m_arch.DumpTriple(strm);
- dumped_something = true;
- }
- if (m_uuid.IsValid())
- {
- if (dumped_something)
- strm.PutCString(", ");
- strm.PutCString("uuid = ");
- m_uuid.Dump(&strm);
- dumped_something = true;
- }
- if (m_object_name)
- {
- if (dumped_something)
- strm.PutCString(", ");
- strm.Printf("object_name = %s", m_object_name.GetCString());
- dumped_something = true;
- }
- if (m_object_offset > 0)
- {
- if (dumped_something)
- strm.PutCString(", ");
- strm.Printf("object_offset = %" PRIu64, m_object_offset);
- dumped_something = true;
- }
- if (m_object_size > 0)
- {
- if (dumped_something)
- strm.PutCString(", ");
- strm.Printf("object size = %" PRIu64, m_object_size);
- dumped_something = true;
- }
- if (m_object_mod_time.IsValid())
- {
- if (dumped_something)
- strm.PutCString(", ");
- strm.Printf("object_mod_time = 0x%" PRIx64, m_object_mod_time.GetAsSecondsSinceJan1_1970());
- }
+ // Only match the symbol file spec if there is one in this ModuleSpec
+ if (GetSymbolFileSpec() && match_module_spec.GetSymbolFileSpecPtr()) {
+ const FileSpec &fspec = match_module_spec.GetSymbolFileSpec();
+ if (!FileSpec::Equal(fspec, GetSymbolFileSpec(),
+ fspec.GetDirectory().IsEmpty() == false))
+ return false;
}
-
- bool
- Matches (const ModuleSpec &match_module_spec, bool exact_arch_match) const
- {
- if (match_module_spec.GetUUIDPtr() && match_module_spec.GetUUID() != GetUUID())
- return false;
- if (match_module_spec.GetObjectName() && match_module_spec.GetObjectName() != GetObjectName())
- return false;
- if (match_module_spec.GetFileSpecPtr())
- {
- const FileSpec &fspec = match_module_spec.GetFileSpec();
- if (!FileSpec::Equal(fspec, GetFileSpec(), fspec.GetDirectory().IsEmpty() == false))
- return false;
- }
- if (GetPlatformFileSpec() && match_module_spec.GetPlatformFileSpecPtr())
- {
- const FileSpec &fspec = match_module_spec.GetPlatformFileSpec();
- if (!FileSpec::Equal(fspec, GetPlatformFileSpec(), fspec.GetDirectory().IsEmpty() == false))
- return false;
-
- }
- // Only match the symbol file spec if there is one in this ModuleSpec
- if (GetSymbolFileSpec() && match_module_spec.GetSymbolFileSpecPtr())
- {
- const FileSpec &fspec = match_module_spec.GetSymbolFileSpec();
- if (!FileSpec::Equal(fspec, GetSymbolFileSpec(), fspec.GetDirectory().IsEmpty() == false))
- return false;
-
- }
- if (match_module_spec.GetArchitecturePtr())
- {
- if (exact_arch_match)
- {
- if (!GetArchitecture().IsExactMatch(match_module_spec.GetArchitecture()))
- return false;
- }
- else
- {
- if (!GetArchitecture().IsCompatibleMatch(match_module_spec.GetArchitecture()))
- return false;
- }
- }
- return true;
+ if (match_module_spec.GetArchitecturePtr()) {
+ if (exact_arch_match) {
+ if (!GetArchitecture().IsExactMatch(
+ match_module_spec.GetArchitecture()))
+ return false;
+ } else {
+ if (!GetArchitecture().IsCompatibleMatch(
+ match_module_spec.GetArchitecture()))
+ return false;
+ }
}
+ return true;
+ }
protected:
- FileSpec m_file;
- FileSpec m_platform_file;
- FileSpec m_symbol_file;
- ArchSpec m_arch;
- UUID m_uuid;
- ConstString m_object_name;
- uint64_t m_object_offset;
- uint64_t m_object_size;
- TimeValue m_object_mod_time;
- mutable PathMappingList m_source_mappings;
+ FileSpec m_file;
+ FileSpec m_platform_file;
+ FileSpec m_symbol_file;
+ ArchSpec m_arch;
+ UUID m_uuid;
+ ConstString m_object_name;
+ uint64_t m_object_offset;
+ uint64_t m_object_size;
+ llvm::sys::TimePoint<> m_object_mod_time;
+ mutable PathMappingList m_source_mappings;
};
-class ModuleSpecList
-{
+class ModuleSpecList {
public:
- ModuleSpecList() : m_specs(), m_mutex() {}
-
- ModuleSpecList(const ModuleSpecList &rhs) : m_specs(), m_mutex()
- {
- std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex);
- std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex);
- m_specs = rhs.m_specs;
- }
-
- ~ModuleSpecList() = default;
-
- ModuleSpecList &
- operator=(const ModuleSpecList &rhs)
- {
- if (this != &rhs)
- {
- std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex);
- std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex);
- m_specs = rhs.m_specs;
- }
- return *this;
- }
-
- size_t
- GetSize() const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_specs.size();
- }
-
- void
- Clear()
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- m_specs.clear();
- }
-
- void
- Append(const ModuleSpec &spec)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- m_specs.push_back(spec);
- }
-
- void
- Append(const ModuleSpecList &rhs)
- {
- std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex);
- std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex);
- m_specs.insert(m_specs.end(), rhs.m_specs.begin(), rhs.m_specs.end());
- }
-
- // The index "i" must be valid and this can't be used in
- // multi-threaded code as no mutex lock is taken.
- ModuleSpec &
- GetModuleSpecRefAtIndex (size_t i)
- {
- return m_specs[i];
- }
-
- bool
- GetModuleSpecAtIndex(size_t i, ModuleSpec &module_spec) const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- if (i < m_specs.size())
- {
- module_spec = m_specs[i];
- return true;
- }
- module_spec.Clear();
- return false;
- }
-
- bool
- FindMatchingModuleSpec(const ModuleSpec &module_spec, ModuleSpec &match_module_spec) const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- bool exact_arch_match = true;
- for (auto spec : m_specs)
- {
- if (spec.Matches(module_spec, exact_arch_match))
- {
- match_module_spec = spec;
- return true;
- }
- }
-
- // If there was an architecture, retry with a compatible arch
- if (module_spec.GetArchitecturePtr())
- {
- exact_arch_match = false;
- for (auto spec : m_specs)
- {
- if (spec.Matches(module_spec, exact_arch_match))
- {
- match_module_spec = spec;
- return true;
- }
- }
- }
- match_module_spec.Clear();
- return false;
- }
-
- size_t
- FindMatchingModuleSpecs(const ModuleSpec &module_spec, ModuleSpecList &matching_list) const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- bool exact_arch_match = true;
- const size_t initial_match_count = matching_list.GetSize();
- for (auto spec : m_specs)
- {
- if (spec.Matches(module_spec, exact_arch_match))
- matching_list.Append(spec);
- }
-
- // If there was an architecture, retry with a compatible arch if no matches were found
- if (module_spec.GetArchitecturePtr() && (initial_match_count == matching_list.GetSize()))
- {
- exact_arch_match = false;
- for (auto spec : m_specs)
- {
- if (spec.Matches(module_spec, exact_arch_match))
- matching_list.Append(spec);
- }
- }
- return matching_list.GetSize() - initial_match_count;
+ ModuleSpecList() : m_specs(), m_mutex() {}
+
+ ModuleSpecList(const ModuleSpecList &rhs) : m_specs(), m_mutex() {
+ std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex);
+ std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex);
+ m_specs = rhs.m_specs;
+ }
+
+ ~ModuleSpecList() = default;
+
+ ModuleSpecList &operator=(const ModuleSpecList &rhs) {
+ if (this != &rhs) {
+ std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex);
+ std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex);
+ m_specs = rhs.m_specs;
+ }
+ return *this;
+ }
+
+ size_t GetSize() const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_specs.size();
+ }
+
+ void Clear() {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ m_specs.clear();
+ }
+
+ void Append(const ModuleSpec &spec) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ m_specs.push_back(spec);
+ }
+
+ void Append(const ModuleSpecList &rhs) {
+ std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex);
+ std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex);
+ m_specs.insert(m_specs.end(), rhs.m_specs.begin(), rhs.m_specs.end());
+ }
+
+ // The index "i" must be valid and this can't be used in
+ // multi-threaded code as no mutex lock is taken.
+ ModuleSpec &GetModuleSpecRefAtIndex(size_t i) { return m_specs[i]; }
+
+ bool GetModuleSpecAtIndex(size_t i, ModuleSpec &module_spec) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ if (i < m_specs.size()) {
+ module_spec = m_specs[i];
+ return true;
+ }
+ module_spec.Clear();
+ return false;
+ }
+
+ bool FindMatchingModuleSpec(const ModuleSpec &module_spec,
+ ModuleSpec &match_module_spec) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ bool exact_arch_match = true;
+ for (auto spec : m_specs) {
+ if (spec.Matches(module_spec, exact_arch_match)) {
+ match_module_spec = spec;
+ return true;
+ }
}
- void
- Dump(Stream &strm)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- uint32_t idx = 0;
- for (auto spec : m_specs)
- {
- strm.Printf("[%u] ", idx);
- spec.Dump(strm);
- strm.EOL();
- ++idx;
+ // If there was an architecture, retry with a compatible arch
+ if (module_spec.GetArchitecturePtr()) {
+ exact_arch_match = false;
+ for (auto spec : m_specs) {
+ if (spec.Matches(module_spec, exact_arch_match)) {
+ match_module_spec = spec;
+ return true;
}
- }
+ }
+ }
+ match_module_spec.Clear();
+ return false;
+ }
+
+ size_t FindMatchingModuleSpecs(const ModuleSpec &module_spec,
+ ModuleSpecList &matching_list) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ bool exact_arch_match = true;
+ const size_t initial_match_count = matching_list.GetSize();
+ for (auto spec : m_specs) {
+ if (spec.Matches(module_spec, exact_arch_match))
+ matching_list.Append(spec);
+ }
+
+ // If there was an architecture, retry with a compatible arch if no matches
+ // were found
+ if (module_spec.GetArchitecturePtr() &&
+ (initial_match_count == matching_list.GetSize())) {
+ exact_arch_match = false;
+ for (auto spec : m_specs) {
+ if (spec.Matches(module_spec, exact_arch_match))
+ matching_list.Append(spec);
+ }
+ }
+ return matching_list.GetSize() - initial_match_count;
+ }
+
+ void Dump(Stream &strm) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ uint32_t idx = 0;
+ for (auto spec : m_specs) {
+ strm.Printf("[%u] ", idx);
+ spec.Dump(strm);
+ strm.EOL();
+ ++idx;
+ }
+ }
protected:
- typedef std::vector<ModuleSpec> collection; ///< The module collection type.
- collection m_specs; ///< The collection of modules.
- mutable std::recursive_mutex m_mutex;
+ typedef std::vector<ModuleSpec> collection; ///< The module collection type.
+ collection m_specs; ///< The collection of modules.
+ mutable std::recursive_mutex m_mutex;
};
} // namespace lldb_private
diff --git a/include/lldb/Core/Opcode.h b/include/lldb/Core/Opcode.h
index eac0746baba1..d5376d44b814 100644
--- a/include/lldb/Core/Opcode.h
+++ b/include/lldb/Core/Opcode.h
@@ -21,266 +21,253 @@
#include "lldb/Host/Endian.h"
#include "lldb/lldb-public.h"
-namespace lldb
-{
- class SBInstruction;
+namespace lldb {
+class SBInstruction;
} // namespace lldb
namespace lldb_private {
- class Opcode
- {
- public:
- enum Type
- {
- eTypeInvalid,
- eType8,
- eType16,
- eType16_2, // a 32-bit Thumb instruction, made up of two words
- eType32,
- eType64,
- eTypeBytes
- };
-
- Opcode () : m_byte_order (lldb::eByteOrderInvalid), m_type (eTypeInvalid)
- {
- }
-
- Opcode (uint8_t inst, lldb::ByteOrder order) : m_byte_order (order), m_type (eType8)
- {
- m_data.inst8 = inst;
- }
-
- Opcode (uint16_t inst, lldb::ByteOrder order) : m_byte_order (order), m_type (eType16)
- {
- m_data.inst16 = inst;
- }
-
- Opcode (uint32_t inst, lldb::ByteOrder order) : m_byte_order (order), m_type (eType32)
- {
- m_data.inst32 = inst;
- }
-
- Opcode (uint64_t inst, lldb::ByteOrder order) : m_byte_order (order), m_type (eType64)
- {
- m_data.inst64 = inst;
- }
-
- Opcode (uint8_t *bytes, size_t length) : m_byte_order (lldb::eByteOrderInvalid)
- {
- SetOpcodeBytes (bytes, length);
- }
-
- void
- Clear()
- {
- m_byte_order = lldb::eByteOrderInvalid;
- m_type = Opcode::eTypeInvalid;
- }
-
- Opcode::Type
- GetType () const
- {
- return m_type;
- }
-
- uint8_t
- GetOpcode8 (uint8_t invalid_opcode = UINT8_MAX) const
- {
- switch (m_type)
- {
- case Opcode::eTypeInvalid: break;
- case Opcode::eType8: return m_data.inst8;
- case Opcode::eType16: break;
- case Opcode::eType16_2: break;
- case Opcode::eType32: break;
- case Opcode::eType64: break;
- case Opcode::eTypeBytes: break;
- }
- return invalid_opcode;
- }
-
- uint16_t
- GetOpcode16 (uint16_t invalid_opcode = UINT16_MAX) const
- {
- switch (m_type)
- {
- case Opcode::eTypeInvalid: break;
- case Opcode::eType8: return m_data.inst8;
- case Opcode::eType16: return GetEndianSwap() ? llvm::ByteSwap_16(m_data.inst16) : m_data.inst16;
- case Opcode::eType16_2: break;
- case Opcode::eType32: break;
- case Opcode::eType64: break;
- case Opcode::eTypeBytes: break;
- }
- return invalid_opcode;
- }
-
- uint32_t
- GetOpcode32 (uint32_t invalid_opcode = UINT32_MAX) const
- {
- switch (m_type)
- {
- case Opcode::eTypeInvalid: break;
- case Opcode::eType8: return m_data.inst8;
- case Opcode::eType16: return GetEndianSwap() ? llvm::ByteSwap_16(m_data.inst16) : m_data.inst16;
- case Opcode::eType16_2: // passthrough
- case Opcode::eType32: return GetEndianSwap() ? llvm::ByteSwap_32(m_data.inst32) : m_data.inst32;
- case Opcode::eType64: break;
- case Opcode::eTypeBytes: break;
- }
- return invalid_opcode;
- }
-
- uint64_t
- GetOpcode64 (uint64_t invalid_opcode = UINT64_MAX) const
- {
- switch (m_type)
- {
- case Opcode::eTypeInvalid: break;
- case Opcode::eType8: return m_data.inst8;
- case Opcode::eType16: return GetEndianSwap() ? llvm::ByteSwap_16(m_data.inst16) : m_data.inst16;
- case Opcode::eType16_2: // passthrough
- case Opcode::eType32: return GetEndianSwap() ? llvm::ByteSwap_32(m_data.inst32) : m_data.inst32;
- case Opcode::eType64: return GetEndianSwap() ? llvm::ByteSwap_64(m_data.inst64) : m_data.inst64;
- case Opcode::eTypeBytes: break;
- }
- return invalid_opcode;
- }
-
- void
- SetOpcode8 (uint8_t inst, lldb::ByteOrder order)
- {
- m_type = eType8;
- m_data.inst8 = inst;
- m_byte_order = order;
- }
-
- void
- SetOpcode16 (uint16_t inst, lldb::ByteOrder order)
- {
- m_type = eType16;
- m_data.inst16 = inst;
- m_byte_order = order;
- }
-
- void
- SetOpcode16_2 (uint32_t inst, lldb::ByteOrder order)
- {
- m_type = eType16_2;
- m_data.inst32 = inst;
- m_byte_order = order;
- }
-
- void
- SetOpcode32 (uint32_t inst, lldb::ByteOrder order)
- {
- m_type = eType32;
- m_data.inst32 = inst;
- m_byte_order = order;
- }
-
- void
- SetOpcode64 (uint64_t inst, lldb::ByteOrder order)
- {
- m_type = eType64;
- m_data.inst64 = inst;
- m_byte_order = order;
- }
-
- void
- SetOpcodeBytes (const void *bytes, size_t length)
- {
- if (bytes != nullptr && length > 0)
- {
- m_type = eTypeBytes;
- m_data.inst.length = length;
- assert (length < sizeof (m_data.inst.bytes));
- memcpy (m_data.inst.bytes, bytes, length);
- m_byte_order = lldb::eByteOrderInvalid;
- }
- else
- {
- m_type = eTypeInvalid;
- m_data.inst.length = 0;
- }
- }
-
- int
- Dump (Stream *s, uint32_t min_byte_width);
-
- const void *
- GetOpcodeBytes () const
- {
- return ((m_type == Opcode::eTypeBytes) ? m_data.inst.bytes : nullptr);
- }
-
- uint32_t
- GetByteSize () const
- {
- switch (m_type)
- {
- case Opcode::eTypeInvalid: break;
- case Opcode::eType8: return sizeof(m_data.inst8);
- case Opcode::eType16: return sizeof(m_data.inst16);
- case Opcode::eType16_2: // passthrough
- case Opcode::eType32: return sizeof(m_data.inst32);
- case Opcode::eType64: return sizeof(m_data.inst64);
- case Opcode::eTypeBytes: return m_data.inst.length;
- }
- return 0;
- }
-
- // Get the opcode exactly as it would be laid out in memory.
- uint32_t
- GetData (DataExtractor &data) const;
-
- protected:
-
- friend class lldb::SBInstruction;
-
- const void *
- GetOpcodeDataBytes () const
- {
- switch (m_type)
- {
- case Opcode::eTypeInvalid: break;
- case Opcode::eType8: return &m_data.inst8;
- case Opcode::eType16: return &m_data.inst16;
- case Opcode::eType16_2: // passthrough
- case Opcode::eType32: return &m_data.inst32;
- case Opcode::eType64: return &m_data.inst64;
- case Opcode::eTypeBytes: return m_data.inst.bytes;
- }
- return nullptr;
- }
-
- lldb::ByteOrder
- GetDataByteOrder () const;
-
- bool
- GetEndianSwap() const
- {
- return (m_byte_order == lldb::eByteOrderBig && endian::InlHostByteOrder() == lldb::eByteOrderLittle) ||
- (m_byte_order == lldb::eByteOrderLittle && endian::InlHostByteOrder() == lldb::eByteOrderBig);
- }
-
- lldb::ByteOrder m_byte_order;
-
- Opcode::Type m_type;
- union
- {
- uint8_t inst8;
- uint16_t inst16;
- uint32_t inst32;
- uint64_t inst64;
- struct
- {
- uint8_t bytes[16]; // This must be big enough to handle any opcode for any supported target.
- uint8_t length;
- } inst;
- } m_data;
- };
+class Opcode {
+public:
+ enum Type {
+ eTypeInvalid,
+ eType8,
+ eType16,
+ eType16_2, // a 32-bit Thumb instruction, made up of two words
+ eType32,
+ eType64,
+ eTypeBytes
+ };
+
+ Opcode() : m_byte_order(lldb::eByteOrderInvalid), m_type(eTypeInvalid) {}
+
+ Opcode(uint8_t inst, lldb::ByteOrder order)
+ : m_byte_order(order), m_type(eType8) {
+ m_data.inst8 = inst;
+ }
+
+ Opcode(uint16_t inst, lldb::ByteOrder order)
+ : m_byte_order(order), m_type(eType16) {
+ m_data.inst16 = inst;
+ }
+
+ Opcode(uint32_t inst, lldb::ByteOrder order)
+ : m_byte_order(order), m_type(eType32) {
+ m_data.inst32 = inst;
+ }
+
+ Opcode(uint64_t inst, lldb::ByteOrder order)
+ : m_byte_order(order), m_type(eType64) {
+ m_data.inst64 = inst;
+ }
+
+ Opcode(uint8_t *bytes, size_t length)
+ : m_byte_order(lldb::eByteOrderInvalid) {
+ SetOpcodeBytes(bytes, length);
+ }
+
+ void Clear() {
+ m_byte_order = lldb::eByteOrderInvalid;
+ m_type = Opcode::eTypeInvalid;
+ }
+
+ Opcode::Type GetType() const { return m_type; }
+
+ uint8_t GetOpcode8(uint8_t invalid_opcode = UINT8_MAX) const {
+ switch (m_type) {
+ case Opcode::eTypeInvalid:
+ break;
+ case Opcode::eType8:
+ return m_data.inst8;
+ case Opcode::eType16:
+ break;
+ case Opcode::eType16_2:
+ break;
+ case Opcode::eType32:
+ break;
+ case Opcode::eType64:
+ break;
+ case Opcode::eTypeBytes:
+ break;
+ }
+ return invalid_opcode;
+ }
+
+ uint16_t GetOpcode16(uint16_t invalid_opcode = UINT16_MAX) const {
+ switch (m_type) {
+ case Opcode::eTypeInvalid:
+ break;
+ case Opcode::eType8:
+ return m_data.inst8;
+ case Opcode::eType16:
+ return GetEndianSwap() ? llvm::ByteSwap_16(m_data.inst16) : m_data.inst16;
+ case Opcode::eType16_2:
+ break;
+ case Opcode::eType32:
+ break;
+ case Opcode::eType64:
+ break;
+ case Opcode::eTypeBytes:
+ break;
+ }
+ return invalid_opcode;
+ }
+
+ uint32_t GetOpcode32(uint32_t invalid_opcode = UINT32_MAX) const {
+ switch (m_type) {
+ case Opcode::eTypeInvalid:
+ break;
+ case Opcode::eType8:
+ return m_data.inst8;
+ case Opcode::eType16:
+ return GetEndianSwap() ? llvm::ByteSwap_16(m_data.inst16) : m_data.inst16;
+ case Opcode::eType16_2: // passthrough
+ case Opcode::eType32:
+ return GetEndianSwap() ? llvm::ByteSwap_32(m_data.inst32) : m_data.inst32;
+ case Opcode::eType64:
+ break;
+ case Opcode::eTypeBytes:
+ break;
+ }
+ return invalid_opcode;
+ }
+
+ uint64_t GetOpcode64(uint64_t invalid_opcode = UINT64_MAX) const {
+ switch (m_type) {
+ case Opcode::eTypeInvalid:
+ break;
+ case Opcode::eType8:
+ return m_data.inst8;
+ case Opcode::eType16:
+ return GetEndianSwap() ? llvm::ByteSwap_16(m_data.inst16) : m_data.inst16;
+ case Opcode::eType16_2: // passthrough
+ case Opcode::eType32:
+ return GetEndianSwap() ? llvm::ByteSwap_32(m_data.inst32) : m_data.inst32;
+ case Opcode::eType64:
+ return GetEndianSwap() ? llvm::ByteSwap_64(m_data.inst64) : m_data.inst64;
+ case Opcode::eTypeBytes:
+ break;
+ }
+ return invalid_opcode;
+ }
+
+ void SetOpcode8(uint8_t inst, lldb::ByteOrder order) {
+ m_type = eType8;
+ m_data.inst8 = inst;
+ m_byte_order = order;
+ }
+
+ void SetOpcode16(uint16_t inst, lldb::ByteOrder order) {
+ m_type = eType16;
+ m_data.inst16 = inst;
+ m_byte_order = order;
+ }
+
+ void SetOpcode16_2(uint32_t inst, lldb::ByteOrder order) {
+ m_type = eType16_2;
+ m_data.inst32 = inst;
+ m_byte_order = order;
+ }
+
+ void SetOpcode32(uint32_t inst, lldb::ByteOrder order) {
+ m_type = eType32;
+ m_data.inst32 = inst;
+ m_byte_order = order;
+ }
+
+ void SetOpcode64(uint64_t inst, lldb::ByteOrder order) {
+ m_type = eType64;
+ m_data.inst64 = inst;
+ m_byte_order = order;
+ }
+
+ void SetOpcodeBytes(const void *bytes, size_t length) {
+ if (bytes != nullptr && length > 0) {
+ m_type = eTypeBytes;
+ m_data.inst.length = length;
+ assert(length < sizeof(m_data.inst.bytes));
+ memcpy(m_data.inst.bytes, bytes, length);
+ m_byte_order = lldb::eByteOrderInvalid;
+ } else {
+ m_type = eTypeInvalid;
+ m_data.inst.length = 0;
+ }
+ }
+
+ int Dump(Stream *s, uint32_t min_byte_width);
+
+ const void *GetOpcodeBytes() const {
+ return ((m_type == Opcode::eTypeBytes) ? m_data.inst.bytes : nullptr);
+ }
+
+ uint32_t GetByteSize() const {
+ switch (m_type) {
+ case Opcode::eTypeInvalid:
+ break;
+ case Opcode::eType8:
+ return sizeof(m_data.inst8);
+ case Opcode::eType16:
+ return sizeof(m_data.inst16);
+ case Opcode::eType16_2: // passthrough
+ case Opcode::eType32:
+ return sizeof(m_data.inst32);
+ case Opcode::eType64:
+ return sizeof(m_data.inst64);
+ case Opcode::eTypeBytes:
+ return m_data.inst.length;
+ }
+ return 0;
+ }
+
+ // Get the opcode exactly as it would be laid out in memory.
+ uint32_t GetData(DataExtractor &data) const;
+
+protected:
+ friend class lldb::SBInstruction;
+
+ const void *GetOpcodeDataBytes() const {
+ switch (m_type) {
+ case Opcode::eTypeInvalid:
+ break;
+ case Opcode::eType8:
+ return &m_data.inst8;
+ case Opcode::eType16:
+ return &m_data.inst16;
+ case Opcode::eType16_2: // passthrough
+ case Opcode::eType32:
+ return &m_data.inst32;
+ case Opcode::eType64:
+ return &m_data.inst64;
+ case Opcode::eTypeBytes:
+ return m_data.inst.bytes;
+ }
+ return nullptr;
+ }
+
+ lldb::ByteOrder GetDataByteOrder() const;
+
+ bool GetEndianSwap() const {
+ return (m_byte_order == lldb::eByteOrderBig &&
+ endian::InlHostByteOrder() == lldb::eByteOrderLittle) ||
+ (m_byte_order == lldb::eByteOrderLittle &&
+ endian::InlHostByteOrder() == lldb::eByteOrderBig);
+ }
+
+ lldb::ByteOrder m_byte_order;
+
+ Opcode::Type m_type;
+ union {
+ uint8_t inst8;
+ uint16_t inst16;
+ uint32_t inst32;
+ uint64_t inst64;
+ struct {
+ uint8_t bytes[16]; // This must be big enough to handle any opcode for any
+ // supported target.
+ uint8_t length;
+ } inst;
+ } m_data;
+};
} // namespace lldb_private
diff --git a/include/lldb/Core/PluginInterface.h b/include/lldb/Core/PluginInterface.h
index 19371ca98601..edda15a1ace0 100644
--- a/include/lldb/Core/PluginInterface.h
+++ b/include/lldb/Core/PluginInterface.h
@@ -18,20 +18,15 @@
namespace lldb_private {
-class PluginInterface
-{
+class PluginInterface {
public:
- virtual
- ~PluginInterface () {}
+ virtual ~PluginInterface() {}
- virtual ConstString
- GetPluginName() = 0;
-
- virtual uint32_t
- GetPluginVersion() = 0;
+ virtual ConstString GetPluginName() = 0;
+ virtual uint32_t GetPluginVersion() = 0;
};
} // namespace lldb_private
-#endif // liblldb_PluginInterface_h_
+#endif // liblldb_PluginInterface_h_
diff --git a/include/lldb/Core/PluginManager.h b/include/lldb/Core/PluginManager.h
index 6f8001fbfd2b..e0de65a6bf16 100644
--- a/include/lldb/Core/PluginManager.h
+++ b/include/lldb/Core/PluginManager.h
@@ -14,523 +14,517 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Host/FileSpec.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class PluginManager
-{
+class PluginManager {
public:
- static void
- Initialize ();
-
- static void
- Terminate ();
-
- //------------------------------------------------------------------
- // ABI
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- ABICreateInstance create_callback);
-
- static bool
- UnregisterPlugin (ABICreateInstance create_callback);
-
- static ABICreateInstance
- GetABICreateCallbackAtIndex (uint32_t idx);
-
- static ABICreateInstance
- GetABICreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // Disassembler
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- DisassemblerCreateInstance create_callback);
-
- static bool
- UnregisterPlugin (DisassemblerCreateInstance create_callback);
-
- static DisassemblerCreateInstance
- GetDisassemblerCreateCallbackAtIndex (uint32_t idx);
-
- static DisassemblerCreateInstance
- GetDisassemblerCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // DynamicLoader
- //------------------------------------------------------------------
- static bool
- RegisterPlugin(const ConstString &name,
- const char *description,
- DynamicLoaderCreateInstance create_callback,
- DebuggerInitializeCallback debugger_init_callback = nullptr);
-
- static bool
- UnregisterPlugin (DynamicLoaderCreateInstance create_callback);
-
- static DynamicLoaderCreateInstance
- GetDynamicLoaderCreateCallbackAtIndex (uint32_t idx);
-
- static DynamicLoaderCreateInstance
- GetDynamicLoaderCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // JITLoader
- //------------------------------------------------------------------
- static bool
- RegisterPlugin(const ConstString &name,
- const char *description,
- JITLoaderCreateInstance create_callback,
- DebuggerInitializeCallback debugger_init_callback = nullptr);
-
- static bool
- UnregisterPlugin (JITLoaderCreateInstance create_callback);
-
- static JITLoaderCreateInstance
- GetJITLoaderCreateCallbackAtIndex (uint32_t idx);
-
- static JITLoaderCreateInstance
- GetJITLoaderCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // EmulateInstruction
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- EmulateInstructionCreateInstance create_callback);
-
- static bool
- UnregisterPlugin (EmulateInstructionCreateInstance create_callback);
-
- static EmulateInstructionCreateInstance
- GetEmulateInstructionCreateCallbackAtIndex (uint32_t idx);
-
- static EmulateInstructionCreateInstance
- GetEmulateInstructionCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // OperatingSystem
- //------------------------------------------------------------------
- static bool RegisterPlugin(const ConstString &name, const char *description,
- OperatingSystemCreateInstance create_callback,
- DebuggerInitializeCallback debugger_init_callback);
-
- static bool
- UnregisterPlugin (OperatingSystemCreateInstance create_callback);
-
- static OperatingSystemCreateInstance
- GetOperatingSystemCreateCallbackAtIndex (uint32_t idx);
-
- static OperatingSystemCreateInstance
- GetOperatingSystemCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // Language
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- LanguageCreateInstance create_callback);
-
- static bool
- UnregisterPlugin (LanguageCreateInstance create_callback);
-
- static LanguageCreateInstance
- GetLanguageCreateCallbackAtIndex (uint32_t idx);
-
- static LanguageCreateInstance
- GetLanguageCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // LanguageRuntime
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- LanguageRuntimeCreateInstance create_callback,
- LanguageRuntimeGetCommandObject command_callback = nullptr);
-
- static bool
- UnregisterPlugin (LanguageRuntimeCreateInstance create_callback);
-
- static LanguageRuntimeCreateInstance
- GetLanguageRuntimeCreateCallbackAtIndex (uint32_t idx);
-
- static LanguageRuntimeGetCommandObject
- GetLanguageRuntimeGetCommandObjectAtIndex (uint32_t idx);
-
- static LanguageRuntimeCreateInstance
- GetLanguageRuntimeCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // SystemRuntime
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- SystemRuntimeCreateInstance create_callback);
-
- static bool
- UnregisterPlugin (SystemRuntimeCreateInstance create_callback);
-
- static SystemRuntimeCreateInstance
- GetSystemRuntimeCreateCallbackAtIndex (uint32_t idx);
-
- static SystemRuntimeCreateInstance
- GetSystemRuntimeCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // ObjectFile
- //------------------------------------------------------------------
- static bool
- RegisterPlugin(const ConstString &name,
- const char *description,
- ObjectFileCreateInstance create_callback,
- ObjectFileCreateMemoryInstance create_memory_callback,
- ObjectFileGetModuleSpecifications get_module_specifications,
- ObjectFileSaveCore save_core = nullptr);
-
- static bool
- UnregisterPlugin (ObjectFileCreateInstance create_callback);
-
- static ObjectFileCreateInstance
- GetObjectFileCreateCallbackAtIndex (uint32_t idx);
-
- static ObjectFileCreateMemoryInstance
- GetObjectFileCreateMemoryCallbackAtIndex (uint32_t idx);
-
- static ObjectFileGetModuleSpecifications
- GetObjectFileGetModuleSpecificationsCallbackAtIndex (uint32_t idx);
-
- static ObjectFileCreateInstance
- GetObjectFileCreateCallbackForPluginName (const ConstString &name);
-
- static ObjectFileCreateMemoryInstance
- GetObjectFileCreateMemoryCallbackForPluginName (const ConstString &name);
-
- static Error
- SaveCore (const lldb::ProcessSP &process_sp, const FileSpec &outfile);
-
- //------------------------------------------------------------------
- // ObjectContainer
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- ObjectContainerCreateInstance create_callback,
- ObjectFileGetModuleSpecifications get_module_specifications);
-
- static bool
- UnregisterPlugin (ObjectContainerCreateInstance create_callback);
-
- static ObjectContainerCreateInstance
- GetObjectContainerCreateCallbackAtIndex (uint32_t idx);
-
- static ObjectContainerCreateInstance
- GetObjectContainerCreateCallbackForPluginName (const ConstString &name);
-
- static ObjectFileGetModuleSpecifications
- GetObjectContainerGetModuleSpecificationsCallbackAtIndex (uint32_t idx);
-
- //------------------------------------------------------------------
- // LogChannel
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- LogChannelCreateInstance create_callback);
-
- static bool
- UnregisterPlugin (LogChannelCreateInstance create_callback);
-
- static LogChannelCreateInstance
- GetLogChannelCreateCallbackAtIndex (uint32_t idx);
-
- static LogChannelCreateInstance
- GetLogChannelCreateCallbackForPluginName (const ConstString &name);
-
- static const char *
- GetLogChannelCreateNameAtIndex (uint32_t idx);
-
- //------------------------------------------------------------------
- // Platform
- //------------------------------------------------------------------
- static bool
- RegisterPlugin(const ConstString &name,
- const char *description,
- PlatformCreateInstance create_callback,
- DebuggerInitializeCallback debugger_init_callback = nullptr);
-
- static bool
- UnregisterPlugin (PlatformCreateInstance create_callback);
-
- static PlatformCreateInstance
- GetPlatformCreateCallbackAtIndex (uint32_t idx);
-
- static PlatformCreateInstance
- GetPlatformCreateCallbackForPluginName (const ConstString &name);
-
- static const char *
- GetPlatformPluginNameAtIndex (uint32_t idx);
-
- static const char *
- GetPlatformPluginDescriptionAtIndex (uint32_t idx);
-
- static size_t
- AutoCompletePlatformName (const char *partial_name,
- StringList &matches);
- //------------------------------------------------------------------
- // Process
- //------------------------------------------------------------------
- static bool
- RegisterPlugin(const ConstString &name,
- const char *description,
- ProcessCreateInstance create_callback,
- DebuggerInitializeCallback debugger_init_callback = nullptr);
-
- static bool
- UnregisterPlugin (ProcessCreateInstance create_callback);
-
- static ProcessCreateInstance
- GetProcessCreateCallbackAtIndex (uint32_t idx);
-
- static ProcessCreateInstance
- GetProcessCreateCallbackForPluginName (const ConstString &name);
-
- static const char *
- GetProcessPluginNameAtIndex (uint32_t idx);
-
- static const char *
- GetProcessPluginDescriptionAtIndex (uint32_t idx);
-
- //------------------------------------------------------------------
- // ScriptInterpreter
- //------------------------------------------------------------------
- static bool
- RegisterPlugin(const ConstString &name, const char *description, lldb::ScriptLanguage script_lang,
- ScriptInterpreterCreateInstance create_callback);
-
- static bool
- UnregisterPlugin(ScriptInterpreterCreateInstance create_callback);
-
- static ScriptInterpreterCreateInstance
- GetScriptInterpreterCreateCallbackAtIndex(uint32_t idx);
-
- static lldb::ScriptInterpreterSP
- GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang,
- CommandInterpreter &interpreter);
-
- //------------------------------------------------------------------
- // SymbolFile
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- SymbolFileCreateInstance create_callback,
- DebuggerInitializeCallback debugger_init_callback = nullptr);
-
- static bool
- UnregisterPlugin (SymbolFileCreateInstance create_callback);
-
- static SymbolFileCreateInstance
- GetSymbolFileCreateCallbackAtIndex (uint32_t idx);
-
- static SymbolFileCreateInstance
- GetSymbolFileCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // SymbolVendor
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- SymbolVendorCreateInstance create_callback);
-
- static bool
- UnregisterPlugin (SymbolVendorCreateInstance create_callback);
-
- static SymbolVendorCreateInstance
- GetSymbolVendorCreateCallbackAtIndex (uint32_t idx);
-
- static SymbolVendorCreateInstance
- GetSymbolVendorCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // UnwindAssembly
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- UnwindAssemblyCreateInstance create_callback);
-
- static bool
- UnregisterPlugin (UnwindAssemblyCreateInstance create_callback);
-
- static UnwindAssemblyCreateInstance
- GetUnwindAssemblyCreateCallbackAtIndex (uint32_t idx);
-
- static UnwindAssemblyCreateInstance
- GetUnwindAssemblyCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // MemoryHistory
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- MemoryHistoryCreateInstance create_callback);
-
- static bool
- UnregisterPlugin (MemoryHistoryCreateInstance create_callback);
-
- static MemoryHistoryCreateInstance
- GetMemoryHistoryCreateCallbackAtIndex (uint32_t idx);
-
- static MemoryHistoryCreateInstance
- GetMemoryHistoryCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // InstrumentationRuntime
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- InstrumentationRuntimeCreateInstance create_callback,
- InstrumentationRuntimeGetType get_type_callback);
-
- static bool
- UnregisterPlugin (InstrumentationRuntimeCreateInstance create_callback);
-
- static InstrumentationRuntimeGetType
- GetInstrumentationRuntimeGetTypeCallbackAtIndex (uint32_t idx);
-
- static InstrumentationRuntimeCreateInstance
- GetInstrumentationRuntimeCreateCallbackAtIndex (uint32_t idx);
-
- static InstrumentationRuntimeCreateInstance
- GetInstrumentationRuntimeCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // TypeSystem
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- TypeSystemCreateInstance create_callback,
- TypeSystemEnumerateSupportedLanguages enumerate_languages_callback);
-
- static bool
- UnregisterPlugin (TypeSystemCreateInstance create_callback);
-
- static TypeSystemCreateInstance
- GetTypeSystemCreateCallbackAtIndex (uint32_t idx);
-
- static TypeSystemCreateInstance
- GetTypeSystemCreateCallbackForPluginName (const ConstString &name);
-
- static TypeSystemEnumerateSupportedLanguages
- GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex (uint32_t idx);
-
- static TypeSystemEnumerateSupportedLanguages
- GetTypeSystemEnumerateSupportedLanguagesCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // REPL
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- REPLCreateInstance create_callback,
- REPLEnumerateSupportedLanguages enumerate_languages_callback);
-
- static bool
- UnregisterPlugin (REPLCreateInstance create_callback);
-
- static REPLCreateInstance
- GetREPLCreateCallbackAtIndex (uint32_t idx);
-
- static REPLCreateInstance
- GetREPLCreateCallbackForPluginName (const ConstString &name);
-
- static REPLEnumerateSupportedLanguages
- GetREPLEnumerateSupportedLanguagesCallbackAtIndex (uint32_t idx);
-
- static REPLEnumerateSupportedLanguages
- GetREPLSystemEnumerateSupportedLanguagesCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // Some plug-ins might register a DebuggerInitializeCallback
- // callback when registering the plug-in. After a new Debugger
- // instance is created, this DebuggerInitialize function will get
- // called. This allows plug-ins to install Properties and do any
- // other initialization that requires a debugger instance.
- //------------------------------------------------------------------
- static void
- DebuggerInitialize (Debugger &debugger);
-
- static lldb::OptionValuePropertiesSP
- GetSettingForDynamicLoaderPlugin (Debugger &debugger,
- const ConstString &setting_name);
-
- static bool
- CreateSettingForDynamicLoaderPlugin (Debugger &debugger,
- const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description,
- bool is_global_property);
-
- static lldb::OptionValuePropertiesSP
- GetSettingForPlatformPlugin (Debugger &debugger,
- const ConstString &setting_name);
-
- static bool
- CreateSettingForPlatformPlugin (Debugger &debugger,
- const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description,
- bool is_global_property);
-
- static lldb::OptionValuePropertiesSP
- GetSettingForProcessPlugin (Debugger &debugger,
- const ConstString &setting_name);
+ static void Initialize();
- static bool
- CreateSettingForProcessPlugin (Debugger &debugger,
- const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description,
- bool is_global_property);
+ static void Terminate();
- static lldb::OptionValuePropertiesSP
- GetSettingForSymbolFilePlugin (Debugger &debugger,
- const ConstString &setting_name);
+ //------------------------------------------------------------------
+ // ABI
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(const ConstString &name, const char *description,
+ ABICreateInstance create_callback);
+
+ static bool UnregisterPlugin(ABICreateInstance create_callback);
+
+ static ABICreateInstance GetABICreateCallbackAtIndex(uint32_t idx);
+
+ static ABICreateInstance
+ GetABICreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // Disassembler
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(const ConstString &name, const char *description,
+ DisassemblerCreateInstance create_callback);
+
+ static bool UnregisterPlugin(DisassemblerCreateInstance create_callback);
+
+ static DisassemblerCreateInstance
+ GetDisassemblerCreateCallbackAtIndex(uint32_t idx);
+
+ static DisassemblerCreateInstance
+ GetDisassemblerCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // DynamicLoader
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin(const ConstString &name, const char *description,
+ DynamicLoaderCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback = nullptr);
+
+ static bool UnregisterPlugin(DynamicLoaderCreateInstance create_callback);
+
+ static DynamicLoaderCreateInstance
+ GetDynamicLoaderCreateCallbackAtIndex(uint32_t idx);
+
+ static DynamicLoaderCreateInstance
+ GetDynamicLoaderCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // JITLoader
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin(const ConstString &name, const char *description,
+ JITLoaderCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback = nullptr);
+
+ static bool UnregisterPlugin(JITLoaderCreateInstance create_callback);
+
+ static JITLoaderCreateInstance
+ GetJITLoaderCreateCallbackAtIndex(uint32_t idx);
+
+ static JITLoaderCreateInstance
+ GetJITLoaderCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // EmulateInstruction
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(const ConstString &name, const char *description,
+ EmulateInstructionCreateInstance create_callback);
+
+ static bool
+ UnregisterPlugin(EmulateInstructionCreateInstance create_callback);
+
+ static EmulateInstructionCreateInstance
+ GetEmulateInstructionCreateCallbackAtIndex(uint32_t idx);
+
+ static EmulateInstructionCreateInstance
+ GetEmulateInstructionCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // OperatingSystem
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(const ConstString &name, const char *description,
+ OperatingSystemCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback);
+
+ static bool UnregisterPlugin(OperatingSystemCreateInstance create_callback);
+
+ static OperatingSystemCreateInstance
+ GetOperatingSystemCreateCallbackAtIndex(uint32_t idx);
+
+ static OperatingSystemCreateInstance
+ GetOperatingSystemCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // Language
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(const ConstString &name, const char *description,
+ LanguageCreateInstance create_callback);
+
+ static bool UnregisterPlugin(LanguageCreateInstance create_callback);
+
+ static LanguageCreateInstance GetLanguageCreateCallbackAtIndex(uint32_t idx);
+
+ static LanguageCreateInstance
+ GetLanguageCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // LanguageRuntime
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin(const ConstString &name, const char *description,
+ LanguageRuntimeCreateInstance create_callback,
+ LanguageRuntimeGetCommandObject command_callback = nullptr);
+
+ static bool UnregisterPlugin(LanguageRuntimeCreateInstance create_callback);
+
+ static LanguageRuntimeCreateInstance
+ GetLanguageRuntimeCreateCallbackAtIndex(uint32_t idx);
+
+ static LanguageRuntimeGetCommandObject
+ GetLanguageRuntimeGetCommandObjectAtIndex(uint32_t idx);
+
+ static LanguageRuntimeCreateInstance
+ GetLanguageRuntimeCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // SystemRuntime
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(const ConstString &name, const char *description,
+ SystemRuntimeCreateInstance create_callback);
+
+ static bool UnregisterPlugin(SystemRuntimeCreateInstance create_callback);
+
+ static SystemRuntimeCreateInstance
+ GetSystemRuntimeCreateCallbackAtIndex(uint32_t idx);
- static bool
- CreateSettingForSymbolFilePlugin (Debugger &debugger,
- const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description,
- bool is_global_property);
+ static SystemRuntimeCreateInstance
+ GetSystemRuntimeCreateCallbackForPluginName(const ConstString &name);
- static lldb::OptionValuePropertiesSP
- GetSettingForJITLoaderPlugin (Debugger &debugger,
+ //------------------------------------------------------------------
+ // ObjectFile
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin(const ConstString &name, const char *description,
+ ObjectFileCreateInstance create_callback,
+ ObjectFileCreateMemoryInstance create_memory_callback,
+ ObjectFileGetModuleSpecifications get_module_specifications,
+ ObjectFileSaveCore save_core = nullptr);
+
+ static bool UnregisterPlugin(ObjectFileCreateInstance create_callback);
+
+ static ObjectFileCreateInstance
+ GetObjectFileCreateCallbackAtIndex(uint32_t idx);
+
+ static ObjectFileCreateMemoryInstance
+ GetObjectFileCreateMemoryCallbackAtIndex(uint32_t idx);
+
+ static ObjectFileGetModuleSpecifications
+ GetObjectFileGetModuleSpecificationsCallbackAtIndex(uint32_t idx);
+
+ static ObjectFileCreateInstance
+ GetObjectFileCreateCallbackForPluginName(const ConstString &name);
+
+ static ObjectFileCreateMemoryInstance
+ GetObjectFileCreateMemoryCallbackForPluginName(const ConstString &name);
+
+ static Error SaveCore(const lldb::ProcessSP &process_sp,
+ const FileSpec &outfile);
+
+ //------------------------------------------------------------------
+ // ObjectContainer
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin(const ConstString &name, const char *description,
+ ObjectContainerCreateInstance create_callback,
+ ObjectFileGetModuleSpecifications get_module_specifications);
+
+ static bool UnregisterPlugin(ObjectContainerCreateInstance create_callback);
+
+ static ObjectContainerCreateInstance
+ GetObjectContainerCreateCallbackAtIndex(uint32_t idx);
+
+ static ObjectContainerCreateInstance
+ GetObjectContainerCreateCallbackForPluginName(const ConstString &name);
+
+ static ObjectFileGetModuleSpecifications
+ GetObjectContainerGetModuleSpecificationsCallbackAtIndex(uint32_t idx);
+
+ //------------------------------------------------------------------
+ // LogChannel
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(const ConstString &name, const char *description,
+ LogChannelCreateInstance create_callback);
+
+ static bool UnregisterPlugin(LogChannelCreateInstance create_callback);
+
+ static LogChannelCreateInstance
+ GetLogChannelCreateCallbackAtIndex(uint32_t idx);
+
+ static LogChannelCreateInstance
+ GetLogChannelCreateCallbackForPluginName(const ConstString &name);
+
+ static const char *GetLogChannelCreateNameAtIndex(uint32_t idx);
+
+ //------------------------------------------------------------------
+ // Platform
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin(const ConstString &name, const char *description,
+ PlatformCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback = nullptr);
+
+ static bool UnregisterPlugin(PlatformCreateInstance create_callback);
+
+ static PlatformCreateInstance GetPlatformCreateCallbackAtIndex(uint32_t idx);
+
+ static PlatformCreateInstance
+ GetPlatformCreateCallbackForPluginName(const ConstString &name);
+
+ static const char *GetPlatformPluginNameAtIndex(uint32_t idx);
+
+ static const char *GetPlatformPluginDescriptionAtIndex(uint32_t idx);
+
+ static size_t AutoCompletePlatformName(llvm::StringRef partial_name,
+ StringList &matches);
+ //------------------------------------------------------------------
+ // Process
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin(const ConstString &name, const char *description,
+ ProcessCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback = nullptr);
+
+ static bool UnregisterPlugin(ProcessCreateInstance create_callback);
+
+ static ProcessCreateInstance GetProcessCreateCallbackAtIndex(uint32_t idx);
+
+ static ProcessCreateInstance
+ GetProcessCreateCallbackForPluginName(const ConstString &name);
+
+ static const char *GetProcessPluginNameAtIndex(uint32_t idx);
+
+ static const char *GetProcessPluginDescriptionAtIndex(uint32_t idx);
+
+ //------------------------------------------------------------------
+ // ScriptInterpreter
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(const ConstString &name, const char *description,
+ lldb::ScriptLanguage script_lang,
+ ScriptInterpreterCreateInstance create_callback);
+
+ static bool UnregisterPlugin(ScriptInterpreterCreateInstance create_callback);
+
+ static ScriptInterpreterCreateInstance
+ GetScriptInterpreterCreateCallbackAtIndex(uint32_t idx);
+
+ static lldb::ScriptInterpreterSP
+ GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang,
+ CommandInterpreter &interpreter);
+
+ //------------------------------------------------------------------
+ // StructuredDataPlugin
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Register a StructuredDataPlugin class along with optional
+ /// callbacks for debugger initialization and Process launch info
+ /// filtering and manipulation.
+ ///
+ /// @param[in] name
+ /// The name of the plugin.
+ ///
+ /// @param[in] description
+ /// A description string for the plugin.
+ ///
+ /// @param[in] create_callback
+ /// The callback that will be invoked to create an instance of
+ /// the callback. This may not be nullptr.
+ ///
+ /// @param[in] debugger_init_callback
+ /// An optional callback that will be made when a Debugger
+ /// instance is initialized.
+ ///
+ /// @param[in] filter_callback
+ /// An optional callback that will be invoked before LLDB
+ /// launches a process for debugging. The callback must
+ /// do the following:
+ /// 1. Only do something if the plugin's behavior is enabled.
+ /// 2. Only make changes for processes that are relevant to the
+ /// plugin. The callback gets a pointer to the Target, which
+ /// can be inspected as needed. The ProcessLaunchInfo is
+ /// provided in read-write mode, and may be modified by the
+ /// plugin if, for instance, additional environment variables
+ /// are needed to support the feature when enabled.
+ ///
+ /// @return
+ /// Returns true upon success; otherwise, false.
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin(const ConstString &name, const char *description,
+ StructuredDataPluginCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback = nullptr,
+ StructuredDataFilterLaunchInfo filter_callback = nullptr);
+
+ static bool
+ UnregisterPlugin(StructuredDataPluginCreateInstance create_callback);
+
+ static StructuredDataPluginCreateInstance
+ GetStructuredDataPluginCreateCallbackAtIndex(uint32_t idx);
+
+ static StructuredDataPluginCreateInstance
+ GetStructuredDataPluginCreateCallbackForPluginName(const ConstString &name);
+
+ static StructuredDataFilterLaunchInfo
+ GetStructuredDataFilterCallbackAtIndex(uint32_t idx,
+ bool &iteration_complete);
+
+ //------------------------------------------------------------------
+ // SymbolFile
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin(const ConstString &name, const char *description,
+ SymbolFileCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback = nullptr);
+
+ static bool UnregisterPlugin(SymbolFileCreateInstance create_callback);
+
+ static SymbolFileCreateInstance
+ GetSymbolFileCreateCallbackAtIndex(uint32_t idx);
+
+ static SymbolFileCreateInstance
+ GetSymbolFileCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // SymbolVendor
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(const ConstString &name, const char *description,
+ SymbolVendorCreateInstance create_callback);
+
+ static bool UnregisterPlugin(SymbolVendorCreateInstance create_callback);
+
+ static SymbolVendorCreateInstance
+ GetSymbolVendorCreateCallbackAtIndex(uint32_t idx);
+
+ static SymbolVendorCreateInstance
+ GetSymbolVendorCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // UnwindAssembly
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(const ConstString &name, const char *description,
+ UnwindAssemblyCreateInstance create_callback);
+
+ static bool UnregisterPlugin(UnwindAssemblyCreateInstance create_callback);
+
+ static UnwindAssemblyCreateInstance
+ GetUnwindAssemblyCreateCallbackAtIndex(uint32_t idx);
+
+ static UnwindAssemblyCreateInstance
+ GetUnwindAssemblyCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // MemoryHistory
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(const ConstString &name, const char *description,
+ MemoryHistoryCreateInstance create_callback);
+
+ static bool UnregisterPlugin(MemoryHistoryCreateInstance create_callback);
+
+ static MemoryHistoryCreateInstance
+ GetMemoryHistoryCreateCallbackAtIndex(uint32_t idx);
+
+ static MemoryHistoryCreateInstance
+ GetMemoryHistoryCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // InstrumentationRuntime
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin(const ConstString &name, const char *description,
+ InstrumentationRuntimeCreateInstance create_callback,
+ InstrumentationRuntimeGetType get_type_callback);
+
+ static bool
+ UnregisterPlugin(InstrumentationRuntimeCreateInstance create_callback);
+
+ static InstrumentationRuntimeGetType
+ GetInstrumentationRuntimeGetTypeCallbackAtIndex(uint32_t idx);
+
+ static InstrumentationRuntimeCreateInstance
+ GetInstrumentationRuntimeCreateCallbackAtIndex(uint32_t idx);
+
+ static InstrumentationRuntimeCreateInstance
+ GetInstrumentationRuntimeCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // TypeSystem
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(
+ const ConstString &name, const char *description,
+ TypeSystemCreateInstance create_callback,
+ TypeSystemEnumerateSupportedLanguages enumerate_languages_callback);
+
+ static bool UnregisterPlugin(TypeSystemCreateInstance create_callback);
+
+ static TypeSystemCreateInstance
+ GetTypeSystemCreateCallbackAtIndex(uint32_t idx);
+
+ static TypeSystemCreateInstance
+ GetTypeSystemCreateCallbackForPluginName(const ConstString &name);
+
+ static TypeSystemEnumerateSupportedLanguages
+ GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex(uint32_t idx);
+
+ static TypeSystemEnumerateSupportedLanguages
+ GetTypeSystemEnumerateSupportedLanguagesCallbackForPluginName(
+ const ConstString &name);
+
+ //------------------------------------------------------------------
+ // REPL
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin(const ConstString &name, const char *description,
+ REPLCreateInstance create_callback,
+ REPLEnumerateSupportedLanguages enumerate_languages_callback);
+
+ static bool UnregisterPlugin(REPLCreateInstance create_callback);
+
+ static REPLCreateInstance GetREPLCreateCallbackAtIndex(uint32_t idx);
+
+ static REPLCreateInstance
+ GetREPLCreateCallbackForPluginName(const ConstString &name);
+
+ static REPLEnumerateSupportedLanguages
+ GetREPLEnumerateSupportedLanguagesCallbackAtIndex(uint32_t idx);
+
+ static REPLEnumerateSupportedLanguages
+ GetREPLSystemEnumerateSupportedLanguagesCallbackForPluginName(
+ const ConstString &name);
+
+ //------------------------------------------------------------------
+ // Some plug-ins might register a DebuggerInitializeCallback
+ // callback when registering the plug-in. After a new Debugger
+ // instance is created, this DebuggerInitialize function will get
+ // called. This allows plug-ins to install Properties and do any
+ // other initialization that requires a debugger instance.
+ //------------------------------------------------------------------
+ static void DebuggerInitialize(Debugger &debugger);
+
+ static lldb::OptionValuePropertiesSP
+ GetSettingForDynamicLoaderPlugin(Debugger &debugger,
const ConstString &setting_name);
- static bool
- CreateSettingForJITLoaderPlugin (Debugger &debugger,
- const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description,
- bool is_global_property);
+ static bool CreateSettingForDynamicLoaderPlugin(
+ Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description, bool is_global_property);
+
+ static lldb::OptionValuePropertiesSP
+ GetSettingForPlatformPlugin(Debugger &debugger,
+ const ConstString &setting_name);
+
+ static bool CreateSettingForPlatformPlugin(
+ Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description, bool is_global_property);
+
+ static lldb::OptionValuePropertiesSP
+ GetSettingForProcessPlugin(Debugger &debugger,
+ const ConstString &setting_name);
+
+ static bool CreateSettingForProcessPlugin(
+ Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description, bool is_global_property);
+
+ static lldb::OptionValuePropertiesSP
+ GetSettingForSymbolFilePlugin(Debugger &debugger,
+ const ConstString &setting_name);
+
+ static bool CreateSettingForSymbolFilePlugin(
+ Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description, bool is_global_property);
+
+ static lldb::OptionValuePropertiesSP
+ GetSettingForJITLoaderPlugin(Debugger &debugger,
+ const ConstString &setting_name);
+
+ static bool CreateSettingForJITLoaderPlugin(
+ Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description, bool is_global_property);
+
+ static lldb::OptionValuePropertiesSP
+ GetSettingForOperatingSystemPlugin(Debugger &debugger,
+ const ConstString &setting_name);
+
+ static bool CreateSettingForOperatingSystemPlugin(
+ Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description, bool is_global_property);
- static lldb::OptionValuePropertiesSP GetSettingForOperatingSystemPlugin(Debugger &debugger,
- const ConstString &setting_name);
+ static lldb::OptionValuePropertiesSP
+ GetSettingForStructuredDataPlugin(Debugger &debugger,
+ const ConstString &setting_name);
- static bool CreateSettingForOperatingSystemPlugin(Debugger &debugger,
- const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description, bool is_global_property);
+ static bool CreateSettingForStructuredDataPlugin(
+ Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description, bool is_global_property);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/RangeMap.h b/include/lldb/Core/RangeMap.h
index eb68859aed3f..73a949fcd25f 100644
--- a/include/lldb/Core/RangeMap.h
+++ b/include/lldb/Core/RangeMap.h
@@ -25,1533 +25,1138 @@
//#define ASSERT_RANGEMAP_ARE_SORTED
namespace lldb_private {
-
- //----------------------------------------------------------------------
- // Templatized classes for dealing with generic ranges and also
- // collections of ranges, or collections of ranges that have associated
- // data.
- //----------------------------------------------------------------------
-
- //----------------------------------------------------------------------
- // A simple range class where you get to define the type of the range
- // base "B", and the type used for the range byte size "S".
- //----------------------------------------------------------------------
- template <typename B, typename S>
- struct Range
- {
- typedef B BaseType;
- typedef S SizeType;
-
- BaseType base;
- SizeType size;
-
- Range () :
- base (0),
- size (0)
- {
- }
-
- Range (BaseType b, SizeType s) :
- base (b),
- size (s)
- {
- }
-
- void
- Clear (BaseType b = 0)
- {
- base = b;
- size = 0;
- }
- // Set the start value for the range, and keep the same size
- BaseType
- GetRangeBase () const
- {
- return base;
- }
-
- void
- SetRangeBase (BaseType b)
- {
- base = b;
- }
-
- void
- Slide (BaseType slide)
- {
- base += slide;
- }
-
- BaseType
- GetRangeEnd () const
- {
- return base + size;
- }
-
- void
- SetRangeEnd (BaseType end)
- {
- if (end > base)
- size = end - base;
- else
- size = 0;
- }
-
- SizeType
- GetByteSize () const
- {
- return size;
- }
-
- void
- SetByteSize (SizeType s)
- {
- size = s;
- }
-
- bool
- IsValid() const
- {
- return size > 0;
- }
-
- bool
- Contains (BaseType r) const
- {
- return (GetRangeBase() <= r) && (r < GetRangeEnd());
- }
-
- bool
- ContainsEndInclusive (BaseType r) const
- {
- return (GetRangeBase() <= r) && (r <= GetRangeEnd());
- }
-
- bool
- Contains (const Range& range) const
- {
- return Contains(range.GetRangeBase()) && ContainsEndInclusive(range.GetRangeEnd());
- }
+//----------------------------------------------------------------------
+// Templatized classes for dealing with generic ranges and also
+// collections of ranges, or collections of ranges that have associated
+// data.
+//----------------------------------------------------------------------
+
+//----------------------------------------------------------------------
+// A simple range class where you get to define the type of the range
+// base "B", and the type used for the range byte size "S".
+//----------------------------------------------------------------------
+template <typename B, typename S> struct Range {
+ typedef B BaseType;
+ typedef S SizeType;
- // Returns true if the two ranges adjoing or intersect
- bool
- DoesAdjoinOrIntersect (const Range &rhs) const
- {
- const BaseType lhs_base = this->GetRangeBase();
- const BaseType rhs_base = rhs.GetRangeBase();
- const BaseType lhs_end = this->GetRangeEnd();
- const BaseType rhs_end = rhs.GetRangeEnd();
- bool result = (lhs_base <= rhs_end) && (lhs_end >= rhs_base);
- return result;
- }
+ BaseType base;
+ SizeType size;
- // Returns true if the two ranges intersect
- bool
- DoesIntersect (const Range &rhs) const
- {
- const BaseType lhs_base = this->GetRangeBase();
- const BaseType rhs_base = rhs.GetRangeBase();
- const BaseType lhs_end = this->GetRangeEnd();
- const BaseType rhs_end = rhs.GetRangeEnd();
- bool result = (lhs_base < rhs_end) && (lhs_end > rhs_base);
- return result;
- }
+ Range() : base(0), size(0) {}
+
+ Range(BaseType b, SizeType s) : base(b), size(s) {}
+
+ void Clear(BaseType b = 0) {
+ base = b;
+ size = 0;
+ }
+
+ // Set the start value for the range, and keep the same size
+ BaseType GetRangeBase() const { return base; }
+
+ void SetRangeBase(BaseType b) { base = b; }
+
+ void Slide(BaseType slide) { base += slide; }
+
+ BaseType GetRangeEnd() const { return base + size; }
+
+ void SetRangeEnd(BaseType end) {
+ if (end > base)
+ size = end - base;
+ else
+ size = 0;
+ }
+
+ SizeType GetByteSize() const { return size; }
+
+ void SetByteSize(SizeType s) { size = s; }
+
+ bool IsValid() const { return size > 0; }
+
+ bool Contains(BaseType r) const {
+ return (GetRangeBase() <= r) && (r < GetRangeEnd());
+ }
+
+ bool ContainsEndInclusive(BaseType r) const {
+ return (GetRangeBase() <= r) && (r <= GetRangeEnd());
+ }
+
+ bool Contains(const Range &range) const {
+ return Contains(range.GetRangeBase()) &&
+ ContainsEndInclusive(range.GetRangeEnd());
+ }
+
+ // Returns true if the two ranges adjoing or intersect
+ bool DoesAdjoinOrIntersect(const Range &rhs) const {
+ const BaseType lhs_base = this->GetRangeBase();
+ const BaseType rhs_base = rhs.GetRangeBase();
+ const BaseType lhs_end = this->GetRangeEnd();
+ const BaseType rhs_end = rhs.GetRangeEnd();
+ bool result = (lhs_base <= rhs_end) && (lhs_end >= rhs_base);
+ return result;
+ }
+
+ // Returns true if the two ranges intersect
+ bool DoesIntersect(const Range &rhs) const {
+ const BaseType lhs_base = this->GetRangeBase();
+ const BaseType rhs_base = rhs.GetRangeBase();
+ const BaseType lhs_end = this->GetRangeEnd();
+ const BaseType rhs_end = rhs.GetRangeEnd();
+ bool result = (lhs_base < rhs_end) && (lhs_end > rhs_base);
+ return result;
+ }
+
+ bool operator<(const Range &rhs) const {
+ if (base == rhs.base)
+ return size < rhs.size;
+ return base < rhs.base;
+ }
+
+ bool operator==(const Range &rhs) const {
+ return base == rhs.base && size == rhs.size;
+ }
+
+ bool operator!=(const Range &rhs) const {
+ return base != rhs.base || size != rhs.size;
+ }
+};
+
+//----------------------------------------------------------------------
+// A range array class where you get to define the type of the ranges
+// that the collection contains.
+//----------------------------------------------------------------------
+
+template <typename B, typename S, unsigned N> class RangeArray {
+public:
+ typedef B BaseType;
+ typedef S SizeType;
+ typedef Range<B, S> Entry;
+ typedef llvm::SmallVector<Entry, N> Collection;
+
+ RangeArray() = default;
+
+ ~RangeArray() = default;
- bool
- operator < (const Range &rhs) const
- {
- if (base == rhs.base)
- return size < rhs.size;
- return base < rhs.base;
- }
-
- bool
- operator == (const Range &rhs) const
- {
- return base == rhs.base && size == rhs.size;
- }
-
- bool
- operator != (const Range &rhs) const
- {
- return base != rhs.base || size != rhs.size;
- }
- };
-
- //----------------------------------------------------------------------
- // A range array class where you get to define the type of the ranges
- // that the collection contains.
- //----------------------------------------------------------------------
-
- template <typename B, typename S, unsigned N>
- class RangeArray
- {
- public:
- typedef B BaseType;
- typedef S SizeType;
- typedef Range<B,S> Entry;
- typedef llvm::SmallVector<Entry, N> Collection;
-
- RangeArray() = default;
-
- ~RangeArray() = default;
-
- void
- Append (const Entry &entry)
- {
- m_entries.push_back (entry);
- }
+ void Append(const Entry &entry) { m_entries.push_back(entry); }
- void
- Append (B base, S size)
- {
- m_entries.emplace_back(base, size);
- }
+ void Append(B base, S size) { m_entries.emplace_back(base, size); }
- bool
- RemoveEntrtAtIndex (uint32_t idx)
- {
- if (idx < m_entries.size())
- {
- m_entries.erase (m_entries.begin() + idx);
- return true;
- }
- return false;
- }
-
- void
- Sort ()
- {
- if (m_entries.size() > 1)
- std::stable_sort (m_entries.begin(), m_entries.end());
- }
-
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- bool
- IsSorted () const
- {
- typename Collection::const_iterator pos, end, prev;
- // First we determine if we can combine any of the Entry objects so we
- // don't end up allocating and making a new collection for no reason
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && *pos < *prev)
- return false;
- }
- return true;
- }
-#endif
+ bool RemoveEntrtAtIndex(uint32_t idx) {
+ if (idx < m_entries.size()) {
+ m_entries.erase(m_entries.begin() + idx);
+ return true;
+ }
+ return false;
+ }
+
+ void Sort() {
+ if (m_entries.size() > 1)
+ std::stable_sort(m_entries.begin(), m_entries.end());
+ }
- void
- CombineConsecutiveRanges ()
- {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ bool IsSorted() const {
+ typename Collection::const_iterator pos, end, prev;
+ // First we determine if we can combine any of the Entry objects so we
+ // don't end up allocating and making a new collection for no reason
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end;
+ prev = pos++) {
+ if (prev != end && *pos < *prev)
+ return false;
+ }
+ return true;
+ }
#endif
- // Can't combine if ranges if we have zero or one range
- if (m_entries.size() > 1)
- {
- // The list should be sorted prior to calling this function
- typename Collection::iterator pos;
- typename Collection::iterator end;
- typename Collection::iterator prev;
- bool can_combine = false;
- // First we determine if we can combine any of the Entry objects so we
- // don't end up allocating and making a new collection for no reason
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && prev->DoesAdjoinOrIntersect(*pos))
- {
- can_combine = true;
- break;
- }
- }
-
- // We we can combine at least one entry, then we make a new collection
- // and populate it accordingly, and then swap it into place.
- if (can_combine)
- {
- Collection minimal_ranges;
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && prev->DoesAdjoinOrIntersect(*pos))
- minimal_ranges.back().SetRangeEnd (std::max<BaseType>(prev->GetRangeEnd(), pos->GetRangeEnd()));
- else
- minimal_ranges.push_back (*pos);
- }
- // Use the swap technique in case our new vector is much smaller.
- // We must swap when using the STL because std::vector objects never
- // release or reduce the memory once it has been allocated/reserved.
- m_entries.swap (minimal_ranges);
- }
- }
- }
- BaseType
- GetMinRangeBase (BaseType fail_value) const
- {
+ void CombineConsecutiveRanges() {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ assert(IsSorted());
#endif
- if (m_entries.empty())
- return fail_value;
- // m_entries must be sorted, so if we aren't empty, we grab the
- // first range's base
- return m_entries.front().GetRangeBase();
- }
-
- BaseType
- GetMaxRangeEnd (BaseType fail_value) const
- {
+ // Can't combine if ranges if we have zero or one range
+ if (m_entries.size() > 1) {
+ // The list should be sorted prior to calling this function
+ typename Collection::iterator pos;
+ typename Collection::iterator end;
+ typename Collection::iterator prev;
+ bool can_combine = false;
+ // First we determine if we can combine any of the Entry objects so we
+ // don't end up allocating and making a new collection for no reason
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end;
+ pos != end; prev = pos++) {
+ if (prev != end && prev->DoesAdjoinOrIntersect(*pos)) {
+ can_combine = true;
+ break;
+ }
+ }
+
+ // We we can combine at least one entry, then we make a new collection
+ // and populate it accordingly, and then swap it into place.
+ if (can_combine) {
+ Collection minimal_ranges;
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end;
+ pos != end; prev = pos++) {
+ if (prev != end && prev->DoesAdjoinOrIntersect(*pos))
+ minimal_ranges.back().SetRangeEnd(
+ std::max<BaseType>(prev->GetRangeEnd(), pos->GetRangeEnd()));
+ else
+ minimal_ranges.push_back(*pos);
+ }
+ // Use the swap technique in case our new vector is much smaller.
+ // We must swap when using the STL because std::vector objects never
+ // release or reduce the memory once it has been allocated/reserved.
+ m_entries.swap(minimal_ranges);
+ }
+ }
+ }
+
+ BaseType GetMinRangeBase(BaseType fail_value) const {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ assert(IsSorted());
#endif
- if (m_entries.empty())
- return fail_value;
- // m_entries must be sorted, so if we aren't empty, we grab the
- // last range's end
- return m_entries.back().GetRangeEnd();
- }
-
- void
- Slide (BaseType slide)
- {
- typename Collection::iterator pos, end;
- for (pos = m_entries.begin(), end = m_entries.end(); pos != end; ++pos)
- pos->Slide (slide);
- }
-
- void
- Clear ()
- {
- m_entries.clear();
- }
-
- bool
- IsEmpty () const
- {
- return m_entries.empty();
- }
-
- size_t
- GetSize () const
- {
- return m_entries.size();
- }
-
- const Entry *
- GetEntryAtIndex (size_t i) const
- {
- return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
- }
-
- // Clients must ensure that "i" is a valid index prior to calling this function
- const Entry &
- GetEntryRef (size_t i) const
- {
- return m_entries[i];
- }
-
- Entry *
- Back()
- {
- return (m_entries.empty() ? nullptr : &m_entries.back());
- }
-
- const Entry *
- Back() const
- {
- return (m_entries.empty() ? nullptr : &m_entries.back());
- }
-
- static bool
- BaseLessThan (const Entry& lhs, const Entry& rhs)
- {
- return lhs.GetRangeBase() < rhs.GetRangeBase();
- }
-
- uint32_t
- FindEntryIndexThatContains (B addr) const
- {
+ if (m_entries.empty())
+ return fail_value;
+ // m_entries must be sorted, so if we aren't empty, we grab the
+ // first range's base
+ return m_entries.front().GetRangeBase();
+ }
+
+ BaseType GetMaxRangeEnd(BaseType fail_value) const {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ assert(IsSorted());
#endif
- if (!m_entries.empty())
- {
- Entry entry (addr, 1);
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
-
- if (pos != end && pos->Contains(addr))
- {
- return std::distance (begin, pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(addr))
- return std::distance (begin, pos);
- }
- }
- return UINT32_MAX;
- }
+ if (m_entries.empty())
+ return fail_value;
+ // m_entries must be sorted, so if we aren't empty, we grab the
+ // last range's end
+ return m_entries.back().GetRangeEnd();
+ }
- const Entry *
- FindEntryThatContains (B addr) const
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- if (!m_entries.empty())
- {
- Entry entry (addr, 1);
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
-
- if (pos != end && pos->Contains(addr))
- {
- return &(*pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(addr))
- {
- return &(*pos);
- }
- }
- }
- return nullptr;
- }
+ void Slide(BaseType slide) {
+ typename Collection::iterator pos, end;
+ for (pos = m_entries.begin(), end = m_entries.end(); pos != end; ++pos)
+ pos->Slide(slide);
+ }
- const Entry *
- FindEntryThatContains (const Entry &range) const
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- if (!m_entries.empty())
- {
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, range, BaseLessThan);
-
- if (pos != end && pos->Contains(range))
- {
- return &(*pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(range))
- {
- return &(*pos);
- }
- }
- }
- return nullptr;
- }
+ void Clear() { m_entries.clear(); }
- protected:
- Collection m_entries;
- };
+ bool IsEmpty() const { return m_entries.empty(); }
- template <typename B, typename S>
- class RangeVector
- {
- public:
- typedef B BaseType;
- typedef S SizeType;
- typedef Range<B,S> Entry;
- typedef std::vector<Entry> Collection;
+ size_t GetSize() const { return m_entries.size(); }
- RangeVector() = default;
+ const Entry *GetEntryAtIndex(size_t i) const {
+ return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
+ }
- ~RangeVector() = default;
+ // Clients must ensure that "i" is a valid index prior to calling this
+ // function
+ const Entry &GetEntryRef(size_t i) const { return m_entries[i]; }
- void
- Append (const Entry &entry)
- {
- m_entries.push_back (entry);
- }
+ Entry *Back() { return (m_entries.empty() ? nullptr : &m_entries.back()); }
- void
- Append (B base, S size)
- {
- m_entries.emplace_back(base, size);
- }
+ const Entry *Back() const {
+ return (m_entries.empty() ? nullptr : &m_entries.back());
+ }
- bool
- RemoveEntrtAtIndex (uint32_t idx)
- {
- if (idx < m_entries.size())
- {
- m_entries.erase (m_entries.begin() + idx);
- return true;
- }
- return false;
- }
-
- void
- Sort ()
- {
- if (m_entries.size() > 1)
- std::stable_sort (m_entries.begin(), m_entries.end());
- }
-
+ static bool BaseLessThan(const Entry &lhs, const Entry &rhs) {
+ return lhs.GetRangeBase() < rhs.GetRangeBase();
+ }
+
+ uint32_t FindEntryIndexThatContains(B addr) const {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- bool
- IsSorted () const
- {
- typename Collection::const_iterator pos, end, prev;
- // First we determine if we can combine any of the Entry objects so we
- // don't end up allocating and making a new collection for no reason
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && *pos < *prev)
- return false;
- }
- return true;
- }
+ assert(IsSorted());
+#endif
+ if (!m_entries.empty()) {
+ Entry entry(addr, 1);
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, entry, BaseLessThan);
+
+ if (pos != end && pos->Contains(addr)) {
+ return std::distance(begin, pos);
+ } else if (pos != begin) {
+ --pos;
+ if (pos->Contains(addr))
+ return std::distance(begin, pos);
+ }
+ }
+ return UINT32_MAX;
+ }
+
+ const Entry *FindEntryThatContains(B addr) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (!m_entries.empty()) {
+ Entry entry(addr, 1);
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, entry, BaseLessThan);
+
+ if (pos != end && pos->Contains(addr)) {
+ return &(*pos);
+ } else if (pos != begin) {
+ --pos;
+ if (pos->Contains(addr)) {
+ return &(*pos);
+ }
+ }
+ }
+ return nullptr;
+ }
+
+ const Entry *FindEntryThatContains(const Entry &range) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
#endif
+ if (!m_entries.empty()) {
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, range, BaseLessThan);
+
+ if (pos != end && pos->Contains(range)) {
+ return &(*pos);
+ } else if (pos != begin) {
+ --pos;
+ if (pos->Contains(range)) {
+ return &(*pos);
+ }
+ }
+ }
+ return nullptr;
+ }
+
+protected:
+ Collection m_entries;
+};
+
+template <typename B, typename S> class RangeVector {
+public:
+ typedef B BaseType;
+ typedef S SizeType;
+ typedef Range<B, S> Entry;
+ typedef std::vector<Entry> Collection;
+
+ RangeVector() = default;
+
+ ~RangeVector() = default;
+
+ void Append(const Entry &entry) { m_entries.push_back(entry); }
+
+ void Append(B base, S size) { m_entries.emplace_back(base, size); }
+
+ bool RemoveEntrtAtIndex(uint32_t idx) {
+ if (idx < m_entries.size()) {
+ m_entries.erase(m_entries.begin() + idx);
+ return true;
+ }
+ return false;
+ }
+
+ void Sort() {
+ if (m_entries.size() > 1)
+ std::stable_sort(m_entries.begin(), m_entries.end());
+ }
- void
- CombineConsecutiveRanges ()
- {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ bool IsSorted() const {
+ typename Collection::const_iterator pos, end, prev;
+ // First we determine if we can combine any of the Entry objects so we
+ // don't end up allocating and making a new collection for no reason
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end;
+ prev = pos++) {
+ if (prev != end && *pos < *prev)
+ return false;
+ }
+ return true;
+ }
#endif
- // Can't combine if ranges if we have zero or one range
- if (m_entries.size() > 1)
- {
- // The list should be sorted prior to calling this function
- typename Collection::iterator pos;
- typename Collection::iterator end;
- typename Collection::iterator prev;
- bool can_combine = false;
- // First we determine if we can combine any of the Entry objects so we
- // don't end up allocating and making a new collection for no reason
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && prev->DoesAdjoinOrIntersect(*pos))
- {
- can_combine = true;
- break;
- }
- }
-
- // We we can combine at least one entry, then we make a new collection
- // and populate it accordingly, and then swap it into place.
- if (can_combine)
- {
- Collection minimal_ranges;
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && prev->DoesAdjoinOrIntersect(*pos))
- minimal_ranges.back().SetRangeEnd (std::max<BaseType>(prev->GetRangeEnd(), pos->GetRangeEnd()));
- else
- minimal_ranges.push_back (*pos);
- }
- // Use the swap technique in case our new vector is much smaller.
- // We must swap when using the STL because std::vector objects never
- // release or reduce the memory once it has been allocated/reserved.
- m_entries.swap (minimal_ranges);
- }
- }
- }
- BaseType
- GetMinRangeBase (BaseType fail_value) const
- {
+ void CombineConsecutiveRanges() {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ assert(IsSorted());
#endif
- if (m_entries.empty())
- return fail_value;
- // m_entries must be sorted, so if we aren't empty, we grab the
- // first range's base
- return m_entries.front().GetRangeBase();
- }
-
- BaseType
- GetMaxRangeEnd (BaseType fail_value) const
- {
+ // Can't combine if ranges if we have zero or one range
+ if (m_entries.size() > 1) {
+ // The list should be sorted prior to calling this function
+ typename Collection::iterator pos;
+ typename Collection::iterator end;
+ typename Collection::iterator prev;
+ bool can_combine = false;
+ // First we determine if we can combine any of the Entry objects so we
+ // don't end up allocating and making a new collection for no reason
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end;
+ pos != end; prev = pos++) {
+ if (prev != end && prev->DoesAdjoinOrIntersect(*pos)) {
+ can_combine = true;
+ break;
+ }
+ }
+
+ // We we can combine at least one entry, then we make a new collection
+ // and populate it accordingly, and then swap it into place.
+ if (can_combine) {
+ Collection minimal_ranges;
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end;
+ pos != end; prev = pos++) {
+ if (prev != end && prev->DoesAdjoinOrIntersect(*pos))
+ minimal_ranges.back().SetRangeEnd(
+ std::max<BaseType>(prev->GetRangeEnd(), pos->GetRangeEnd()));
+ else
+ minimal_ranges.push_back(*pos);
+ }
+ // Use the swap technique in case our new vector is much smaller.
+ // We must swap when using the STL because std::vector objects never
+ // release or reduce the memory once it has been allocated/reserved.
+ m_entries.swap(minimal_ranges);
+ }
+ }
+ }
+
+ BaseType GetMinRangeBase(BaseType fail_value) const {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ assert(IsSorted());
#endif
- if (m_entries.empty())
- return fail_value;
- // m_entries must be sorted, so if we aren't empty, we grab the
- // last range's end
- return m_entries.back().GetRangeEnd();
- }
-
- void
- Slide (BaseType slide)
- {
- typename Collection::iterator pos, end;
- for (pos = m_entries.begin(), end = m_entries.end(); pos != end; ++pos)
- pos->Slide (slide);
- }
-
- void
- Clear ()
- {
- m_entries.clear();
- }
+ if (m_entries.empty())
+ return fail_value;
+ // m_entries must be sorted, so if we aren't empty, we grab the
+ // first range's base
+ return m_entries.front().GetRangeBase();
+ }
+
+ BaseType GetMaxRangeEnd(BaseType fail_value) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (m_entries.empty())
+ return fail_value;
+ // m_entries must be sorted, so if we aren't empty, we grab the
+ // last range's end
+ return m_entries.back().GetRangeEnd();
+ }
- void
- Reserve (typename Collection::size_type size)
- {
- m_entries.reserve (size);
- }
+ void Slide(BaseType slide) {
+ typename Collection::iterator pos, end;
+ for (pos = m_entries.begin(), end = m_entries.end(); pos != end; ++pos)
+ pos->Slide(slide);
+ }
- bool
- IsEmpty () const
- {
- return m_entries.empty();
- }
-
- size_t
- GetSize () const
- {
- return m_entries.size();
- }
-
- const Entry *
- GetEntryAtIndex (size_t i) const
- {
- return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
- }
-
- // Clients must ensure that "i" is a valid index prior to calling this function
- const Entry &
- GetEntryRef (size_t i) const
- {
- return m_entries[i];
- }
-
- Entry *
- Back()
- {
- return (m_entries.empty() ? nullptr : &m_entries.back());
- }
-
- const Entry *
- Back() const
- {
- return (m_entries.empty() ? nullptr : &m_entries.back());
- }
-
- static bool
- BaseLessThan (const Entry& lhs, const Entry& rhs)
- {
- return lhs.GetRangeBase() < rhs.GetRangeBase();
- }
-
- uint32_t
- FindEntryIndexThatContains (B addr) const
- {
+ void Clear() { m_entries.clear(); }
+
+ void Reserve(typename Collection::size_type size) { m_entries.reserve(size); }
+
+ bool IsEmpty() const { return m_entries.empty(); }
+
+ size_t GetSize() const { return m_entries.size(); }
+
+ const Entry *GetEntryAtIndex(size_t i) const {
+ return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
+ }
+
+ // Clients must ensure that "i" is a valid index prior to calling this
+ // function
+ const Entry &GetEntryRef(size_t i) const { return m_entries[i]; }
+
+ Entry *Back() { return (m_entries.empty() ? nullptr : &m_entries.back()); }
+
+ const Entry *Back() const {
+ return (m_entries.empty() ? nullptr : &m_entries.back());
+ }
+
+ static bool BaseLessThan(const Entry &lhs, const Entry &rhs) {
+ return lhs.GetRangeBase() < rhs.GetRangeBase();
+ }
+
+ uint32_t FindEntryIndexThatContains(B addr) const {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ assert(IsSorted());
#endif
- if (!m_entries.empty())
- {
- Entry entry (addr, 1);
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
-
- if (pos != end && pos->Contains(addr))
- {
- return std::distance (begin, pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(addr))
- return std::distance (begin, pos);
- }
- }
- return UINT32_MAX;
- }
-
- const Entry *
- FindEntryThatContains (B addr) const
- {
+ if (!m_entries.empty()) {
+ Entry entry(addr, 1);
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, entry, BaseLessThan);
+
+ if (pos != end && pos->Contains(addr)) {
+ return std::distance(begin, pos);
+ } else if (pos != begin) {
+ --pos;
+ if (pos->Contains(addr))
+ return std::distance(begin, pos);
+ }
+ }
+ return UINT32_MAX;
+ }
+
+ const Entry *FindEntryThatContains(B addr) const {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ assert(IsSorted());
#endif
- if (!m_entries.empty())
- {
- Entry entry (addr, 1);
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
-
- if (pos != end && pos->Contains(addr))
- {
- return &(*pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(addr))
- {
- return &(*pos);
- }
- }
- }
- return nullptr;
- }
-
- const Entry *
- FindEntryThatContains (const Entry &range) const
- {
+ if (!m_entries.empty()) {
+ Entry entry(addr, 1);
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, entry, BaseLessThan);
+
+ if (pos != end && pos->Contains(addr)) {
+ return &(*pos);
+ } else if (pos != begin) {
+ --pos;
+ if (pos->Contains(addr)) {
+ return &(*pos);
+ }
+ }
+ }
+ return nullptr;
+ }
+
+ const Entry *FindEntryThatContains(const Entry &range) const {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ assert(IsSorted());
#endif
- if (!m_entries.empty())
- {
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, range, BaseLessThan);
-
- if (pos != end && pos->Contains(range))
- {
- return &(*pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(range))
- {
- return &(*pos);
- }
- }
- }
- return nullptr;
- }
-
- protected:
- Collection m_entries;
- };
-
- //----------------------------------------------------------------------
- // A simple range with data class where you get to define the type of
- // the range base "B", the type used for the range byte size "S", and
- // the type for the associated data "T".
- //----------------------------------------------------------------------
- template <typename B, typename S, typename T>
- struct RangeData : public Range<B,S>
- {
- typedef T DataType;
-
- DataType data;
-
- RangeData () :
- Range<B,S> (),
- data ()
- {
- }
-
- RangeData (B base, S size) :
- Range<B,S> (base, size),
- data ()
- {
- }
-
- RangeData (B base, S size, DataType d) :
- Range<B,S> (base, size),
- data (d)
- {
- }
-
- bool
- operator < (const RangeData &rhs) const
- {
- if (this->base == rhs.base)
- {
- if (this->size == rhs.size)
- return this->data < rhs.data;
- else
- return this->size < rhs.size;
- }
- return this->base < rhs.base;
- }
-
- bool
- operator == (const RangeData &rhs) const
- {
- return this->GetRangeBase() == rhs.GetRangeBase() &&
- this->GetByteSize() == rhs.GetByteSize() &&
- this->data == rhs.data;
- }
-
- bool
- operator != (const RangeData &rhs) const
- {
- return this->GetRangeBase() != rhs.GetRangeBase() ||
- this->GetByteSize() != rhs.GetByteSize() ||
- this->data != rhs.data;
- }
- };
-
- template <typename B, typename S, typename T, unsigned N>
- class RangeDataArray
- {
- public:
- typedef RangeData<B,S,T> Entry;
- typedef llvm::SmallVector<Entry, N> Collection;
-
- RangeDataArray() = default;
-
- ~RangeDataArray() = default;
-
- void
- Append (const Entry &entry)
- {
- m_entries.push_back (entry);
- }
-
- void
- Sort ()
- {
- if (m_entries.size() > 1)
- std::stable_sort (m_entries.begin(), m_entries.end());
- }
-
+ if (!m_entries.empty()) {
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, range, BaseLessThan);
+
+ if (pos != end && pos->Contains(range)) {
+ return &(*pos);
+ } else if (pos != begin) {
+ --pos;
+ if (pos->Contains(range)) {
+ return &(*pos);
+ }
+ }
+ }
+ return nullptr;
+ }
+
+protected:
+ Collection m_entries;
+};
+
+//----------------------------------------------------------------------
+// A simple range with data class where you get to define the type of
+// the range base "B", the type used for the range byte size "S", and
+// the type for the associated data "T".
+//----------------------------------------------------------------------
+template <typename B, typename S, typename T>
+struct RangeData : public Range<B, S> {
+ typedef T DataType;
+
+ DataType data;
+
+ RangeData() : Range<B, S>(), data() {}
+
+ RangeData(B base, S size) : Range<B, S>(base, size), data() {}
+
+ RangeData(B base, S size, DataType d) : Range<B, S>(base, size), data(d) {}
+
+ bool operator<(const RangeData &rhs) const {
+ if (this->base == rhs.base) {
+ if (this->size == rhs.size)
+ return this->data < rhs.data;
+ else
+ return this->size < rhs.size;
+ }
+ return this->base < rhs.base;
+ }
+
+ bool operator==(const RangeData &rhs) const {
+ return this->GetRangeBase() == rhs.GetRangeBase() &&
+ this->GetByteSize() == rhs.GetByteSize() && this->data == rhs.data;
+ }
+
+ bool operator!=(const RangeData &rhs) const {
+ return this->GetRangeBase() != rhs.GetRangeBase() ||
+ this->GetByteSize() != rhs.GetByteSize() || this->data != rhs.data;
+ }
+};
+
+template <typename B, typename S, typename T, unsigned N> class RangeDataArray {
+public:
+ typedef RangeData<B, S, T> Entry;
+ typedef llvm::SmallVector<Entry, N> Collection;
+
+ RangeDataArray() = default;
+
+ ~RangeDataArray() = default;
+
+ void Append(const Entry &entry) { m_entries.push_back(entry); }
+
+ void Sort() {
+ if (m_entries.size() > 1)
+ std::stable_sort(m_entries.begin(), m_entries.end());
+ }
+
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- bool
- IsSorted () const
- {
- typename Collection::const_iterator pos, end, prev;
- // First we determine if we can combine any of the Entry objects so we
- // don't end up allocating and making a new collection for no reason
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && *pos < *prev)
- return false;
- }
- return true;
- }
+ bool IsSorted() const {
+ typename Collection::const_iterator pos, end, prev;
+ // First we determine if we can combine any of the Entry objects so we
+ // don't end up allocating and making a new collection for no reason
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end;
+ prev = pos++) {
+ if (prev != end && *pos < *prev)
+ return false;
+ }
+ return true;
+ }
#endif
- void
- CombineConsecutiveEntriesWithEqualData ()
- {
+ void CombineConsecutiveEntriesWithEqualData() {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ assert(IsSorted());
#endif
- typename Collection::iterator pos;
- typename Collection::iterator end;
- typename Collection::iterator prev;
- bool can_combine = false;
- // First we determine if we can combine any of the Entry objects so we
- // don't end up allocating and making a new collection for no reason
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && prev->data == pos->data)
- {
- can_combine = true;
- break;
- }
- }
-
- // We we can combine at least one entry, then we make a new collection
- // and populate it accordingly, and then swap it into place.
- if (can_combine)
- {
- Collection minimal_ranges;
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && prev->data == pos->data)
- minimal_ranges.back().SetRangeEnd (pos->GetRangeEnd());
- else
- minimal_ranges.push_back (*pos);
- }
- // Use the swap technique in case our new vector is much smaller.
- // We must swap when using the STL because std::vector objects never
- // release or reduce the memory once it has been allocated/reserved.
- m_entries.swap (minimal_ranges);
- }
- }
-
- void
- Clear ()
- {
- m_entries.clear();
- }
-
- bool
- IsEmpty () const
- {
- return m_entries.empty();
- }
-
- size_t
- GetSize () const
- {
- return m_entries.size();
- }
-
- const Entry *
- GetEntryAtIndex (size_t i) const
- {
- return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
- }
-
- // Clients must ensure that "i" is a valid index prior to calling this function
- const Entry &
- GetEntryRef (size_t i) const
- {
- return m_entries[i];
- }
-
- static bool
- BaseLessThan (const Entry& lhs, const Entry& rhs)
- {
- return lhs.GetRangeBase() < rhs.GetRangeBase();
- }
-
- uint32_t
- FindEntryIndexThatContains (B addr) const
- {
+ typename Collection::iterator pos;
+ typename Collection::iterator end;
+ typename Collection::iterator prev;
+ bool can_combine = false;
+ // First we determine if we can combine any of the Entry objects so we
+ // don't end up allocating and making a new collection for no reason
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end;
+ prev = pos++) {
+ if (prev != end && prev->data == pos->data) {
+ can_combine = true;
+ break;
+ }
+ }
+
+ // We we can combine at least one entry, then we make a new collection
+ // and populate it accordingly, and then swap it into place.
+ if (can_combine) {
+ Collection minimal_ranges;
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end;
+ pos != end; prev = pos++) {
+ if (prev != end && prev->data == pos->data)
+ minimal_ranges.back().SetRangeEnd(pos->GetRangeEnd());
+ else
+ minimal_ranges.push_back(*pos);
+ }
+ // Use the swap technique in case our new vector is much smaller.
+ // We must swap when using the STL because std::vector objects never
+ // release or reduce the memory once it has been allocated/reserved.
+ m_entries.swap(minimal_ranges);
+ }
+ }
+
+ void Clear() { m_entries.clear(); }
+
+ bool IsEmpty() const { return m_entries.empty(); }
+
+ size_t GetSize() const { return m_entries.size(); }
+
+ const Entry *GetEntryAtIndex(size_t i) const {
+ return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
+ }
+
+ // Clients must ensure that "i" is a valid index prior to calling this
+ // function
+ const Entry &GetEntryRef(size_t i) const { return m_entries[i]; }
+
+ static bool BaseLessThan(const Entry &lhs, const Entry &rhs) {
+ return lhs.GetRangeBase() < rhs.GetRangeBase();
+ }
+
+ uint32_t FindEntryIndexThatContains(B addr) const {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ assert(IsSorted());
#endif
- if ( !m_entries.empty() )
- {
- Entry entry (addr, 1);
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
-
- if (pos != end && pos->Contains(addr))
- {
- return std::distance (begin, pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(addr))
- return std::distance (begin, pos);
- }
- }
- return UINT32_MAX;
- }
-
- Entry *
- FindEntryThatContains (B addr)
- {
+ if (!m_entries.empty()) {
+ Entry entry(addr, 1);
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, entry, BaseLessThan);
+
+ if (pos != end && pos->Contains(addr)) {
+ return std::distance(begin, pos);
+ } else if (pos != begin) {
+ --pos;
+ if (pos->Contains(addr))
+ return std::distance(begin, pos);
+ }
+ }
+ return UINT32_MAX;
+ }
+
+ Entry *FindEntryThatContains(B addr) {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ assert(IsSorted());
#endif
- if ( !m_entries.empty() )
- {
- Entry entry;
- entry.SetRangeBase(addr);
- entry.SetByteSize(1);
- typename Collection::iterator begin = m_entries.begin();
- typename Collection::iterator end = m_entries.end();
- typename Collection::iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
-
- if (pos != end && pos->Contains(addr))
- {
- return &(*pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(addr))
- {
- return &(*pos);
- }
- }
- }
- return nullptr;
- }
-
- const Entry *
- FindEntryThatContains (B addr) const
- {
+ if (!m_entries.empty()) {
+ Entry entry;
+ entry.SetRangeBase(addr);
+ entry.SetByteSize(1);
+ typename Collection::iterator begin = m_entries.begin();
+ typename Collection::iterator end = m_entries.end();
+ typename Collection::iterator pos =
+ std::lower_bound(begin, end, entry, BaseLessThan);
+
+ if (pos != end && pos->Contains(addr)) {
+ return &(*pos);
+ } else if (pos != begin) {
+ --pos;
+ if (pos->Contains(addr)) {
+ return &(*pos);
+ }
+ }
+ }
+ return nullptr;
+ }
+
+ const Entry *FindEntryThatContains(B addr) const {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ assert(IsSorted());
#endif
- if ( !m_entries.empty() )
- {
- Entry entry;
- entry.SetRangeBase(addr);
- entry.SetByteSize(1);
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
-
- if (pos != end && pos->Contains(addr))
- {
- return &(*pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(addr))
- {
- return &(*pos);
- }
- }
- }
- return nullptr;
- }
-
- const Entry *
- FindEntryThatContains (const Entry &range) const
- {
+ if (!m_entries.empty()) {
+ Entry entry;
+ entry.SetRangeBase(addr);
+ entry.SetByteSize(1);
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, entry, BaseLessThan);
+
+ if (pos != end && pos->Contains(addr)) {
+ return &(*pos);
+ } else if (pos != begin) {
+ --pos;
+ if (pos->Contains(addr)) {
+ return &(*pos);
+ }
+ }
+ }
+ return nullptr;
+ }
+
+ const Entry *FindEntryThatContains(const Entry &range) const {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ assert(IsSorted());
#endif
- if ( !m_entries.empty() )
- {
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, range, BaseLessThan);
-
- if (pos != end && pos->Contains(range))
- {
- return &(*pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(range))
- {
- return &(*pos);
- }
- }
- }
- return nullptr;
- }
-
- Entry *
- Back()
- {
- return (m_entries.empty() ? nullptr : &m_entries.back());
- }
+ if (!m_entries.empty()) {
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, range, BaseLessThan);
- const Entry *
- Back() const
- {
- return (m_entries.empty() ? nullptr : &m_entries.back());
+ if (pos != end && pos->Contains(range)) {
+ return &(*pos);
+ } else if (pos != begin) {
+ --pos;
+ if (pos->Contains(range)) {
+ return &(*pos);
}
+ }
+ }
+ return nullptr;
+ }
- protected:
- Collection m_entries;
- };
+ Entry *Back() { return (m_entries.empty() ? nullptr : &m_entries.back()); }
- // Same as RangeDataArray, but uses std::vector as to not
- // require static storage of N items in the class itself
- template <typename B, typename S, typename T>
- class RangeDataVector
- {
- public:
- typedef RangeData<B,S,T> Entry;
- typedef std::vector<Entry> Collection;
+ const Entry *Back() const {
+ return (m_entries.empty() ? nullptr : &m_entries.back());
+ }
- RangeDataVector() = default;
+protected:
+ Collection m_entries;
+};
- ~RangeDataVector() = default;
+// Same as RangeDataArray, but uses std::vector as to not
+// require static storage of N items in the class itself
+template <typename B, typename S, typename T> class RangeDataVector {
+public:
+ typedef RangeData<B, S, T> Entry;
+ typedef std::vector<Entry> Collection;
+
+ RangeDataVector() = default;
+
+ ~RangeDataVector() = default;
+
+ void Append(const Entry &entry) { m_entries.push_back(entry); }
+
+ void Sort() {
+ if (m_entries.size() > 1)
+ std::stable_sort(m_entries.begin(), m_entries.end());
+ }
- void
- Append (const Entry &entry)
- {
- m_entries.push_back (entry);
- }
-
- void
- Sort ()
- {
- if (m_entries.size() > 1)
- std::stable_sort (m_entries.begin(), m_entries.end());
- }
-
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- bool
- IsSorted () const
- {
- typename Collection::const_iterator pos, end, prev;
- // First we determine if we can combine any of the Entry objects so we
- // don't end up allocating and making a new collection for no reason
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && *pos < *prev)
- return false;
- }
- return true;
- }
+ bool IsSorted() const {
+ typename Collection::const_iterator pos, end, prev;
+ // First we determine if we can combine any of the Entry objects so we
+ // don't end up allocating and making a new collection for no reason
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end;
+ prev = pos++) {
+ if (prev != end && *pos < *prev)
+ return false;
+ }
+ return true;
+ }
#endif
-
- void
- CombineConsecutiveEntriesWithEqualData ()
- {
+
+ void CombineConsecutiveEntriesWithEqualData() {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ assert(IsSorted());
#endif
- typename Collection::iterator pos;
- typename Collection::iterator end;
- typename Collection::iterator prev;
- bool can_combine = false;
- // First we determine if we can combine any of the Entry objects so we
- // don't end up allocating and making a new collection for no reason
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && prev->data == pos->data)
- {
- can_combine = true;
- break;
- }
- }
-
- // We we can combine at least one entry, then we make a new collection
- // and populate it accordingly, and then swap it into place.
- if (can_combine)
- {
- Collection minimal_ranges;
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && prev->data == pos->data)
- minimal_ranges.back().SetRangeEnd (pos->GetRangeEnd());
- else
- minimal_ranges.push_back (*pos);
- }
- // Use the swap technique in case our new vector is much smaller.
- // We must swap when using the STL because std::vector objects never
- // release or reduce the memory once it has been allocated/reserved.
- m_entries.swap (minimal_ranges);
- }
- }
-
- // Calculate the byte size of ranges with zero byte sizes by finding
- // the next entry with a base address > the current base address
- void
- CalculateSizesOfZeroByteSizeRanges (S full_size = 0)
- {
+ typename Collection::iterator pos;
+ typename Collection::iterator end;
+ typename Collection::iterator prev;
+ bool can_combine = false;
+ // First we determine if we can combine any of the Entry objects so we
+ // don't end up allocating and making a new collection for no reason
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end;
+ prev = pos++) {
+ if (prev != end && prev->data == pos->data) {
+ can_combine = true;
+ break;
+ }
+ }
+
+ // We we can combine at least one entry, then we make a new collection
+ // and populate it accordingly, and then swap it into place.
+ if (can_combine) {
+ Collection minimal_ranges;
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end;
+ pos != end; prev = pos++) {
+ if (prev != end && prev->data == pos->data)
+ minimal_ranges.back().SetRangeEnd(pos->GetRangeEnd());
+ else
+ minimal_ranges.push_back(*pos);
+ }
+ // Use the swap technique in case our new vector is much smaller.
+ // We must swap when using the STL because std::vector objects never
+ // release or reduce the memory once it has been allocated/reserved.
+ m_entries.swap(minimal_ranges);
+ }
+ }
+
+ // Calculate the byte size of ranges with zero byte sizes by finding
+ // the next entry with a base address > the current base address
+ void CalculateSizesOfZeroByteSizeRanges(S full_size = 0) {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ assert(IsSorted());
#endif
- typename Collection::iterator pos;
- typename Collection::iterator end;
- typename Collection::iterator next;
- for (pos = m_entries.begin(), end = m_entries.end(); pos != end; ++pos)
- {
- if (pos->GetByteSize() == 0)
- {
- // Watch out for multiple entries with same address and make sure
- // we find an entry that is greater than the current base address
- // before we use that for the size
- auto curr_base = pos->GetRangeBase();
- for (next = pos + 1; next != end; ++next)
- {
- auto next_base = next->GetRangeBase();
- if (next_base > curr_base)
- {
- pos->SetByteSize (next_base - curr_base);
- break;
- }
- }
- if (next == end && full_size > curr_base)
- pos->SetByteSize (full_size - curr_base);
- }
- }
- }
-
- void
- Clear ()
- {
- m_entries.clear();
- }
-
- void
- Reserve (typename Collection::size_type size)
- {
- m_entries.resize (size);
- }
-
- bool
- IsEmpty () const
- {
- return m_entries.empty();
- }
-
- size_t
- GetSize () const
- {
- return m_entries.size();
- }
-
- const Entry *
- GetEntryAtIndex (size_t i) const
- {
- return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
- }
-
- Entry *
- GetMutableEntryAtIndex (size_t i)
- {
- return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
- }
-
- // Clients must ensure that "i" is a valid index prior to calling this function
- const Entry &
- GetEntryRef (size_t i) const
- {
- return m_entries[i];
- }
-
- static bool
- BaseLessThan (const Entry& lhs, const Entry& rhs)
- {
- return lhs.GetRangeBase() < rhs.GetRangeBase();
- }
-
- uint32_t
- FindEntryIndexThatContains (B addr) const
- {
+ typename Collection::iterator pos;
+ typename Collection::iterator end;
+ typename Collection::iterator next;
+ for (pos = m_entries.begin(), end = m_entries.end(); pos != end; ++pos) {
+ if (pos->GetByteSize() == 0) {
+ // Watch out for multiple entries with same address and make sure
+ // we find an entry that is greater than the current base address
+ // before we use that for the size
+ auto curr_base = pos->GetRangeBase();
+ for (next = pos + 1; next != end; ++next) {
+ auto next_base = next->GetRangeBase();
+ if (next_base > curr_base) {
+ pos->SetByteSize(next_base - curr_base);
+ break;
+ }
+ }
+ if (next == end && full_size > curr_base)
+ pos->SetByteSize(full_size - curr_base);
+ }
+ }
+ }
+
+ void Clear() { m_entries.clear(); }
+
+ void Reserve(typename Collection::size_type size) { m_entries.resize(size); }
+
+ bool IsEmpty() const { return m_entries.empty(); }
+
+ size_t GetSize() const { return m_entries.size(); }
+
+ const Entry *GetEntryAtIndex(size_t i) const {
+ return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
+ }
+
+ Entry *GetMutableEntryAtIndex(size_t i) {
+ return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
+ }
+
+ // Clients must ensure that "i" is a valid index prior to calling this
+ // function
+ const Entry &GetEntryRef(size_t i) const { return m_entries[i]; }
+
+ static bool BaseLessThan(const Entry &lhs, const Entry &rhs) {
+ return lhs.GetRangeBase() < rhs.GetRangeBase();
+ }
+
+ uint32_t FindEntryIndexThatContains(B addr) const {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ assert(IsSorted());
#endif
- if ( !m_entries.empty() )
- {
- Entry entry (addr, 1);
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
-
- while(pos != begin && pos[-1].Contains(addr))
- --pos;
-
- if (pos != end && pos->Contains(addr))
- return std::distance (begin, pos);
- }
- return UINT32_MAX;
- }
-
- uint32_t
- FindEntryIndexesThatContain(B addr, std::vector<uint32_t> &indexes) const
- {
+ if (!m_entries.empty()) {
+ Entry entry(addr, 1);
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, entry, BaseLessThan);
+
+ while (pos != begin && pos[-1].Contains(addr))
+ --pos;
+
+ if (pos != end && pos->Contains(addr))
+ return std::distance(begin, pos);
+ }
+ return UINT32_MAX;
+ }
+
+ uint32_t FindEntryIndexesThatContain(B addr,
+ std::vector<uint32_t> &indexes) const {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ assert(IsSorted());
#endif
- if (!m_entries.empty())
- {
- typename Collection::const_iterator pos;
- for (const auto &entry : m_entries)
- {
- if (entry.Contains(addr))
- indexes.push_back(entry.data);
- }
- }
- return indexes.size() ;
- }
-
- Entry *
- FindEntryThatContains (B addr)
- {
+ if (!m_entries.empty()) {
+ typename Collection::const_iterator pos;
+ for (const auto &entry : m_entries) {
+ if (entry.Contains(addr))
+ indexes.push_back(entry.data);
+ }
+ }
+ return indexes.size();
+ }
+
+ Entry *FindEntryThatContains(B addr) {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ assert(IsSorted());
#endif
- if ( !m_entries.empty() )
- {
- Entry entry;
- entry.SetRangeBase(addr);
- entry.SetByteSize(1);
- typename Collection::iterator begin = m_entries.begin();
- typename Collection::iterator end = m_entries.end();
- typename Collection::iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
-
- while(pos != begin && pos[-1].Contains(addr))
- --pos;
-
- if (pos != end && pos->Contains(addr))
- return &(*pos);
- }
- return nullptr;
- }
-
- const Entry *
- FindEntryThatContains (B addr) const
- {
+ if (!m_entries.empty()) {
+ Entry entry;
+ entry.SetRangeBase(addr);
+ entry.SetByteSize(1);
+ typename Collection::iterator begin = m_entries.begin();
+ typename Collection::iterator end = m_entries.end();
+ typename Collection::iterator pos =
+ std::lower_bound(begin, end, entry, BaseLessThan);
+
+ while (pos != begin && pos[-1].Contains(addr))
+ --pos;
+
+ if (pos != end && pos->Contains(addr))
+ return &(*pos);
+ }
+ return nullptr;
+ }
+
+ const Entry *FindEntryThatContains(B addr) const {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ assert(IsSorted());
#endif
- if ( !m_entries.empty() )
- {
- Entry entry;
- entry.SetRangeBase(addr);
- entry.SetByteSize(1);
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
-
- while(pos != begin && pos[-1].Contains(addr))
- --pos;
-
- if (pos != end && pos->Contains(addr))
- return &(*pos);
- }
- return nullptr;
- }
-
- const Entry *
- FindEntryThatContains (const Entry &range) const
- {
+ if (!m_entries.empty()) {
+ Entry entry;
+ entry.SetRangeBase(addr);
+ entry.SetByteSize(1);
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, entry, BaseLessThan);
+
+ while (pos != begin && pos[-1].Contains(addr))
+ --pos;
+
+ if (pos != end && pos->Contains(addr))
+ return &(*pos);
+ }
+ return nullptr;
+ }
+
+ const Entry *FindEntryThatContains(const Entry &range) const {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ assert(IsSorted());
#endif
- if ( !m_entries.empty() )
- {
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, range, BaseLessThan);
-
- while(pos != begin && pos[-1].Contains(range))
- --pos;
-
- if (pos != end && pos->Contains(range))
- return &(*pos);
- }
- return nullptr;
- }
-
- const Entry*
- FindEntryStartsAt (B addr) const
- {
+ if (!m_entries.empty()) {
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, range, BaseLessThan);
+
+ while (pos != begin && pos[-1].Contains(range))
+ --pos;
+
+ if (pos != end && pos->Contains(range))
+ return &(*pos);
+ }
+ return nullptr;
+ }
+
+ const Entry *FindEntryStartsAt(B addr) const {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ assert(IsSorted());
#endif
- if (!m_entries.empty())
- {
- auto begin = m_entries.begin(), end = m_entries.end();
- auto pos = std::lower_bound (begin, end, Entry(addr, 1), BaseLessThan);
- if (pos != end && pos->base == addr)
- return &(*pos);
- }
- return nullptr;
- }
-
- const Entry *
- FindEntryThatContainsOrFollows(B addr) const
- {
+ if (!m_entries.empty()) {
+ auto begin = m_entries.begin(), end = m_entries.end();
+ auto pos = std::lower_bound(begin, end, Entry(addr, 1), BaseLessThan);
+ if (pos != end && pos->base == addr)
+ return &(*pos);
+ }
+ return nullptr;
+ }
+
+ // This method will return the entry that contains the given address, or the
+ // entry following that address. If you give it an address of 0 and the first
+ // entry starts at address 0x100, you will get the entry at 0x100.
+ //
+ // For most uses, FindEntryThatContains is the correct one to use, this is a
+ // less commonly needed behavior. It was added for core file memory regions,
+ // where we want to present a gap in the memory regions as a distinct region,
+ // so we need to know the start address of the next memory section that
+ // exists.
+ const Entry *FindEntryThatContainsOrFollows(B addr) const {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert(IsSorted());
+ assert(IsSorted());
#endif
- if (!m_entries.empty())
- {
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos =
- std::lower_bound(m_entries.begin(), end, addr, [](const Entry &lhs, B rhs_base) -> bool {
- return lhs.GetRangeEnd() <= rhs_base;
- });
-
- if (pos != end)
- return &(*pos);
- }
- return nullptr;
- }
+ if (!m_entries.empty()) {
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(m_entries.begin(), end, addr,
+ [](const Entry &lhs, B rhs_base) -> bool {
+ return lhs.GetRangeEnd() <= rhs_base;
+ });
- Entry *
- Back()
- {
- return (m_entries.empty() ? nullptr : &m_entries.back());
- }
-
- const Entry *
- Back() const
- {
- return (m_entries.empty() ? nullptr : &m_entries.back());
- }
-
- protected:
- Collection m_entries;
- };
-
- //----------------------------------------------------------------------
- // A simple range with data class where you get to define the type of
- // the range base "B", the type used for the range byte size "S", and
- // the type for the associated data "T".
- //----------------------------------------------------------------------
- template <typename B, typename T>
- struct AddressData
- {
- typedef B BaseType;
- typedef T DataType;
-
- BaseType addr;
- DataType data;
-
- AddressData () :
- addr (),
- data ()
- {
- }
-
- AddressData (B a, DataType d) :
- addr (a),
- data (d)
- {
- }
-
- bool
- operator < (const AddressData &rhs) const
- {
- if (this->addr == rhs.addr)
- return this->data < rhs.data;
- return this->addr < rhs.addr;
- }
-
- bool
- operator == (const AddressData &rhs) const
- {
- return this->addr == rhs.addr &&
- this->data == rhs.data;
- }
-
- bool
- operator != (const AddressData &rhs) const
- {
- return this->addr != rhs.addr ||
- this->data == rhs.data;
- }
- };
+ while (pos != begin && pos[-1].Contains(addr))
+ --pos;
- template <typename B, typename T, unsigned N>
- class AddressDataArray
- {
- public:
- typedef AddressData<B,T> Entry;
- typedef llvm::SmallVector<Entry, N> Collection;
+ if (pos != end)
+ return &(*pos);
+ }
+ return nullptr;
+ }
- AddressDataArray() = default;
+ Entry *Back() { return (m_entries.empty() ? nullptr : &m_entries.back()); }
- ~AddressDataArray() = default;
+ const Entry *Back() const {
+ return (m_entries.empty() ? nullptr : &m_entries.back());
+ }
- void
- Append (const Entry &entry)
- {
- m_entries.push_back (entry);
- }
-
- void
- Sort ()
- {
- if (m_entries.size() > 1)
- std::stable_sort (m_entries.begin(), m_entries.end());
- }
-
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- bool
- IsSorted () const
- {
- typename Collection::const_iterator pos, end, prev;
- // First we determine if we can combine any of the Entry objects so we
- // don't end up allocating and making a new collection for no reason
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && *pos < *prev)
- return false;
- }
- return true;
- }
-#endif
+protected:
+ Collection m_entries;
+};
- void
- Clear ()
- {
- m_entries.clear();
- }
-
- bool
- IsEmpty () const
- {
- return m_entries.empty();
- }
-
- size_t
- GetSize () const
- {
- return m_entries.size();
- }
-
- const Entry *
- GetEntryAtIndex (size_t i) const
- {
- return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
- }
+//----------------------------------------------------------------------
+// A simple range with data class where you get to define the type of
+// the range base "B", the type used for the range byte size "S", and
+// the type for the associated data "T".
+//----------------------------------------------------------------------
+template <typename B, typename T> struct AddressData {
+ typedef B BaseType;
+ typedef T DataType;
- // Clients must ensure that "i" is a valid index prior to calling this function
- const Entry &
- GetEntryRef (size_t i) const
- {
- return m_entries[i];
- }
+ BaseType addr;
+ DataType data;
+
+ AddressData() : addr(), data() {}
+
+ AddressData(B a, DataType d) : addr(a), data(d) {}
+
+ bool operator<(const AddressData &rhs) const {
+ if (this->addr == rhs.addr)
+ return this->data < rhs.data;
+ return this->addr < rhs.addr;
+ }
+
+ bool operator==(const AddressData &rhs) const {
+ return this->addr == rhs.addr && this->data == rhs.data;
+ }
+
+ bool operator!=(const AddressData &rhs) const {
+ return this->addr != rhs.addr || this->data == rhs.data;
+ }
+};
+
+template <typename B, typename T, unsigned N> class AddressDataArray {
+public:
+ typedef AddressData<B, T> Entry;
+ typedef llvm::SmallVector<Entry, N> Collection;
+
+ AddressDataArray() = default;
+
+ ~AddressDataArray() = default;
+
+ void Append(const Entry &entry) { m_entries.push_back(entry); }
+
+ void Sort() {
+ if (m_entries.size() > 1)
+ std::stable_sort(m_entries.begin(), m_entries.end());
+ }
- static bool
- BaseLessThan (const Entry& lhs, const Entry& rhs)
- {
- return lhs.addr < rhs.addr;
- }
-
- Entry *
- FindEntry (B addr, bool exact_match_only)
- {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
+ bool IsSorted() const {
+ typename Collection::const_iterator pos, end, prev;
+ // First we determine if we can combine any of the Entry objects so we
+ // don't end up allocating and making a new collection for no reason
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end;
+ prev = pos++) {
+ if (prev != end && *pos < *prev)
+ return false;
+ }
+ return true;
+ }
#endif
- if ( !m_entries.empty() )
- {
- Entry entry;
- entry.addr = addr;
- typename Collection::iterator begin = m_entries.begin();
- typename Collection::iterator end = m_entries.end();
- typename Collection::iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
-
- while(pos != begin && pos[-1].addr == addr)
- --pos;
-
- if (pos != end)
- {
- if (pos->addr == addr || !exact_match_only)
- return &(*pos);
- }
- }
- return nullptr;
- }
-
- const Entry *
- FindNextEntry (const Entry *entry)
- {
- if (entry >= &*m_entries.begin() && entry + 1 < &*m_entries.end())
- return entry + 1;
- return nullptr;
- }
-
- Entry *
- Back()
- {
- return (m_entries.empty() ? nullptr : &m_entries.back());
- }
- const Entry *
- Back() const
- {
- return (m_entries.empty() ? nullptr : &m_entries.back());
- }
+ void Clear() { m_entries.clear(); }
+
+ bool IsEmpty() const { return m_entries.empty(); }
+
+ size_t GetSize() const { return m_entries.size(); }
- protected:
- Collection m_entries;
- };
+ const Entry *GetEntryAtIndex(size_t i) const {
+ return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
+ }
+
+ // Clients must ensure that "i" is a valid index prior to calling this
+ // function
+ const Entry &GetEntryRef(size_t i) const { return m_entries[i]; }
+
+ static bool BaseLessThan(const Entry &lhs, const Entry &rhs) {
+ return lhs.addr < rhs.addr;
+ }
+
+ Entry *FindEntry(B addr, bool exact_match_only) {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (!m_entries.empty()) {
+ Entry entry;
+ entry.addr = addr;
+ typename Collection::iterator begin = m_entries.begin();
+ typename Collection::iterator end = m_entries.end();
+ typename Collection::iterator pos =
+ std::lower_bound(begin, end, entry, BaseLessThan);
+
+ while (pos != begin && pos[-1].addr == addr)
+ --pos;
+
+ if (pos != end) {
+ if (pos->addr == addr || !exact_match_only)
+ return &(*pos);
+ }
+ }
+ return nullptr;
+ }
+
+ const Entry *FindNextEntry(const Entry *entry) {
+ if (entry >= &*m_entries.begin() && entry + 1 < &*m_entries.end())
+ return entry + 1;
+ return nullptr;
+ }
+
+ Entry *Back() { return (m_entries.empty() ? nullptr : &m_entries.back()); }
+
+ const Entry *Back() const {
+ return (m_entries.empty() ? nullptr : &m_entries.back());
+ }
+
+protected:
+ Collection m_entries;
+};
} // namespace lldb_private
diff --git a/include/lldb/Core/RegisterValue.h b/include/lldb/Core/RegisterValue.h
index 0626b5f2c857..78dfbea97032 100644
--- a/include/lldb/Core/RegisterValue.h
+++ b/include/lldb/Core/RegisterValue.h
@@ -18,376 +18,260 @@
#include "llvm/ADT/APInt.h"
// Project includes
-#include "lldb/lldb-public.h"
-#include "lldb/lldb-private.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Core/Scalar.h"
+#include "lldb/Host/Endian.h"
+#include "lldb/lldb-private.h"
+#include "lldb/lldb-public.h"
namespace lldb_private {
- class RegisterValue
- {
- public:
- enum
- {
- kMaxRegisterByteSize = 32u
- };
-
- enum Type
- {
- eTypeInvalid,
- eTypeUInt8,
- eTypeUInt16,
- eTypeUInt32,
- eTypeUInt64,
- eTypeUInt128,
- eTypeFloat,
- eTypeDouble,
- eTypeLongDouble,
- eTypeBytes
- };
-
- RegisterValue () :
- m_type (eTypeInvalid),
- m_scalar ((unsigned long)0)
- {
- }
-
- explicit
- RegisterValue (uint8_t inst) :
- m_type (eTypeUInt8)
- {
- m_scalar = inst;
- }
-
- explicit
- RegisterValue (uint16_t inst) :
- m_type (eTypeUInt16)
- {
- m_scalar = inst;
- }
-
- explicit
- RegisterValue (uint32_t inst) :
- m_type (eTypeUInt32)
- {
- m_scalar = inst;
- }
-
- explicit
- RegisterValue (uint64_t inst) :
- m_type (eTypeUInt64)
- {
- m_scalar = inst;
- }
-
- explicit
- RegisterValue (llvm::APInt inst) :
- m_type (eTypeUInt128)
- {
- m_scalar = llvm::APInt(inst);
- }
-
- explicit
- RegisterValue (float value) :
- m_type (eTypeFloat)
- {
- m_scalar = value;
- }
-
- explicit
- RegisterValue (double value) :
- m_type (eTypeDouble)
- {
- m_scalar = value;
- }
-
- explicit
- RegisterValue (long double value) :
- m_type (eTypeLongDouble)
- {
- m_scalar = value;
- }
-
- explicit
- RegisterValue (uint8_t *bytes, size_t length, lldb::ByteOrder byte_order)
- {
- SetBytes (bytes, length, byte_order);
- }
-
- RegisterValue::Type
- GetType () const
- {
- return m_type;
- }
-
- bool
- CopyValue (const RegisterValue &rhs);
-
- void
- SetType (RegisterValue::Type type)
- {
- m_type = type;
- }
-
- RegisterValue::Type
- SetType (const RegisterInfo *reg_info);
-
- bool
- GetData (DataExtractor &data) const;
-
- // Copy the register value from this object into a buffer in "dst"
- // and obey the "dst_byte_order" when copying the data. Also watch out
- // in case "dst_len" is longer or shorter than the register value
- // described by "reg_info" and only copy the least significant bytes
- // of the register value, or pad the destination with zeroes if the
- // register byte size is shorter that "dst_len" (all while correctly
- // abiding the "dst_byte_order"). Returns the number of bytes copied
- // into "dst".
- uint32_t
- GetAsMemoryData (const RegisterInfo *reg_info,
- void *dst,
- uint32_t dst_len,
- lldb::ByteOrder dst_byte_order,
- Error &error) const;
-
- uint32_t
- SetFromMemoryData (const RegisterInfo *reg_info,
- const void *src,
- uint32_t src_len,
- lldb::ByteOrder src_byte_order,
- Error &error);
-
- bool
- GetScalarValue (Scalar &scalar) const;
-
- uint8_t
- GetAsUInt8(uint8_t fail_value = UINT8_MAX, bool *success_ptr = nullptr) const
- {
- if (m_type == eTypeUInt8)
- {
- if (success_ptr)
- *success_ptr = true;
- return m_scalar.UChar(fail_value);
- }
- if (success_ptr)
- *success_ptr = true;
- return fail_value;
- }
-
- uint16_t
- GetAsUInt16(uint16_t fail_value = UINT16_MAX, bool *success_ptr = nullptr) const;
-
- uint32_t
- GetAsUInt32(uint32_t fail_value = UINT32_MAX, bool *success_ptr = nullptr) const;
-
- uint64_t
- GetAsUInt64(uint64_t fail_value = UINT64_MAX, bool *success_ptr = nullptr) const;
-
- llvm::APInt
- GetAsUInt128(const llvm::APInt& fail_value, bool *success_ptr = nullptr) const;
-
- float
- GetAsFloat(float fail_value = 0.0f, bool *success_ptr = nullptr) const;
-
- double
- GetAsDouble(double fail_value = 0.0, bool *success_ptr = nullptr) const;
-
- long double
- GetAsLongDouble(long double fail_value = 0.0, bool *success_ptr = nullptr) const;
-
- void
- SetValueToInvalid ()
- {
- m_type = eTypeInvalid;
- }
-
- bool
- ClearBit (uint32_t bit);
-
- bool
- SetBit (uint32_t bit);
-
- bool
- operator == (const RegisterValue &rhs) const;
-
- bool
- operator != (const RegisterValue &rhs) const;
-
- void
- operator = (uint8_t uint)
- {
- m_type = eTypeUInt8;
- m_scalar = uint;
- }
-
- void
- operator = (uint16_t uint)
- {
- m_type = eTypeUInt16;
- m_scalar = uint;
- }
-
- void
- operator = (uint32_t uint)
- {
- m_type = eTypeUInt32;
- m_scalar = uint;
- }
-
- void
- operator = (uint64_t uint)
- {
- m_type = eTypeUInt64;
- m_scalar = uint;
- }
-
- void
- operator = (llvm::APInt uint)
- {
- m_type = eTypeUInt128;
- m_scalar = llvm::APInt(uint);
- }
-
- void
- operator = (float f)
- {
- m_type = eTypeFloat;
- m_scalar = f;
- }
-
- void
- operator = (double f)
- {
- m_type = eTypeDouble;
- m_scalar = f;
- }
-
- void
- operator = (long double f)
- {
- m_type = eTypeLongDouble;
- m_scalar = f;
- }
-
- void
- SetUInt8 (uint8_t uint)
- {
- m_type = eTypeUInt8;
- m_scalar = uint;
- }
-
- void
- SetUInt16 (uint16_t uint)
- {
- m_type = eTypeUInt16;
- m_scalar = uint;
- }
-
- void
- SetUInt32 (uint32_t uint, Type t = eTypeUInt32)
- {
- m_type = t;
- m_scalar = uint;
- }
-
- void
- SetUInt64 (uint64_t uint, Type t = eTypeUInt64)
- {
- m_type = t;
- m_scalar = uint;
- }
-
- void
- SetUInt128 (llvm::APInt uint)
- {
- m_type = eTypeUInt128;
- m_scalar = uint;
- }
-
- bool
- SetUInt (uint64_t uint, uint32_t byte_size);
-
- void
- SetFloat (float f)
- {
- m_type = eTypeFloat;
- m_scalar = f;
- }
-
- void
- SetDouble (double f)
- {
- m_type = eTypeDouble;
- m_scalar = f;
- }
-
- void
- SetLongDouble (long double f)
- {
- m_type = eTypeLongDouble;
- m_scalar = f;
- }
-
- void
- SetBytes (const void *bytes, size_t length, lldb::ByteOrder byte_order);
-
- bool
- SignExtend (uint32_t sign_bitpos);
-
- Error
- SetValueFromCString (const RegisterInfo *reg_info,
- const char *value_str);
-
- Error
- SetValueFromData (const RegisterInfo *reg_info,
- DataExtractor &data,
- lldb::offset_t offset,
- bool partial_data_ok);
-
- // The default value of 0 for reg_name_right_align_at means no alignment at all.
- bool
- Dump (Stream *s,
- const RegisterInfo *reg_info,
- bool prefix_with_name,
- bool prefix_with_alt_name,
- lldb::Format format,
- uint32_t reg_name_right_align_at = 0) const;
-
- const void *
- GetBytes () const;
-
- lldb::ByteOrder
- GetByteOrder () const
- {
- if (m_type == eTypeBytes)
- return buffer.byte_order;
- return endian::InlHostByteOrder();
- }
-
- uint32_t
- GetByteSize () const;
-
- static uint32_t
- GetMaxByteSize ()
- {
- return kMaxRegisterByteSize;
- }
-
- void
- Clear();
-
- protected:
- RegisterValue::Type m_type;
- Scalar m_scalar;
-
- struct
- {
- uint8_t bytes[kMaxRegisterByteSize]; // This must be big enough to hold any register for any supported target.
- uint8_t length;
- lldb::ByteOrder byte_order;
- } buffer;
- };
+class RegisterValue {
+public:
+ enum { kMaxRegisterByteSize = 32u };
+
+ enum Type {
+ eTypeInvalid,
+ eTypeUInt8,
+ eTypeUInt16,
+ eTypeUInt32,
+ eTypeUInt64,
+ eTypeUInt128,
+ eTypeFloat,
+ eTypeDouble,
+ eTypeLongDouble,
+ eTypeBytes
+ };
+
+ RegisterValue() : m_type(eTypeInvalid), m_scalar((unsigned long)0) {}
+
+ explicit RegisterValue(uint8_t inst) : m_type(eTypeUInt8) { m_scalar = inst; }
+
+ explicit RegisterValue(uint16_t inst) : m_type(eTypeUInt16) {
+ m_scalar = inst;
+ }
+
+ explicit RegisterValue(uint32_t inst) : m_type(eTypeUInt32) {
+ m_scalar = inst;
+ }
+
+ explicit RegisterValue(uint64_t inst) : m_type(eTypeUInt64) {
+ m_scalar = inst;
+ }
+
+ explicit RegisterValue(llvm::APInt inst) : m_type(eTypeUInt128) {
+ m_scalar = llvm::APInt(inst);
+ }
+
+ explicit RegisterValue(float value) : m_type(eTypeFloat) { m_scalar = value; }
+
+ explicit RegisterValue(double value) : m_type(eTypeDouble) {
+ m_scalar = value;
+ }
+
+ explicit RegisterValue(long double value) : m_type(eTypeLongDouble) {
+ m_scalar = value;
+ }
+
+ explicit RegisterValue(uint8_t *bytes, size_t length,
+ lldb::ByteOrder byte_order) {
+ SetBytes(bytes, length, byte_order);
+ }
+
+ RegisterValue::Type GetType() const { return m_type; }
+
+ bool CopyValue(const RegisterValue &rhs);
+
+ void SetType(RegisterValue::Type type) { m_type = type; }
+
+ RegisterValue::Type SetType(const RegisterInfo *reg_info);
+
+ bool GetData(DataExtractor &data) const;
+
+ // Copy the register value from this object into a buffer in "dst"
+ // and obey the "dst_byte_order" when copying the data. Also watch out
+ // in case "dst_len" is longer or shorter than the register value
+ // described by "reg_info" and only copy the least significant bytes
+ // of the register value, or pad the destination with zeroes if the
+ // register byte size is shorter that "dst_len" (all while correctly
+ // abiding the "dst_byte_order"). Returns the number of bytes copied
+ // into "dst".
+ uint32_t GetAsMemoryData(const RegisterInfo *reg_info, void *dst,
+ uint32_t dst_len, lldb::ByteOrder dst_byte_order,
+ Error &error) const;
+
+ uint32_t SetFromMemoryData(const RegisterInfo *reg_info, const void *src,
+ uint32_t src_len, lldb::ByteOrder src_byte_order,
+ Error &error);
+
+ bool GetScalarValue(Scalar &scalar) const;
+
+ uint8_t GetAsUInt8(uint8_t fail_value = UINT8_MAX,
+ bool *success_ptr = nullptr) const {
+ if (m_type == eTypeUInt8) {
+ if (success_ptr)
+ *success_ptr = true;
+ return m_scalar.UChar(fail_value);
+ }
+ if (success_ptr)
+ *success_ptr = true;
+ return fail_value;
+ }
+
+ uint16_t GetAsUInt16(uint16_t fail_value = UINT16_MAX,
+ bool *success_ptr = nullptr) const;
+
+ uint32_t GetAsUInt32(uint32_t fail_value = UINT32_MAX,
+ bool *success_ptr = nullptr) const;
+
+ uint64_t GetAsUInt64(uint64_t fail_value = UINT64_MAX,
+ bool *success_ptr = nullptr) const;
+
+ llvm::APInt GetAsUInt128(const llvm::APInt &fail_value,
+ bool *success_ptr = nullptr) const;
+
+ float GetAsFloat(float fail_value = 0.0f, bool *success_ptr = nullptr) const;
+
+ double GetAsDouble(double fail_value = 0.0,
+ bool *success_ptr = nullptr) const;
+
+ long double GetAsLongDouble(long double fail_value = 0.0,
+ bool *success_ptr = nullptr) const;
+
+ void SetValueToInvalid() { m_type = eTypeInvalid; }
+
+ bool ClearBit(uint32_t bit);
+
+ bool SetBit(uint32_t bit);
+
+ bool operator==(const RegisterValue &rhs) const;
+
+ bool operator!=(const RegisterValue &rhs) const;
+
+ void operator=(uint8_t uint) {
+ m_type = eTypeUInt8;
+ m_scalar = uint;
+ }
+
+ void operator=(uint16_t uint) {
+ m_type = eTypeUInt16;
+ m_scalar = uint;
+ }
+
+ void operator=(uint32_t uint) {
+ m_type = eTypeUInt32;
+ m_scalar = uint;
+ }
+
+ void operator=(uint64_t uint) {
+ m_type = eTypeUInt64;
+ m_scalar = uint;
+ }
+
+ void operator=(llvm::APInt uint) {
+ m_type = eTypeUInt128;
+ m_scalar = llvm::APInt(uint);
+ }
+
+ void operator=(float f) {
+ m_type = eTypeFloat;
+ m_scalar = f;
+ }
+
+ void operator=(double f) {
+ m_type = eTypeDouble;
+ m_scalar = f;
+ }
+
+ void operator=(long double f) {
+ m_type = eTypeLongDouble;
+ m_scalar = f;
+ }
+
+ void SetUInt8(uint8_t uint) {
+ m_type = eTypeUInt8;
+ m_scalar = uint;
+ }
+
+ void SetUInt16(uint16_t uint) {
+ m_type = eTypeUInt16;
+ m_scalar = uint;
+ }
+
+ void SetUInt32(uint32_t uint, Type t = eTypeUInt32) {
+ m_type = t;
+ m_scalar = uint;
+ }
+
+ void SetUInt64(uint64_t uint, Type t = eTypeUInt64) {
+ m_type = t;
+ m_scalar = uint;
+ }
+
+ void SetUInt128(llvm::APInt uint) {
+ m_type = eTypeUInt128;
+ m_scalar = uint;
+ }
+
+ bool SetUInt(uint64_t uint, uint32_t byte_size);
+
+ void SetFloat(float f) {
+ m_type = eTypeFloat;
+ m_scalar = f;
+ }
+
+ void SetDouble(double f) {
+ m_type = eTypeDouble;
+ m_scalar = f;
+ }
+
+ void SetLongDouble(long double f) {
+ m_type = eTypeLongDouble;
+ m_scalar = f;
+ }
+
+ void SetBytes(const void *bytes, size_t length, lldb::ByteOrder byte_order);
+
+ bool SignExtend(uint32_t sign_bitpos);
+
+ Error SetValueFromString(const RegisterInfo *reg_info,
+ llvm::StringRef value_str);
+ Error SetValueFromString(const RegisterInfo *reg_info,
+ const char *value_str) = delete;
+
+ Error SetValueFromData(const RegisterInfo *reg_info, DataExtractor &data,
+ lldb::offset_t offset, bool partial_data_ok);
+
+ // The default value of 0 for reg_name_right_align_at means no alignment at
+ // all.
+ bool Dump(Stream *s, const RegisterInfo *reg_info, bool prefix_with_name,
+ bool prefix_with_alt_name, lldb::Format format,
+ uint32_t reg_name_right_align_at = 0) const;
+
+ const void *GetBytes() const;
+
+ lldb::ByteOrder GetByteOrder() const {
+ if (m_type == eTypeBytes)
+ return buffer.byte_order;
+ return endian::InlHostByteOrder();
+ }
+
+ uint32_t GetByteSize() const;
+
+ static uint32_t GetMaxByteSize() { return kMaxRegisterByteSize; }
+
+ void Clear();
+
+protected:
+ RegisterValue::Type m_type;
+ Scalar m_scalar;
+
+ struct {
+ uint8_t bytes[kMaxRegisterByteSize]; // This must be big enough to hold any
+ // register for any supported target.
+ uint8_t length;
+ lldb::ByteOrder byte_order;
+ } buffer;
+};
} // namespace lldb_private
diff --git a/include/lldb/Core/RegularExpression.h b/include/lldb/Core/RegularExpression.h
index b0ece5154ce1..fe34ef545dc4 100644
--- a/include/lldb/Core/RegularExpression.h
+++ b/include/lldb/Core/RegularExpression.h
@@ -16,28 +16,22 @@
typedef llvm_regmatch_t regmatch_t;
typedef llvm_regex_t regex_t;
-inline int regcomp(llvm_regex_t * a, const char *b, int c)
-{
- return llvm_regcomp(a, b, c);
+inline int regcomp(llvm_regex_t *a, const char *b, int c) {
+ return llvm_regcomp(a, b, c);
}
-inline size_t regerror(int a, const llvm_regex_t *b, char *c, size_t d)
-{
- return llvm_regerror(a, b, c, d);
+inline size_t regerror(int a, const llvm_regex_t *b, char *c, size_t d) {
+ return llvm_regerror(a, b, c, d);
}
-inline int regexec(const llvm_regex_t * a, const char * b, size_t c,
- llvm_regmatch_t d [], int e)
-{
- return llvm_regexec(a, b, c, d, e);
+inline int regexec(const llvm_regex_t *a, const char *b, size_t c,
+ llvm_regmatch_t d[], int e) {
+ return llvm_regexec(a, b, c, d, e);
}
-inline void regfree(llvm_regex_t * a)
-{
- llvm_regfree(a);
-}
+inline void regfree(llvm_regex_t *a) { llvm_regfree(a); }
#else
-#if __ANDROID_NDK__
+#ifdef __ANDROID__
#include <regex>
#endif
#include <regex.h>
@@ -47,9 +41,8 @@ inline void regfree(llvm_regex_t * a)
#include <string>
#include <vector>
-namespace llvm
-{
- class StringRef;
+namespace llvm {
+class StringRef;
} // namespace llvm
namespace lldb_private {
@@ -62,182 +55,160 @@ namespace lldb_private {
/// \c regcomp(), \c regerror(), \c regexec(), and \c regfree() from
/// the header file in \c /usr/include/regex\.h.
//----------------------------------------------------------------------
-class RegularExpression
-{
+class RegularExpression {
public:
- class Match
- {
- public:
- Match (uint32_t max_matches) :
- m_matches ()
- {
- if (max_matches > 0)
- m_matches.resize(max_matches + 1);
- }
-
- void
- Clear()
- {
- const size_t num_matches = m_matches.size();
- regmatch_t invalid_match = { -1, -1 };
- for (size_t i=0; i<num_matches; ++i)
- m_matches[i] = invalid_match;
- }
-
- size_t
- GetSize () const
- {
- return m_matches.size();
- }
-
- regmatch_t *
- GetData ()
- {
- return (m_matches.empty() ? nullptr : m_matches.data());
- }
-
- bool
- GetMatchAtIndex (const char* s, uint32_t idx, std::string& match_str) const;
-
- bool
- GetMatchAtIndex (const char* s, uint32_t idx, llvm::StringRef& match_str) const;
-
- bool
- GetMatchSpanningIndices (const char* s, uint32_t idx1, uint32_t idx2, llvm::StringRef& match_str) const;
-
- protected:
- std::vector<regmatch_t> m_matches; ///< Where parenthesized subexpressions results are stored
- };
-
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// The default constructor that initializes the object state such
- /// that it contains no compiled regular expression.
- //------------------------------------------------------------------
- RegularExpression ();
-
- explicit
- RegularExpression (const char* re);
-
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// Any previously compiled regular expression contained in this
- /// object will be freed.
- //------------------------------------------------------------------
- ~RegularExpression ();
-
- RegularExpression (const RegularExpression &rhs);
-
- const RegularExpression & operator=(const RegularExpression &rhs);
-
- //------------------------------------------------------------------
- /// Compile a regular expression.
- ///
- /// Compile a regular expression using the supplied regular
- /// expression text. The compiled regular expression lives
- /// in this object so that it can be readily used for regular
- /// expression matches. Execute() can be called after the regular
- /// expression is compiled. Any previously compiled regular
- /// expression contained in this object will be freed.
- ///
- /// @param[in] re
- /// A NULL terminated C string that represents the regular
- /// expression to compile.
- ///
- /// @return
- /// \b true if the regular expression compiles successfully,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool
- Compile (const char* re);
-
- //------------------------------------------------------------------
- /// Executes a regular expression.
- ///
- /// Execute a regular expression match using the compiled regular
- /// expression that is already in this object against the match
- /// string \a s. If any parens are used for regular expression
- /// matches \a match_count should indicate the number of regmatch_t
- /// values that are present in \a match_ptr.
- ///
- /// @param[in] string
- /// The string to match against the compile regular expression.
- ///
- /// @param[in] match
- /// A pointer to a RegularExpression::Match structure that was
- /// properly initialized with the desired number of maximum
- /// matches, or nullptr if no parenthesized matching is needed.
- ///
- /// @return
- /// \b true if \a string matches the compiled regular
- /// expression, \b false otherwise.
- //------------------------------------------------------------------
- bool
- Execute(const char* string, Match *match = nullptr) const;
-
- size_t
- GetErrorAsCString (char *err_str, size_t err_str_max_len) const;
-
- //------------------------------------------------------------------
- /// Free the compiled regular expression.
- ///
- /// If this object contains a valid compiled regular expression,
- /// this function will free any resources it was consuming.
- //------------------------------------------------------------------
- void
- Free ();
-
- //------------------------------------------------------------------
- /// Access the regular expression text.
- ///
- /// Returns the text that was used to compile the current regular
- /// expression.
- ///
- /// @return
- /// The NULL terminated C string that was used to compile the
- /// current regular expression
- //------------------------------------------------------------------
- const char*
- GetText () const;
-
- //------------------------------------------------------------------
- /// Test if valid.
- ///
- /// Test if this object contains a valid regular expression.
- ///
- /// @return
- /// \b true if the regular expression compiled and is ready
- /// for execution, \b false otherwise.
- //------------------------------------------------------------------
- bool
- IsValid () const;
-
- void
- Clear ()
- {
- Free();
- m_re.clear();
- m_comp_err = 1;
+ class Match {
+ public:
+ Match(uint32_t max_matches) : m_matches() {
+ if (max_matches > 0)
+ m_matches.resize(max_matches + 1);
+ }
+
+ void Clear() {
+ const size_t num_matches = m_matches.size();
+ regmatch_t invalid_match = {-1, -1};
+ for (size_t i = 0; i < num_matches; ++i)
+ m_matches[i] = invalid_match;
}
-
- int
- GetErrorCode() const
- {
- return m_comp_err;
+
+ size_t GetSize() const { return m_matches.size(); }
+
+ regmatch_t *GetData() {
+ return (m_matches.empty() ? nullptr : m_matches.data());
}
- bool
- operator < (const RegularExpression& rhs) const;
+ bool GetMatchAtIndex(llvm::StringRef s, uint32_t idx,
+ std::string &match_str) const;
+
+ bool GetMatchAtIndex(llvm::StringRef s, uint32_t idx,
+ llvm::StringRef &match_str) const;
+
+ bool GetMatchSpanningIndices(llvm::StringRef s, uint32_t idx1,
+ uint32_t idx2,
+ llvm::StringRef &match_str) const;
+
+ protected:
+ std::vector<regmatch_t>
+ m_matches; ///< Where parenthesized subexpressions results are stored
+ };
+
+ //------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// The default constructor that initializes the object state such
+ /// that it contains no compiled regular expression.
+ //------------------------------------------------------------------
+ RegularExpression();
+
+ explicit RegularExpression(llvm::StringRef string);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ ///
+ /// Any previously compiled regular expression contained in this
+ /// object will be freed.
+ //------------------------------------------------------------------
+ ~RegularExpression();
+
+ RegularExpression(const RegularExpression &rhs);
+
+ const RegularExpression &operator=(const RegularExpression &rhs);
+
+ //------------------------------------------------------------------
+ /// Compile a regular expression.
+ ///
+ /// Compile a regular expression using the supplied regular
+ /// expression text. The compiled regular expression lives
+ /// in this object so that it can be readily used for regular
+ /// expression matches. Execute() can be called after the regular
+ /// expression is compiled. Any previously compiled regular
+ /// expression contained in this object will be freed.
+ ///
+ /// @param[in] re
+ /// A NULL terminated C string that represents the regular
+ /// expression to compile.
+ ///
+ /// @return
+ /// \b true if the regular expression compiles successfully,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool Compile(llvm::StringRef string);
+ bool Compile(const char *) = delete;
+
+ //------------------------------------------------------------------
+ /// Executes a regular expression.
+ ///
+ /// Execute a regular expression match using the compiled regular
+ /// expression that is already in this object against the match
+ /// string \a s. If any parens are used for regular expression
+ /// matches \a match_count should indicate the number of regmatch_t
+ /// values that are present in \a match_ptr.
+ ///
+ /// @param[in] string
+ /// The string to match against the compile regular expression.
+ ///
+ /// @param[in] match
+ /// A pointer to a RegularExpression::Match structure that was
+ /// properly initialized with the desired number of maximum
+ /// matches, or nullptr if no parenthesized matching is needed.
+ ///
+ /// @return
+ /// \b true if \a string matches the compiled regular
+ /// expression, \b false otherwise.
+ //------------------------------------------------------------------
+ bool Execute(llvm::StringRef string, Match *match = nullptr) const;
+ bool Execute(const char *, Match * = nullptr) = delete;
+
+ size_t GetErrorAsCString(char *err_str, size_t err_str_max_len) const;
+
+ //------------------------------------------------------------------
+ /// Free the compiled regular expression.
+ ///
+ /// If this object contains a valid compiled regular expression,
+ /// this function will free any resources it was consuming.
+ //------------------------------------------------------------------
+ void Free();
+
+ //------------------------------------------------------------------
+ /// Access the regular expression text.
+ ///
+ /// Returns the text that was used to compile the current regular
+ /// expression.
+ ///
+ /// @return
+ /// The NULL terminated C string that was used to compile the
+ /// current regular expression
+ //------------------------------------------------------------------
+ llvm::StringRef GetText() const;
+
+ //------------------------------------------------------------------
+ /// Test if valid.
+ ///
+ /// Test if this object contains a valid regular expression.
+ ///
+ /// @return
+ /// \b true if the regular expression compiled and is ready
+ /// for execution, \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsValid() const;
+
+ void Clear() {
+ Free();
+ m_re.clear();
+ m_comp_err = 1;
+ }
+
+ int GetErrorCode() const { return m_comp_err; }
+
+ bool operator<(const RegularExpression &rhs) const;
private:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- std::string m_re; ///< A copy of the original regular expression text
- int m_comp_err; ///< Error code for the regular expression compilation
- regex_t m_preg; ///< The compiled regular expression
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ std::string m_re; ///< A copy of the original regular expression text
+ int m_comp_err; ///< Error code for the regular expression compilation
+ regex_t m_preg; ///< The compiled regular expression
};
} // namespace lldb_private
diff --git a/include/lldb/Core/STLUtils.h b/include/lldb/Core/STLUtils.h
index b3c2124f447d..d851ed5464c9 100644
--- a/include/lldb/Core/STLUtils.h
+++ b/include/lldb/Core/STLUtils.h
@@ -24,61 +24,50 @@
//----------------------------------------------------------------------
// C string less than compare function object
//----------------------------------------------------------------------
-struct CStringCompareFunctionObject
-{
- bool operator() (const char* s1, const char* s2) const
- {
- return strcmp(s1, s2) < 0;
- }
+struct CStringCompareFunctionObject {
+ bool operator()(const char *s1, const char *s2) const {
+ return strcmp(s1, s2) < 0;
+ }
};
//----------------------------------------------------------------------
// C string equality function object (binary predicate).
//----------------------------------------------------------------------
-struct CStringEqualBinaryPredicate
-{
- bool operator()(const char* s1, const char* s2) const
- {
- return strcmp(s1, s2) == 0;
- }
+struct CStringEqualBinaryPredicate {
+ bool operator()(const char *s1, const char *s2) const {
+ return strcmp(s1, s2) == 0;
+ }
};
//----------------------------------------------------------------------
// Templated type for finding an entry in a std::map<F,S> whose value
// is equal to something
//----------------------------------------------------------------------
-template <class F, class S>
-class ValueEquals
-{
+template <class F, class S> class ValueEquals {
public:
- ValueEquals (const S& val) : second_value(val)
- {}
+ ValueEquals(const S &val) : second_value(val) {}
- // Compare the second item
- bool operator() (std::pair<const F, S> elem)
- {
- return elem.second == second_value;
- }
+ // Compare the second item
+ bool operator()(std::pair<const F, S> elem) {
+ return elem.second == second_value;
+ }
private:
- S second_value;
+ S second_value;
};
template <class T>
-inline void
-PrintAllCollectionElements(std::ostream &s,
- const T& coll,
- const char* header_cstr = nullptr,
- const char* separator_cstr = " ")
-{
- typename T::const_iterator pos;
+inline void PrintAllCollectionElements(std::ostream &s, const T &coll,
+ const char *header_cstr = nullptr,
+ const char *separator_cstr = " ") {
+ typename T::const_iterator pos;
- if (header_cstr)
- s << header_cstr;
- for (pos=coll.begin(); pos!=coll.end(); ++pos) {
- s << *pos << separator_cstr;
- }
- s << std::endl;
+ if (header_cstr)
+ s << header_cstr;
+ for (pos = coll.begin(); pos != coll.end(); ++pos) {
+ s << *pos << separator_cstr;
+ }
+ s << std::endl;
}
// The function object below can be used to delete a STL container that
@@ -86,10 +75,8 @@ PrintAllCollectionElements(std::ostream &s,
//
// Usage: std::for_each(vector.begin(), vector.end(), for_each_delete());
-struct for_each_cplusplus_delete
-{
- template <typename T>
- void operator()(T *ptr){ delete ptr;}
+struct for_each_cplusplus_delete {
+ template <typename T> void operator()(T *ptr) { delete ptr; }
};
typedef std::vector<std::string> STLStringArray;
diff --git a/include/lldb/Core/Scalar.h b/include/lldb/Core/Scalar.h
index be2176e2b50e..cee257711c5f 100644
--- a/include/lldb/Core/Scalar.h
+++ b/include/lldb/Core/Scalar.h
@@ -11,8 +11,8 @@
#define liblldb_Scalar_h_
#include "lldb/lldb-private.h"
-#include "llvm/ADT/APInt.h"
#include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/APInt.h"
#define NUM_OF_WORDS_INT128 2
#define BITWIDTH_INT128 128
@@ -27,343 +27,307 @@ namespace lldb_private {
// their types and values before performing these operations. Type
// promotion currently follows the ANSI C type promotion rules.
//----------------------------------------------------------------------
-class Scalar
-{
+class Scalar {
public:
- enum Type
- {
- e_void = 0,
- e_sint,
- e_uint,
- e_slong,
- e_ulong,
- e_slonglong,
- e_ulonglong,
- e_float,
- e_double,
- e_long_double,
- e_uint128,
- e_sint128,
- e_uint256,
- e_sint256
- };
-
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- Scalar();
- Scalar(int v) : m_type(e_sint), m_float((float)0) { m_integer = llvm::APInt(sizeof(int) * 8, v, true);}
- Scalar(unsigned int v) : m_type(e_uint), m_float((float)0) { m_integer = llvm::APInt(sizeof(int) * 8, v);}
- Scalar(long v) : m_type(e_slong), m_float((float)0) { m_integer = llvm::APInt(sizeof(long) * 8, v, true);}
- Scalar(unsigned long v) : m_type(e_ulong), m_float((float)0) { m_integer = llvm::APInt(sizeof(long) * 8, v);}
- Scalar(long long v) : m_type(e_slonglong), m_float((float)0) { m_integer = llvm::APInt(sizeof(long long) * 8, v, true);}
- Scalar(unsigned long long v): m_type(e_ulonglong), m_float((float)0) { m_integer = llvm::APInt(sizeof(long long) * 8, v);}
- Scalar(float v) : m_type(e_float), m_float(v) { m_float = llvm::APFloat(v); }
- Scalar(double v) : m_type(e_double), m_float(v) { m_float = llvm::APFloat(v); }
- Scalar(long double v, bool ieee_quad)
- : m_type(e_long_double), m_float((float)0), m_ieee_quad(ieee_quad)
- {
- if(ieee_quad)
- m_float = llvm::APFloat(llvm::APFloat::IEEEquad, llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x));
- else
- m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x));
- }
- Scalar(llvm::APInt v) :
- m_type(),
- m_float((float)0)
- {
- m_integer = llvm::APInt(v);
- switch(m_integer.getBitWidth())
- {
- case 8:
- case 16:
- case 32:
- if(m_integer.isSignedIntN(sizeof(sint_t) * 8))
- m_type = e_sint;
- else
- m_type = e_uint;
- break;
- case 64:
- if(m_integer.isSignedIntN(sizeof(slonglong_t) * 8))
- m_type = e_slonglong;
- else
- m_type = e_ulonglong;
- break;
- case 128:
- if(m_integer.isSignedIntN(BITWIDTH_INT128))
- m_type = e_sint128;
- else
- m_type = e_uint128;
- break;
- case 256:
- if(m_integer.isSignedIntN(BITWIDTH_INT256))
- m_type = e_sint256;
- else
- m_type = e_uint256;
- break;
- }
- }
- Scalar(const Scalar& rhs);
- //Scalar(const RegisterValue& reg_value);
- virtual ~Scalar();
-
- bool
- SignExtend (uint32_t bit_pos);
-
- bool
- ExtractBitfield (uint32_t bit_size,
- uint32_t bit_offset);
-
- bool
- SetBit(uint32_t bit);
-
- bool
- ClearBit(uint32_t bit);
-
- const void *
- GetBytes() const;
-
- size_t
- GetByteSize() const;
-
- bool
- GetData (DataExtractor &data, size_t limit_byte_size = UINT32_MAX) const;
-
- size_t
- GetAsMemoryData (void *dst,
- size_t dst_len,
- lldb::ByteOrder dst_byte_order,
- Error &error) const;
-
- bool
- IsZero() const;
-
- void
- Clear() { m_type = e_void; m_integer.clearAllBits(); }
-
- const char *
- GetTypeAsCString() const;
-
- void
- GetValue (Stream *s, bool show_type) const;
-
- bool
- IsValid() const
- {
- return (m_type >= e_sint) && (m_type <= e_long_double);
+ enum Type {
+ e_void = 0,
+ e_sint,
+ e_uint,
+ e_slong,
+ e_ulong,
+ e_slonglong,
+ e_ulonglong,
+ e_float,
+ e_double,
+ e_long_double,
+ e_uint128,
+ e_sint128,
+ e_uint256,
+ e_sint256
+ };
+
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ Scalar();
+ Scalar(int v) : m_type(e_sint), m_float((float)0) {
+ m_integer = llvm::APInt(sizeof(int) * 8, v, true);
+ }
+ Scalar(unsigned int v) : m_type(e_uint), m_float((float)0) {
+ m_integer = llvm::APInt(sizeof(int) * 8, v);
+ }
+ Scalar(long v) : m_type(e_slong), m_float((float)0) {
+ m_integer = llvm::APInt(sizeof(long) * 8, v, true);
+ }
+ Scalar(unsigned long v) : m_type(e_ulong), m_float((float)0) {
+ m_integer = llvm::APInt(sizeof(long) * 8, v);
+ }
+ Scalar(long long v) : m_type(e_slonglong), m_float((float)0) {
+ m_integer = llvm::APInt(sizeof(long long) * 8, v, true);
+ }
+ Scalar(unsigned long long v) : m_type(e_ulonglong), m_float((float)0) {
+ m_integer = llvm::APInt(sizeof(long long) * 8, v);
+ }
+ Scalar(float v) : m_type(e_float), m_float(v) { m_float = llvm::APFloat(v); }
+ Scalar(double v) : m_type(e_double), m_float(v) {
+ m_float = llvm::APFloat(v);
+ }
+ Scalar(long double v, bool ieee_quad)
+ : m_type(e_long_double), m_float((float)0), m_ieee_quad(ieee_quad) {
+ if (ieee_quad)
+ m_float = llvm::APFloat(llvm::APFloat::IEEEquad(),
+ llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
+ ((type128 *)&v)->x));
+ else
+ m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended(),
+ llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
+ ((type128 *)&v)->x));
+ }
+ Scalar(llvm::APInt v) : m_type(), m_float((float)0) {
+ m_integer = llvm::APInt(v);
+ switch (m_integer.getBitWidth()) {
+ case 8:
+ case 16:
+ case 32:
+ if (m_integer.isSignedIntN(sizeof(sint_t) * 8))
+ m_type = e_sint;
+ else
+ m_type = e_uint;
+ break;
+ case 64:
+ if (m_integer.isSignedIntN(sizeof(slonglong_t) * 8))
+ m_type = e_slonglong;
+ else
+ m_type = e_ulonglong;
+ break;
+ case 128:
+ if (m_integer.isSignedIntN(BITWIDTH_INT128))
+ m_type = e_sint128;
+ else
+ m_type = e_uint128;
+ break;
+ case 256:
+ if (m_integer.isSignedIntN(BITWIDTH_INT256))
+ m_type = e_sint256;
+ else
+ m_type = e_uint256;
+ break;
}
+ }
+ Scalar(const Scalar &rhs);
+ // Scalar(const RegisterValue& reg_value);
+ virtual ~Scalar();
+
+ bool SignExtend(uint32_t bit_pos);
- bool
- Promote(Scalar::Type type);
-
- bool
- Cast (Scalar::Type type);
-
- bool
- MakeSigned ();
-
- bool
- MakeUnsigned ();
-
- static const char *
- GetValueTypeAsCString (Scalar::Type value_type);
-
- static Scalar::Type
- GetValueTypeForSignedIntegerWithByteSize (size_t byte_size);
-
- static Scalar::Type
- GetValueTypeForUnsignedIntegerWithByteSize (size_t byte_size);
-
- static Scalar::Type
- GetValueTypeForFloatWithByteSize (size_t byte_size);
-
- //----------------------------------------------------------------------
- // All operators can benefits from the implicit conversions that will
- // happen automagically by the compiler, so no temporary objects will
- // need to be created. As a result, we currently don't need a variety of
- // overloaded set value accessors.
- //----------------------------------------------------------------------
- Scalar& operator= (const int i);
- Scalar& operator= (unsigned int v);
- Scalar& operator= (long v);
- Scalar& operator= (unsigned long v);
- Scalar& operator= (long long v);
- Scalar& operator= (unsigned long long v);
- Scalar& operator= (float v);
- Scalar& operator= (double v);
- Scalar& operator= (long double v);
- Scalar& operator= (llvm::APInt v);
- Scalar& operator= (const Scalar& rhs); // Assignment operator
- Scalar& operator+= (const Scalar& rhs);
- Scalar& operator<<= (const Scalar& rhs); // Shift left
- Scalar& operator>>= (const Scalar& rhs); // Shift right (arithmetic)
- Scalar& operator&= (const Scalar& rhs);
-
- //----------------------------------------------------------------------
- // Shifts the current value to the right without maintaining the current
- // sign of the value (if it is signed).
- //----------------------------------------------------------------------
- bool
- ShiftRightLogical(const Scalar& rhs); // Returns true on success
-
- //----------------------------------------------------------------------
- // Takes the absolute value of the current value if it is signed, else
- // the value remains unchanged.
- // Returns false if the contained value has a void type.
- //----------------------------------------------------------------------
- bool
- AbsoluteValue(); // Returns true on success
- //----------------------------------------------------------------------
- // Negates the current value (even for unsigned values).
- // Returns false if the contained value has a void type.
- //----------------------------------------------------------------------
- bool
- UnaryNegate(); // Returns true on success
- //----------------------------------------------------------------------
- // Inverts all bits in the current value as long as it isn't void or
- // a float/double/long double type.
- // Returns false if the contained value has a void/float/double/long
- // double type, else the value is inverted and true is returned.
- //----------------------------------------------------------------------
- bool
- OnesComplement(); // Returns true on success
-
- //----------------------------------------------------------------------
- // Access the type of the current value.
- //----------------------------------------------------------------------
- Scalar::Type
- GetType() const { return m_type; }
-
- //----------------------------------------------------------------------
- // Returns a casted value of the current contained data without
- // modifying the current value. FAIL_VALUE will be returned if the type
- // of the value is void or invalid.
- //----------------------------------------------------------------------
- int
- SInt(int fail_value = 0) const;
-
- unsigned char
- UChar(unsigned char fail_value = 0) const;
-
- signed char
- SChar(char fail_value = 0) const;
-
- unsigned short
- UShort(unsigned short fail_value = 0) const;
-
- short
- SShort(short fail_value = 0) const;
-
- unsigned int
- UInt(unsigned int fail_value = 0) const;
-
- long
- SLong(long fail_value = 0) const;
-
- unsigned long
- ULong(unsigned long fail_value = 0) const;
-
- long long
- SLongLong(long long fail_value = 0) const;
-
- unsigned long long
- ULongLong(unsigned long long fail_value = 0) const;
-
- llvm::APInt
- SInt128(llvm::APInt& fail_value) const;
-
- llvm::APInt
- UInt128(const llvm::APInt& fail_value) const;
-
- llvm::APInt
- SInt256(llvm::APInt& fail_value) const;
-
- llvm::APInt
- UInt256(const llvm::APInt& fail_value) const;
-
- float
- Float(float fail_value = 0.0f) const;
-
- double
- Double(double fail_value = 0.0) const;
-
- long double
- LongDouble(long double fail_value = 0.0) const;
-
- Error
- SetValueFromCString (const char *s, lldb::Encoding encoding, size_t byte_size);
-
- Error
- SetValueFromData (DataExtractor &data, lldb::Encoding encoding, size_t byte_size);
-
- static bool
- UIntValueIsValidForSize (uint64_t uval64, size_t total_byte_size)
- {
- if (total_byte_size > 8)
- return false;
-
- if (total_byte_size == 8)
- return true;
-
- const uint64_t max = ((uint64_t)1 << (uint64_t)(total_byte_size * 8)) - 1;
- return uval64 <= max;
- }
+ bool ExtractBitfield(uint32_t bit_size, uint32_t bit_offset);
+
+ bool SetBit(uint32_t bit);
+
+ bool ClearBit(uint32_t bit);
+
+ const void *GetBytes() const;
+
+ size_t GetByteSize() const;
+
+ bool GetData(DataExtractor &data, size_t limit_byte_size = UINT32_MAX) const;
- static bool
- SIntValueIsValidForSize (int64_t sval64, size_t total_byte_size)
- {
- if (total_byte_size > 8)
- return false;
+ size_t GetAsMemoryData(void *dst, size_t dst_len,
+ lldb::ByteOrder dst_byte_order, Error &error) const;
- if (total_byte_size == 8)
- return true;
+ bool IsZero() const;
- const int64_t max = ((int64_t)1 << (uint64_t)(total_byte_size * 8 - 1)) - 1;
- const int64_t min = ~(max);
- return min <= sval64 && sval64 <= max;
- }
+ void Clear() {
+ m_type = e_void;
+ m_integer.clearAllBits();
+ }
+
+ const char *GetTypeAsCString() const;
+
+ void GetValue(Stream *s, bool show_type) const;
+
+ bool IsValid() const {
+ return (m_type >= e_sint) && (m_type <= e_long_double);
+ }
+
+ bool Promote(Scalar::Type type);
+
+ bool Cast(Scalar::Type type);
+
+ bool MakeSigned();
+
+ bool MakeUnsigned();
+
+ static const char *GetValueTypeAsCString(Scalar::Type value_type);
+
+ static Scalar::Type
+ GetValueTypeForSignedIntegerWithByteSize(size_t byte_size);
+
+ static Scalar::Type
+ GetValueTypeForUnsignedIntegerWithByteSize(size_t byte_size);
+
+ static Scalar::Type GetValueTypeForFloatWithByteSize(size_t byte_size);
+
+ //----------------------------------------------------------------------
+ // All operators can benefits from the implicit conversions that will
+ // happen automagically by the compiler, so no temporary objects will
+ // need to be created. As a result, we currently don't need a variety of
+ // overloaded set value accessors.
+ //----------------------------------------------------------------------
+ Scalar &operator=(const int i);
+ Scalar &operator=(unsigned int v);
+ Scalar &operator=(long v);
+ Scalar &operator=(unsigned long v);
+ Scalar &operator=(long long v);
+ Scalar &operator=(unsigned long long v);
+ Scalar &operator=(float v);
+ Scalar &operator=(double v);
+ Scalar &operator=(long double v);
+ Scalar &operator=(llvm::APInt v);
+ Scalar &operator=(const Scalar &rhs); // Assignment operator
+ Scalar &operator+=(const Scalar &rhs);
+ Scalar &operator<<=(const Scalar &rhs); // Shift left
+ Scalar &operator>>=(const Scalar &rhs); // Shift right (arithmetic)
+ Scalar &operator&=(const Scalar &rhs);
+
+ //----------------------------------------------------------------------
+ // Shifts the current value to the right without maintaining the current
+ // sign of the value (if it is signed).
+ //----------------------------------------------------------------------
+ bool ShiftRightLogical(const Scalar &rhs); // Returns true on success
+
+ //----------------------------------------------------------------------
+ // Takes the absolute value of the current value if it is signed, else
+ // the value remains unchanged.
+ // Returns false if the contained value has a void type.
+ //----------------------------------------------------------------------
+ bool AbsoluteValue(); // Returns true on success
+ //----------------------------------------------------------------------
+ // Negates the current value (even for unsigned values).
+ // Returns false if the contained value has a void type.
+ //----------------------------------------------------------------------
+ bool UnaryNegate(); // Returns true on success
+ //----------------------------------------------------------------------
+ // Inverts all bits in the current value as long as it isn't void or
+ // a float/double/long double type.
+ // Returns false if the contained value has a void/float/double/long
+ // double type, else the value is inverted and true is returned.
+ //----------------------------------------------------------------------
+ bool OnesComplement(); // Returns true on success
+
+ //----------------------------------------------------------------------
+ // Access the type of the current value.
+ //----------------------------------------------------------------------
+ Scalar::Type GetType() const { return m_type; }
+
+ //----------------------------------------------------------------------
+ // Returns a casted value of the current contained data without
+ // modifying the current value. FAIL_VALUE will be returned if the type
+ // of the value is void or invalid.
+ //----------------------------------------------------------------------
+ int SInt(int fail_value = 0) const;
+
+ unsigned char UChar(unsigned char fail_value = 0) const;
+
+ signed char SChar(char fail_value = 0) const;
+
+ unsigned short UShort(unsigned short fail_value = 0) const;
+
+ short SShort(short fail_value = 0) const;
+
+ unsigned int UInt(unsigned int fail_value = 0) const;
+
+ long SLong(long fail_value = 0) const;
+
+ unsigned long ULong(unsigned long fail_value = 0) const;
+
+ long long SLongLong(long long fail_value = 0) const;
+
+ unsigned long long ULongLong(unsigned long long fail_value = 0) const;
+
+ llvm::APInt SInt128(llvm::APInt &fail_value) const;
+
+ llvm::APInt UInt128(const llvm::APInt &fail_value) const;
+
+ llvm::APInt SInt256(llvm::APInt &fail_value) const;
+
+ llvm::APInt UInt256(const llvm::APInt &fail_value) const;
+
+ float Float(float fail_value = 0.0f) const;
+
+ double Double(double fail_value = 0.0) const;
+
+ long double LongDouble(long double fail_value = 0.0) const;
+
+ Error SetValueFromCString(const char *s, lldb::Encoding encoding,
+ size_t byte_size);
+
+ Error SetValueFromData(DataExtractor &data, lldb::Encoding encoding,
+ size_t byte_size);
+
+ static bool UIntValueIsValidForSize(uint64_t uval64, size_t total_byte_size) {
+ if (total_byte_size > 8)
+ return false;
+
+ if (total_byte_size == 8)
+ return true;
+
+ const uint64_t max = ((uint64_t)1 << (uint64_t)(total_byte_size * 8)) - 1;
+ return uval64 <= max;
+ }
+
+ static bool SIntValueIsValidForSize(int64_t sval64, size_t total_byte_size) {
+ if (total_byte_size > 8)
+ return false;
+
+ if (total_byte_size == 8)
+ return true;
+
+ const int64_t max = ((int64_t)1 << (uint64_t)(total_byte_size * 8 - 1)) - 1;
+ const int64_t min = ~(max);
+ return min <= sval64 && sval64 <= max;
+ }
protected:
- typedef char schar_t;
- typedef unsigned char uchar_t;
- typedef short sshort_t;
- typedef unsigned short ushort_t;
- typedef int sint_t;
- typedef unsigned int uint_t;
- typedef long slong_t;
- typedef unsigned long ulong_t;
- typedef long long slonglong_t;
- typedef unsigned long long ulonglong_t;
- typedef float float_t;
- typedef double double_t;
- typedef long double long_double_t;
-
- //------------------------------------------------------------------
- // Classes that inherit from Scalar can see and modify these
- //------------------------------------------------------------------
- Scalar::Type m_type;
- llvm::APInt m_integer;
- llvm::APFloat m_float;
- bool m_ieee_quad = false;
+ typedef char schar_t;
+ typedef unsigned char uchar_t;
+ typedef short sshort_t;
+ typedef unsigned short ushort_t;
+ typedef int sint_t;
+ typedef unsigned int uint_t;
+ typedef long slong_t;
+ typedef unsigned long ulong_t;
+ typedef long long slonglong_t;
+ typedef unsigned long long ulonglong_t;
+ typedef float float_t;
+ typedef double double_t;
+ typedef long double long_double_t;
+
+ //------------------------------------------------------------------
+ // Classes that inherit from Scalar can see and modify these
+ //------------------------------------------------------------------
+ Scalar::Type m_type;
+ llvm::APInt m_integer;
+ llvm::APFloat m_float;
+ bool m_ieee_quad = false;
private:
- friend const Scalar operator+ (const Scalar& lhs, const Scalar& rhs);
- friend const Scalar operator- (const Scalar& lhs, const Scalar& rhs);
- friend const Scalar operator/ (const Scalar& lhs, const Scalar& rhs);
- friend const Scalar operator* (const Scalar& lhs, const Scalar& rhs);
- friend const Scalar operator& (const Scalar& lhs, const Scalar& rhs);
- friend const Scalar operator| (const Scalar& lhs, const Scalar& rhs);
- friend const Scalar operator% (const Scalar& lhs, const Scalar& rhs);
- friend const Scalar operator^ (const Scalar& lhs, const Scalar& rhs);
- friend const Scalar operator<< (const Scalar& lhs, const Scalar& rhs);
- friend const Scalar operator>> (const Scalar& lhs, const Scalar& rhs);
- friend bool operator== (const Scalar& lhs, const Scalar& rhs);
- friend bool operator!= (const Scalar& lhs, const Scalar& rhs);
- friend bool operator< (const Scalar& lhs, const Scalar& rhs);
- friend bool operator<= (const Scalar& lhs, const Scalar& rhs);
- friend bool operator> (const Scalar& lhs, const Scalar& rhs);
- friend bool operator>= (const Scalar& lhs, const Scalar& rhs);
-
+ friend const Scalar operator+(const Scalar &lhs, const Scalar &rhs);
+ friend const Scalar operator-(const Scalar &lhs, const Scalar &rhs);
+ friend const Scalar operator/(const Scalar &lhs, const Scalar &rhs);
+ friend const Scalar operator*(const Scalar &lhs, const Scalar &rhs);
+ friend const Scalar operator&(const Scalar &lhs, const Scalar &rhs);
+ friend const Scalar operator|(const Scalar &lhs, const Scalar &rhs);
+ friend const Scalar operator%(const Scalar &lhs, const Scalar &rhs);
+ friend const Scalar operator^(const Scalar &lhs, const Scalar &rhs);
+ friend const Scalar operator<<(const Scalar &lhs, const Scalar &rhs);
+ friend const Scalar operator>>(const Scalar &lhs, const Scalar &rhs);
+ friend bool operator==(const Scalar &lhs, const Scalar &rhs);
+ friend bool operator!=(const Scalar &lhs, const Scalar &rhs);
+ friend bool operator<(const Scalar &lhs, const Scalar &rhs);
+ friend bool operator<=(const Scalar &lhs, const Scalar &rhs);
+ friend bool operator>(const Scalar &lhs, const Scalar &rhs);
+ friend bool operator>=(const Scalar &lhs, const Scalar &rhs);
};
//----------------------------------------------------------------------
@@ -381,23 +345,23 @@ private:
// Differentiate among members functions, non-member functions, and
// friend functions
//----------------------------------------------------------------------
-const Scalar operator+ (const Scalar& lhs, const Scalar& rhs);
-const Scalar operator- (const Scalar& lhs, const Scalar& rhs);
-const Scalar operator/ (const Scalar& lhs, const Scalar& rhs);
-const Scalar operator* (const Scalar& lhs, const Scalar& rhs);
-const Scalar operator& (const Scalar& lhs, const Scalar& rhs);
-const Scalar operator| (const Scalar& lhs, const Scalar& rhs);
-const Scalar operator% (const Scalar& lhs, const Scalar& rhs);
-const Scalar operator^ (const Scalar& lhs, const Scalar& rhs);
-const Scalar operator<< (const Scalar& lhs, const Scalar& rhs);
-const Scalar operator>> (const Scalar& lhs, const Scalar& rhs);
-bool operator== (const Scalar& lhs, const Scalar& rhs);
-bool operator!= (const Scalar& lhs, const Scalar& rhs);
-bool operator< (const Scalar& lhs, const Scalar& rhs);
-bool operator<= (const Scalar& lhs, const Scalar& rhs);
-bool operator> (const Scalar& lhs, const Scalar& rhs);
-bool operator>= (const Scalar& lhs, const Scalar& rhs);
+const Scalar operator+(const Scalar &lhs, const Scalar &rhs);
+const Scalar operator-(const Scalar &lhs, const Scalar &rhs);
+const Scalar operator/(const Scalar &lhs, const Scalar &rhs);
+const Scalar operator*(const Scalar &lhs, const Scalar &rhs);
+const Scalar operator&(const Scalar &lhs, const Scalar &rhs);
+const Scalar operator|(const Scalar &lhs, const Scalar &rhs);
+const Scalar operator%(const Scalar &lhs, const Scalar &rhs);
+const Scalar operator^(const Scalar &lhs, const Scalar &rhs);
+const Scalar operator<<(const Scalar &lhs, const Scalar &rhs);
+const Scalar operator>>(const Scalar &lhs, const Scalar &rhs);
+bool operator==(const Scalar &lhs, const Scalar &rhs);
+bool operator!=(const Scalar &lhs, const Scalar &rhs);
+bool operator<(const Scalar &lhs, const Scalar &rhs);
+bool operator<=(const Scalar &lhs, const Scalar &rhs);
+bool operator>(const Scalar &lhs, const Scalar &rhs);
+bool operator>=(const Scalar &lhs, const Scalar &rhs);
} // namespace lldb_private
-#endif // liblldb_Scalar_h_
+#endif // liblldb_Scalar_h_
diff --git a/include/lldb/Core/SearchFilter.h b/include/lldb/Core/SearchFilter.h
index 5c76fb5aad30..6b3a79e99520 100644
--- a/include/lldb/Core/SearchFilter.h
+++ b/include/lldb/Core/SearchFilter.h
@@ -14,8 +14,9 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/FileSpecList.h"
+#include "lldb/Core/StructuredData.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -30,45 +31,40 @@ namespace lldb_private {
/// Provides the callback and search depth for the SearchFilter search.
//----------------------------------------------------------------------
-class Searcher
-{
+class Searcher {
public:
- typedef enum {
- eCallbackReturnStop = 0, // Stop the iteration
- eCallbackReturnContinue, // Continue the iteration
- eCallbackReturnPop // Pop one level up and continue iterating
- } CallbackReturn;
-
- typedef enum {
- eDepthTarget,
- eDepthModule,
- eDepthCompUnit,
- eDepthFunction,
- eDepthBlock,
- eDepthAddress
- } Depth;
-
- Searcher ();
-
- virtual ~Searcher ();
-
- virtual CallbackReturn
- SearchCallback (SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool complete) = 0;
-
- virtual Depth
- GetDepth () = 0;
-
- //------------------------------------------------------------------
- /// Prints a canonical description for the searcher to the stream \a s.
- ///
- /// @param[in] s
- /// Stream to which the output is copied.
- //------------------------------------------------------------------
- virtual void
- GetDescription(Stream *s);
+ typedef enum {
+ eCallbackReturnStop = 0, // Stop the iteration
+ eCallbackReturnContinue, // Continue the iteration
+ eCallbackReturnPop // Pop one level up and continue iterating
+ } CallbackReturn;
+
+ typedef enum {
+ eDepthTarget,
+ eDepthModule,
+ eDepthCompUnit,
+ eDepthFunction,
+ eDepthBlock,
+ eDepthAddress
+ } Depth;
+
+ Searcher();
+
+ virtual ~Searcher();
+
+ virtual CallbackReturn SearchCallback(SearchFilter &filter,
+ SymbolContext &context, Address *addr,
+ bool complete) = 0;
+
+ virtual Depth GetDepth() = 0;
+
+ //------------------------------------------------------------------
+ /// Prints a canonical description for the searcher to the stream \a s.
+ ///
+ /// @param[in] s
+ /// Stream to which the output is copied.
+ //------------------------------------------------------------------
+ virtual void GetDescription(Stream *s);
};
//----------------------------------------------------------------------
@@ -82,206 +78,254 @@ public:
/// General Outline:
/// Provides the callback and search depth for the SearchFilter search.
///
-/// The search is done by cooperation between the search filter and the searcher.
+/// The search is done by cooperation between the search filter and the
+/// searcher.
/// The search filter does the heavy work of recursing through the SymbolContext
-/// space of the target program's symbol space. The Searcher specifies the depth
-/// at which it wants its callback to be invoked. Note that since the resolution
+/// space of the target program's symbol space. The Searcher specifies the
+/// depth
+/// at which it wants its callback to be invoked. Note that since the
+/// resolution
/// of the Searcher may be greater than that of the SearchFilter, before the
/// Searcher qualifies an address it should pass it to "AddressPasses."
/// The default implementation is "Everything Passes."
//----------------------------------------------------------------------
-class SearchFilter
-{
+class SearchFilter {
public:
- //------------------------------------------------------------------
- /// The basic constructor takes a Target, which gives the space to search.
- ///
- /// @param[in] target
- /// The Target that provides the module list to search.
- //------------------------------------------------------------------
- SearchFilter (const lldb::TargetSP &target_sp);
-
- SearchFilter (const SearchFilter& rhs);
-
- virtual
- ~SearchFilter ();
-
- SearchFilter&
- operator=(const SearchFilter& rhs);
-
- //------------------------------------------------------------------
- /// Call this method with a file spec to see if that spec passes the filter.
- ///
- /// @param[in] spec
- /// The file spec to check against the filter.
- /// @return
- /// \b true if \a spec passes, and \b false otherwise.
- //------------------------------------------------------------------
- virtual bool
- ModulePasses (const FileSpec &spec);
-
- //------------------------------------------------------------------
- /// Call this method with a Module to see if that module passes the filter.
- ///
- /// @param[in] module
- /// The Module to check against the filter.
- ///
- /// @return
- /// \b true if \a module passes, and \b false otherwise.
- //------------------------------------------------------------------
- virtual bool
- ModulePasses (const lldb::ModuleSP &module_sp);
-
- //------------------------------------------------------------------
- /// Call this method with a Address to see if \a address passes the filter.
- ///
- /// @param[in] addr
- /// The address to check against the filter.
- ///
- /// @return
- /// \b true if \a address passes, and \b false otherwise.
- //------------------------------------------------------------------
- virtual bool
- AddressPasses (Address &addr);
-
- //------------------------------------------------------------------
- /// Call this method with a FileSpec to see if \a file spec passes the filter
- /// as the name of a compilation unit.
- ///
- /// @param[in] fileSpec
- /// The file spec to check against the filter.
- ///
- /// @return
- /// \b true if \a file spec passes, and \b false otherwise.
- //------------------------------------------------------------------
- virtual bool
- CompUnitPasses (FileSpec &fileSpec);
-
- //------------------------------------------------------------------
- /// Call this method with a CompileUnit to see if \a comp unit passes the filter.
- ///
- /// @param[in] compUnit
- /// The CompileUnit to check against the filter.
- ///
- /// @return
- /// \b true if \a Comp Unit passes, and \b false otherwise.
- //------------------------------------------------------------------
- virtual bool
- CompUnitPasses (CompileUnit &compUnit);
-
- //------------------------------------------------------------------
- /// Call this method to do the search using the Searcher.
- ///
- /// @param[in] searcher
- /// The searcher to drive with this search.
- ///
- //------------------------------------------------------------------
- virtual void
- Search (Searcher &searcher);
-
- //------------------------------------------------------------------
- /// Call this method to do the search using the Searcher in the module list
- /// \a modules.
- ///
- /// @param[in] searcher
- /// The searcher to drive with this search.
- ///
- /// @param[in] modules
- /// The module list within which to restrict the search.
- ///
- //------------------------------------------------------------------
- virtual void
- SearchInModuleList (Searcher &searcher, ModuleList &modules);
-
- //------------------------------------------------------------------
- /// This determines which items are REQUIRED for the filter to pass.
- /// For instance, if you are filtering by Compilation Unit, obviously
- /// symbols that have no compilation unit can't pass So return eSymbolContextCU
- /// and search callbacks can then short cut the search to avoid looking at
- /// things that obviously won't pass.
- ///
- /// @return
- /// The required elements for the search, which is an or'ed together
- /// set of lldb:SearchContextItem enum's.
- ///
- //------------------------------------------------------------------
- virtual uint32_t
- GetFilterRequiredItems ();
-
- //------------------------------------------------------------------
- /// Prints a canonical description for the search filter to the stream \a s.
- ///
- /// @param[in] s
- /// Stream to which the output is copied.
- //------------------------------------------------------------------
- virtual void
- GetDescription(Stream *s);
-
- //------------------------------------------------------------------
- /// Standard "Dump" method. At present it does nothing.
- //------------------------------------------------------------------
- virtual void
- Dump (Stream *s) const;
-
- lldb::SearchFilterSP
- CopyForBreakpoint (Breakpoint &breakpoint);
+ //------------------------------------------------------------------
+ /// The basic constructor takes a Target, which gives the space to search.
+ ///
+ /// @param[in] target
+ /// The Target that provides the module list to search.
+ //------------------------------------------------------------------
+ SearchFilter(const lldb::TargetSP &target_sp);
+
+ SearchFilter(const SearchFilter &rhs);
+
+ SearchFilter(const lldb::TargetSP &target_sp, unsigned char filterType);
+
+ virtual ~SearchFilter();
+
+ SearchFilter &operator=(const SearchFilter &rhs);
+
+ //------------------------------------------------------------------
+ /// Call this method with a file spec to see if that spec passes the filter.
+ ///
+ /// @param[in] spec
+ /// The file spec to check against the filter.
+ /// @return
+ /// \b true if \a spec passes, and \b false otherwise.
+ //------------------------------------------------------------------
+ virtual bool ModulePasses(const FileSpec &spec);
+
+ //------------------------------------------------------------------
+ /// Call this method with a Module to see if that module passes the filter.
+ ///
+ /// @param[in] module
+ /// The Module to check against the filter.
+ ///
+ /// @return
+ /// \b true if \a module passes, and \b false otherwise.
+ //------------------------------------------------------------------
+ virtual bool ModulePasses(const lldb::ModuleSP &module_sp);
+
+ //------------------------------------------------------------------
+ /// Call this method with a Address to see if \a address passes the filter.
+ ///
+ /// @param[in] addr
+ /// The address to check against the filter.
+ ///
+ /// @return
+ /// \b true if \a address passes, and \b false otherwise.
+ //------------------------------------------------------------------
+ virtual bool AddressPasses(Address &addr);
+
+ //------------------------------------------------------------------
+ /// Call this method with a FileSpec to see if \a file spec passes the filter
+ /// as the name of a compilation unit.
+ ///
+ /// @param[in] fileSpec
+ /// The file spec to check against the filter.
+ ///
+ /// @return
+ /// \b true if \a file spec passes, and \b false otherwise.
+ //------------------------------------------------------------------
+ virtual bool CompUnitPasses(FileSpec &fileSpec);
+
+ //------------------------------------------------------------------
+ /// Call this method with a CompileUnit to see if \a comp unit passes the
+ /// filter.
+ ///
+ /// @param[in] compUnit
+ /// The CompileUnit to check against the filter.
+ ///
+ /// @return
+ /// \b true if \a Comp Unit passes, and \b false otherwise.
+ //------------------------------------------------------------------
+ virtual bool CompUnitPasses(CompileUnit &compUnit);
+
+ //------------------------------------------------------------------
+ /// Call this method to do the search using the Searcher.
+ ///
+ /// @param[in] searcher
+ /// The searcher to drive with this search.
+ ///
+ //------------------------------------------------------------------
+ virtual void Search(Searcher &searcher);
+
+ //------------------------------------------------------------------
+ /// Call this method to do the search using the Searcher in the module list
+ /// \a modules.
+ ///
+ /// @param[in] searcher
+ /// The searcher to drive with this search.
+ ///
+ /// @param[in] modules
+ /// The module list within which to restrict the search.
+ ///
+ //------------------------------------------------------------------
+ virtual void SearchInModuleList(Searcher &searcher, ModuleList &modules);
+
+ //------------------------------------------------------------------
+ /// This determines which items are REQUIRED for the filter to pass.
+ /// For instance, if you are filtering by Compilation Unit, obviously
+ /// symbols that have no compilation unit can't pass So return
+ /// eSymbolContextCU
+ /// and search callbacks can then short cut the search to avoid looking at
+ /// things that obviously won't pass.
+ ///
+ /// @return
+ /// The required elements for the search, which is an or'ed together
+ /// set of lldb:SearchContextItem enum's.
+ ///
+ //------------------------------------------------------------------
+ virtual uint32_t GetFilterRequiredItems();
+
+ //------------------------------------------------------------------
+ /// Prints a canonical description for the search filter to the stream \a s.
+ ///
+ /// @param[in] s
+ /// Stream to which the output is copied.
+ //------------------------------------------------------------------
+ virtual void GetDescription(Stream *s);
+
+ //------------------------------------------------------------------
+ /// Standard "Dump" method. At present it does nothing.
+ //------------------------------------------------------------------
+ virtual void Dump(Stream *s) const;
+
+ lldb::SearchFilterSP CopyForBreakpoint(Breakpoint &breakpoint);
+
+ static lldb::SearchFilterSP
+ CreateFromStructuredData(Target &target,
+ const StructuredData::Dictionary &data_dict,
+ Error &error);
+
+ virtual StructuredData::ObjectSP SerializeToStructuredData() {
+ return StructuredData::ObjectSP();
+ }
+
+ static const char *GetSerializationKey() { return "SearchFilter"; }
+
+ static const char *GetSerializationSubclassKey() { return "Type"; }
+
+ static const char *GetSerializationSubclassOptionsKey() { return "Options"; }
+
+ enum FilterTy {
+ Unconstrained = 0,
+ Exception,
+ ByModule,
+ ByModules,
+ ByModulesAndCU,
+ LastKnownFilterType = ByModulesAndCU,
+ UnknownFilter
+ };
+
+ static const char *g_ty_to_name[LastKnownFilterType + 2];
+
+ enum FilterTy GetFilterTy() {
+ if (SubclassID > FilterTy::LastKnownFilterType)
+ return FilterTy::UnknownFilter;
+ else
+ return (enum FilterTy)SubclassID;
+ }
+
+ const char *GetFilterName() { return FilterTyToName(GetFilterTy()); }
+
+ static const char *FilterTyToName(enum FilterTy);
+
+ static FilterTy NameToFilterTy(const char *name);
protected:
- // These are utility functions to assist with the search iteration. They are used by the
- // default Search method.
-
- Searcher::CallbackReturn
- DoModuleIteration (const SymbolContext &context,
- Searcher &searcher);
-
- Searcher::CallbackReturn
- DoModuleIteration (const lldb::ModuleSP& module_sp,
- Searcher &searcher);
-
- Searcher::CallbackReturn
- DoCUIteration (const lldb::ModuleSP& module_sp,
- const SymbolContext &context,
- Searcher &searcher);
-
- Searcher::CallbackReturn
- DoFunctionIteration (Function *function,
- const SymbolContext &context,
- Searcher &searcher);
-
- virtual lldb::SearchFilterSP
- DoCopyForBreakpoint (Breakpoint &breakpoint) = 0;
-
- void
- SetTarget(lldb::TargetSP &target_sp)
- {
- m_target_sp = target_sp;
- }
-
- lldb::TargetSP m_target_sp; // Every filter has to be associated with a target for
- // now since you need a starting place for the search.
+ // Serialization of SearchFilter options:
+ enum OptionNames { ModList = 0, CUList, LanguageName, LastOptionName };
+ static const char *g_option_names[LastOptionName];
+
+ static const char *GetKey(enum OptionNames enum_value) {
+ return g_option_names[enum_value];
+ }
+
+ StructuredData::DictionarySP
+ WrapOptionsDict(StructuredData::DictionarySP options_dict_sp);
+
+ void SerializeFileSpecList(StructuredData::DictionarySP &options_dict_sp,
+ OptionNames name, FileSpecList &file_list);
+
+ // These are utility functions to assist with the search iteration. They are
+ // used by the
+ // default Search method.
+
+ Searcher::CallbackReturn DoModuleIteration(const SymbolContext &context,
+ Searcher &searcher);
+
+ Searcher::CallbackReturn DoModuleIteration(const lldb::ModuleSP &module_sp,
+ Searcher &searcher);
+
+ Searcher::CallbackReturn DoCUIteration(const lldb::ModuleSP &module_sp,
+ const SymbolContext &context,
+ Searcher &searcher);
+
+ Searcher::CallbackReturn DoFunctionIteration(Function *function,
+ const SymbolContext &context,
+ Searcher &searcher);
+
+ virtual lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) = 0;
+
+ void SetTarget(lldb::TargetSP &target_sp) { m_target_sp = target_sp; }
+
+ lldb::TargetSP
+ m_target_sp; // Every filter has to be associated with a target for
+ // now since you need a starting place for the search.
+private:
+ unsigned char SubclassID;
};
//----------------------------------------------------------------------
-/// @class SearchFilterForUnconstrainedSearches SearchFilter.h "lldb/Core/SearchFilter.h"
-/// @brief This is a SearchFilter that searches through all modules. It also consults the Target::ModuleIsExcludedForUnconstrainedSearches.
+/// @class SearchFilterForUnconstrainedSearches SearchFilter.h
+/// "lldb/Core/SearchFilter.h"
+/// @brief This is a SearchFilter that searches through all modules. It also
+/// consults the Target::ModuleIsExcludedForUnconstrainedSearches.
//----------------------------------------------------------------------
-class SearchFilterForUnconstrainedSearches :
- public SearchFilter
-{
+class SearchFilterForUnconstrainedSearches : public SearchFilter {
public:
- SearchFilterForUnconstrainedSearches (const lldb::TargetSP &target_sp) : SearchFilter(target_sp) {}
- ~SearchFilterForUnconstrainedSearches() override = default;
-
- bool
- ModulePasses (const FileSpec &module_spec) override;
-
- bool
- ModulePasses (const lldb::ModuleSP &module_sp) override;
+ SearchFilterForUnconstrainedSearches(const lldb::TargetSP &target_sp)
+ : SearchFilter(target_sp, FilterTy::Unconstrained) {}
+
+ ~SearchFilterForUnconstrainedSearches() override = default;
+
+ bool ModulePasses(const FileSpec &module_spec) override;
+
+ bool ModulePasses(const lldb::ModuleSP &module_sp) override;
+
+ static lldb::SearchFilterSP
+ CreateFromStructuredData(Target &target,
+ const StructuredData::Dictionary &data_dict,
+ Error &error);
+
+ StructuredData::ObjectSP SerializeToStructuredData() override;
protected:
- lldb::SearchFilterSP
- DoCopyForBreakpoint (Breakpoint &breakpoint) override;
+ lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override;
};
//----------------------------------------------------------------------
@@ -289,176 +333,166 @@ protected:
/// @brief This is a SearchFilter that restricts the search to a given module.
//----------------------------------------------------------------------
-class SearchFilterByModule :
- public SearchFilter
-{
+class SearchFilterByModule : public SearchFilter {
public:
- //------------------------------------------------------------------
- /// The basic constructor takes a Target, which gives the space to search,
- /// and the module to restrict the search to.
- ///
- /// @param[in] target
- /// The Target that provides the module list to search.
- ///
- /// @param[in] module
- /// The Module that limits the search.
- //------------------------------------------------------------------
- SearchFilterByModule (const lldb::TargetSP &targetSP,
- const FileSpec &module);
+ //------------------------------------------------------------------
+ /// The basic constructor takes a Target, which gives the space to search,
+ /// and the module to restrict the search to.
+ ///
+ /// @param[in] target
+ /// The Target that provides the module list to search.
+ ///
+ /// @param[in] module
+ /// The Module that limits the search.
+ //------------------------------------------------------------------
+ SearchFilterByModule(const lldb::TargetSP &targetSP, const FileSpec &module);
- SearchFilterByModule (const SearchFilterByModule& rhs);
+ SearchFilterByModule(const SearchFilterByModule &rhs);
- ~SearchFilterByModule() override;
+ ~SearchFilterByModule() override;
- SearchFilterByModule&
- operator=(const SearchFilterByModule& rhs);
+ SearchFilterByModule &operator=(const SearchFilterByModule &rhs);
- bool
- ModulePasses (const lldb::ModuleSP &module_sp) override;
+ bool ModulePasses(const lldb::ModuleSP &module_sp) override;
- bool
- ModulePasses (const FileSpec &spec) override;
+ bool ModulePasses(const FileSpec &spec) override;
- bool
- AddressPasses (Address &address) override;
+ bool AddressPasses(Address &address) override;
- bool
- CompUnitPasses (FileSpec &fileSpec) override;
+ bool CompUnitPasses(FileSpec &fileSpec) override;
- bool
- CompUnitPasses (CompileUnit &compUnit) override;
+ bool CompUnitPasses(CompileUnit &compUnit) override;
- void
- GetDescription(Stream *s) override;
+ void GetDescription(Stream *s) override;
- uint32_t
- GetFilterRequiredItems () override;
+ uint32_t GetFilterRequiredItems() override;
- void
- Dump (Stream *s) const override;
+ void Dump(Stream *s) const override;
- void
- Search (Searcher &searcher) override;
+ void Search(Searcher &searcher) override;
+
+ static lldb::SearchFilterSP
+ CreateFromStructuredData(Target &target,
+ const StructuredData::Dictionary &data_dict,
+ Error &error);
+
+ StructuredData::ObjectSP SerializeToStructuredData() override;
protected:
- lldb::SearchFilterSP
- DoCopyForBreakpoint (Breakpoint &breakpoint) override;
+ lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override;
private:
- FileSpec m_module_spec;
+ FileSpec m_module_spec;
};
-class SearchFilterByModuleList :
- public SearchFilter
-{
+class SearchFilterByModuleList : public SearchFilter {
public:
- //------------------------------------------------------------------
- /// The basic constructor takes a Target, which gives the space to search,
- /// and the module list to restrict the search to.
- ///
- /// @param[in] target
- /// The Target that provides the module list to search.
- ///
- /// @param[in] module
- /// The Module that limits the search.
- //------------------------------------------------------------------
- SearchFilterByModuleList (const lldb::TargetSP &targetSP,
- const FileSpecList &module_list);
+ //------------------------------------------------------------------
+ /// The basic constructor takes a Target, which gives the space to search,
+ /// and the module list to restrict the search to.
+ ///
+ /// @param[in] target
+ /// The Target that provides the module list to search.
+ ///
+ /// @param[in] module
+ /// The Module that limits the search.
+ //------------------------------------------------------------------
+ SearchFilterByModuleList(const lldb::TargetSP &targetSP,
+ const FileSpecList &module_list);
+
+ SearchFilterByModuleList(const lldb::TargetSP &targetSP,
+ const FileSpecList &module_list,
+ enum FilterTy filter_ty);
- SearchFilterByModuleList (const SearchFilterByModuleList& rhs);
+ SearchFilterByModuleList(const SearchFilterByModuleList &rhs);
- ~SearchFilterByModuleList() override;
+ ~SearchFilterByModuleList() override;
- SearchFilterByModuleList&
- operator=(const SearchFilterByModuleList& rhs);
+ SearchFilterByModuleList &operator=(const SearchFilterByModuleList &rhs);
- bool
- ModulePasses (const lldb::ModuleSP &module_sp) override;
+ bool ModulePasses(const lldb::ModuleSP &module_sp) override;
- bool
- ModulePasses (const FileSpec &spec) override;
+ bool ModulePasses(const FileSpec &spec) override;
- bool
- AddressPasses (Address &address) override;
+ bool AddressPasses(Address &address) override;
- bool
- CompUnitPasses (FileSpec &fileSpec) override;
+ bool CompUnitPasses(FileSpec &fileSpec) override;
- bool
- CompUnitPasses (CompileUnit &compUnit) override;
+ bool CompUnitPasses(CompileUnit &compUnit) override;
- void
- GetDescription(Stream *s) override;
+ void GetDescription(Stream *s) override;
- uint32_t
- GetFilterRequiredItems () override;
+ uint32_t GetFilterRequiredItems() override;
- void
- Dump (Stream *s) const override;
-
- void
- Search (Searcher &searcher) override;
+ void Dump(Stream *s) const override;
+
+ void Search(Searcher &searcher) override;
+
+ static lldb::SearchFilterSP
+ CreateFromStructuredData(Target &target,
+ const StructuredData::Dictionary &data_dict,
+ Error &error);
+
+ StructuredData::ObjectSP SerializeToStructuredData() override;
+
+ void SerializeUnwrapped(StructuredData::DictionarySP &options_dict_sp);
protected:
- lldb::SearchFilterSP
- DoCopyForBreakpoint (Breakpoint &breakpoint) override;
+ lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override;
protected:
- FileSpecList m_module_spec_list;
+ FileSpecList m_module_spec_list;
};
-class SearchFilterByModuleListAndCU :
- public SearchFilterByModuleList
-{
+class SearchFilterByModuleListAndCU : public SearchFilterByModuleList {
public:
- //------------------------------------------------------------------
- /// The basic constructor takes a Target, which gives the space to search,
- /// and the module list to restrict the search to.
- ///
- /// @param[in] target
- /// The Target that provides the module list to search.
- ///
- /// @param[in] module
- /// The Module that limits the search.
- //------------------------------------------------------------------
- SearchFilterByModuleListAndCU (const lldb::TargetSP &targetSP,
- const FileSpecList &module_list,
- const FileSpecList &cu_list);
+ //------------------------------------------------------------------
+ /// The basic constructor takes a Target, which gives the space to search,
+ /// and the module list to restrict the search to.
+ ///
+ /// @param[in] target
+ /// The Target that provides the module list to search.
+ ///
+ /// @param[in] module
+ /// The Module that limits the search.
+ //------------------------------------------------------------------
+ SearchFilterByModuleListAndCU(const lldb::TargetSP &targetSP,
+ const FileSpecList &module_list,
+ const FileSpecList &cu_list);
+
+ SearchFilterByModuleListAndCU(const SearchFilterByModuleListAndCU &rhs);
+
+ ~SearchFilterByModuleListAndCU() override;
+
+ SearchFilterByModuleListAndCU &
+ operator=(const SearchFilterByModuleListAndCU &rhs);
- SearchFilterByModuleListAndCU (const SearchFilterByModuleListAndCU& rhs);
+ bool AddressPasses(Address &address) override;
- ~SearchFilterByModuleListAndCU() override;
+ bool CompUnitPasses(FileSpec &fileSpec) override;
- SearchFilterByModuleListAndCU&
- operator=(const SearchFilterByModuleListAndCU& rhs);
+ bool CompUnitPasses(CompileUnit &compUnit) override;
- bool
- AddressPasses (Address &address) override;
+ void GetDescription(Stream *s) override;
- bool
- CompUnitPasses (FileSpec &fileSpec) override;
+ uint32_t GetFilterRequiredItems() override;
- bool
- CompUnitPasses (CompileUnit &compUnit) override;
+ void Dump(Stream *s) const override;
- void
- GetDescription(Stream *s) override;
+ void Search(Searcher &searcher) override;
- uint32_t
- GetFilterRequiredItems () override;
+ static lldb::SearchFilterSP
+ CreateFromStructuredData(Target &target,
+ const StructuredData::Dictionary &data_dict,
+ Error &error);
- void
- Dump (Stream *s) const override;
+ StructuredData::ObjectSP SerializeToStructuredData() override;
- void
- Search (Searcher &searcher) override;
-
protected:
- lldb::SearchFilterSP
- DoCopyForBreakpoint (Breakpoint &breakpoint) override;
+ lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override;
private:
- FileSpecList m_cu_spec_list;
+ FileSpecList m_cu_spec_list;
};
} // namespace lldb_private
diff --git a/include/lldb/Core/Section.h b/include/lldb/Core/Section.h
index 0837e326f97b..5afaa11359db 100644
--- a/include/lldb/Core/Section.h
+++ b/include/lldb/Core/Section.h
@@ -10,380 +10,254 @@
#ifndef liblldb_Section_h_
#define liblldb_Section_h_
-#include "lldb/lldb-private.h"
#include "lldb/Core/AddressRange.h"
+#include "lldb/Core/ConstString.h"
#include "lldb/Core/Flags.h"
#include "lldb/Core/ModuleChild.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/RangeMap.h"
#include "lldb/Core/UserID.h"
#include "lldb/Core/VMRange.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/lldb-private.h"
#include <limits.h>
namespace lldb_private {
-class SectionList
-{
+class SectionList {
public:
- typedef std::vector<lldb::SectionSP> collection;
- typedef collection::iterator iterator;
- typedef collection::const_iterator const_iterator;
+ typedef std::vector<lldb::SectionSP> collection;
+ typedef collection::iterator iterator;
+ typedef collection::const_iterator const_iterator;
+
+ SectionList();
- SectionList();
+ ~SectionList();
- ~SectionList();
+ SectionList &operator=(const SectionList &rhs);
- SectionList &
- operator =(const SectionList& rhs);
+ size_t AddSection(const lldb::SectionSP &section_sp);
- size_t
- AddSection (const lldb::SectionSP& section_sp);
+ size_t AddUniqueSection(const lldb::SectionSP &section_sp);
- size_t
- AddUniqueSection (const lldb::SectionSP& section_sp);
+ size_t FindSectionIndex(const Section *sect);
- size_t
- FindSectionIndex (const Section* sect);
+ bool ContainsSection(lldb::user_id_t sect_id) const;
- bool
- ContainsSection(lldb::user_id_t sect_id) const;
+ void Dump(Stream *s, Target *target, bool show_header, uint32_t depth) const;
- void
- Dump (Stream *s, Target *target, bool show_header, uint32_t depth) const;
+ lldb::SectionSP FindSectionByName(const ConstString &section_dstr) const;
- lldb::SectionSP
- FindSectionByName (const ConstString &section_dstr) const;
+ lldb::SectionSP FindSectionByID(lldb::user_id_t sect_id) const;
- lldb::SectionSP
- FindSectionByID (lldb::user_id_t sect_id) const;
+ lldb::SectionSP FindSectionByType(lldb::SectionType sect_type,
+ bool check_children,
+ size_t start_idx = 0) const;
- lldb::SectionSP
- FindSectionByType (lldb::SectionType sect_type, bool check_children, size_t start_idx = 0) const;
+ lldb::SectionSP
+ FindSectionContainingFileAddress(lldb::addr_t addr,
+ uint32_t depth = UINT32_MAX) const;
- lldb::SectionSP
- FindSectionContainingFileAddress (lldb::addr_t addr, uint32_t depth = UINT32_MAX) const;
+ // Get the number of sections in this list only
+ size_t GetSize() const { return m_sections.size(); }
- // Get the number of sections in this list only
- size_t
- GetSize () const
- {
- return m_sections.size();
- }
+ // Get the number of sections in this list, and any contained child sections
+ size_t GetNumSections(uint32_t depth) const;
- // Get the number of sections in this list, and any contained child sections
- size_t
- GetNumSections (uint32_t depth) const;
+ bool ReplaceSection(lldb::user_id_t sect_id,
+ const lldb::SectionSP &section_sp,
+ uint32_t depth = UINT32_MAX);
- bool
- ReplaceSection (lldb::user_id_t sect_id, const lldb::SectionSP& section_sp, uint32_t depth = UINT32_MAX);
+ // Warning, this can be slow as it's removing items from a std::vector.
+ bool DeleteSection(size_t idx);
- // Warning, this can be slow as it's removing items from a std::vector.
- bool
- DeleteSection (size_t idx);
+ lldb::SectionSP GetSectionAtIndex(size_t idx) const;
- lldb::SectionSP
- GetSectionAtIndex (size_t idx) const;
+ size_t Slide(lldb::addr_t slide_amount, bool slide_children);
- size_t
- Slide (lldb::addr_t slide_amount, bool slide_children);
-
- void
- Clear ()
- {
- m_sections.clear();
- }
+ void Clear() { m_sections.clear(); }
protected:
- collection m_sections;
+ collection m_sections;
};
-
-class Section :
- public std::enable_shared_from_this<Section>,
- public ModuleChild,
- public UserID,
- public Flags
-{
+class Section : public std::enable_shared_from_this<Section>,
+ public ModuleChild,
+ public UserID,
+ public Flags {
public:
- // Create a root section (one that has no parent)
- Section (const lldb::ModuleSP &module_sp,
- ObjectFile *obj_file,
- lldb::user_id_t sect_id,
- const ConstString &name,
- lldb::SectionType sect_type,
- lldb::addr_t file_vm_addr,
- lldb::addr_t vm_size,
- lldb::offset_t file_offset,
- lldb::offset_t file_size,
- uint32_t log2align,
- uint32_t flags,
- uint32_t target_byte_size = 1);
-
- // Create a section that is a child of parent_section_sp
- Section (const lldb::SectionSP &parent_section_sp, // NULL for top level sections, non-NULL for child sections
- const lldb::ModuleSP &module_sp,
- ObjectFile *obj_file,
- lldb::user_id_t sect_id,
- const ConstString &name,
- lldb::SectionType sect_type,
- lldb::addr_t file_vm_addr,
- lldb::addr_t vm_size,
- lldb::offset_t file_offset,
- lldb::offset_t file_size,
- uint32_t log2align,
- uint32_t flags,
- uint32_t target_byte_size = 1);
-
- ~Section ();
-
- static int
- Compare (const Section& a, const Section& b);
-
- bool
- ContainsFileAddress (lldb::addr_t vm_addr) const;
-
- SectionList&
- GetChildren ()
- {
- return m_children;
- }
-
- const SectionList&
- GetChildren () const
- {
- return m_children;
- }
-
- void
- Dump (Stream *s, Target *target, uint32_t depth) const;
-
- void
- DumpName (Stream *s) const;
-
- lldb::addr_t
- GetLoadBaseAddress (Target *target) const;
-
- bool
- ResolveContainedAddress (lldb::addr_t offset, Address &so_addr) const;
-
- lldb::offset_t
- GetFileOffset () const
- {
- return m_file_offset;
- }
-
- void
- SetFileOffset (lldb::offset_t file_offset)
- {
- m_file_offset = file_offset;
- }
-
- lldb::offset_t
- GetFileSize () const
- {
- return m_file_size;
- }
-
- void
- SetFileSize (lldb::offset_t file_size)
- {
- m_file_size = file_size;
- }
-
- lldb::addr_t
- GetFileAddress () const;
-
- bool
- SetFileAddress (lldb::addr_t file_addr);
-
- lldb::addr_t
- GetOffset () const;
-
-
- lldb::addr_t
- GetByteSize () const
- {
- return m_byte_size;
- }
-
- void
- SetByteSize (lldb::addr_t byte_size)
- {
- m_byte_size = byte_size;
- }
-
- bool
- IsFake() const
- {
- return m_fake;
- }
-
- void
- SetIsFake(bool fake)
- {
- m_fake = fake;
- }
-
- bool
- IsEncrypted () const
- {
- return m_encrypted;
- }
-
- void
- SetIsEncrypted (bool b)
- {
- m_encrypted = b;
- }
-
- bool
- IsDescendant (const Section *section);
-
- const ConstString&
- GetName () const
- {
- return m_name;
- }
-
- bool
- Slide (lldb::addr_t slide_amount, bool slide_children);
-
-
- lldb::SectionType
- GetType () const
- {
- return m_type;
- }
-
- lldb::SectionSP
- GetParent () const
- {
- return m_parent_wp.lock();
- }
-
- bool
- IsThreadSpecific () const
- {
- return m_thread_specific;
- }
-
- void
- SetIsThreadSpecific (bool b)
- {
- m_thread_specific = b;
- }
-
- //------------------------------------------------------------------
- /// Get the permissions as OR'ed bits from lldb::Permissions
- //------------------------------------------------------------------
- uint32_t
- GetPermissions() const;
-
- //------------------------------------------------------------------
- /// Set the permissions using bits OR'ed from lldb::Permissions
- //------------------------------------------------------------------
- void
- SetPermissions(uint32_t permissions);
-
- ObjectFile *
- GetObjectFile ()
- {
- return m_obj_file;
- }
- const ObjectFile *
- GetObjectFile () const
- {
- return m_obj_file;
- }
-
- //------------------------------------------------------------------
- /// Read the section data from the object file that the section
- /// resides in.
- ///
- /// @param[in] dst
- /// Where to place the data
- ///
- /// @param[in] dst_len
- /// How many bytes of section data to read
- ///
- /// @param[in] offset
- /// The offset in bytes within this section's data at which to
- /// start copying data from.
- ///
- /// @return
- /// The number of bytes read from the section, or zero if the
- /// section has no data or \a offset is not a valid offset
- /// in this section.
- //------------------------------------------------------------------
- lldb::offset_t
- GetSectionData (void *dst, lldb::offset_t dst_len, lldb::offset_t offset = 0);
-
- //------------------------------------------------------------------
- /// Get the shared reference to the section data from the object
- /// file that the section resides in. No copies of the data will be
- /// make unless the object file has been read from memory. If the
- /// object file is on disk, it will shared the mmap data for the
- /// entire object file.
- ///
- /// @param[in] data
- /// Where to place the data, address byte size, and byte order
- ///
- /// @return
- /// The number of bytes read from the section, or zero if the
- /// section has no data or \a offset is not a valid offset
- /// in this section.
- //------------------------------------------------------------------
- lldb::offset_t
- GetSectionData (DataExtractor& data) const;
-
- uint32_t GetLog2Align()
- {
- return m_log2align;
- }
-
- void
- SetLog2Align(uint32_t align)
- {
- m_log2align = align;
- }
-
- // Get the number of host bytes required to hold a target byte
- uint32_t
- GetTargetByteSize() const
- {
- return m_target_byte_size;
- }
+ // Create a root section (one that has no parent)
+ Section(const lldb::ModuleSP &module_sp, ObjectFile *obj_file,
+ lldb::user_id_t sect_id, const ConstString &name,
+ lldb::SectionType sect_type, lldb::addr_t file_vm_addr,
+ lldb::addr_t vm_size, lldb::offset_t file_offset,
+ lldb::offset_t file_size, uint32_t log2align, uint32_t flags,
+ uint32_t target_byte_size = 1);
-protected:
+ // Create a section that is a child of parent_section_sp
+ Section(const lldb::SectionSP &parent_section_sp, // NULL for top level
+ // sections, non-NULL for
+ // child sections
+ const lldb::ModuleSP &module_sp, ObjectFile *obj_file,
+ lldb::user_id_t sect_id, const ConstString &name,
+ lldb::SectionType sect_type, lldb::addr_t file_vm_addr,
+ lldb::addr_t vm_size, lldb::offset_t file_offset,
+ lldb::offset_t file_size, uint32_t log2align, uint32_t flags,
+ uint32_t target_byte_size = 1);
+
+ ~Section();
+
+ static int Compare(const Section &a, const Section &b);
+
+ bool ContainsFileAddress(lldb::addr_t vm_addr) const;
+
+ SectionList &GetChildren() { return m_children; }
+
+ const SectionList &GetChildren() const { return m_children; }
+
+ void Dump(Stream *s, Target *target, uint32_t depth) const;
+
+ void DumpName(Stream *s) const;
+
+ lldb::addr_t GetLoadBaseAddress(Target *target) const;
+
+ bool ResolveContainedAddress(lldb::addr_t offset, Address &so_addr) const;
+
+ lldb::offset_t GetFileOffset() const { return m_file_offset; }
+
+ void SetFileOffset(lldb::offset_t file_offset) {
+ m_file_offset = file_offset;
+ }
+
+ lldb::offset_t GetFileSize() const { return m_file_size; }
+
+ void SetFileSize(lldb::offset_t file_size) { m_file_size = file_size; }
+
+ lldb::addr_t GetFileAddress() const;
+
+ bool SetFileAddress(lldb::addr_t file_addr);
+
+ lldb::addr_t GetOffset() const;
- ObjectFile *m_obj_file; // The object file that data for this section should be read from
- lldb::SectionType m_type; // The type of this section
- lldb::SectionWP m_parent_wp; // Weak pointer to parent section
- ConstString m_name; // Name of this section
- lldb::addr_t m_file_addr; // The absolute file virtual address range of this section if m_parent == NULL,
- // offset from parent file virtual address if m_parent != NULL
- lldb::addr_t m_byte_size; // Size in bytes that this section will occupy in memory at runtime
- lldb::offset_t m_file_offset; // Object file offset (if any)
- lldb::offset_t m_file_size; // Object file size (can be smaller than m_byte_size for zero filled sections...)
- uint32_t m_log2align; // log_2(align) of the section (i.e. section has to be aligned to 2^m_log2align)
- SectionList m_children; // Child sections
- bool m_fake : 1, // If true, then this section only can contain the address if one of its
- // children contains an address. This allows for gaps between the children
- // that are contained in the address range for this section, but do not produce
- // hits unless the children contain the address.
- m_encrypted : 1, // Set to true if the contents are encrypted
- m_thread_specific : 1, // This section is thread specific
- m_readable : 1, // If this section has read permissions
- m_writable : 1, // If this section has write permissions
- m_executable : 1; // If this section has executable permissions
- uint32_t m_target_byte_size; // Some architectures have non-8-bit byte size. This is specified as
- // as a multiple number of a host bytes
+ lldb::addr_t GetByteSize() const { return m_byte_size; }
+
+ void SetByteSize(lldb::addr_t byte_size) { m_byte_size = byte_size; }
+
+ bool IsFake() const { return m_fake; }
+
+ void SetIsFake(bool fake) { m_fake = fake; }
+
+ bool IsEncrypted() const { return m_encrypted; }
+
+ void SetIsEncrypted(bool b) { m_encrypted = b; }
+
+ bool IsDescendant(const Section *section);
+
+ const ConstString &GetName() const { return m_name; }
+
+ bool Slide(lldb::addr_t slide_amount, bool slide_children);
+
+ lldb::SectionType GetType() const { return m_type; }
+
+ lldb::SectionSP GetParent() const { return m_parent_wp.lock(); }
+
+ bool IsThreadSpecific() const { return m_thread_specific; }
+
+ void SetIsThreadSpecific(bool b) { m_thread_specific = b; }
+
+ //------------------------------------------------------------------
+ /// Get the permissions as OR'ed bits from lldb::Permissions
+ //------------------------------------------------------------------
+ uint32_t GetPermissions() const;
+
+ //------------------------------------------------------------------
+ /// Set the permissions using bits OR'ed from lldb::Permissions
+ //------------------------------------------------------------------
+ void SetPermissions(uint32_t permissions);
+
+ ObjectFile *GetObjectFile() { return m_obj_file; }
+ const ObjectFile *GetObjectFile() const { return m_obj_file; }
+
+ //------------------------------------------------------------------
+ /// Read the section data from the object file that the section
+ /// resides in.
+ ///
+ /// @param[in] dst
+ /// Where to place the data
+ ///
+ /// @param[in] dst_len
+ /// How many bytes of section data to read
+ ///
+ /// @param[in] offset
+ /// The offset in bytes within this section's data at which to
+ /// start copying data from.
+ ///
+ /// @return
+ /// The number of bytes read from the section, or zero if the
+ /// section has no data or \a offset is not a valid offset
+ /// in this section.
+ //------------------------------------------------------------------
+ lldb::offset_t GetSectionData(void *dst, lldb::offset_t dst_len,
+ lldb::offset_t offset = 0);
+
+ //------------------------------------------------------------------
+ /// Get the shared reference to the section data from the object
+ /// file that the section resides in. No copies of the data will be
+ /// make unless the object file has been read from memory. If the
+ /// object file is on disk, it will shared the mmap data for the
+ /// entire object file.
+ ///
+ /// @param[in] data
+ /// Where to place the data, address byte size, and byte order
+ ///
+ /// @return
+ /// The number of bytes read from the section, or zero if the
+ /// section has no data or \a offset is not a valid offset
+ /// in this section.
+ //------------------------------------------------------------------
+ lldb::offset_t GetSectionData(DataExtractor &data) const;
+
+ uint32_t GetLog2Align() { return m_log2align; }
+
+ void SetLog2Align(uint32_t align) { m_log2align = align; }
+
+ // Get the number of host bytes required to hold a target byte
+ uint32_t GetTargetByteSize() const { return m_target_byte_size; }
+
+protected:
+ ObjectFile *m_obj_file; // The object file that data for this section should
+ // be read from
+ lldb::SectionType m_type; // The type of this section
+ lldb::SectionWP m_parent_wp; // Weak pointer to parent section
+ ConstString m_name; // Name of this section
+ lldb::addr_t m_file_addr; // The absolute file virtual address range of this
+ // section if m_parent == NULL,
+ // offset from parent file virtual address if m_parent != NULL
+ lldb::addr_t m_byte_size; // Size in bytes that this section will occupy in
+ // memory at runtime
+ lldb::offset_t m_file_offset; // Object file offset (if any)
+ lldb::offset_t m_file_size; // Object file size (can be smaller than
+ // m_byte_size for zero filled sections...)
+ uint32_t m_log2align; // log_2(align) of the section (i.e. section has to be
+ // aligned to 2^m_log2align)
+ SectionList m_children; // Child sections
+ bool m_fake : 1, // If true, then this section only can contain the address if
+ // one of its
+ // children contains an address. This allows for gaps between the children
+ // that are contained in the address range for this section, but do not
+ // produce
+ // hits unless the children contain the address.
+ m_encrypted : 1, // Set to true if the contents are encrypted
+ m_thread_specific : 1, // This section is thread specific
+ m_readable : 1, // If this section has read permissions
+ m_writable : 1, // If this section has write permissions
+ m_executable : 1; // If this section has executable permissions
+ uint32_t m_target_byte_size; // Some architectures have non-8-bit byte size.
+ // This is specified as
+ // as a multiple number of a host bytes
private:
- DISALLOW_COPY_AND_ASSIGN (Section);
+ DISALLOW_COPY_AND_ASSIGN(Section);
};
-
} // namespace lldb_private
-#endif // liblldb_Section_h_
+#endif // liblldb_Section_h_
diff --git a/include/lldb/Core/SourceManager.h b/include/lldb/Core/SourceManager.h
index 5504bafd6b7e..9ca2a3297230 100644
--- a/include/lldb/Core/SourceManager.h
+++ b/include/lldb/Core/SourceManager.h
@@ -10,187 +10,161 @@
#ifndef liblldb_SourceManager_h_
#define liblldb_SourceManager_h_
+// Project includes
+#include "lldb/Host/FileSpec.h"
+#include "lldb/lldb-private.h"
+
+// Other libraries and framework includes
+#include "llvm/Support/Chrono.h"
+
// C Includes
// C++ Includes
#include <map>
#include <memory>
#include <vector>
-// Other libraries and framework includes
-// Project includes
-#include "lldb/lldb-private.h"
-#include "lldb/Host/FileSpec.h"
-
namespace lldb_private {
-class SourceManager
-{
+class SourceManager {
public:
#ifndef SWIG
- class File
- {
- friend bool operator== (const SourceManager::File &lhs, const SourceManager::File &rhs);
-
- public:
- File (const FileSpec &file_spec, Target *target);
- ~File();
-
- void
- UpdateIfNeeded ();
-
- size_t
- DisplaySourceLines (uint32_t line,
- uint32_t context_before,
- uint32_t context_after,
- Stream *s);
- void
- FindLinesMatchingRegex (RegularExpression& regex,
- uint32_t start_line,
- uint32_t end_line,
+ class File {
+ friend bool operator==(const SourceManager::File &lhs,
+ const SourceManager::File &rhs);
+
+ public:
+ File(const FileSpec &file_spec, Target *target);
+ File(const FileSpec &file_spec, lldb::DebuggerSP debugger_sp);
+ ~File() = default;
+
+ void UpdateIfNeeded();
+
+ size_t DisplaySourceLines(uint32_t line, uint32_t column,
+ uint32_t context_before, uint32_t context_after,
+ Stream *s);
+ void FindLinesMatchingRegex(RegularExpression &regex, uint32_t start_line,
+ uint32_t end_line,
std::vector<uint32_t> &match_lines);
- bool
- GetLine (uint32_t line_no, std::string &buffer);
-
- uint32_t
- GetLineOffset (uint32_t line);
-
- bool
- LineIsValid (uint32_t line);
-
- bool
- FileSpecMatches (const FileSpec &file_spec);
-
- const FileSpec &
- GetFileSpec ()
- {
- return m_file_spec;
- }
-
- uint32_t
- GetSourceMapModificationID() const
- {
- return m_source_map_mod_id;
- }
-
- const char *
- PeekLineData (uint32_t line);
-
- uint32_t
- GetLineLength (uint32_t line, bool include_newline_chars);
-
- uint32_t
- GetNumLines ();
-
- protected:
- bool
- CalculateLineOffsets (uint32_t line = UINT32_MAX);
-
- FileSpec m_file_spec_orig; // The original file spec that was used (can be different from m_file_spec)
- FileSpec m_file_spec; // The actually file spec being used (if the target has source mappings, this might be different from m_file_spec_orig)
- TimeValue m_mod_time; // Keep the modification time that this file data is valid for
- uint32_t m_source_map_mod_id; // If the target uses path remappings, be sure to clear our notion of a source file if the path modification ID changes
- lldb::DataBufferSP m_data_sp;
- typedef std::vector<uint32_t> LineOffsets;
- LineOffsets m_offsets;
- };
+ bool GetLine(uint32_t line_no, std::string &buffer);
+
+ uint32_t GetLineOffset(uint32_t line);
+
+ bool LineIsValid(uint32_t line);
+
+ bool FileSpecMatches(const FileSpec &file_spec);
+
+ const FileSpec &GetFileSpec() { return m_file_spec; }
+
+ uint32_t GetSourceMapModificationID() const { return m_source_map_mod_id; }
+
+ const char *PeekLineData(uint32_t line);
+
+ uint32_t GetLineLength(uint32_t line, bool include_newline_chars);
+
+ uint32_t GetNumLines();
+
+ protected:
+ bool CalculateLineOffsets(uint32_t line = UINT32_MAX);
+
+ FileSpec m_file_spec_orig; // The original file spec that was used (can be
+ // different from m_file_spec)
+ FileSpec m_file_spec; // The actually file spec being used (if the target
+ // has source mappings, this might be different from
+ // m_file_spec_orig)
+
+ // Keep the modification time that this file data is valid for
+ llvm::sys::TimePoint<> m_mod_time;
+
+ // If the target uses path remappings, be sure to clear our notion of a
+ // source file if the path modification ID changes
+ uint32_t m_source_map_mod_id = 0;
+ lldb::DataBufferSP m_data_sp;
+ typedef std::vector<uint32_t> LineOffsets;
+ LineOffsets m_offsets;
+ lldb::DebuggerWP m_debugger_wp;
+
+ private:
+ void CommonInitializer(const FileSpec &file_spec, Target *target);
+ };
#endif // SWIG
- typedef std::shared_ptr<File> FileSP;
+ typedef std::shared_ptr<File> FileSP;
#ifndef SWIG
- // The SourceFileCache class separates the source manager from the cache of source files, so the
- // cache can be stored in the Debugger, but the source managers can be per target.
- class SourceFileCache
- {
- public:
- SourceFileCache() = default;
- ~SourceFileCache() = default;
-
- void AddSourceFile (const FileSP &file_sp);
- FileSP FindSourceFile (const FileSpec &file_spec) const;
-
- protected:
- typedef std::map <FileSpec, FileSP> FileCache;
- FileCache m_file_cache;
- };
+ // The SourceFileCache class separates the source manager from the cache of
+ // source files, so the
+ // cache can be stored in the Debugger, but the source managers can be per
+ // target.
+ class SourceFileCache {
+ public:
+ SourceFileCache() = default;
+ ~SourceFileCache() = default;
+
+ void AddSourceFile(const FileSP &file_sp);
+ FileSP FindSourceFile(const FileSpec &file_spec) const;
+
+ protected:
+ typedef std::map<FileSpec, FileSP> FileCache;
+ FileCache m_file_cache;
+ };
#endif // SWIG
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- // A source manager can be made with a non-null target, in which case it can use the path remappings to find
- // source files that are not in their build locations. With no target it won't be able to do this.
- SourceManager (const lldb::DebuggerSP &debugger_sp);
- SourceManager (const lldb::TargetSP &target_sp);
-
- ~SourceManager();
-
- FileSP
- GetLastFile ()
- {
- return m_last_file_sp;
- }
-
- size_t
- DisplaySourceLinesWithLineNumbers(const FileSpec &file,
- uint32_t line,
- uint32_t context_before,
- uint32_t context_after,
- const char* current_line_cstr,
- Stream *s,
- const SymbolContextList *bp_locs = nullptr);
-
- // This variant uses the last file we visited.
- size_t
- DisplaySourceLinesWithLineNumbersUsingLastFile(uint32_t start_line,
- uint32_t count,
- uint32_t curr_line,
- const char* current_line_cstr,
- Stream *s,
- const SymbolContextList *bp_locs = nullptr);
-
- size_t
- DisplayMoreWithLineNumbers(Stream *s,
- uint32_t count,
- bool reverse,
- const SymbolContextList *bp_locs = nullptr);
-
- bool
- SetDefaultFileAndLine (const FileSpec &file_spec, uint32_t line);
-
- bool
- GetDefaultFileAndLine (FileSpec &file_spec, uint32_t &line);
-
- bool
- DefaultFileAndLineSet ()
- {
- return (m_last_file_sp.get() != nullptr);
- }
-
- void
- FindLinesMatchingRegex (FileSpec &file_spec,
- RegularExpression& regex,
- uint32_t start_line,
- uint32_t end_line,
- std::vector<uint32_t> &match_lines);
-
- FileSP
- GetFile (const FileSpec &file_spec);
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ // A source manager can be made with a non-null target, in which case it can
+ // use the path remappings to find
+ // source files that are not in their build locations. With no target it
+ // won't be able to do this.
+ SourceManager(const lldb::DebuggerSP &debugger_sp);
+ SourceManager(const lldb::TargetSP &target_sp);
+
+ ~SourceManager();
+
+ FileSP GetLastFile() { return m_last_file_sp; }
+
+ size_t
+ DisplaySourceLinesWithLineNumbers(const FileSpec &file, uint32_t line,
+ uint32_t column, uint32_t context_before,
+ uint32_t context_after,
+ const char *current_line_cstr, Stream *s,
+ const SymbolContextList *bp_locs = nullptr);
+
+ // This variant uses the last file we visited.
+ size_t DisplaySourceLinesWithLineNumbersUsingLastFile(
+ uint32_t start_line, uint32_t count, uint32_t curr_line, uint32_t column,
+ const char *current_line_cstr, Stream *s,
+ const SymbolContextList *bp_locs = nullptr);
+
+ size_t DisplayMoreWithLineNumbers(Stream *s, uint32_t count, bool reverse,
+ const SymbolContextList *bp_locs = nullptr);
+
+ bool SetDefaultFileAndLine(const FileSpec &file_spec, uint32_t line);
+
+ bool GetDefaultFileAndLine(FileSpec &file_spec, uint32_t &line);
+
+ bool DefaultFileAndLineSet() { return (m_last_file_sp.get() != nullptr); }
+
+ void FindLinesMatchingRegex(FileSpec &file_spec, RegularExpression &regex,
+ uint32_t start_line, uint32_t end_line,
+ std::vector<uint32_t> &match_lines);
+
+ FileSP GetFile(const FileSpec &file_spec);
protected:
- FileSP m_last_file_sp;
- uint32_t m_last_line;
- uint32_t m_last_count;
- bool m_default_set;
- lldb::TargetWP m_target_wp;
- lldb::DebuggerWP m_debugger_wp;
-
+ FileSP m_last_file_sp;
+ uint32_t m_last_line;
+ uint32_t m_last_count;
+ bool m_default_set;
+ lldb::TargetWP m_target_wp;
+ lldb::DebuggerWP m_debugger_wp;
+
private:
- DISALLOW_COPY_AND_ASSIGN (SourceManager);
+ DISALLOW_COPY_AND_ASSIGN(SourceManager);
};
-bool operator== (const SourceManager::File &lhs, const SourceManager::File &rhs);
+bool operator==(const SourceManager::File &lhs, const SourceManager::File &rhs);
} // namespace lldb_private
diff --git a/include/lldb/Core/State.h b/include/lldb/Core/State.h
index 8057b3e0584c..a9d7692ca458 100644
--- a/include/lldb/Core/State.h
+++ b/include/lldb/Core/State.h
@@ -29,8 +29,7 @@ namespace lldb_private {
/// returned string comes from constant string buffers and does
/// not need to be freed.
//------------------------------------------------------------------
-const char *
-StateAsCString (lldb::StateType state);
+const char *StateAsCString(lldb::StateType state);
//------------------------------------------------------------------
/// Check if a state represents a state where the process or thread
@@ -43,13 +42,12 @@ StateAsCString (lldb::StateType state);
/// \b true if the state represents a process or thread state
/// where the process or thread is running, \b false otherwise.
//------------------------------------------------------------------
-bool
-StateIsRunningState (lldb::StateType state);
+bool StateIsRunningState(lldb::StateType state);
//------------------------------------------------------------------
/// Check if a state represents a state where the process or thread
/// is stopped. Stopped can mean stopped when the process is still
-/// around, or stopped when the process has exited or doesn't exist
+/// around, or stopped when the process has exited or doesn't exist
/// yet. The \a must_exist argument tells us which of these cases is
/// desired.
///
@@ -62,17 +60,15 @@ StateIsRunningState (lldb::StateType state);
///
/// @return
/// \b true if the state represents a process or thread state
-/// where the process or thread is stopped. If \a must_exist is
+/// where the process or thread is stopped. If \a must_exist is
/// \b true, then the process can't be exited or unloaded,
/// otherwise exited and unloaded or other states where the
-/// process no longer exists are considered to be stopped.
+/// process no longer exists are considered to be stopped.
//------------------------------------------------------------------
-bool
-StateIsStoppedState (lldb::StateType state, bool must_exist);
+bool StateIsStoppedState(lldb::StateType state, bool must_exist);
+
+const char *GetPermissionsAsCString(uint32_t permissions);
-const char *
-GetPermissionsAsCString (uint32_t permissions);
-
} // namespace lldb_private
-#endif // liblldb_State_h_
+#endif // liblldb_State_h_
diff --git a/include/lldb/Core/Stream.h b/include/lldb/Core/Stream.h
index f784069894ec..1bea3e179223 100644
--- a/include/lldb/Core/Stream.h
+++ b/include/lldb/Core/Stream.h
@@ -16,8 +16,10 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/Flags.h"
+#include "lldb/lldb-private.h"
+
+#include "llvm/Support/FormatVariadic.h"
namespace lldb_private {
@@ -25,590 +27,544 @@ namespace lldb_private {
/// @class Stream Stream.h "lldb/Core/Stream.h"
/// @brief A stream class that can stream formatted output to a file.
//----------------------------------------------------------------------
-class Stream
-{
+class Stream {
public:
- //------------------------------------------------------------------
- /// \a m_flags bit values.
- //------------------------------------------------------------------
- enum
- {
- eVerbose = (1 << 0), ///< If set, verbose logging is enabled
- eDebug = (1 << 1), ///< If set, debug logging is enabled
- eAddPrefix = (1 << 2), ///< Add number prefixes for binary, octal and hex when eBinary is clear
- eBinary = (1 << 3) ///< Get and put data as binary instead of as the default string mode.
- };
-
- //------------------------------------------------------------------
- /// Construct with flags and address size and byte order.
- ///
- /// Construct with dump flags \a flags and the default address
- /// size. \a flags can be any of the above enumeration logical OR'ed
- /// together.
- //------------------------------------------------------------------
- Stream (uint32_t flags,
- uint32_t addr_size,
- lldb::ByteOrder byte_order);
-
- //------------------------------------------------------------------
- /// Construct a default Stream, not binary, host byte order and
- /// host addr size.
- ///
- //------------------------------------------------------------------
- Stream ();
-
- //------------------------------------------------------------------
- /// Destructor
- //------------------------------------------------------------------
- virtual
- ~Stream ();
-
- //------------------------------------------------------------------
- // Subclasses must override these methods
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Flush the stream.
- ///
- /// Subclasses should flush the stream to make any output appear
- /// if the stream has any buffering.
- //------------------------------------------------------------------
- virtual void
- Flush () = 0;
-
- //------------------------------------------------------------------
- /// Output character bytes to the stream.
- ///
- /// Appends \a src_len characters from the buffer \a src to the
- /// stream.
- ///
- /// @param[in] src
- /// A buffer containing at least \a src_len bytes of data.
- ///
- /// @param[in] src_len
- /// A number of bytes to append to the stream.
- ///
- /// @return
- /// The number of bytes that were appended to the stream.
- //------------------------------------------------------------------
- virtual size_t
- Write (const void *src, size_t src_len) = 0;
-
- //------------------------------------------------------------------
- // Member functions
- //------------------------------------------------------------------
- size_t
- PutChar (char ch);
-
- //------------------------------------------------------------------
- /// Set the byte_order value.
- ///
- /// Sets the byte order of the data to extract. Extracted values
- /// will be swapped if necessary when decoding.
- ///
- /// @param[in] byte_order
- /// The byte order value to use when extracting data.
- ///
- /// @return
- /// The old byte order value.
- //------------------------------------------------------------------
- lldb::ByteOrder
- SetByteOrder (lldb::ByteOrder byte_order);
-
- //------------------------------------------------------------------
- /// Format a C string from a printf style format and variable
- /// arguments and encode and append the resulting C string as hex
- /// bytes.
- ///
- /// @param[in] format
- /// A printf style format string.
- ///
- /// @param[in] ...
- /// Any additional arguments needed for the printf format string.
- ///
- /// @return
- /// The number of bytes that were appended to the stream.
- //------------------------------------------------------------------
- size_t
- PrintfAsRawHex8 (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
-
- //------------------------------------------------------------------
- /// Format a C string from a printf style format and variable
- /// arguments and encode and append the resulting C string as hex
- /// bytes.
- ///
- /// @param[in] format
- /// A printf style format string.
- ///
- /// @param[in] ...
- /// Any additional arguments needed for the printf format string.
- ///
- /// @return
- /// The number of bytes that were appended to the stream.
- //------------------------------------------------------------------
- size_t
- PutHex8 (uint8_t uvalue);
-
- size_t
- PutNHex8 (size_t n, uint8_t uvalue);
-
- size_t
- PutHex16 (uint16_t uvalue,
- lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
-
- size_t
- PutHex32 (uint32_t uvalue,
- lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
-
- size_t
- PutHex64 (uint64_t uvalue,
- lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
-
- size_t
- PutMaxHex64 (uint64_t uvalue,
- size_t byte_size,
- lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
- size_t
- PutFloat (float f,
- lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
-
- size_t
- PutDouble (double d,
- lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
-
- size_t
- PutLongDouble (long double ld,
+ //------------------------------------------------------------------
+ /// \a m_flags bit values.
+ //------------------------------------------------------------------
+ enum {
+ eVerbose = (1 << 0), ///< If set, verbose logging is enabled
+ eDebug = (1 << 1), ///< If set, debug logging is enabled
+ eAddPrefix = (1 << 2), ///< Add number prefixes for binary, octal and hex
+ ///when eBinary is clear
+ eBinary = (1 << 3) ///< Get and put data as binary instead of as the default
+ ///string mode.
+ };
+
+ //------------------------------------------------------------------
+ /// Construct with flags and address size and byte order.
+ ///
+ /// Construct with dump flags \a flags and the default address
+ /// size. \a flags can be any of the above enumeration logical OR'ed
+ /// together.
+ //------------------------------------------------------------------
+ Stream(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order);
+
+ //------------------------------------------------------------------
+ /// Construct a default Stream, not binary, host byte order and
+ /// host addr size.
+ ///
+ //------------------------------------------------------------------
+ Stream();
+
+ //------------------------------------------------------------------
+ /// Destructor
+ //------------------------------------------------------------------
+ virtual ~Stream();
+
+ //------------------------------------------------------------------
+ // Subclasses must override these methods
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Flush the stream.
+ ///
+ /// Subclasses should flush the stream to make any output appear
+ /// if the stream has any buffering.
+ //------------------------------------------------------------------
+ virtual void Flush() = 0;
+
+ //------------------------------------------------------------------
+ /// Output character bytes to the stream.
+ ///
+ /// Appends \a src_len characters from the buffer \a src to the
+ /// stream.
+ ///
+ /// @param[in] src
+ /// A buffer containing at least \a src_len bytes of data.
+ ///
+ /// @param[in] src_len
+ /// A number of bytes to append to the stream.
+ ///
+ /// @return
+ /// The number of bytes that were appended to the stream.
+ //------------------------------------------------------------------
+ virtual size_t Write(const void *src, size_t src_len) = 0;
+
+ //------------------------------------------------------------------
+ // Member functions
+ //------------------------------------------------------------------
+ size_t PutChar(char ch);
+
+ //------------------------------------------------------------------
+ /// Set the byte_order value.
+ ///
+ /// Sets the byte order of the data to extract. Extracted values
+ /// will be swapped if necessary when decoding.
+ ///
+ /// @param[in] byte_order
+ /// The byte order value to use when extracting data.
+ ///
+ /// @return
+ /// The old byte order value.
+ //------------------------------------------------------------------
+ lldb::ByteOrder SetByteOrder(lldb::ByteOrder byte_order);
+
+ //------------------------------------------------------------------
+ /// Format a C string from a printf style format and variable
+ /// arguments and encode and append the resulting C string as hex
+ /// bytes.
+ ///
+ /// @param[in] format
+ /// A printf style format string.
+ ///
+ /// @param[in] ...
+ /// Any additional arguments needed for the printf format string.
+ ///
+ /// @return
+ /// The number of bytes that were appended to the stream.
+ //------------------------------------------------------------------
+ size_t PrintfAsRawHex8(const char *format, ...)
+ __attribute__((__format__(__printf__, 2, 3)));
+
+ //------------------------------------------------------------------
+ /// Format a C string from a printf style format and variable
+ /// arguments and encode and append the resulting C string as hex
+ /// bytes.
+ ///
+ /// @param[in] format
+ /// A printf style format string.
+ ///
+ /// @param[in] ...
+ /// Any additional arguments needed for the printf format string.
+ ///
+ /// @return
+ /// The number of bytes that were appended to the stream.
+ //------------------------------------------------------------------
+ size_t PutHex8(uint8_t uvalue);
+
+ size_t PutNHex8(size_t n, uint8_t uvalue);
+
+ size_t PutHex16(uint16_t uvalue,
+ lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
+
+ size_t PutHex32(uint32_t uvalue,
+ lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
+
+ size_t PutHex64(uint64_t uvalue,
+ lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
+
+ size_t PutMaxHex64(uint64_t uvalue, size_t byte_size,
+ lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
+ size_t PutFloat(float f,
+ lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
+
+ size_t PutDouble(double d,
lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
- size_t
- PutPointer (void *ptr);
-
- // Append \a src_len bytes from \a src to the stream as hex characters
- // (two ascii characters per byte of input data)
- size_t
- PutBytesAsRawHex8 (const void *src,
- size_t src_len,
- lldb::ByteOrder src_byte_order = lldb::eByteOrderInvalid,
- lldb::ByteOrder dst_byte_order = lldb::eByteOrderInvalid);
-
- // Append \a src_len bytes from \a s to the stream as binary data.
- size_t
- PutRawBytes (const void *s,
- size_t src_len,
- lldb::ByteOrder src_byte_order = lldb::eByteOrderInvalid,
- lldb::ByteOrder dst_byte_order = lldb::eByteOrderInvalid);
-
- size_t
- PutCStringAsRawHex8 (const char *s);
-
- //------------------------------------------------------------------
- /// Output a NULL terminated C string \a cstr to the stream \a s.
- ///
- /// @param[in] cstr
- /// A NULL terminated C string.
- ///
- /// @return
- /// A reference to this class so multiple things can be streamed
- /// in one statement.
- //------------------------------------------------------------------
- Stream&
- operator<< (const char *cstr);
-
- //------------------------------------------------------------------
- /// Output a pointer value \a p to the stream \a s.
- ///
- /// @param[in] p
- /// A void pointer.
- ///
- /// @return
- /// A reference to this class so multiple things can be streamed
- /// in one statement.
- //------------------------------------------------------------------
- Stream&
- operator<< (const void *p);
-
- //------------------------------------------------------------------
- /// Output a character \a ch to the stream \a s.
- ///
- /// @param[in] ch
- /// A printable character value.
- ///
- /// @return
- /// A reference to this class so multiple things can be streamed
- /// in one statement.
- //------------------------------------------------------------------
- Stream&
- operator<< (char ch);
-
- //------------------------------------------------------------------
- /// Output a uint8_t \a uval to the stream \a s.
- ///
- /// @param[in] uval
- /// A uint8_t value.
- ///
- /// @return
- /// A reference to this class so multiple things can be streamed
- /// in one statement.
- //------------------------------------------------------------------
- Stream&
- operator<< (uint8_t uval);
-
- //------------------------------------------------------------------
- /// Output a uint16_t \a uval to the stream \a s.
- ///
- /// @param[in] uval
- /// A uint16_t value.
- ///
- /// @return
- /// A reference to this class so multiple things can be streamed
- /// in one statement.
- //------------------------------------------------------------------
- Stream&
- operator<< (uint16_t uval);
-
- //------------------------------------------------------------------
- /// Output a uint32_t \a uval to the stream \a s.
- ///
- /// @param[in] uval
- /// A uint32_t value.
- ///
- /// @return
- /// A reference to this class so multiple things can be streamed
- /// in one statement.
- //------------------------------------------------------------------
- Stream&
- operator<< (uint32_t uval);
-
- //------------------------------------------------------------------
- /// Output a uint64_t \a uval to the stream \a s.
- ///
- /// @param[in] uval
- /// A uint64_t value.
- ///
- /// @return
- /// A reference to this class so multiple things can be streamed
- /// in one statement.
- //------------------------------------------------------------------
- Stream&
- operator<< (uint64_t uval);
-
- //------------------------------------------------------------------
- /// Output a int8_t \a sval to the stream \a s.
- ///
- /// @param[in] sval
- /// A int8_t value.
- ///
- /// @return
- /// A reference to this class so multiple things can be streamed
- /// in one statement.
- //------------------------------------------------------------------
- Stream&
- operator<< (int8_t sval);
-
- //------------------------------------------------------------------
- /// Output a int16_t \a sval to the stream \a s.
- ///
- /// @param[in] sval
- /// A int16_t value.
- ///
- /// @return
- /// A reference to this class so multiple things can be streamed
- /// in one statement.
- //------------------------------------------------------------------
- Stream&
- operator<< (int16_t sval);
-
- //------------------------------------------------------------------
- /// Output a int32_t \a sval to the stream \a s.
- ///
- /// @param[in] sval
- /// A int32_t value.
- ///
- /// @return
- /// A reference to this class so multiple things can be streamed
- /// in one statement.
- //------------------------------------------------------------------
- Stream&
- operator<< (int32_t sval);
-
- //------------------------------------------------------------------
- /// Output a int64_t \a sval to the stream \a s.
- ///
- /// @param[in] sval
- /// A int64_t value.
- ///
- /// @return
- /// A reference to this class so multiple things can be streamed
- /// in one statement.
- //------------------------------------------------------------------
- Stream&
- operator<< (int64_t sval);
-
- //------------------------------------------------------------------
- /// Output an address value to this stream.
- ///
- /// Put an address \a addr out to the stream with optional \a prefix
- /// and \a suffix strings.
- ///
- /// @param[in] addr
- /// An address value.
- ///
- /// @param[in] addr_size
- /// Size in bytes of the address, used for formatting.
- ///
- /// @param[in] prefix
- /// A prefix C string. If nullptr, no prefix will be output.
- ///
- /// @param[in] suffix
- /// A suffix C string. If nullptr, no suffix will be output.
- //------------------------------------------------------------------
- void
- Address(uint64_t addr, uint32_t addr_size, const char *prefix = nullptr, const char *suffix = nullptr);
-
- //------------------------------------------------------------------
- /// Output an address range to this stream.
- ///
- /// Put an address range \a lo_addr - \a hi_addr out to the stream
- /// with optional \a prefix and \a suffix strings.
- ///
- /// @param[in] lo_addr
- /// The start address of the address range.
- ///
- /// @param[in] hi_addr
- /// The end address of the address range.
- ///
- /// @param[in] addr_size
- /// Size in bytes of the address, used for formatting.
- ///
- /// @param[in] prefix
- /// A prefix C string. If nullptr, no prefix will be output.
- ///
- /// @param[in] suffix
- /// A suffix C string. If nullptr, no suffix will be output.
- //------------------------------------------------------------------
- void
- AddressRange(uint64_t lo_addr, uint64_t hi_addr, uint32_t addr_size, const char *prefix = nullptr, const char *suffix = nullptr);
-
- //------------------------------------------------------------------
- /// Output a C string to the stream.
- ///
- /// Print a C string \a cstr to the stream.
- ///
- /// @param[in] cstr
- /// The string to be output to the stream.
- //------------------------------------------------------------------
- size_t
- PutCString (const char *cstr);
-
- //------------------------------------------------------------------
- /// Output and End of Line character to the stream.
- //------------------------------------------------------------------
- size_t
- EOL();
-
- //------------------------------------------------------------------
- /// Get the address size in bytes.
- ///
- /// @return
- /// The size of an address in bytes that is used when outputting
- /// address and pointer values to the stream.
- //------------------------------------------------------------------
- uint32_t
- GetAddressByteSize () const;
-
- //------------------------------------------------------------------
- /// Test if debug logging is enabled.
- ///
- /// @return
- // \b true if the debug flag bit is set in this stream, \b
- // false otherwise.
- //------------------------------------------------------------------
- bool
- GetDebug() const;
-
- //------------------------------------------------------------------
- /// The flags accessor.
- ///
- /// @return
- /// A reference to the Flags member variable.
- //------------------------------------------------------------------
- Flags&
- GetFlags();
-
- //------------------------------------------------------------------
- /// The flags const accessor.
- ///
- /// @return
- /// A const reference to the Flags member variable.
- //------------------------------------------------------------------
- const Flags&
- GetFlags() const;
-
- //------------------------------------------------------------------
- //// The byte order accessor.
- ////
- //// @return
- //// The byte order.
- //------------------------------------------------------------------
- lldb::ByteOrder
- GetByteOrder() const;
-
- //------------------------------------------------------------------
- /// Get the current indentation level.
- ///
- /// @return
- /// The current indentation level as an integer.
- //------------------------------------------------------------------
- int
- GetIndentLevel () const;
-
- //------------------------------------------------------------------
- /// Test if verbose logging is enabled.
- ///
- /// @return
- // \b true if the verbose flag bit is set in this stream, \b
- // false otherwise.
- //------------------------------------------------------------------
- bool
- GetVerbose() const;
-
- //------------------------------------------------------------------
- /// Indent the current line in the stream.
- ///
- /// Indent the current line using the current indentation level and
- /// print an optional string following the indentation spaces.
- ///
- /// @param[in] s
- /// A C string to print following the indentation. If nullptr, just
- /// output the indentation characters.
- //------------------------------------------------------------------
- size_t
- Indent(const char *s = nullptr);
-
- //------------------------------------------------------------------
- /// Decrement the current indentation level.
- //------------------------------------------------------------------
- void
- IndentLess (int amount = 2);
-
- //------------------------------------------------------------------
- /// Increment the current indentation level.
- //------------------------------------------------------------------
- void
- IndentMore (int amount = 2);
-
- //------------------------------------------------------------------
- /// Output an offset value.
- ///
- /// Put an offset \a uval out to the stream using the printf format
- /// in \a format.
- ///
- /// @param[in] offset
- /// The offset value.
- ///
- /// @param[in] format
- /// The printf style format to use when outputting the offset.
- //------------------------------------------------------------------
- void
- Offset (uint32_t offset, const char *format = "0x%8.8x: ");
-
- //------------------------------------------------------------------
- /// Output printf formatted output to the stream.
- ///
- /// Print some formatted output to the stream.
- ///
- /// @param[in] format
- /// A printf style format string.
- ///
- /// @param[in] ...
- /// Variable arguments that are needed for the printf style
- /// format string \a format.
- //------------------------------------------------------------------
- size_t
- Printf (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
-
- size_t
- PrintfVarArg(const char *format, va_list args);
-
- //------------------------------------------------------------------
- /// Output a quoted C string value to the stream.
- ///
- /// Print a double quoted NULL terminated C string to the stream
- /// using the printf format in \a format.
- ///
- /// @param[in] cstr
- /// A NULL terminated C string value.
- ///
- /// @param[in] format
- /// The optional C string format that can be overridden.
- //------------------------------------------------------------------
- void
- QuotedCString (const char *cstr, const char *format = "\"%s\"");
-
- //------------------------------------------------------------------
- /// Set the address size in bytes.
- ///
- /// @param[in] addr_size
- /// The new size in bytes of an address to use when outputting
- /// address and pointer values.
- //------------------------------------------------------------------
- void
- SetAddressByteSize (uint32_t addr_size);
-
- //------------------------------------------------------------------
- /// Set the current indentation level.
- ///
- /// @param[in] level
- /// The new indentation level.
- //------------------------------------------------------------------
- void
- SetIndentLevel (int level);
-
- //------------------------------------------------------------------
- /// Output a SLEB128 number to the stream.
- ///
- /// Put an SLEB128 \a uval out to the stream using the printf format
- /// in \a format.
- ///
- /// @param[in] uval
- /// A uint64_t value that was extracted as a SLEB128 value.
- ///
- /// @param[in] format
- /// The optional printf format that can be overridden.
- //------------------------------------------------------------------
- size_t
- PutSLEB128 (int64_t uval);
-
- //------------------------------------------------------------------
- /// Output a ULEB128 number to the stream.
- ///
- /// Put an ULEB128 \a uval out to the stream using the printf format
- /// in \a format.
- ///
- /// @param[in] uval
- /// A uint64_t value that was extracted as a ULEB128 value.
- ///
- /// @param[in] format
- /// The optional printf format that can be overridden.
- //------------------------------------------------------------------
- size_t
- PutULEB128 (uint64_t uval);
-
- static void
- UnitTest(Stream *s);
+ size_t PutLongDouble(long double ld,
+ lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
+
+ size_t PutPointer(void *ptr);
+
+ // Append \a src_len bytes from \a src to the stream as hex characters
+ // (two ascii characters per byte of input data)
+ size_t
+ PutBytesAsRawHex8(const void *src, size_t src_len,
+ lldb::ByteOrder src_byte_order = lldb::eByteOrderInvalid,
+ lldb::ByteOrder dst_byte_order = lldb::eByteOrderInvalid);
+
+ // Append \a src_len bytes from \a s to the stream as binary data.
+ size_t PutRawBytes(const void *s, size_t src_len,
+ lldb::ByteOrder src_byte_order = lldb::eByteOrderInvalid,
+ lldb::ByteOrder dst_byte_order = lldb::eByteOrderInvalid);
+
+ size_t PutCStringAsRawHex8(const char *s);
+
+ //------------------------------------------------------------------
+ /// Output a NULL terminated C string \a cstr to the stream \a s.
+ ///
+ /// @param[in] cstr
+ /// A NULL terminated C string.
+ ///
+ /// @return
+ /// A reference to this class so multiple things can be streamed
+ /// in one statement.
+ //------------------------------------------------------------------
+ Stream &operator<<(const char *cstr);
+
+ Stream &operator<<(llvm::StringRef str);
+
+ //------------------------------------------------------------------
+ /// Output a pointer value \a p to the stream \a s.
+ ///
+ /// @param[in] p
+ /// A void pointer.
+ ///
+ /// @return
+ /// A reference to this class so multiple things can be streamed
+ /// in one statement.
+ //------------------------------------------------------------------
+ Stream &operator<<(const void *p);
+
+ //------------------------------------------------------------------
+ /// Output a character \a ch to the stream \a s.
+ ///
+ /// @param[in] ch
+ /// A printable character value.
+ ///
+ /// @return
+ /// A reference to this class so multiple things can be streamed
+ /// in one statement.
+ //------------------------------------------------------------------
+ Stream &operator<<(char ch);
+
+ //------------------------------------------------------------------
+ /// Output a uint8_t \a uval to the stream \a s.
+ ///
+ /// @param[in] uval
+ /// A uint8_t value.
+ ///
+ /// @return
+ /// A reference to this class so multiple things can be streamed
+ /// in one statement.
+ //------------------------------------------------------------------
+ Stream &operator<<(uint8_t uval);
+
+ //------------------------------------------------------------------
+ /// Output a uint16_t \a uval to the stream \a s.
+ ///
+ /// @param[in] uval
+ /// A uint16_t value.
+ ///
+ /// @return
+ /// A reference to this class so multiple things can be streamed
+ /// in one statement.
+ //------------------------------------------------------------------
+ Stream &operator<<(uint16_t uval);
+
+ //------------------------------------------------------------------
+ /// Output a uint32_t \a uval to the stream \a s.
+ ///
+ /// @param[in] uval
+ /// A uint32_t value.
+ ///
+ /// @return
+ /// A reference to this class so multiple things can be streamed
+ /// in one statement.
+ //------------------------------------------------------------------
+ Stream &operator<<(uint32_t uval);
+
+ //------------------------------------------------------------------
+ /// Output a uint64_t \a uval to the stream \a s.
+ ///
+ /// @param[in] uval
+ /// A uint64_t value.
+ ///
+ /// @return
+ /// A reference to this class so multiple things can be streamed
+ /// in one statement.
+ //------------------------------------------------------------------
+ Stream &operator<<(uint64_t uval);
+
+ //------------------------------------------------------------------
+ /// Output a int8_t \a sval to the stream \a s.
+ ///
+ /// @param[in] sval
+ /// A int8_t value.
+ ///
+ /// @return
+ /// A reference to this class so multiple things can be streamed
+ /// in one statement.
+ //------------------------------------------------------------------
+ Stream &operator<<(int8_t sval);
+
+ //------------------------------------------------------------------
+ /// Output a int16_t \a sval to the stream \a s.
+ ///
+ /// @param[in] sval
+ /// A int16_t value.
+ ///
+ /// @return
+ /// A reference to this class so multiple things can be streamed
+ /// in one statement.
+ //------------------------------------------------------------------
+ Stream &operator<<(int16_t sval);
+
+ //------------------------------------------------------------------
+ /// Output a int32_t \a sval to the stream \a s.
+ ///
+ /// @param[in] sval
+ /// A int32_t value.
+ ///
+ /// @return
+ /// A reference to this class so multiple things can be streamed
+ /// in one statement.
+ //------------------------------------------------------------------
+ Stream &operator<<(int32_t sval);
+
+ //------------------------------------------------------------------
+ /// Output a int64_t \a sval to the stream \a s.
+ ///
+ /// @param[in] sval
+ /// A int64_t value.
+ ///
+ /// @return
+ /// A reference to this class so multiple things can be streamed
+ /// in one statement.
+ //------------------------------------------------------------------
+ Stream &operator<<(int64_t sval);
+
+ //------------------------------------------------------------------
+ /// Output an address value to this stream.
+ ///
+ /// Put an address \a addr out to the stream with optional \a prefix
+ /// and \a suffix strings.
+ ///
+ /// @param[in] addr
+ /// An address value.
+ ///
+ /// @param[in] addr_size
+ /// Size in bytes of the address, used for formatting.
+ ///
+ /// @param[in] prefix
+ /// A prefix C string. If nullptr, no prefix will be output.
+ ///
+ /// @param[in] suffix
+ /// A suffix C string. If nullptr, no suffix will be output.
+ //------------------------------------------------------------------
+ void Address(uint64_t addr, uint32_t addr_size, const char *prefix = nullptr,
+ const char *suffix = nullptr);
+
+ //------------------------------------------------------------------
+ /// Output an address range to this stream.
+ ///
+ /// Put an address range \a lo_addr - \a hi_addr out to the stream
+ /// with optional \a prefix and \a suffix strings.
+ ///
+ /// @param[in] lo_addr
+ /// The start address of the address range.
+ ///
+ /// @param[in] hi_addr
+ /// The end address of the address range.
+ ///
+ /// @param[in] addr_size
+ /// Size in bytes of the address, used for formatting.
+ ///
+ /// @param[in] prefix
+ /// A prefix C string. If nullptr, no prefix will be output.
+ ///
+ /// @param[in] suffix
+ /// A suffix C string. If nullptr, no suffix will be output.
+ //------------------------------------------------------------------
+ void AddressRange(uint64_t lo_addr, uint64_t hi_addr, uint32_t addr_size,
+ const char *prefix = nullptr, const char *suffix = nullptr);
+
+ //------------------------------------------------------------------
+ /// Output a C string to the stream.
+ ///
+ /// Print a C string \a cstr to the stream.
+ ///
+ /// @param[in] cstr
+ /// The string to be output to the stream.
+ //------------------------------------------------------------------
+ size_t PutCString(llvm::StringRef cstr);
+
+ //------------------------------------------------------------------
+ /// Output and End of Line character to the stream.
+ //------------------------------------------------------------------
+ size_t EOL();
+
+ //------------------------------------------------------------------
+ /// Get the address size in bytes.
+ ///
+ /// @return
+ /// The size of an address in bytes that is used when outputting
+ /// address and pointer values to the stream.
+ //------------------------------------------------------------------
+ uint32_t GetAddressByteSize() const;
+
+ //------------------------------------------------------------------
+ /// Test if debug logging is enabled.
+ ///
+ /// @return
+ // \b true if the debug flag bit is set in this stream, \b
+ // false otherwise.
+ //------------------------------------------------------------------
+ bool GetDebug() const;
+
+ //------------------------------------------------------------------
+ /// The flags accessor.
+ ///
+ /// @return
+ /// A reference to the Flags member variable.
+ //------------------------------------------------------------------
+ Flags &GetFlags();
+
+ //------------------------------------------------------------------
+ /// The flags const accessor.
+ ///
+ /// @return
+ /// A const reference to the Flags member variable.
+ //------------------------------------------------------------------
+ const Flags &GetFlags() const;
+
+ //------------------------------------------------------------------
+ //// The byte order accessor.
+ ////
+ //// @return
+ //// The byte order.
+ //------------------------------------------------------------------
+ lldb::ByteOrder GetByteOrder() const;
+
+ //------------------------------------------------------------------
+ /// Get the current indentation level.
+ ///
+ /// @return
+ /// The current indentation level as an integer.
+ //------------------------------------------------------------------
+ int GetIndentLevel() const;
+
+ //------------------------------------------------------------------
+ /// Test if verbose logging is enabled.
+ ///
+ /// @return
+ // \b true if the verbose flag bit is set in this stream, \b
+ // false otherwise.
+ //------------------------------------------------------------------
+ bool GetVerbose() const;
+
+ //------------------------------------------------------------------
+ /// Indent the current line in the stream.
+ ///
+ /// Indent the current line using the current indentation level and
+ /// print an optional string following the indentation spaces.
+ ///
+ /// @param[in] s
+ /// A C string to print following the indentation. If nullptr, just
+ /// output the indentation characters.
+ //------------------------------------------------------------------
+ size_t Indent(const char *s = nullptr);
+ size_t Indent(llvm::StringRef s);
+
+ //------------------------------------------------------------------
+ /// Decrement the current indentation level.
+ //------------------------------------------------------------------
+ void IndentLess(int amount = 2);
+
+ //------------------------------------------------------------------
+ /// Increment the current indentation level.
+ //------------------------------------------------------------------
+ void IndentMore(int amount = 2);
+
+ //------------------------------------------------------------------
+ /// Output an offset value.
+ ///
+ /// Put an offset \a uval out to the stream using the printf format
+ /// in \a format.
+ ///
+ /// @param[in] offset
+ /// The offset value.
+ ///
+ /// @param[in] format
+ /// The printf style format to use when outputting the offset.
+ //------------------------------------------------------------------
+ void Offset(uint32_t offset, const char *format = "0x%8.8x: ");
+
+ //------------------------------------------------------------------
+ /// Output printf formatted output to the stream.
+ ///
+ /// Print some formatted output to the stream.
+ ///
+ /// @param[in] format
+ /// A printf style format string.
+ ///
+ /// @param[in] ...
+ /// Variable arguments that are needed for the printf style
+ /// format string \a format.
+ //------------------------------------------------------------------
+ size_t Printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
+
+ size_t PrintfVarArg(const char *format, va_list args);
+
+ template <typename... Args> void Format(const char *format, Args &&... args) {
+ PutCString(llvm::formatv(format, std::forward<Args>(args)...).str());
+ }
+
+ //------------------------------------------------------------------
+ /// Output a quoted C string value to the stream.
+ ///
+ /// Print a double quoted NULL terminated C string to the stream
+ /// using the printf format in \a format.
+ ///
+ /// @param[in] cstr
+ /// A NULL terminated C string value.
+ ///
+ /// @param[in] format
+ /// The optional C string format that can be overridden.
+ //------------------------------------------------------------------
+ void QuotedCString(const char *cstr, const char *format = "\"%s\"");
+
+ //------------------------------------------------------------------
+ /// Set the address size in bytes.
+ ///
+ /// @param[in] addr_size
+ /// The new size in bytes of an address to use when outputting
+ /// address and pointer values.
+ //------------------------------------------------------------------
+ void SetAddressByteSize(uint32_t addr_size);
+
+ //------------------------------------------------------------------
+ /// Set the current indentation level.
+ ///
+ /// @param[in] level
+ /// The new indentation level.
+ //------------------------------------------------------------------
+ void SetIndentLevel(int level);
+
+ //------------------------------------------------------------------
+ /// Output a SLEB128 number to the stream.
+ ///
+ /// Put an SLEB128 \a uval out to the stream using the printf format
+ /// in \a format.
+ ///
+ /// @param[in] uval
+ /// A uint64_t value that was extracted as a SLEB128 value.
+ ///
+ /// @param[in] format
+ /// The optional printf format that can be overridden.
+ //------------------------------------------------------------------
+ size_t PutSLEB128(int64_t uval);
+
+ //------------------------------------------------------------------
+ /// Output a ULEB128 number to the stream.
+ ///
+ /// Put an ULEB128 \a uval out to the stream using the printf format
+ /// in \a format.
+ ///
+ /// @param[in] uval
+ /// A uint64_t value that was extracted as a ULEB128 value.
+ ///
+ /// @param[in] format
+ /// The optional printf format that can be overridden.
+ //------------------------------------------------------------------
+ size_t PutULEB128(uint64_t uval);
+
+ static void UnitTest(Stream *s);
protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- Flags m_flags; ///< Dump flags.
- uint32_t m_addr_size; ///< Size of an address in bytes.
- lldb::ByteOrder m_byte_order; ///< Byte order to use when encoding scalar types.
- int m_indent_level; ///< Indention level.
-
- size_t _PutHex8 (uint8_t uvalue, bool add_prefix);
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ Flags m_flags; ///< Dump flags.
+ uint32_t m_addr_size; ///< Size of an address in bytes.
+ lldb::ByteOrder
+ m_byte_order; ///< Byte order to use when encoding scalar types.
+ int m_indent_level; ///< Indention level.
+
+ size_t _PutHex8(uint8_t uvalue, bool add_prefix);
};
} // namespace lldb_private
-#endif // liblldb_Stream_h_
+#endif // liblldb_Stream_h_
diff --git a/include/lldb/Core/StreamAsynchronousIO.h b/include/lldb/Core/StreamAsynchronousIO.h
index b069cfd496e1..b3bb49e16e35 100644
--- a/include/lldb/Core/StreamAsynchronousIO.h
+++ b/include/lldb/Core/StreamAsynchronousIO.h
@@ -1,4 +1,5 @@
-//===-- StreamAsynchronousIO.h -----------------------------------*- C++ -*-===//
+//===-- StreamAsynchronousIO.h -----------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,24 +17,20 @@
namespace lldb_private {
-class StreamAsynchronousIO :
- public Stream
-{
+class StreamAsynchronousIO : public Stream {
public:
- StreamAsynchronousIO (Debugger &debugger, bool for_stdout);
-
- ~StreamAsynchronousIO () override;
-
- void
- Flush () override;
-
- size_t
- Write (const void *src, size_t src_len) override;
-
+ StreamAsynchronousIO(Debugger &debugger, bool for_stdout);
+
+ ~StreamAsynchronousIO() override;
+
+ void Flush() override;
+
+ size_t Write(const void *src, size_t src_len) override;
+
private:
- Debugger &m_debugger;
- std::string m_data;
- bool m_for_stdout;
+ Debugger &m_debugger;
+ std::string m_data;
+ bool m_for_stdout;
};
} // namespace lldb_private
diff --git a/include/lldb/Core/StreamBuffer.h b/include/lldb/Core/StreamBuffer.h
index 9d25e842ecc5..4eef19ff29f7 100644
--- a/include/lldb/Core/StreamBuffer.h
+++ b/include/lldb/Core/StreamBuffer.h
@@ -10,78 +10,47 @@
#ifndef liblldb_StreamBuffer_h_
#define liblldb_StreamBuffer_h_
+#include "lldb/Core/Stream.h"
+#include "llvm/ADT/SmallVector.h"
#include <stdio.h>
#include <string>
-#include "llvm/ADT/SmallVector.h"
-#include "lldb/Core/Stream.h"
namespace lldb_private {
-template <unsigned N>
-class StreamBuffer : public Stream
-{
+template <unsigned N> class StreamBuffer : public Stream {
public:
- StreamBuffer () :
- Stream (0, 4, lldb::eByteOrderBig),
- m_packet ()
- {
- }
-
+ StreamBuffer() : Stream(0, 4, lldb::eByteOrderBig), m_packet() {}
- StreamBuffer (uint32_t flags,
- uint32_t addr_size,
- lldb::ByteOrder byte_order) :
- Stream (flags, addr_size, byte_order),
- m_packet ()
- {
- }
+ StreamBuffer(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order)
+ : Stream(flags, addr_size, byte_order), m_packet() {}
- virtual
- ~StreamBuffer ()
- {
- }
+ virtual ~StreamBuffer() {}
- virtual void
- Flush ()
- {
- // Nothing to do when flushing a buffer based stream...
- }
+ virtual void Flush() {
+ // Nothing to do when flushing a buffer based stream...
+ }
- virtual size_t
- Write (const void *s, size_t length)
- {
- if (s && length)
- m_packet.append ((const char *)s, ((const char *)s) + length);
- return length;
- }
+ virtual size_t Write(const void *s, size_t length) {
+ if (s && length)
+ m_packet.append((const char *)s, ((const char *)s) + length);
+ return length;
+ }
- void
- Clear()
- {
- m_packet.clear();
- }
+ void Clear() { m_packet.clear(); }
- // Beware, this might not be NULL terminated as you can expect from
- // StringString as there may be random bits in the llvm::SmallVector. If
- // you are using this class to create a C string, be sure the call PutChar ('\0')
- // after you have created your string, or use StreamString.
- const char *
- GetData () const
- {
- return m_packet.data();
- }
+ // Beware, this might not be NULL terminated as you can expect from
+ // StringString as there may be random bits in the llvm::SmallVector. If
+ // you are using this class to create a C string, be sure the call PutChar
+ // ('\0')
+ // after you have created your string, or use StreamString.
+ const char *GetData() const { return m_packet.data(); }
- size_t
- GetSize() const
- {
- return m_packet.size();
- }
+ size_t GetSize() const { return m_packet.size(); }
protected:
- llvm::SmallVector<char, N> m_packet;
-
+ llvm::SmallVector<char, N> m_packet;
};
} // namespace lldb_private
-#endif // #ifndef liblldb_StreamBuffer_h_
+#endif // #ifndef liblldb_StreamBuffer_h_
diff --git a/include/lldb/Core/StreamCallback.h b/include/lldb/Core/StreamCallback.h
index 9e91eb94a74c..4dc72c8c54c8 100644
--- a/include/lldb/Core/StreamCallback.h
+++ b/include/lldb/Core/StreamCallback.h
@@ -18,28 +18,24 @@
namespace lldb_private {
-class StreamCallback :
- public Stream
-{
+class StreamCallback : public Stream {
public:
- StreamCallback (lldb::LogOutputCallback callback, void *baton);
-
- ~StreamCallback () override;
-
- void
- Flush () override;
-
- size_t
- Write (const void *src, size_t src_len) override;
-
+ StreamCallback(lldb::LogOutputCallback callback, void *baton);
+
+ ~StreamCallback() override;
+
+ void Flush() override;
+
+ size_t Write(const void *src, size_t src_len) override;
+
private:
- typedef std::map<lldb::tid_t, StreamString> collection;
- lldb::LogOutputCallback m_callback;
- void *m_baton;
- collection m_accumulated_data;
- std::mutex m_collection_mutex;
+ typedef std::map<lldb::tid_t, StreamString> collection;
+ lldb::LogOutputCallback m_callback;
+ void *m_baton;
+ collection m_accumulated_data;
+ std::mutex m_collection_mutex;
- StreamString &FindStreamForThread(lldb::tid_t cur_tid);
+ StreamString &FindStreamForThread(lldb::tid_t cur_tid);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/StreamFile.h b/include/lldb/Core/StreamFile.h
index 781f0a599493..8b860321b6b7 100644
--- a/include/lldb/Core/StreamFile.h
+++ b/include/lldb/Core/StreamFile.h
@@ -23,54 +23,42 @@
namespace lldb_private {
-class StreamFile : public Stream
-{
+class StreamFile : public Stream {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- StreamFile ();
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ StreamFile();
- StreamFile (uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order);
+ StreamFile(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order);
- StreamFile (int fd, bool transfer_ownership);
+ StreamFile(int fd, bool transfer_ownership);
- StreamFile (const char *path);
+ StreamFile(const char *path);
- StreamFile (const char *path,
- uint32_t options,
- uint32_t permissions = lldb::eFilePermissionsFileDefault);
+ StreamFile(const char *path, uint32_t options,
+ uint32_t permissions = lldb::eFilePermissionsFileDefault);
- StreamFile (FILE *fh, bool transfer_ownership);
+ StreamFile(FILE *fh, bool transfer_ownership);
- ~StreamFile() override;
+ ~StreamFile() override;
- File &
- GetFile ()
- {
- return m_file;
- }
+ File &GetFile() { return m_file; }
- const File &
- GetFile () const
- {
- return m_file;
- }
+ const File &GetFile() const { return m_file; }
- void
- Flush () override;
+ void Flush() override;
- size_t
- Write (const void *s, size_t length) override;
+ size_t Write(const void *s, size_t length) override;
protected:
- //------------------------------------------------------------------
- // Classes that inherit from StreamFile can see and modify these
- //------------------------------------------------------------------
- File m_file;
-
+ //------------------------------------------------------------------
+ // Classes that inherit from StreamFile can see and modify these
+ //------------------------------------------------------------------
+ File m_file;
+
private:
- DISALLOW_COPY_AND_ASSIGN (StreamFile);
+ DISALLOW_COPY_AND_ASSIGN(StreamFile);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/StreamGDBRemote.h b/include/lldb/Core/StreamGDBRemote.h
index 834f412d0a03..150b3012cd0d 100644
--- a/include/lldb/Core/StreamGDBRemote.h
+++ b/include/lldb/Core/StreamGDBRemote.h
@@ -1,4 +1,5 @@
-//===-- StreamGDBRemote.h ----------------------------------------*- C++ -*-===//
+//===-- StreamGDBRemote.h ----------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -19,34 +20,31 @@
#include "lldb/Core/StreamString.h"
namespace lldb_private {
-
- class StreamGDBRemote : public StreamString
- {
- public:
- StreamGDBRemote ();
-
- StreamGDBRemote (uint32_t flags,
- uint32_t addr_size,
- lldb::ByteOrder byte_order);
-
- ~StreamGDBRemote() override;
-
- //------------------------------------------------------------------
- /// Output a block of data to the stream performing GDB-remote escaping.
- ///
- /// @param[in] s
- /// A block of data.
- ///
- /// @param[in] src_len
- /// The amount of data to write.
- ///
- /// @return
- /// Number of bytes written.
- //------------------------------------------------------------------
- int
- PutEscapedBytes (const void* s,
- size_t src_len);
- };
+
+class StreamGDBRemote : public StreamString {
+public:
+ StreamGDBRemote();
+
+ StreamGDBRemote(uint32_t flags, uint32_t addr_size,
+ lldb::ByteOrder byte_order);
+
+ ~StreamGDBRemote() override;
+
+ //------------------------------------------------------------------
+ /// Output a block of data to the stream performing GDB-remote escaping.
+ ///
+ /// @param[in] s
+ /// A block of data.
+ ///
+ /// @param[in] src_len
+ /// The amount of data to write.
+ ///
+ /// @return
+ /// Number of bytes written.
+ //------------------------------------------------------------------
+ // TODO: Convert this function to take ArrayRef<uint8_t>
+ int PutEscapedBytes(const void *s, size_t src_len);
+};
} // namespace lldb_private
diff --git a/include/lldb/Core/StreamString.h b/include/lldb/Core/StreamString.h
index 5b6bde7a13c2..88501a1bf611 100644
--- a/include/lldb/Core/StreamString.h
+++ b/include/lldb/Core/StreamString.h
@@ -16,49 +16,34 @@
namespace lldb_private {
-class StreamString : public Stream
-{
+class StreamString : public Stream {
public:
- StreamString ();
+ StreamString();
- StreamString (uint32_t flags,
- uint32_t addr_size,
- lldb::ByteOrder byte_order);
+ StreamString(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order);
- ~StreamString () override;
+ ~StreamString() override;
- void
- Flush () override;
+ void Flush() override;
- size_t
- Write (const void *s, size_t length) override;
+ size_t Write(const void *s, size_t length) override;
- void
- Clear();
+ void Clear();
- bool
- Empty() const;
+ bool Empty() const;
- const char *
- GetData () const;
+ size_t GetSize() const;
- size_t
- GetSize() const;
+ size_t GetSizeOfLastLine() const;
- size_t
- GetSizeOfLastLine () const;
+ llvm::StringRef GetString() const;
- std::string &
- GetString();
+ const char *GetData() const { return m_packet.c_str(); }
- const std::string &
- GetString() const;
-
- void
- FillLastLineToColumn (uint32_t column, char fill_char);
+ void FillLastLineToColumn(uint32_t column, char fill_char);
protected:
- std::string m_packet;
+ std::string m_packet;
};
} // namespace lldb_private
diff --git a/include/lldb/Core/StreamTee.h b/include/lldb/Core/StreamTee.h
index 6059e0e1f8e9..48f92c839481 100644
--- a/include/lldb/Core/StreamTee.h
+++ b/include/lldb/Core/StreamTee.h
@@ -18,143 +18,122 @@
namespace lldb_private {
-class StreamTee : public Stream
-{
+class StreamTee : public Stream {
public:
- StreamTee() : Stream(), m_streams_mutex(), m_streams() {}
-
- StreamTee(lldb::StreamSP &stream_sp) : Stream(), m_streams_mutex(), m_streams()
- {
- // No need to lock mutex during construction
- if (stream_sp)
- m_streams.push_back(stream_sp);
- }
-
- StreamTee(lldb::StreamSP &stream_sp, lldb::StreamSP &stream_2_sp) : Stream(), m_streams_mutex(), m_streams()
- {
- // No need to lock mutex during construction
- if (stream_sp)
- m_streams.push_back(stream_sp);
- if (stream_2_sp)
- m_streams.push_back(stream_2_sp);
- }
-
- StreamTee(const StreamTee &rhs) : Stream(rhs), m_streams_mutex(), m_streams()
- {
- // Don't copy until we lock down "rhs"
- std::lock_guard<std::recursive_mutex> guard(rhs.m_streams_mutex);
- m_streams = rhs.m_streams;
- }
-
- ~StreamTee () override
- {
- }
-
- StreamTee &
- operator=(const StreamTee &rhs)
- {
- if (this != &rhs)
- {
- Stream::operator=(rhs);
- std::lock_guard<std::recursive_mutex> lhs_locker(m_streams_mutex);
- std::lock_guard<std::recursive_mutex> rhs_locker(rhs.m_streams_mutex);
- m_streams = rhs.m_streams;
- }
- return *this;
+ StreamTee() : Stream(), m_streams_mutex(), m_streams() {}
+
+ StreamTee(lldb::StreamSP &stream_sp)
+ : Stream(), m_streams_mutex(), m_streams() {
+ // No need to lock mutex during construction
+ if (stream_sp)
+ m_streams.push_back(stream_sp);
+ }
+
+ StreamTee(lldb::StreamSP &stream_sp, lldb::StreamSP &stream_2_sp)
+ : Stream(), m_streams_mutex(), m_streams() {
+ // No need to lock mutex during construction
+ if (stream_sp)
+ m_streams.push_back(stream_sp);
+ if (stream_2_sp)
+ m_streams.push_back(stream_2_sp);
+ }
+
+ StreamTee(const StreamTee &rhs)
+ : Stream(rhs), m_streams_mutex(), m_streams() {
+ // Don't copy until we lock down "rhs"
+ std::lock_guard<std::recursive_mutex> guard(rhs.m_streams_mutex);
+ m_streams = rhs.m_streams;
+ }
+
+ ~StreamTee() override {}
+
+ StreamTee &operator=(const StreamTee &rhs) {
+ if (this != &rhs) {
+ Stream::operator=(rhs);
+ std::lock_guard<std::recursive_mutex> lhs_locker(m_streams_mutex);
+ std::lock_guard<std::recursive_mutex> rhs_locker(rhs.m_streams_mutex);
+ m_streams = rhs.m_streams;
}
-
- void
- Flush() override
- {
- std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
- collection::iterator pos, end;
- for (pos = m_streams.begin(), end = m_streams.end(); pos != end; ++pos)
- {
- // Allow for our collection to contain NULL streams. This allows
- // the StreamTee to be used with hard coded indexes for clients
- // that might want N total streams with only a few that are set
- // to valid values.
- Stream *strm = pos->get();
- if (strm)
- strm->Flush();
- }
- }
-
- size_t
- Write(const void *s, size_t length) override
- {
- std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
- if (m_streams.empty())
- return 0;
-
- size_t min_bytes_written = SIZE_MAX;
- collection::iterator pos, end;
- for (pos = m_streams.begin(), end = m_streams.end(); pos != end; ++pos)
- {
- // Allow for our collection to contain NULL streams. This allows
- // the StreamTee to be used with hard coded indexes for clients
- // that might want N total streams with only a few that are set
- // to valid values.
- Stream *strm = pos->get();
- if (strm)
- {
- const size_t bytes_written = strm->Write(s, length);
- if (min_bytes_written > bytes_written)
- min_bytes_written = bytes_written;
- }
- }
- if (min_bytes_written == SIZE_MAX)
- return 0;
- return min_bytes_written;
- }
-
- size_t
- AppendStream(const lldb::StreamSP &stream_sp)
- {
- size_t new_idx = m_streams.size();
- std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
- m_streams.push_back(stream_sp);
- return new_idx;
+ return *this;
+ }
+
+ void Flush() override {
+ std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
+ collection::iterator pos, end;
+ for (pos = m_streams.begin(), end = m_streams.end(); pos != end; ++pos) {
+ // Allow for our collection to contain NULL streams. This allows
+ // the StreamTee to be used with hard coded indexes for clients
+ // that might want N total streams with only a few that are set
+ // to valid values.
+ Stream *strm = pos->get();
+ if (strm)
+ strm->Flush();
}
-
- size_t
- GetNumStreams() const
- {
- size_t result = 0;
- {
- std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
- result = m_streams.size();
- }
- return result;
+ }
+
+ size_t Write(const void *s, size_t length) override {
+ std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
+ if (m_streams.empty())
+ return 0;
+
+ size_t min_bytes_written = SIZE_MAX;
+ collection::iterator pos, end;
+ for (pos = m_streams.begin(), end = m_streams.end(); pos != end; ++pos) {
+ // Allow for our collection to contain NULL streams. This allows
+ // the StreamTee to be used with hard coded indexes for clients
+ // that might want N total streams with only a few that are set
+ // to valid values.
+ Stream *strm = pos->get();
+ if (strm) {
+ const size_t bytes_written = strm->Write(s, length);
+ if (min_bytes_written > bytes_written)
+ min_bytes_written = bytes_written;
+ }
}
-
- lldb::StreamSP
- GetStreamAtIndex(uint32_t idx)
- {
- lldb::StreamSP stream_sp;
- std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
- if (idx < m_streams.size())
- stream_sp = m_streams[idx];
- return stream_sp;
- }
-
- void
- SetStreamAtIndex(uint32_t idx, const lldb::StreamSP &stream_sp)
+ if (min_bytes_written == SIZE_MAX)
+ return 0;
+ return min_bytes_written;
+ }
+
+ size_t AppendStream(const lldb::StreamSP &stream_sp) {
+ size_t new_idx = m_streams.size();
+ std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
+ m_streams.push_back(stream_sp);
+ return new_idx;
+ }
+
+ size_t GetNumStreams() const {
+ size_t result = 0;
{
- std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
- // Resize our stream vector as necessary to fit as many streams
- // as needed. This also allows this class to be used with hard
- // coded indexes that can be used contain many streams, not all
- // of which are valid.
- if (idx >= m_streams.size())
- m_streams.resize(idx + 1);
- m_streams[idx] = stream_sp;
+ std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
+ result = m_streams.size();
}
+ return result;
+ }
+
+ lldb::StreamSP GetStreamAtIndex(uint32_t idx) {
+ lldb::StreamSP stream_sp;
+ std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
+ if (idx < m_streams.size())
+ stream_sp = m_streams[idx];
+ return stream_sp;
+ }
+
+ void SetStreamAtIndex(uint32_t idx, const lldb::StreamSP &stream_sp) {
+ std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
+ // Resize our stream vector as necessary to fit as many streams
+ // as needed. This also allows this class to be used with hard
+ // coded indexes that can be used contain many streams, not all
+ // of which are valid.
+ if (idx >= m_streams.size())
+ m_streams.resize(idx + 1);
+ m_streams[idx] = stream_sp;
+ }
protected:
- typedef std::vector<lldb::StreamSP> collection;
- mutable std::recursive_mutex m_streams_mutex;
- collection m_streams;
+ typedef std::vector<lldb::StreamSP> collection;
+ mutable std::recursive_mutex m_streams_mutex;
+ collection m_streams;
};
} // namespace lldb_private
diff --git a/include/lldb/Core/StringList.h b/include/lldb/Core/StringList.h
index 53bdb6994a56..2cd974dea947 100644
--- a/include/lldb/Core/StringList.h
+++ b/include/lldb/Core/StringList.h
@@ -20,159 +20,120 @@
#include "llvm/ADT/StringRef.h"
// Project includes
-#include "lldb/lldb-forward.h"
#include "lldb/Core/STLUtils.h"
+#include "lldb/lldb-forward.h"
namespace lldb_private {
-class StringList
-{
+class StringList {
public:
- StringList ();
-
- StringList (const char *str);
-
- StringList (const char **strv, int strc);
-
- virtual
- ~StringList ();
-
- void
- AppendString (const std::string &s);
-
- void
- AppendString (std::string &&s);
-
- void
- AppendString (const char *str);
-
- void
- AppendString (const char *str, size_t str_len);
-
- void
- AppendString(llvm::StringRef str);
-
- void
- AppendList (const char ** strv, int strc);
-
- void
- AppendList (StringList strings);
-
- bool
- ReadFileLines (FileSpec &input_file);
-
- size_t
- GetSize () const;
-
- void
- SetSize (size_t n)
- {
- m_strings.resize(n);
- }
-
- size_t
- GetMaxStringLength () const;
-
- std::string &
- operator [](size_t idx)
- {
- // No bounds checking, verify "idx" is good prior to calling this function
- return m_strings[idx];
- }
-
- const std::string &
- operator [](size_t idx) const
- {
- // No bounds checking, verify "idx" is good prior to calling this function
- return m_strings[idx];
- }
-
- void
- PopBack ()
- {
- m_strings.pop_back();
- }
- const char *
- GetStringAtIndex (size_t idx) const;
-
- void
- Join (const char *separator, Stream &strm);
-
- void
- Clear ();
-
- void
- LongestCommonPrefix (std::string &common_prefix);
-
- void
- InsertStringAtIndex (size_t idx, const std::string &str);
-
- void
- InsertStringAtIndex (size_t idx, std::string &&str);
-
- void
- InsertStringAtIndex (size_t id, const char *str);
-
- void
- DeleteStringAtIndex (size_t id);
-
- void
- RemoveBlankLines ();
-
- size_t
- SplitIntoLines (const std::string &lines);
-
- size_t
- SplitIntoLines (const char *lines, size_t len);
-
- std::string
- CopyList(const char* item_preamble = nullptr,
- const char* items_sep = "\n") const;
-
- StringList&
- operator << (const char* str);
-
- StringList&
- operator << (const std::string &s);
-
- StringList&
- operator << (StringList strings);
-
- // Copy assignment for a vector of strings
- StringList&
- operator = (const std::vector<std::string> &rhs);
-
- // This string list contains a list of valid auto completion
- // strings, and the "s" is passed in. "matches" is filled in
- // with zero or more string values that start with "s", and
- // the first string to exactly match one of the string
- // values in this collection, will have "exact_matches_idx"
- // filled in to match the index, or "exact_matches_idx" will
- // have SIZE_MAX
- size_t
- AutoComplete (const char *s,
- StringList &matches,
- size_t &exact_matches_idx) const;
-
- // Dump the StringList to the given lldb_private::Log, `log`, one item per line.
- // If given, `name` will be used to identify the start and end of the list in the output.
- virtual void LogDump(Log *log, const char *name = nullptr);
-
- // Static helper to convert an iterable of strings to a StringList, and then
- // dump it with the semantics of the `LogDump` method.
- template<typename T> static void LogDump(Log *log, T s_iterable, const char *name = nullptr)
- {
- if (!log)
- return;
- // Make a copy of the iterable as a StringList
- StringList l{};
- for (const auto &s : s_iterable)
- l << s;
-
- l.LogDump(log, name);
- }
+ StringList();
+
+ StringList(const char *str);
+
+ StringList(const char **strv, int strc);
+
+ virtual ~StringList();
+
+ void AppendString(const std::string &s);
+
+ void AppendString(std::string &&s);
+
+ void AppendString(const char *str);
+
+ void AppendString(const char *str, size_t str_len);
+
+ void AppendString(llvm::StringRef str);
+
+ void AppendList(const char **strv, int strc);
+
+ void AppendList(StringList strings);
+
+ bool ReadFileLines(FileSpec &input_file);
+
+ size_t GetSize() const;
+
+ void SetSize(size_t n) { m_strings.resize(n); }
+
+ size_t GetMaxStringLength() const;
+
+ std::string &operator[](size_t idx) {
+ // No bounds checking, verify "idx" is good prior to calling this function
+ return m_strings[idx];
+ }
+
+ const std::string &operator[](size_t idx) const {
+ // No bounds checking, verify "idx" is good prior to calling this function
+ return m_strings[idx];
+ }
+
+ void PopBack() { m_strings.pop_back(); }
+ const char *GetStringAtIndex(size_t idx) const;
+
+ void Join(const char *separator, Stream &strm);
+
+ void Clear();
+
+ void LongestCommonPrefix(std::string &common_prefix);
+
+ void InsertStringAtIndex(size_t idx, const std::string &str);
+
+ void InsertStringAtIndex(size_t idx, std::string &&str);
+
+ void InsertStringAtIndex(size_t id, const char *str);
+
+ void DeleteStringAtIndex(size_t id);
+
+ void RemoveBlankLines();
+
+ size_t SplitIntoLines(const std::string &lines);
+
+ size_t SplitIntoLines(const char *lines, size_t len);
+
+ std::string CopyList(const char *item_preamble = nullptr,
+ const char *items_sep = "\n") const;
+
+ StringList &operator<<(const char *str);
+
+ StringList &operator<<(const std::string &s);
+
+ StringList &operator<<(StringList strings);
+
+ // Copy assignment for a vector of strings
+ StringList &operator=(const std::vector<std::string> &rhs);
+
+ // This string list contains a list of valid auto completion
+ // strings, and the "s" is passed in. "matches" is filled in
+ // with zero or more string values that start with "s", and
+ // the first string to exactly match one of the string
+ // values in this collection, will have "exact_matches_idx"
+ // filled in to match the index, or "exact_matches_idx" will
+ // have SIZE_MAX
+ size_t AutoComplete(llvm::StringRef s, StringList &matches,
+ size_t &exact_matches_idx) const;
+
+ // Dump the StringList to the given lldb_private::Log, `log`, one item per
+ // line.
+ // If given, `name` will be used to identify the start and end of the list in
+ // the output.
+ virtual void LogDump(Log *log, const char *name = nullptr);
+
+ // Static helper to convert an iterable of strings to a StringList, and then
+ // dump it with the semantics of the `LogDump` method.
+ template <typename T>
+ static void LogDump(Log *log, T s_iterable, const char *name = nullptr) {
+ if (!log)
+ return;
+ // Make a copy of the iterable as a StringList
+ StringList l{};
+ for (const auto &s : s_iterable)
+ l << s;
+
+ l.LogDump(log, name);
+ }
+
private:
- STLStringArray m_strings;
+ STLStringArray m_strings;
};
} // namespace lldb_private
diff --git a/include/lldb/Core/StructuredData.h b/include/lldb/Core/StructuredData.h
index 52f34521ef0e..efd8100f1185 100644
--- a/include/lldb/Core/StructuredData.h
+++ b/include/lldb/Core/StructuredData.h
@@ -23,9 +23,9 @@
#include "llvm/ADT/StringRef.h"
// Project includes
-#include "lldb/lldb-defines.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Stream.h"
+#include "lldb/lldb-defines.h"
namespace lldb_private {
@@ -34,730 +34,525 @@ namespace lldb_private {
/// @brief A class which can hold structured data
///
/// The StructuredData class is designed to hold the data from a JSON
-/// or plist style file -- a serialized data structure with dictionaries
-/// (maps, hashes), arrays, and concrete values like integers, floating
+/// or plist style file -- a serialized data structure with dictionaries
+/// (maps, hashes), arrays, and concrete values like integers, floating
/// point numbers, strings, booleans.
///
/// StructuredData does not presuppose any knowledge of the schema for
/// the data it is holding; it can parse JSON data, for instance, and
/// other parts of lldb can iterate through the parsed data set to find
-/// keys and values that may be present.
+/// keys and values that may be present.
//----------------------------------------------------------------------
-class StructuredData
-{
+class StructuredData {
public:
- class Object;
- class Array;
- class Integer;
- class Float;
- class Boolean;
- class String;
- class Dictionary;
- class Generic;
-
- typedef std::shared_ptr<Object> ObjectSP;
- typedef std::shared_ptr<Array> ArraySP;
- typedef std::shared_ptr<Integer> IntegerSP;
- typedef std::shared_ptr<Float> FloatSP;
- typedef std::shared_ptr<Boolean> BooleanSP;
- typedef std::shared_ptr<String> StringSP;
- typedef std::shared_ptr<Dictionary> DictionarySP;
- typedef std::shared_ptr<Generic> GenericSP;
-
- enum class Type
- {
- eTypeInvalid = -1,
- eTypeNull = 0,
- eTypeGeneric,
- eTypeArray,
- eTypeInteger,
- eTypeFloat,
- eTypeBoolean,
- eTypeString,
- eTypeDictionary
- };
-
- class Object :
- public std::enable_shared_from_this<Object>
- {
- public:
-
- Object (Type t = Type::eTypeInvalid) :
- m_type (t)
- {
- }
-
- virtual ~Object() = default;
-
- virtual bool
- IsValid() const
- {
- return true;
- }
-
- virtual void
- Clear ()
- {
- m_type = Type::eTypeInvalid;
- }
-
- Type
- GetType () const
- {
- return m_type;
- }
-
- void
- SetType (Type t)
- {
- m_type = t;
- }
-
- Array *
- GetAsArray ()
- {
- return ((m_type == Type::eTypeArray) ? static_cast<Array *>(this) : nullptr);
- }
-
- Dictionary *
- GetAsDictionary ()
- {
- return ((m_type == Type::eTypeDictionary) ? static_cast<Dictionary *>(this) : nullptr);
- }
-
- Integer *
- GetAsInteger ()
- {
- return ((m_type == Type::eTypeInteger) ? static_cast<Integer *>(this) : nullptr);
- }
-
- uint64_t
- GetIntegerValue (uint64_t fail_value = 0)
- {
- Integer *integer = GetAsInteger ();
- return ((integer != nullptr) ? integer->GetValue() : fail_value);
- }
-
- Float *
- GetAsFloat ()
- {
- return ((m_type == Type::eTypeFloat) ? static_cast<Float *>(this) : nullptr);
- }
-
- double
- GetFloatValue (double fail_value = 0.0)
- {
- Float *f = GetAsFloat ();
- return ((f != nullptr) ? f->GetValue() : fail_value);
- }
-
- Boolean *
- GetAsBoolean ()
- {
- return ((m_type == Type::eTypeBoolean) ? static_cast<Boolean *>(this) : nullptr);
- }
-
- bool
- GetBooleanValue (bool fail_value = false)
- {
- Boolean *b = GetAsBoolean ();
- return ((b != nullptr) ? b->GetValue() : fail_value);
- }
-
- String *
- GetAsString ()
- {
- return ((m_type == Type::eTypeString) ? static_cast<String *>(this) : nullptr);
- }
-
- std::string
- GetStringValue(const char *fail_value = nullptr)
- {
- String *s = GetAsString ();
- if (s)
- return s->GetValue();
-
- if (fail_value && fail_value[0])
- return std::string(fail_value);
-
- return std::string();
- }
-
- Generic *
- GetAsGeneric()
- {
- return ((m_type == Type::eTypeGeneric) ? static_cast<Generic *>(this) : nullptr);
- }
-
- ObjectSP
- GetObjectForDotSeparatedPath (llvm::StringRef path);
-
- void DumpToStdout() const;
-
- virtual void
- Dump (Stream &s) const = 0;
-
- private:
- Type m_type;
- };
-
- class Array : public Object
- {
- public:
- Array () :
- Object (Type::eTypeArray)
- {
- }
-
- ~Array() override = default;
-
- bool
- ForEach (std::function <bool(Object* object)> const &foreach_callback) const
- {
- for (const auto &object_sp : m_items)
- {
- if (foreach_callback(object_sp.get()) == false)
- return false;
- }
- return true;
- }
-
- size_t
- GetSize() const
- {
- return m_items.size();
- }
-
- ObjectSP
- operator[](size_t idx)
- {
- if (idx < m_items.size())
- return m_items[idx];
- return ObjectSP();
- }
-
- ObjectSP
- GetItemAtIndex(size_t idx) const
- {
- assert(idx < GetSize());
- if (idx < m_items.size())
- return m_items[idx];
- return ObjectSP();
- }
-
- template <class IntType>
- bool
- GetItemAtIndexAsInteger(size_t idx, IntType &result) const
- {
- ObjectSP value_sp = GetItemAtIndex(idx);
- if (value_sp.get())
- {
- if (auto int_value = value_sp->GetAsInteger())
- {
- result = static_cast<IntType>(int_value->GetValue());
- return true;
- }
- }
- return false;
- }
-
- template <class IntType>
- bool
- GetItemAtIndexAsInteger(size_t idx, IntType &result, IntType default_val) const
- {
- bool success = GetItemAtIndexAsInteger(idx, result);
- if (!success)
- result = default_val;
- return success;
- }
-
- bool
- GetItemAtIndexAsString(size_t idx, std::string &result) const
- {
- ObjectSP value_sp = GetItemAtIndex(idx);
- if (value_sp.get())
- {
- if (auto string_value = value_sp->GetAsString())
- {
- result = string_value->GetValue();
- return true;
- }
- }
- return false;
- }
-
- bool
- GetItemAtIndexAsString(size_t idx, std::string &result, const std::string &default_val) const
- {
- bool success = GetItemAtIndexAsString(idx, result);
- if (!success)
- result = default_val;
- return success;
- }
-
- bool
- GetItemAtIndexAsString(size_t idx, ConstString &result) const
- {
- ObjectSP value_sp = GetItemAtIndex(idx);
- if (value_sp.get()) {
- if (auto string_value = value_sp->GetAsString())
- {
- result = ConstString(string_value->GetValue());
- return true;
- }
- }
- return false;
- }
-
- bool
- GetItemAtIndexAsString(size_t idx, ConstString &result, const char *default_val) const
- {
- bool success = GetItemAtIndexAsString(idx, result);
- if (!success)
- result.SetCString(default_val);
- return success;
- }
-
- bool
- GetItemAtIndexAsDictionary(size_t idx, Dictionary *&result) const
- {
- result = nullptr;
- ObjectSP value_sp = GetItemAtIndex(idx);
- if (value_sp.get())
- {
- result = value_sp->GetAsDictionary();
- return (result != nullptr);
- }
- return false;
- }
-
- bool
- GetItemAtIndexAsArray(size_t idx, Array *&result) const
- {
- result = nullptr;
- ObjectSP value_sp = GetItemAtIndex(idx);
- if (value_sp.get())
- {
- result = value_sp->GetAsArray();
- return (result != nullptr);
- }
- return false;
- }
-
- void
- Push(ObjectSP item)
- {
- m_items.push_back(item);
- }
-
- void
- AddItem(ObjectSP item)
- {
- m_items.push_back(item);
- }
-
- void Dump(Stream &s) const override;
-
- protected:
- typedef std::vector<ObjectSP> collection;
- collection m_items;
- };
-
- class Integer : public Object
- {
- public:
- Integer (uint64_t i = 0) :
- Object (Type::eTypeInteger),
- m_value (i)
- {
- }
-
- ~Integer() override = default;
-
- void
- SetValue (uint64_t value)
- {
- m_value = value;
- }
-
- uint64_t
- GetValue ()
- {
- return m_value;
- }
-
- void Dump(Stream &s) const override;
-
- protected:
- uint64_t m_value;
- };
-
- class Float : public Object
- {
- public:
- Float (double d = 0.0) :
- Object (Type::eTypeFloat),
- m_value (d)
- {
- }
-
- ~Float() override = default;
-
- void
- SetValue (double value)
- {
- m_value = value;
- }
-
- double
- GetValue ()
- {
- return m_value;
- }
-
- void Dump(Stream &s) const override;
-
- protected:
- double m_value;
- };
-
- class Boolean : public Object
- {
- public:
- Boolean (bool b = false) :
- Object (Type::eTypeBoolean),
- m_value (b)
- {
- }
-
- ~Boolean() override = default;
-
- void
- SetValue (bool value)
- {
- m_value = value;
- }
-
- bool
- GetValue ()
- {
- return m_value;
- }
-
- void Dump(Stream &s) const override;
-
- protected:
- bool m_value;
- };
-
- class String : public Object
- {
- public:
- String(const char *cstr = nullptr) :
- Object (Type::eTypeString),
- m_value ()
- {
- if (cstr)
- m_value = cstr;
- }
-
- String (const std::string &s) :
- Object (Type::eTypeString),
- m_value (s)
- {
- }
-
- String (const std::string &&s) :
- Object (Type::eTypeString),
- m_value (s)
- {
- }
-
- void
- SetValue (const std::string &string)
- {
- m_value = string;
- }
-
- const std::string &
- GetValue ()
- {
- return m_value;
- }
-
- void Dump(Stream &s) const override;
-
- protected:
- std::string m_value;
- };
-
- class Dictionary : public Object
- {
- public:
-
- Dictionary () :
- Object (Type::eTypeDictionary),
- m_dict ()
- {
- }
-
- ~Dictionary() override = default;
-
- size_t
- GetSize() const
- {
- return m_dict.size();
- }
-
- void
- ForEach (std::function <bool(ConstString key, Object* object)> const &callback) const
- {
- for (const auto &pair : m_dict)
- {
- if (callback (pair.first, pair.second.get()) == false)
- break;
- }
- }
-
- ObjectSP
- GetKeys() const
- {
- ObjectSP object_sp(new Array ());
- Array *array = object_sp->GetAsArray();
- collection::const_iterator iter;
- for (iter = m_dict.begin(); iter != m_dict.end(); ++iter)
- {
- ObjectSP key_object_sp(new String());
- key_object_sp->GetAsString()->SetValue(iter->first.AsCString());
- array->Push(key_object_sp);
- }
- return object_sp;
- }
-
- ObjectSP
- GetValueForKey(llvm::StringRef key) const
- {
- ObjectSP value_sp;
- if (!key.empty())
- {
- ConstString key_cs(key);
- for (collection::const_iterator iter = m_dict.begin(); iter != m_dict.end(); ++iter)
- {
- if (key_cs == iter->first)
- {
- value_sp = iter->second;
- break;
- }
- }
- }
- return value_sp;
- }
-
- template <class IntType>
- bool
- GetValueForKeyAsInteger(llvm::StringRef key, IntType &result) const
- {
- ObjectSP value_sp = GetValueForKey(key);
- if (value_sp) {
- if (auto int_value = value_sp->GetAsInteger())
- {
- result = static_cast<IntType>(int_value->GetValue());
- return true;
- }
- }
- return false;
- }
-
- template <class IntType>
- bool
- GetValueForKeyAsInteger(llvm::StringRef key, IntType &result, IntType default_val) const
- {
- bool success = GetValueForKeyAsInteger<IntType>(key, result);
- if (!success)
- result = default_val;
- return success;
- }
-
- bool
- GetValueForKeyAsString(llvm::StringRef key, std::string &result) const
- {
- ObjectSP value_sp = GetValueForKey(key);
- if (value_sp.get())
- {
- if (auto string_value = value_sp->GetAsString())
- {
- result = string_value->GetValue();
- return true;
- }
- }
- return false;
- }
-
- bool
- GetValueForKeyAsString(llvm::StringRef key, std::string &result, const char *default_val) const
- {
- bool success = GetValueForKeyAsString(key, result);
- if (!success)
- {
- if (default_val)
- result = default_val;
- else
- result.clear();
- }
- return success;
- }
-
- bool
- GetValueForKeyAsString(llvm::StringRef key, ConstString &result) const
- {
- ObjectSP value_sp = GetValueForKey(key);
- if (value_sp.get())
- {
- if (auto string_value = value_sp->GetAsString())
- {
- result = ConstString(string_value->GetValue());
- return true;
- }
- }
- return false;
- }
-
- bool
- GetValueForKeyAsString(llvm::StringRef key, ConstString &result, const char *default_val) const
- {
- bool success = GetValueForKeyAsString(key, result);
- if (!success)
- result.SetCString(default_val);
- return success;
- }
-
- bool
- GetValueForKeyAsDictionary(llvm::StringRef key, Dictionary *&result) const
- {
- result = nullptr;
- ObjectSP value_sp = GetValueForKey(key);
- if (value_sp.get())
- {
- result = value_sp->GetAsDictionary();
- return (result != nullptr);
- }
- return false;
- }
-
- bool
- GetValueForKeyAsArray(llvm::StringRef key, Array *&result) const
- {
- result = nullptr;
- ObjectSP value_sp = GetValueForKey(key);
- if (value_sp.get())
- {
- result = value_sp->GetAsArray();
- return (result != nullptr);
- }
- return false;
- }
-
- bool
- HasKey(llvm::StringRef key) const
- {
- ConstString key_cs(key);
- collection::const_iterator search = m_dict.find(key_cs);
- return search != m_dict.end();
- }
-
- void
- AddItem (llvm::StringRef key, ObjectSP value_sp)
- {
- ConstString key_cs(key);
- m_dict[key_cs] = value_sp;
- }
-
- void
- AddIntegerItem (llvm::StringRef key, uint64_t value)
- {
- AddItem (key, ObjectSP (new Integer(value)));
- }
-
- void
- AddFloatItem (llvm::StringRef key, double value)
- {
- AddItem (key, ObjectSP (new Float(value)));
- }
-
- void
- AddStringItem (llvm::StringRef key, std::string value)
- {
- AddItem (key, ObjectSP (new String(std::move(value))));
- }
-
- void
- AddBooleanItem (llvm::StringRef key, bool value)
- {
- AddItem (key, ObjectSP (new Boolean(value)));
- }
-
- void Dump(Stream &s) const override;
-
- protected:
- typedef std::map<ConstString, ObjectSP> collection;
- collection m_dict;
- };
-
- class Null : public Object
- {
- public:
- Null () :
- Object (Type::eTypeNull)
- {
- }
-
- ~Null() override = default;
-
- bool
- IsValid() const override
- {
- return false;
- }
-
- void Dump(Stream &s) const override;
- };
-
- class Generic : public Object
- {
- public:
- explicit Generic(void *object = nullptr) :
- Object (Type::eTypeGeneric),
- m_object (object)
- {
- }
-
- void
- SetValue(void *value)
- {
- m_object = value;
- }
-
- void *
- GetValue() const
- {
- return m_object;
- }
-
- bool
- IsValid() const override
- {
- return m_object != nullptr;
- }
+ class Object;
+ class Array;
+ class Integer;
+ class Float;
+ class Boolean;
+ class String;
+ class Dictionary;
+ class Generic;
+
+ typedef std::shared_ptr<Object> ObjectSP;
+ typedef std::shared_ptr<Array> ArraySP;
+ typedef std::shared_ptr<Integer> IntegerSP;
+ typedef std::shared_ptr<Float> FloatSP;
+ typedef std::shared_ptr<Boolean> BooleanSP;
+ typedef std::shared_ptr<String> StringSP;
+ typedef std::shared_ptr<Dictionary> DictionarySP;
+ typedef std::shared_ptr<Generic> GenericSP;
+
+ enum class Type {
+ eTypeInvalid = -1,
+ eTypeNull = 0,
+ eTypeGeneric,
+ eTypeArray,
+ eTypeInteger,
+ eTypeFloat,
+ eTypeBoolean,
+ eTypeString,
+ eTypeDictionary
+ };
+
+ class Object : public std::enable_shared_from_this<Object> {
+ public:
+ Object(Type t = Type::eTypeInvalid) : m_type(t) {}
+
+ virtual ~Object() = default;
+
+ virtual bool IsValid() const { return true; }
+
+ virtual void Clear() { m_type = Type::eTypeInvalid; }
+
+ Type GetType() const { return m_type; }
+
+ void SetType(Type t) { m_type = t; }
+
+ Array *GetAsArray() {
+ return ((m_type == Type::eTypeArray) ? static_cast<Array *>(this)
+ : nullptr);
+ }
+
+ Dictionary *GetAsDictionary() {
+ return ((m_type == Type::eTypeDictionary)
+ ? static_cast<Dictionary *>(this)
+ : nullptr);
+ }
+
+ Integer *GetAsInteger() {
+ return ((m_type == Type::eTypeInteger) ? static_cast<Integer *>(this)
+ : nullptr);
+ }
+
+ uint64_t GetIntegerValue(uint64_t fail_value = 0) {
+ Integer *integer = GetAsInteger();
+ return ((integer != nullptr) ? integer->GetValue() : fail_value);
+ }
+
+ Float *GetAsFloat() {
+ return ((m_type == Type::eTypeFloat) ? static_cast<Float *>(this)
+ : nullptr);
+ }
+
+ double GetFloatValue(double fail_value = 0.0) {
+ Float *f = GetAsFloat();
+ return ((f != nullptr) ? f->GetValue() : fail_value);
+ }
+
+ Boolean *GetAsBoolean() {
+ return ((m_type == Type::eTypeBoolean) ? static_cast<Boolean *>(this)
+ : nullptr);
+ }
+
+ bool GetBooleanValue(bool fail_value = false) {
+ Boolean *b = GetAsBoolean();
+ return ((b != nullptr) ? b->GetValue() : fail_value);
+ }
+
+ String *GetAsString() {
+ return ((m_type == Type::eTypeString) ? static_cast<String *>(this)
+ : nullptr);
+ }
+
+ std::string GetStringValue(const char *fail_value = nullptr) {
+ String *s = GetAsString();
+ if (s)
+ return s->GetValue();
+
+ if (fail_value && fail_value[0])
+ return std::string(fail_value);
+
+ return std::string();
+ }
+
+ Generic *GetAsGeneric() {
+ return ((m_type == Type::eTypeGeneric) ? static_cast<Generic *>(this)
+ : nullptr);
+ }
+
+ ObjectSP GetObjectForDotSeparatedPath(llvm::StringRef path);
+
+ void DumpToStdout(bool pretty_print = true) const;
+
+ virtual void Dump(Stream &s, bool pretty_print = true) const = 0;
+
+ private:
+ Type m_type;
+ };
+
+ class Array : public Object {
+ public:
+ Array() : Object(Type::eTypeArray) {}
+
+ ~Array() override = default;
+
+ bool
+ ForEach(std::function<bool(Object *object)> const &foreach_callback) const {
+ for (const auto &object_sp : m_items) {
+ if (foreach_callback(object_sp.get()) == false)
+ return false;
+ }
+ return true;
+ }
+
+ size_t GetSize() const { return m_items.size(); }
+
+ ObjectSP operator[](size_t idx) {
+ if (idx < m_items.size())
+ return m_items[idx];
+ return ObjectSP();
+ }
+
+ ObjectSP GetItemAtIndex(size_t idx) const {
+ assert(idx < GetSize());
+ if (idx < m_items.size())
+ return m_items[idx];
+ return ObjectSP();
+ }
+
+ template <class IntType>
+ bool GetItemAtIndexAsInteger(size_t idx, IntType &result) const {
+ ObjectSP value_sp = GetItemAtIndex(idx);
+ if (value_sp.get()) {
+ if (auto int_value = value_sp->GetAsInteger()) {
+ result = static_cast<IntType>(int_value->GetValue());
+ return true;
+ }
+ }
+ return false;
+ }
+
+ template <class IntType>
+ bool GetItemAtIndexAsInteger(size_t idx, IntType &result,
+ IntType default_val) const {
+ bool success = GetItemAtIndexAsInteger(idx, result);
+ if (!success)
+ result = default_val;
+ return success;
+ }
+
+ bool GetItemAtIndexAsString(size_t idx, std::string &result) const {
+ ObjectSP value_sp = GetItemAtIndex(idx);
+ if (value_sp.get()) {
+ if (auto string_value = value_sp->GetAsString()) {
+ result = string_value->GetValue();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ bool GetItemAtIndexAsString(size_t idx, std::string &result,
+ const std::string &default_val) const {
+ bool success = GetItemAtIndexAsString(idx, result);
+ if (!success)
+ result = default_val;
+ return success;
+ }
+
+ bool GetItemAtIndexAsString(size_t idx, ConstString &result) const {
+ ObjectSP value_sp = GetItemAtIndex(idx);
+ if (value_sp.get()) {
+ if (auto string_value = value_sp->GetAsString()) {
+ result = ConstString(string_value->GetValue());
+ return true;
+ }
+ }
+ return false;
+ }
- void Dump(Stream &s) const override;
+ bool GetItemAtIndexAsString(size_t idx, ConstString &result,
+ const char *default_val) const {
+ bool success = GetItemAtIndexAsString(idx, result);
+ if (!success)
+ result.SetCString(default_val);
+ return success;
+ }
- private:
- void *m_object;
- };
+ bool GetItemAtIndexAsDictionary(size_t idx, Dictionary *&result) const {
+ result = nullptr;
+ ObjectSP value_sp = GetItemAtIndex(idx);
+ if (value_sp.get()) {
+ result = value_sp->GetAsDictionary();
+ return (result != nullptr);
+ }
+ return false;
+ }
- static ObjectSP
- ParseJSON (std::string json_text);
+ bool GetItemAtIndexAsArray(size_t idx, Array *&result) const {
+ result = nullptr;
+ ObjectSP value_sp = GetItemAtIndex(idx);
+ if (value_sp.get()) {
+ result = value_sp->GetAsArray();
+ return (result != nullptr);
+ }
+ return false;
+ }
+
+ void Push(ObjectSP item) { m_items.push_back(item); }
+
+ void AddItem(ObjectSP item) { m_items.push_back(item); }
+
+ void Dump(Stream &s, bool pretty_print = true) const override;
+
+ protected:
+ typedef std::vector<ObjectSP> collection;
+ collection m_items;
+ };
+
+ class Integer : public Object {
+ public:
+ Integer(uint64_t i = 0) : Object(Type::eTypeInteger), m_value(i) {}
+
+ ~Integer() override = default;
+
+ void SetValue(uint64_t value) { m_value = value; }
+
+ uint64_t GetValue() { return m_value; }
+
+ void Dump(Stream &s, bool pretty_print = true) const override;
+
+ protected:
+ uint64_t m_value;
+ };
+
+ class Float : public Object {
+ public:
+ Float(double d = 0.0) : Object(Type::eTypeFloat), m_value(d) {}
+
+ ~Float() override = default;
+
+ void SetValue(double value) { m_value = value; }
+
+ double GetValue() { return m_value; }
+
+ void Dump(Stream &s, bool pretty_print = true) const override;
+
+ protected:
+ double m_value;
+ };
+
+ class Boolean : public Object {
+ public:
+ Boolean(bool b = false) : Object(Type::eTypeBoolean), m_value(b) {}
+
+ ~Boolean() override = default;
+
+ void SetValue(bool value) { m_value = value; }
+
+ bool GetValue() { return m_value; }
+
+ void Dump(Stream &s, bool pretty_print = true) const override;
+
+ protected:
+ bool m_value;
+ };
+
+ class String : public Object {
+ public:
+ String(const char *cstr = nullptr) : Object(Type::eTypeString), m_value() {
+ if (cstr)
+ m_value = cstr;
+ }
+
+ String(const std::string &s) : Object(Type::eTypeString), m_value(s) {}
+
+ String(const std::string &&s) : Object(Type::eTypeString), m_value(s) {}
+
+ void SetValue(const std::string &string) { m_value = string; }
+
+ const std::string &GetValue() { return m_value; }
+
+ void Dump(Stream &s, bool pretty_print = true) const override;
+
+ protected:
+ std::string m_value;
+ };
+
+ class Dictionary : public Object {
+ public:
+ Dictionary() : Object(Type::eTypeDictionary), m_dict() {}
+
+ ~Dictionary() override = default;
+
+ size_t GetSize() const { return m_dict.size(); }
+
+ void ForEach(std::function<bool(ConstString key, Object *object)> const
+ &callback) const {
+ for (const auto &pair : m_dict) {
+ if (callback(pair.first, pair.second.get()) == false)
+ break;
+ }
+ }
+
+ ObjectSP GetKeys() const {
+ ObjectSP object_sp(new Array());
+ Array *array = object_sp->GetAsArray();
+ collection::const_iterator iter;
+ for (iter = m_dict.begin(); iter != m_dict.end(); ++iter) {
+ ObjectSP key_object_sp(new String());
+ key_object_sp->GetAsString()->SetValue(iter->first.AsCString());
+ array->Push(key_object_sp);
+ }
+ return object_sp;
+ }
+
+ ObjectSP GetValueForKey(llvm::StringRef key) const {
+ ObjectSP value_sp;
+ if (!key.empty()) {
+ ConstString key_cs(key);
+ collection::const_iterator iter = m_dict.find(key_cs);
+ if (iter != m_dict.end())
+ value_sp = iter->second;
+ }
+ return value_sp;
+ }
+
+ bool GetValueForKeyAsBoolean(llvm::StringRef key, bool &result) const {
+ bool success = false;
+ ObjectSP value_sp = GetValueForKey(key);
+ if (value_sp.get()) {
+ Boolean *result_ptr = value_sp->GetAsBoolean();
+ if (result_ptr) {
+ result = result_ptr->GetValue();
+ success = true;
+ }
+ }
+ return success;
+ }
+ template <class IntType>
+ bool GetValueForKeyAsInteger(llvm::StringRef key, IntType &result) const {
+ ObjectSP value_sp = GetValueForKey(key);
+ if (value_sp) {
+ if (auto int_value = value_sp->GetAsInteger()) {
+ result = static_cast<IntType>(int_value->GetValue());
+ return true;
+ }
+ }
+ return false;
+ }
+
+ template <class IntType>
+ bool GetValueForKeyAsInteger(llvm::StringRef key, IntType &result,
+ IntType default_val) const {
+ bool success = GetValueForKeyAsInteger<IntType>(key, result);
+ if (!success)
+ result = default_val;
+ return success;
+ }
+
+ bool GetValueForKeyAsString(llvm::StringRef key,
+ std::string &result) const {
+ ObjectSP value_sp = GetValueForKey(key);
+ if (value_sp.get()) {
+ if (auto string_value = value_sp->GetAsString()) {
+ result = string_value->GetValue();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ bool GetValueForKeyAsString(llvm::StringRef key, std::string &result,
+ const char *default_val) const {
+ bool success = GetValueForKeyAsString(key, result);
+ if (!success) {
+ if (default_val)
+ result = default_val;
+ else
+ result.clear();
+ }
+ return success;
+ }
+
+ bool GetValueForKeyAsString(llvm::StringRef key,
+ ConstString &result) const {
+ ObjectSP value_sp = GetValueForKey(key);
+ if (value_sp.get()) {
+ if (auto string_value = value_sp->GetAsString()) {
+ result = ConstString(string_value->GetValue());
+ return true;
+ }
+ }
+ return false;
+ }
+
+ bool GetValueForKeyAsString(llvm::StringRef key, ConstString &result,
+ const char *default_val) const {
+ bool success = GetValueForKeyAsString(key, result);
+ if (!success)
+ result.SetCString(default_val);
+ return success;
+ }
+
+ bool GetValueForKeyAsDictionary(llvm::StringRef key,
+ Dictionary *&result) const {
+ result = nullptr;
+ ObjectSP value_sp = GetValueForKey(key);
+ if (value_sp.get()) {
+ result = value_sp->GetAsDictionary();
+ return (result != nullptr);
+ }
+ return false;
+ }
+
+ bool GetValueForKeyAsArray(llvm::StringRef key, Array *&result) const {
+ result = nullptr;
+ ObjectSP value_sp = GetValueForKey(key);
+ if (value_sp.get()) {
+ result = value_sp->GetAsArray();
+ return (result != nullptr);
+ }
+ return false;
+ }
+
+ bool HasKey(llvm::StringRef key) const {
+ ConstString key_cs(key);
+ collection::const_iterator search = m_dict.find(key_cs);
+ return search != m_dict.end();
+ }
+
+ void AddItem(llvm::StringRef key, ObjectSP value_sp) {
+ ConstString key_cs(key);
+ m_dict[key_cs] = value_sp;
+ }
+
+ void AddIntegerItem(llvm::StringRef key, uint64_t value) {
+ AddItem(key, ObjectSP(new Integer(value)));
+ }
+
+ void AddFloatItem(llvm::StringRef key, double value) {
+ AddItem(key, ObjectSP(new Float(value)));
+ }
+
+ void AddStringItem(llvm::StringRef key, std::string value) {
+ AddItem(key, ObjectSP(new String(std::move(value))));
+ }
+
+ void AddBooleanItem(llvm::StringRef key, bool value) {
+ AddItem(key, ObjectSP(new Boolean(value)));
+ }
+
+ void Dump(Stream &s, bool pretty_print = true) const override;
+
+ protected:
+ typedef std::map<ConstString, ObjectSP> collection;
+ collection m_dict;
+ };
+
+ class Null : public Object {
+ public:
+ Null() : Object(Type::eTypeNull) {}
+
+ ~Null() override = default;
+
+ bool IsValid() const override { return false; }
+
+ void Dump(Stream &s, bool pretty_print = true) const override;
+ };
+
+ class Generic : public Object {
+ public:
+ explicit Generic(void *object = nullptr)
+ : Object(Type::eTypeGeneric), m_object(object) {}
+
+ void SetValue(void *value) { m_object = value; }
+
+ void *GetValue() const { return m_object; }
+
+ bool IsValid() const override { return m_object != nullptr; }
+
+ void Dump(Stream &s, bool pretty_print = true) const override;
+
+ private:
+ void *m_object;
+ };
+
+ static ObjectSP ParseJSON(std::string json_text);
+
+ static ObjectSP ParseJSONFromFile(const FileSpec &file, Error &error);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/ThreadSafeDenseMap.h b/include/lldb/Core/ThreadSafeDenseMap.h
index 6b2b59b7617c..9b52e0355314 100644
--- a/include/lldb/Core/ThreadSafeDenseMap.h
+++ b/include/lldb/Core/ThreadSafeDenseMap.h
@@ -1,4 +1,5 @@
-//===-- ThreadSafeDenseMap.h ------------------------------------------*- C++ -*-===//
+//===-- ThreadSafeDenseMap.h ------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -12,74 +13,58 @@
// C Includes
// C++ Includes
+#include <mutex>
// Other libraries and framework includes
#include "llvm/ADT/DenseMap.h"
// Project includes
-#include "lldb/Host/Mutex.h"
namespace lldb_private {
-
-template <typename _KeyType, typename _ValueType>
-class ThreadSafeDenseMap
-{
+
+template <typename _KeyType, typename _ValueType,
+ typename _MutexType = std::mutex>
+class ThreadSafeDenseMap {
public:
- typedef llvm::DenseMap<_KeyType,_ValueType> LLVMMapType;
-
- ThreadSafeDenseMap(unsigned map_initial_capacity = 0,
- Mutex::Type mutex_type = Mutex::eMutexTypeNormal) :
- m_map(map_initial_capacity),
- m_mutex(mutex_type)
- {
- }
-
- void
- Insert (_KeyType k, _ValueType v)
- {
- Mutex::Locker locker(m_mutex);
- m_map.insert(std::make_pair(k,v));
- }
-
- void
- Erase (_KeyType k)
- {
- Mutex::Locker locker(m_mutex);
- m_map.erase(k);
- }
-
- _ValueType
- Lookup (_KeyType k)
- {
- Mutex::Locker locker(m_mutex);
- return m_map.lookup(k);
- }
+ typedef llvm::DenseMap<_KeyType, _ValueType> LLVMMapType;
+
+ ThreadSafeDenseMap(unsigned map_initial_capacity = 0)
+ : m_map(map_initial_capacity), m_mutex() {}
+
+ void Insert(_KeyType k, _ValueType v) {
+ std::lock_guard<_MutexType> guard(m_mutex);
+ m_map.insert(std::make_pair(k, v));
+ }
+
+ void Erase(_KeyType k) {
+ std::lock_guard<_MutexType> guard(m_mutex);
+ m_map.erase(k);
+ }
+
+ _ValueType Lookup(_KeyType k) {
+ std::lock_guard<_MutexType> guard(m_mutex);
+ return m_map.lookup(k);
+ }
- bool
- Lookup (_KeyType k,
- _ValueType& v)
- {
- Mutex::Locker locker(m_mutex);
- auto iter = m_map.find(k),
- end = m_map.end();
- if (iter == end)
- return false;
- v = iter->second;
- return true;
- }
+ bool Lookup(_KeyType k, _ValueType &v) {
+ std::lock_guard<_MutexType> guard(m_mutex);
+ auto iter = m_map.find(k), end = m_map.end();
+ if (iter == end)
+ return false;
+ v = iter->second;
+ return true;
+ }
- void
- Clear ()
- {
- Mutex::Locker locker(m_mutex);
- m_map.clear();
- }
+ void Clear() {
+ std::lock_guard<_MutexType> guard(m_mutex);
+ m_map.clear();
+ }
protected:
- LLVMMapType m_map;
- Mutex m_mutex;
+ LLVMMapType m_map;
+ _MutexType m_mutex;
};
} // namespace lldb_private
-#endif // liblldb_ThreadSafeSTLMap_h_
+#endif // liblldb_ThreadSafeSTLMap_h_
diff --git a/include/lldb/Core/ThreadSafeDenseSet.h b/include/lldb/Core/ThreadSafeDenseSet.h
index e019c70ed5e5..49c55e96abe1 100644
--- a/include/lldb/Core/ThreadSafeDenseSet.h
+++ b/include/lldb/Core/ThreadSafeDenseSet.h
@@ -1,4 +1,5 @@
-//===-- ThreadSafeDenseSet.h ------------------------------------------*- C++ -*-===//
+//===-- ThreadSafeDenseSet.h ------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -12,61 +13,48 @@
// C Includes
// C++ Includes
+#include <mutex>
// Other libraries and framework includes
#include "llvm/ADT/DenseSet.h"
// Project includes
-#include "lldb/Host/Mutex.h"
namespace lldb_private {
-
- template <typename _ElementType>
- class ThreadSafeDenseSet
- {
- public:
- typedef llvm::DenseSet<_ElementType> LLVMSetType;
-
- ThreadSafeDenseSet(unsigned set_initial_capacity = 0,
- Mutex::Type mutex_type = Mutex::eMutexTypeNormal) :
- m_set(set_initial_capacity),
- m_mutex(mutex_type)
- {
- }
-
- void
- Insert (_ElementType e)
- {
- Mutex::Locker locker(m_mutex);
- m_set.insert(e);
- }
-
- void
- Erase (_ElementType e)
- {
- Mutex::Locker locker(m_mutex);
- m_set.erase(e);
- }
-
- bool
- Lookup (_ElementType e)
- {
- Mutex::Locker locker(m_mutex);
- return (m_set.count(e) > 0);
- }
-
- void
- Clear ()
- {
- Mutex::Locker locker(m_mutex);
- m_set.clear();
- }
-
- protected:
- LLVMSetType m_set;
- Mutex m_mutex;
- };
-
+
+template <typename _ElementType, typename _MutexType = std::mutex>
+class ThreadSafeDenseSet {
+public:
+ typedef llvm::DenseSet<_ElementType> LLVMSetType;
+
+ ThreadSafeDenseSet(unsigned set_initial_capacity = 0)
+ : m_set(set_initial_capacity), m_mutex() {}
+
+ void Insert(_ElementType e) {
+ std::lock_guard<_MutexType> guard(m_mutex);
+ m_set.insert(e);
+ }
+
+ void Erase(_ElementType e) {
+ std::lock_guard<_MutexType> guard(m_mutex);
+ m_set.erase(e);
+ }
+
+ bool Lookup(_ElementType e) {
+ std::lock_guard<_MutexType> guard(m_mutex);
+ return (m_set.count(e) > 0);
+ }
+
+ void Clear() {
+ stds::lock_guard<_MutexType> guard(m_mutex);
+ m_set.clear();
+ }
+
+protected:
+ LLVMSetType m_set;
+ _MutexType m_mutex;
+};
+
} // namespace lldb_private
-#endif // liblldb_ThreadSafeDenseSet_h_
+#endif // liblldb_ThreadSafeDenseSet_h_
diff --git a/include/lldb/Core/ThreadSafeSTLMap.h b/include/lldb/Core/ThreadSafeSTLMap.h
index 4a885ff1a480..5520920c4559 100644
--- a/include/lldb/Core/ThreadSafeSTLMap.h
+++ b/include/lldb/Core/ThreadSafeSTLMap.h
@@ -21,158 +21,117 @@
namespace lldb_private {
-template <typename _Key, typename _Tp>
-class ThreadSafeSTLMap
-{
+template <typename _Key, typename _Tp> class ThreadSafeSTLMap {
public:
- typedef std::map<_Key,_Tp> collection;
- typedef typename collection::iterator iterator;
- typedef typename collection::const_iterator const_iterator;
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- ThreadSafeSTLMap() : m_collection(), m_mutex() {}
-
- ~ThreadSafeSTLMap()
- {
+ typedef std::map<_Key, _Tp> collection;
+ typedef typename collection::iterator iterator;
+ typedef typename collection::const_iterator const_iterator;
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ ThreadSafeSTLMap() : m_collection(), m_mutex() {}
+
+ ~ThreadSafeSTLMap() {}
+
+ bool IsEmpty() const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_collection.empty();
+ }
+
+ void Clear() {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_collection.clear();
+ }
+
+ size_t Erase(const _Key &key) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return EraseNoLock(key);
+ }
+
+ size_t EraseNoLock(const _Key &key) { return m_collection.erase(key); }
+
+ bool GetValueForKey(const _Key &key, _Tp &value) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return GetValueForKeyNoLock(key, value);
+ }
+
+ // Call this if you have already manually locked the mutex using the
+ // GetMutex() accessor
+ bool GetValueForKeyNoLock(const _Key &key, _Tp &value) const {
+ const_iterator pos = m_collection.find(key);
+ if (pos != m_collection.end()) {
+ value = pos->second;
+ return true;
}
-
- bool
- IsEmpty() const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_collection.empty();
- }
-
- void
- Clear()
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_collection.clear();
- }
-
- size_t
- Erase(const _Key &key)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return EraseNoLock(key);
- }
-
- size_t
- EraseNoLock (const _Key& key)
- {
- return m_collection.erase (key);
+ return false;
+ }
+
+ bool GetFirstKeyForValue(const _Tp &value, _Key &key) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return GetFirstKeyForValueNoLock(value, key);
+ }
+
+ bool GetFirstKeyForValueNoLock(const _Tp &value, _Key &key) const {
+ const_iterator pos, end = m_collection.end();
+ for (pos = m_collection.begin(); pos != end; ++pos) {
+ if (pos->second == value) {
+ key = pos->first;
+ return true;
+ }
}
-
- bool
- GetValueForKey(const _Key &key, _Tp &value) const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return GetValueForKeyNoLock(key, value);
+ return false;
+ }
+
+ bool LowerBound(const _Key &key, _Key &match_key, _Tp &match_value,
+ bool decrement_if_not_equal) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return LowerBoundNoLock(key, match_key, match_value,
+ decrement_if_not_equal);
+ }
+
+ bool LowerBoundNoLock(const _Key &key, _Key &match_key, _Tp &match_value,
+ bool decrement_if_not_equal) const {
+ const_iterator pos = m_collection.lower_bound(key);
+ if (pos != m_collection.end()) {
+ match_key = pos->first;
+ if (decrement_if_not_equal && key != match_key &&
+ pos != m_collection.begin()) {
+ --pos;
+ match_key = pos->first;
+ }
+ match_value = pos->second;
+ return true;
}
+ return false;
+ }
- // Call this if you have already manually locked the mutex using the
- // GetMutex() accessor
- bool
- GetValueForKeyNoLock (const _Key& key, _Tp &value) const
- {
- const_iterator pos = m_collection.find(key);
- if (pos != m_collection.end())
- {
- value = pos->second;
- return true;
- }
- return false;
- }
+ iterator lower_bound_unsafe(const _Key &key) {
+ return m_collection.lower_bound(key);
+ }
- bool
- GetFirstKeyForValue(const _Tp &value, _Key &key) const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return GetFirstKeyForValueNoLock(value, key);
- }
+ void SetValueForKey(const _Key &key, const _Tp &value) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ SetValueForKeyNoLock(key, value);
+ }
- bool
- GetFirstKeyForValueNoLock (const _Tp &value, _Key& key) const
- {
- const_iterator pos, end = m_collection.end();
- for (pos = m_collection.begin(); pos != end; ++pos)
- {
- if (pos->second == value)
- {
- key = pos->first;
- return true;
- }
- }
- return false;
- }
+ // Call this if you have already manually locked the mutex using the
+ // GetMutex() accessor
+ void SetValueForKeyNoLock(const _Key &key, const _Tp &value) {
+ m_collection[key] = value;
+ }
- bool
- LowerBound(const _Key &key, _Key &match_key, _Tp &match_value, bool decrement_if_not_equal) const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return LowerBoundNoLock(key, match_key, match_value, decrement_if_not_equal);
- }
-
- bool
- LowerBoundNoLock (const _Key& key,
- _Key& match_key,
- _Tp &match_value,
- bool decrement_if_not_equal) const
- {
- const_iterator pos = m_collection.lower_bound (key);
- if (pos != m_collection.end())
- {
- match_key = pos->first;
- if (decrement_if_not_equal && key != match_key && pos != m_collection.begin())
- {
- --pos;
- match_key = pos->first;
- }
- match_value = pos->second;
- return true;
- }
- return false;
- }
-
- iterator
- lower_bound_unsafe (const _Key& key)
- {
- return m_collection.lower_bound (key);
- }
-
- void
- SetValueForKey(const _Key &key, const _Tp &value)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- SetValueForKeyNoLock(key, value);
- }
-
- // Call this if you have already manually locked the mutex using the
- // GetMutex() accessor
- void
- SetValueForKeyNoLock (const _Key& key, const _Tp &value)
- {
- m_collection[key] = value;
- }
-
- std::recursive_mutex &
- GetMutex()
- {
- return m_mutex;
- }
+ std::recursive_mutex &GetMutex() { return m_mutex; }
private:
- collection m_collection;
- mutable std::recursive_mutex m_mutex;
+ collection m_collection;
+ mutable std::recursive_mutex m_mutex;
- //------------------------------------------------------------------
- // For ThreadSafeSTLMap only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (ThreadSafeSTLMap);
+ //------------------------------------------------------------------
+ // For ThreadSafeSTLMap only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(ThreadSafeSTLMap);
};
-
} // namespace lldb_private
-#endif // liblldb_ThreadSafeSTLMap_h_
+#endif // liblldb_ThreadSafeSTLMap_h_
diff --git a/include/lldb/Core/ThreadSafeSTLVector.h b/include/lldb/Core/ThreadSafeSTLVector.h
index dd90d49afcb8..466f4309c2d5 100644
--- a/include/lldb/Core/ThreadSafeSTLVector.h
+++ b/include/lldb/Core/ThreadSafeSTLVector.h
@@ -1,4 +1,5 @@
-//===-- ThreadSafeSTLVector.h ------------------------------------*- C++ -*-===//
+//===-- ThreadSafeSTLVector.h ------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -12,88 +13,69 @@
// C Includes
// C++ Includes
-#include <vector>
#include <mutex>
+#include <vector>
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-defines.h"
namespace lldb_private {
-
- template <typename _Object>
- class ThreadSafeSTLVector
- {
- public:
- typedef std::vector<_Object> collection;
- typedef typename collection::iterator iterator;
- typedef typename collection::const_iterator const_iterator;
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- ThreadSafeSTLVector() : m_collection(), m_mutex() {}
-
- ~ThreadSafeSTLVector() = default;
-
- bool
- IsEmpty() const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_collection.empty();
- }
-
- void
- Clear()
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_collection.clear();
- }
-
- size_t
- GetCount()
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_collection.size();
- }
-
- void
- AppendObject (_Object& object)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- m_collection.push_back(object);
- }
-
- _Object
- GetObject (size_t index)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_collection.at(index);
- }
-
- void
- SetObject (size_t index, const _Object& object)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- m_collection.at(index) = object;
- }
-
- std::recursive_mutex &
- GetMutex()
- {
- return m_mutex;
- }
-
- private:
- collection m_collection;
- mutable std::recursive_mutex m_mutex;
-
- //------------------------------------------------------------------
- // For ThreadSafeSTLVector only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (ThreadSafeSTLVector);
- };
-
-
+
+template <typename _Object> class ThreadSafeSTLVector {
+public:
+ typedef std::vector<_Object> collection;
+ typedef typename collection::iterator iterator;
+ typedef typename collection::const_iterator const_iterator;
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ ThreadSafeSTLVector() : m_collection(), m_mutex() {}
+
+ ~ThreadSafeSTLVector() = default;
+
+ bool IsEmpty() const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_collection.empty();
+ }
+
+ void Clear() {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_collection.clear();
+ }
+
+ size_t GetCount() {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_collection.size();
+ }
+
+ void AppendObject(_Object &object) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ m_collection.push_back(object);
+ }
+
+ _Object GetObject(size_t index) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_collection.at(index);
+ }
+
+ void SetObject(size_t index, const _Object &object) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ m_collection.at(index) = object;
+ }
+
+ std::recursive_mutex &GetMutex() { return m_mutex; }
+
+private:
+ collection m_collection;
+ mutable std::recursive_mutex m_mutex;
+
+ //------------------------------------------------------------------
+ // For ThreadSafeSTLVector only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(ThreadSafeSTLVector);
+};
+
} // namespace lldb_private
-#endif // liblldb_ThreadSafeSTLVector_h_
+#endif // liblldb_ThreadSafeSTLVector_h_
diff --git a/include/lldb/Core/ThreadSafeValue.h b/include/lldb/Core/ThreadSafeValue.h
index cad36a0c1637..60eaf91c4f02 100644
--- a/include/lldb/Core/ThreadSafeValue.h
+++ b/include/lldb/Core/ThreadSafeValue.h
@@ -20,71 +20,50 @@
namespace lldb_private {
-template <class T>
-class ThreadSafeValue
-{
+template <class T> class ThreadSafeValue {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- ThreadSafeValue() : m_value(), m_mutex() {}
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ ThreadSafeValue() : m_value(), m_mutex() {}
- ThreadSafeValue(const T &value) : m_value(value), m_mutex() {}
+ ThreadSafeValue(const T &value) : m_value(value), m_mutex() {}
- ~ThreadSafeValue()
- {
- }
+ ~ThreadSafeValue() {}
- T
- GetValue() const
+ T GetValue() const {
+ T value;
{
- T value;
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- value = m_value;
- }
- return value;
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ value = m_value;
}
+ return value;
+ }
- // Call this if you have already manually locked the mutex using the
- // GetMutex() accessor
- const T&
- GetValueNoLock () const
- {
- return m_value;
- }
+ // Call this if you have already manually locked the mutex using the
+ // GetMutex() accessor
+ const T &GetValueNoLock() const { return m_value; }
- void
- SetValue(const T &value)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- m_value = value;
- }
+ void SetValue(const T &value) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ m_value = value;
+ }
- // Call this if you have already manually locked the mutex using the
- // GetMutex() accessor
- void
- SetValueNoLock (const T& value)
- {
- m_value = value;
- }
+ // Call this if you have already manually locked the mutex using the
+ // GetMutex() accessor
+ void SetValueNoLock(const T &value) { m_value = value; }
- std::recursive_mutex &
- GetMutex()
- {
- return m_mutex;
- }
+ std::recursive_mutex &GetMutex() { return m_mutex; }
private:
- T m_value;
- mutable std::recursive_mutex m_mutex;
+ T m_value;
+ mutable std::recursive_mutex m_mutex;
- //------------------------------------------------------------------
- // For ThreadSafeValue only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (ThreadSafeValue);
+ //------------------------------------------------------------------
+ // For ThreadSafeValue only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(ThreadSafeValue);
};
-
} // namespace lldb_private
-#endif // liblldb_ThreadSafeValue_h_
+#endif // liblldb_ThreadSafeValue_h_
diff --git a/include/lldb/Core/Timer.h b/include/lldb/Core/Timer.h
index 4d89700644cc..854d3c31f54f 100644
--- a/include/lldb/Core/Timer.h
+++ b/include/lldb/Core/Timer.h
@@ -21,7 +21,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
-#include "lldb/Host/TimeValue.h"
+#include "llvm/Support/Chrono.h"
namespace lldb_private {
@@ -37,120 +37,42 @@ namespace lldb_private {
/// in a scope.
//----------------------------------------------------------------------
-class Timer
-{
+class Timer {
public:
- //--------------------------------------------------------------
- /// Default constructor.
- //--------------------------------------------------------------
- Timer(const char *category, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
+ //--------------------------------------------------------------
+ /// Default constructor.
+ //--------------------------------------------------------------
+ Timer(const char *category, const char *format, ...)
+ __attribute__((format(printf, 3, 4)));
- //--------------------------------------------------------------
- /// Destructor
- //--------------------------------------------------------------
- ~Timer();
+ //--------------------------------------------------------------
+ /// Destructor
+ //--------------------------------------------------------------
+ ~Timer();
- void
- Dump ();
+ void Dump();
- static void
- SetDisplayDepth (uint32_t depth);
-
- static void
- SetQuiet (bool value);
+ static void SetDisplayDepth(uint32_t depth);
- static void
- DumpCategoryTimes (Stream *s);
+ static void SetQuiet(bool value);
- static void
- ResetCategoryTimes ();
+ static void DumpCategoryTimes(Stream *s);
-protected:
- void
- ChildStarted (const TimeValue& time);
-
- void
- ChildStopped (const TimeValue& time);
+ static void ResetCategoryTimes();
- uint64_t
- GetTotalElapsedNanoSeconds();
-
- uint64_t
- GetTimerElapsedNanoSeconds();
+protected:
+ using TimePoint = std::chrono::steady_clock::time_point;
+ void ChildDuration(TimePoint::duration dur) { m_child_duration += dur; }
- const char *m_category;
- TimeValue m_total_start;
- TimeValue m_timer_start;
- uint64_t m_total_ticks; // Total running time for this timer including when other timers below this are running
- uint64_t m_timer_ticks; // Ticks for this timer that do not include when other timers below this one are running
+ const char *m_category;
+ TimePoint m_total_start;
+ TimePoint::duration m_child_duration{0};
- static std::atomic<bool> g_quiet;
- static std::atomic<unsigned> g_display_depth;
+ static std::atomic<bool> g_quiet;
+ static std::atomic<unsigned> g_display_depth;
private:
- Timer();
- DISALLOW_COPY_AND_ASSIGN (Timer);
-};
-
-class IntervalTimer
-{
-public:
- IntervalTimer() :
- m_start (TimeValue::Now())
- {
- }
-
- ~IntervalTimer() = default;
-
- uint64_t
- GetElapsedNanoSeconds() const
- {
- return TimeValue::Now() - m_start;
- }
-
- void
- Reset ()
- {
- m_start = TimeValue::Now();
- }
-
- int
- PrintfElapsed (const char *format, ...) __attribute__ ((format (printf, 2, 3)))
- {
- TimeValue now (TimeValue::Now());
- const uint64_t elapsed_nsec = now - m_start;
- const char *unit = nullptr;
- float elapsed_value;
- if (elapsed_nsec < 1000)
- {
- unit = "ns";
- elapsed_value = (float)elapsed_nsec;
- }
- else if (elapsed_nsec < 1000000)
- {
- unit = "us";
- elapsed_value = (float)elapsed_nsec/1000.0f;
- }
- else if (elapsed_nsec < 1000000000)
- {
- unit = "ms";
- elapsed_value = (float)elapsed_nsec/1000000.0f;
- }
- else
- {
- unit = "sec";
- elapsed_value = (float)elapsed_nsec/1000000000.0f;
- }
- int result = printf ("%3.2f %s: ", elapsed_value, unit);
- va_list args;
- va_start (args, format);
- result += vprintf (format, args);
- va_end (args);
- return result;
- }
-
-protected:
- TimeValue m_start;
+ DISALLOW_COPY_AND_ASSIGN(Timer);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/UUID.h b/include/lldb/Core/UUID.h
index 88426cfb6c75..7cf5cf389400 100644
--- a/include/lldb/Core/UUID.h
+++ b/include/lldb/Core/UUID.h
@@ -20,91 +20,77 @@
namespace lldb_private {
-class UUID
-{
+class UUID {
public:
- // Most UUIDs are 16 bytes, but some Linux build-ids (SHA1) are 20.
- typedef uint8_t ValueType[20];
-
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- UUID ();
- UUID (const UUID& rhs);
- UUID (const void *uuid_bytes, uint32_t num_uuid_bytes);
-
- ~UUID ();
-
- const UUID&
- operator=(const UUID& rhs);
-
- void
- Clear ();
-
- void
- Dump (Stream *s) const;
-
- const void *
- GetBytes() const;
-
- size_t
- GetByteSize();
-
- bool
- IsValid () const;
-
- bool
- SetBytes (const void *uuid_bytes, uint32_t num_uuid_bytes = 16);
-
- std::string
- GetAsString(const char *separator = nullptr) const;
-
- size_t
- SetFromCString (const char *c_str, uint32_t num_uuid_bytes = 16);
-
- // Decode as many UUID bytes (up to 16) as possible from the C string "cstr"
- // This is used for auto completion where a partial UUID might have been
- // typed in. It
- //------------------------------------------------------------------
- /// Decode as many UUID bytes (up to 16) as possible from the C
- /// string \a cstr.
- ///
- /// @param[in] cstr
- /// A NULL terminate C string that points at a UUID string value
- /// (no leading spaces). The string must contain only hex
- /// characters and optionally can contain the '-' sepearators.
- ///
- /// @param[in] uuid_bytes
- /// A buffer of bytes that will contain a full or patially
- /// decoded UUID.
- ///
- /// @param[out] end
- /// If \a end is not nullptr, it will be filled in with the a
- /// pointer to the character after the last successfully decoded
- /// byte.
- ///
- /// @return
- /// Returns the number of bytes that were successfully decoded
- /// which should be 16 if a full UUID value was properly decoded.
- //------------------------------------------------------------------
- static size_t
- DecodeUUIDBytesFromCString (const char *cstr, ValueType &uuid_bytes, const char **end, uint32_t num_uuid_bytes = 16);
-
+ // Most UUIDs are 16 bytes, but some Linux build-ids (SHA1) are 20.
+ typedef uint8_t ValueType[20];
+
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ UUID();
+ UUID(const UUID &rhs);
+ UUID(const void *uuid_bytes, uint32_t num_uuid_bytes);
+
+ ~UUID();
+
+ const UUID &operator=(const UUID &rhs);
+
+ void Clear();
+
+ void Dump(Stream *s) const;
+
+ const void *GetBytes() const;
+
+ size_t GetByteSize();
+
+ bool IsValid() const;
+
+ bool SetBytes(const void *uuid_bytes, uint32_t num_uuid_bytes = 16);
+
+ std::string GetAsString(const char *separator = nullptr) const;
+
+ size_t SetFromCString(const char *c_str, uint32_t num_uuid_bytes = 16);
+
+ // Decode as many UUID bytes (up to 16) as possible from the C string "cstr"
+ // This is used for auto completion where a partial UUID might have been
+ // typed in. It
+ //------------------------------------------------------------------
+ /// Decode as many UUID bytes (up to 16) as possible from the C
+ /// string \a cstr.
+ ///
+ /// @param[in] cstr
+ /// A NULL terminate C string that points at a UUID string value
+ /// (no leading spaces). The string must contain only hex
+ /// characters and optionally can contain the '-' sepearators.
+ ///
+ /// @param[in] uuid_bytes
+ /// A buffer of bytes that will contain a full or patially
+ /// decoded UUID.
+ ///
+ /// @return
+ /// The original string, with all decoded bytes removed.
+ //------------------------------------------------------------------
+ static llvm::StringRef
+ DecodeUUIDBytesFromString(llvm::StringRef str, ValueType &uuid_bytes,
+ uint32_t &bytes_decoded,
+ uint32_t num_uuid_bytes = 16);
+
protected:
- //------------------------------------------------------------------
- // Classes that inherit from UUID can see and modify these
- //------------------------------------------------------------------
- uint32_t m_num_uuid_bytes; // Should be 16 or 20
- ValueType m_uuid;
+ //------------------------------------------------------------------
+ // Classes that inherit from UUID can see and modify these
+ //------------------------------------------------------------------
+ uint32_t m_num_uuid_bytes; // Should be 16 or 20
+ ValueType m_uuid;
};
-bool operator == (const UUID &lhs, const UUID &rhs);
-bool operator != (const UUID &lhs, const UUID &rhs);
-bool operator < (const UUID &lhs, const UUID &rhs);
-bool operator <= (const UUID &lhs, const UUID &rhs);
-bool operator > (const UUID &lhs, const UUID &rhs);
-bool operator >= (const UUID &lhs, const UUID &rhs);
+bool operator==(const UUID &lhs, const UUID &rhs);
+bool operator!=(const UUID &lhs, const UUID &rhs);
+bool operator<(const UUID &lhs, const UUID &rhs);
+bool operator<=(const UUID &lhs, const UUID &rhs);
+bool operator>(const UUID &lhs, const UUID &rhs);
+bool operator>=(const UUID &lhs, const UUID &rhs);
} // namespace lldb_private
-#endif // liblldb_UUID_h_
+#endif // liblldb_UUID_h_
diff --git a/include/lldb/Core/UniqueCStringMap.h b/include/lldb/Core/UniqueCStringMap.h
index 1e50f747f2a8..77a350aaea15 100644
--- a/include/lldb/Core/UniqueCStringMap.h
+++ b/include/lldb/Core/UniqueCStringMap.h
@@ -30,326 +30,240 @@ namespace lldb_private {
// Any other string table that has guaranteed unique values can also
// be used.
//----------------------------------------------------------------------
-template <typename T>
-class UniqueCStringMap
-{
+template <typename T> class UniqueCStringMap {
public:
- struct Entry
- {
- Entry () :
- cstring(nullptr),
- value()
- {
- }
-
- Entry (const char *cstr) :
- cstring(cstr),
- value()
- {
- }
-
- Entry (const char *cstr, const T&v) :
- cstring(cstr),
- value(v)
- {
- }
-
- bool
- operator < (const Entry& rhs) const
- {
- return cstring < rhs.cstring;
- }
-
- const char* cstring;
- T value;
- };
-
- //------------------------------------------------------------------
- // Call this function multiple times to add a bunch of entries to
- // this map, then later call UniqueCStringMap<T>::Sort() before doing
- // any searches by name.
- //------------------------------------------------------------------
- void
- Append (const char *unique_cstr, const T& value)
- {
- m_map.push_back (typename UniqueCStringMap<T>::Entry(unique_cstr, value));
- }
-
- void
- Append (const Entry &e)
- {
- m_map.push_back (e);
- }
-
- void
- Clear ()
- {
- m_map.clear();
+ struct Entry {
+ Entry() {}
+
+ Entry(llvm::StringRef cstr) : cstring(cstr), value() {}
+
+ Entry(llvm::StringRef cstr, const T &v) : cstring(cstr), value(v) {}
+
+ bool operator<(const Entry &rhs) const { return cstring < rhs.cstring; }
+
+ llvm::StringRef cstring;
+ T value;
+ };
+
+ //------------------------------------------------------------------
+ // Call this function multiple times to add a bunch of entries to
+ // this map, then later call UniqueCStringMap<T>::Sort() before doing
+ // any searches by name.
+ //------------------------------------------------------------------
+ void Append(llvm::StringRef unique_cstr, const T &value) {
+ m_map.push_back(typename UniqueCStringMap<T>::Entry(unique_cstr, value));
+ }
+
+ void Append(const Entry &e) { m_map.push_back(e); }
+
+ void Clear() { m_map.clear(); }
+
+ //------------------------------------------------------------------
+ // Call this function to always keep the map sorted when putting
+ // entries into the map.
+ //------------------------------------------------------------------
+ void Insert(llvm::StringRef unique_cstr, const T &value) {
+ typename UniqueCStringMap<T>::Entry e(unique_cstr, value);
+ m_map.insert(std::upper_bound(m_map.begin(), m_map.end(), e), e);
+ }
+
+ void Insert(const Entry &e) {
+ m_map.insert(std::upper_bound(m_map.begin(), m_map.end(), e), e);
+ }
+
+ //------------------------------------------------------------------
+ // Get an entries by index in a variety of forms.
+ //
+ // The caller is responsible for ensuring that the collection does
+ // not change during while using the returned values.
+ //------------------------------------------------------------------
+ bool GetValueAtIndex(uint32_t idx, T &value) const {
+ if (idx < m_map.size()) {
+ value = m_map[idx].value;
+ return true;
}
-
- //------------------------------------------------------------------
- // Call this function to always keep the map sorted when putting
- // entries into the map.
- //------------------------------------------------------------------
- void
- Insert (const char *unique_cstr, const T& value)
- {
- typename UniqueCStringMap<T>::Entry e(unique_cstr, value);
- m_map.insert (std::upper_bound (m_map.begin(), m_map.end(), e), e);
+ return false;
+ }
+
+ llvm::StringRef GetCStringAtIndexUnchecked(uint32_t idx) const {
+ return m_map[idx].cstring;
+ }
+
+ // Use this function if you have simple types in your map that you
+ // can easily copy when accessing values by index.
+ T GetValueAtIndexUnchecked(uint32_t idx) const { return m_map[idx].value; }
+
+ // Use this function if you have complex types in your map that you
+ // don't want to copy when accessing values by index.
+ const T &GetValueRefAtIndexUnchecked(uint32_t idx) const {
+ return m_map[idx].value;
+ }
+
+ llvm::StringRef GetCStringAtIndex(uint32_t idx) const {
+ return ((idx < m_map.size()) ? m_map[idx].cstring : llvm::StringRef());
+ }
+
+ //------------------------------------------------------------------
+ // Find the value for the unique string in the map.
+ //
+ // Return the value for \a unique_cstr if one is found, return
+ // \a fail_value otherwise. This method works well for simple type
+ // T values and only if there is a sensible failure value that can
+ // be returned and that won't match any existing values.
+ //------------------------------------------------------------------
+ T Find(llvm::StringRef unique_cstr, T fail_value) const {
+ Entry search_entry(unique_cstr);
+ const_iterator end = m_map.end();
+ const_iterator pos = std::lower_bound(m_map.begin(), end, search_entry);
+ if (pos != end) {
+ if (pos->cstring == unique_cstr)
+ return pos->value;
}
-
- void
- Insert (const Entry &e)
- {
- m_map.insert (std::upper_bound (m_map.begin(), m_map.end(), e), e);
+ return fail_value;
+ }
+
+ //------------------------------------------------------------------
+ // Get a pointer to the first entry that matches "name". nullptr will
+ // be returned if there is no entry that matches "name".
+ //
+ // The caller is responsible for ensuring that the collection does
+ // not change during while using the returned pointer.
+ //------------------------------------------------------------------
+ const Entry *FindFirstValueForName(llvm::StringRef unique_cstr) const {
+ Entry search_entry(unique_cstr);
+ const_iterator end = m_map.end();
+ const_iterator pos = std::lower_bound(m_map.begin(), end, search_entry);
+ if (pos != end) {
+ llvm::StringRef pos_cstr = pos->cstring;
+ if (pos_cstr == unique_cstr)
+ return &(*pos);
}
-
- //------------------------------------------------------------------
- // Get an entries by index in a variety of forms.
- //
- // The caller is responsible for ensuring that the collection does
- // not change during while using the returned values.
- //------------------------------------------------------------------
- bool
- GetValueAtIndex (uint32_t idx, T &value) const
- {
- if (idx < m_map.size())
- {
- value = m_map[idx].value;
- return true;
- }
- return false;
+ return nullptr;
+ }
+
+ //------------------------------------------------------------------
+ // Get a pointer to the next entry that matches "name" from a
+ // previously returned Entry pointer. nullptr will be returned if there
+ // is no subsequent entry that matches "name".
+ //
+ // The caller is responsible for ensuring that the collection does
+ // not change during while using the returned pointer.
+ //------------------------------------------------------------------
+ const Entry *FindNextValueForName(const Entry *entry_ptr) const {
+ if (!m_map.empty()) {
+ const Entry *first_entry = &m_map[0];
+ const Entry *after_last_entry = first_entry + m_map.size();
+ const Entry *next_entry = entry_ptr + 1;
+ if (first_entry <= next_entry && next_entry < after_last_entry) {
+ if (next_entry->cstring == entry_ptr->cstring)
+ return next_entry;
+ }
}
-
- const char *
- GetCStringAtIndexUnchecked (uint32_t idx) const
- {
- return m_map[idx].cstring;
- }
-
- // Use this function if you have simple types in your map that you
- // can easily copy when accessing values by index.
- T
- GetValueAtIndexUnchecked (uint32_t idx) const
- {
- return m_map[idx].value;
+ return nullptr;
+ }
+
+ size_t GetValues(llvm::StringRef unique_cstr, std::vector<T> &values) const {
+ const size_t start_size = values.size();
+
+ Entry search_entry(unique_cstr);
+ const_iterator pos, end = m_map.end();
+ for (pos = std::lower_bound(m_map.begin(), end, search_entry); pos != end;
+ ++pos) {
+ if (pos->cstring == unique_cstr)
+ values.push_back(pos->value);
+ else
+ break;
}
- // Use this function if you have complex types in your map that you
- // don't want to copy when accessing values by index.
- const T &
- GetValueRefAtIndexUnchecked (uint32_t idx) const
- {
- return m_map[idx].value;
- }
+ return values.size() - start_size;
+ }
- const char *
- GetCStringAtIndex (uint32_t idx) const
- {
- return ((idx < m_map.size()) ? m_map[idx].cstring : nullptr);
- }
+ size_t GetValues(const RegularExpression &regex,
+ std::vector<T> &values) const {
+ const size_t start_size = values.size();
- //------------------------------------------------------------------
- // Find the value for the unique string in the map.
- //
- // Return the value for \a unique_cstr if one is found, return
- // \a fail_value otherwise. This method works well for simple type
- // T values and only if there is a sensible failure value that can
- // be returned and that won't match any existing values.
- //------------------------------------------------------------------
- T
- Find (const char *unique_cstr, T fail_value) const
- {
- Entry search_entry (unique_cstr);
- const_iterator end = m_map.end();
- const_iterator pos = std::lower_bound (m_map.begin(), end, search_entry);
- if (pos != end)
- {
- if (pos->cstring == unique_cstr)
- return pos->value;
- }
- return fail_value;
+ const_iterator pos, end = m_map.end();
+ for (pos = m_map.begin(); pos != end; ++pos) {
+ if (regex.Execute(pos->cstring))
+ values.push_back(pos->value);
}
- //------------------------------------------------------------------
- // Get a pointer to the first entry that matches "name". nullptr will
- // be returned if there is no entry that matches "name".
- //
- // The caller is responsible for ensuring that the collection does
- // not change during while using the returned pointer.
- //------------------------------------------------------------------
- const Entry *
- FindFirstValueForName (const char *unique_cstr) const
- {
- Entry search_entry (unique_cstr);
- const_iterator end = m_map.end();
- const_iterator pos = std::lower_bound (m_map.begin(), end, search_entry);
- if (pos != end)
- {
- const char *pos_cstr = pos->cstring;
- if (pos_cstr == unique_cstr)
- return &(*pos);
- }
- return nullptr;
+ return values.size() - start_size;
+ }
+
+ //------------------------------------------------------------------
+ // Get the total number of entries in this map.
+ //------------------------------------------------------------------
+ size_t GetSize() const { return m_map.size(); }
+
+ //------------------------------------------------------------------
+ // Returns true if this map is empty.
+ //------------------------------------------------------------------
+ bool IsEmpty() const { return m_map.empty(); }
+
+ //------------------------------------------------------------------
+ // Reserve memory for at least "n" entries in the map. This is
+ // useful to call when you know you will be adding a lot of entries
+ // using UniqueCStringMap::Append() (which should be followed by a
+ // call to UniqueCStringMap::Sort()) or to UniqueCStringMap::Insert().
+ //------------------------------------------------------------------
+ void Reserve(size_t n) { m_map.reserve(n); }
+
+ //------------------------------------------------------------------
+ // Sort the unsorted contents in this map. A typical code flow would
+ // be:
+ // size_t approximate_num_entries = ....
+ // UniqueCStringMap<uint32_t> my_map;
+ // my_map.Reserve (approximate_num_entries);
+ // for (...)
+ // {
+ // my_map.Append (UniqueCStringMap::Entry(GetName(...), GetValue(...)));
+ // }
+ // my_map.Sort();
+ //------------------------------------------------------------------
+ void Sort() { std::sort(m_map.begin(), m_map.end()); }
+
+ //------------------------------------------------------------------
+ // Since we are using a vector to contain our items it will always
+ // double its memory consumption as things are added to the vector,
+ // so if you intend to keep a UniqueCStringMap around and have
+ // a lot of entries in the map, you will want to call this function
+ // to create a new vector and copy _only_ the exact size needed as
+ // part of the finalization of the string map.
+ //------------------------------------------------------------------
+ void SizeToFit() {
+ if (m_map.size() < m_map.capacity()) {
+ collection temp(m_map.begin(), m_map.end());
+ m_map.swap(temp);
}
-
- //------------------------------------------------------------------
- // Get a pointer to the next entry that matches "name" from a
- // previously returned Entry pointer. nullptr will be returned if there
- // is no subsequent entry that matches "name".
- //
- // The caller is responsible for ensuring that the collection does
- // not change during while using the returned pointer.
- //------------------------------------------------------------------
- const Entry *
- FindNextValueForName (const Entry *entry_ptr) const
- {
- if (!m_map.empty())
- {
- const Entry *first_entry = &m_map[0];
- const Entry *after_last_entry = first_entry + m_map.size();
- const Entry *next_entry = entry_ptr + 1;
- if (first_entry <= next_entry && next_entry < after_last_entry)
- {
- if (next_entry->cstring == entry_ptr->cstring)
- return next_entry;
- }
- }
- return nullptr;
- }
-
- size_t
- GetValues (const char *unique_cstr, std::vector<T> &values) const
- {
- const size_t start_size = values.size();
-
- Entry search_entry (unique_cstr);
- const_iterator pos, end = m_map.end();
- for (pos = std::lower_bound (m_map.begin(), end, search_entry); pos != end; ++pos)
- {
- if (pos->cstring == unique_cstr)
- values.push_back (pos->value);
- else
- break;
- }
-
- return values.size() - start_size;
- }
-
- size_t
- GetValues (const RegularExpression& regex, std::vector<T> &values) const
- {
- const size_t start_size = values.size();
-
- const_iterator pos, end = m_map.end();
- for (pos = m_map.begin(); pos != end; ++pos)
- {
- if (regex.Execute(pos->cstring))
- values.push_back (pos->value);
- }
-
- return values.size() - start_size;
- }
-
- //------------------------------------------------------------------
- // Get the total number of entries in this map.
- //------------------------------------------------------------------
- size_t
- GetSize () const
- {
- return m_map.size();
- }
-
- //------------------------------------------------------------------
- // Returns true if this map is empty.
- //------------------------------------------------------------------
- bool
- IsEmpty() const
- {
- return m_map.empty();
- }
-
- //------------------------------------------------------------------
- // Reserve memory for at least "n" entries in the map. This is
- // useful to call when you know you will be adding a lot of entries
- // using UniqueCStringMap::Append() (which should be followed by a
- // call to UniqueCStringMap::Sort()) or to UniqueCStringMap::Insert().
- //------------------------------------------------------------------
- void
- Reserve (size_t n)
- {
- m_map.reserve (n);
- }
-
- //------------------------------------------------------------------
- // Sort the unsorted contents in this map. A typical code flow would
- // be:
- // size_t approximate_num_entries = ....
- // UniqueCStringMap<uint32_t> my_map;
- // my_map.Reserve (approximate_num_entries);
- // for (...)
- // {
- // my_map.Append (UniqueCStringMap::Entry(GetName(...), GetValue(...)));
- // }
- // my_map.Sort();
- //------------------------------------------------------------------
- void
- Sort ()
- {
- std::sort (m_map.begin(), m_map.end());
- }
-
- //------------------------------------------------------------------
- // Since we are using a vector to contain our items it will always
- // double its memory consumption as things are added to the vector,
- // so if you intend to keep a UniqueCStringMap around and have
- // a lot of entries in the map, you will want to call this function
- // to create a new vector and copy _only_ the exact size needed as
- // part of the finalization of the string map.
- //------------------------------------------------------------------
- void
- SizeToFit ()
- {
- if (m_map.size() < m_map.capacity())
- {
- collection temp (m_map.begin(), m_map.end());
- m_map.swap(temp);
- }
- }
-
- size_t
- Erase (const char *unique_cstr)
- {
- size_t num_removed = 0;
- Entry search_entry (unique_cstr);
- iterator end = m_map.end();
- iterator begin = m_map.begin();
- iterator lower_pos = std::lower_bound (begin, end, search_entry);
- if (lower_pos != end)
- {
- if (lower_pos->cstring == unique_cstr)
- {
- iterator upper_pos = std::upper_bound (lower_pos, end, search_entry);
- if (lower_pos == upper_pos)
- {
- m_map.erase (lower_pos);
- num_removed = 1;
- }
- else
- {
- num_removed = std::distance (lower_pos, upper_pos);
- m_map.erase (lower_pos, upper_pos);
- }
- }
+ }
+
+ size_t Erase(llvm::StringRef unique_cstr) {
+ size_t num_removed = 0;
+ Entry search_entry(unique_cstr);
+ iterator end = m_map.end();
+ iterator begin = m_map.begin();
+ iterator lower_pos = std::lower_bound(begin, end, search_entry);
+ if (lower_pos != end) {
+ if (lower_pos->cstring == unique_cstr) {
+ iterator upper_pos = std::upper_bound(lower_pos, end, search_entry);
+ if (lower_pos == upper_pos) {
+ m_map.erase(lower_pos);
+ num_removed = 1;
+ } else {
+ num_removed = std::distance(lower_pos, upper_pos);
+ m_map.erase(lower_pos, upper_pos);
}
- return num_removed;
+ }
}
+ return num_removed;
+ }
protected:
- typedef std::vector<Entry> collection;
- typedef typename collection::iterator iterator;
- typedef typename collection::const_iterator const_iterator;
- collection m_map;
+ typedef std::vector<Entry> collection;
+ typedef typename collection::iterator iterator;
+ typedef typename collection::const_iterator const_iterator;
+ collection m_map;
};
} // namespace lldb_private
diff --git a/include/lldb/Core/UserID.h b/include/lldb/Core/UserID.h
index 230e43fa551f..596448334555 100644
--- a/include/lldb/Core/UserID.h
+++ b/include/lldb/Core/UserID.h
@@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//
-
#ifndef liblldb_UserID_h_
#define liblldb_UserID_h_
@@ -30,101 +29,90 @@ namespace lldb_private {
/// index, functions can use it to store the symbol table index or the
/// DWARF offset.
//----------------------------------------------------------------------
-struct UserID
-{
- //------------------------------------------------------------------
- /// Construct with optional user ID.
- //------------------------------------------------------------------
- UserID (lldb::user_id_t uid = LLDB_INVALID_UID) : m_uid(uid) {}
-
- //------------------------------------------------------------------
- /// Destructor.
- //------------------------------------------------------------------
- ~UserID ()
- {
- }
-
- //------------------------------------------------------------------
- /// Clears the object state.
- ///
- /// Clears the object contents back to a default invalid state.
- //------------------------------------------------------------------
- void
- Clear () { m_uid = LLDB_INVALID_UID; }
-
- //------------------------------------------------------------------
- /// Get accessor for the user ID.
- ///
- /// @return
- /// The user ID.
- //------------------------------------------------------------------
- lldb::user_id_t
- GetID () const { return m_uid; }
-
- //------------------------------------------------------------------
- /// Set accessor for the user ID.
- ///
- /// @param[in] uid
- /// The new user ID.
- //------------------------------------------------------------------
- void
- SetID (lldb::user_id_t uid) { m_uid = uid; }
-
- //------------------------------------------------------------------
- /// Unary predicate function object that can search for a matching
- /// user ID.
- ///
- /// Function object that can be used on any class that inherits
- /// from UserID:
- /// \code
- /// iterator pos;
- /// pos = std::find_if (coll.begin(), coll.end(), UserID::IDMatches(blockID));
- /// \endcode
- //------------------------------------------------------------------
- class IDMatches
- {
- public:
- //--------------------------------------------------------------
- /// Construct with the user ID to look for.
- //--------------------------------------------------------------
- IDMatches (lldb::user_id_t uid) : m_uid(uid) {}
-
- //--------------------------------------------------------------
- /// Unary predicate function object callback.
- //--------------------------------------------------------------
- bool
- operator () (const UserID& rhs) const { return m_uid == rhs.GetID(); }
-
- private:
- //--------------------------------------------------------------
- // Member variables.
- //--------------------------------------------------------------
- const lldb::user_id_t m_uid; ///< The user ID we are looking for
- };
-
+struct UserID {
+ //------------------------------------------------------------------
+ /// Construct with optional user ID.
+ //------------------------------------------------------------------
+ UserID(lldb::user_id_t uid = LLDB_INVALID_UID) : m_uid(uid) {}
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ //------------------------------------------------------------------
+ ~UserID() {}
+
+ //------------------------------------------------------------------
+ /// Clears the object state.
+ ///
+ /// Clears the object contents back to a default invalid state.
+ //------------------------------------------------------------------
+ void Clear() { m_uid = LLDB_INVALID_UID; }
+
+ //------------------------------------------------------------------
+ /// Get accessor for the user ID.
+ ///
+ /// @return
+ /// The user ID.
+ //------------------------------------------------------------------
+ lldb::user_id_t GetID() const { return m_uid; }
+
+ //------------------------------------------------------------------
+ /// Set accessor for the user ID.
+ ///
+ /// @param[in] uid
+ /// The new user ID.
+ //------------------------------------------------------------------
+ void SetID(lldb::user_id_t uid) { m_uid = uid; }
+
+ //------------------------------------------------------------------
+ /// Unary predicate function object that can search for a matching
+ /// user ID.
+ ///
+ /// Function object that can be used on any class that inherits
+ /// from UserID:
+ /// \code
+ /// iterator pos;
+ /// pos = std::find_if (coll.begin(), coll.end(), UserID::IDMatches(blockID));
+ /// \endcode
+ //------------------------------------------------------------------
+ class IDMatches {
+ public:
+ //--------------------------------------------------------------
+ /// Construct with the user ID to look for.
+ //--------------------------------------------------------------
+ IDMatches(lldb::user_id_t uid) : m_uid(uid) {}
+
+ //--------------------------------------------------------------
+ /// Unary predicate function object callback.
+ //--------------------------------------------------------------
+ bool operator()(const UserID &rhs) const { return m_uid == rhs.GetID(); }
+
+ private:
+ //--------------------------------------------------------------
+ // Member variables.
+ //--------------------------------------------------------------
+ const lldb::user_id_t m_uid; ///< The user ID we are looking for
+ };
protected:
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- lldb::user_id_t m_uid; ///< The user ID that uniquely identifies an object.
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ lldb::user_id_t m_uid; ///< The user ID that uniquely identifies an object.
};
-inline bool operator== (const UserID& lhs, const UserID& rhs)
-{
+inline bool operator==(const UserID &lhs, const UserID &rhs) {
return lhs.GetID() == rhs.GetID();
}
-inline bool operator!= (const UserID& lhs, const UserID& rhs)
-{
+inline bool operator!=(const UserID &lhs, const UserID &rhs) {
return lhs.GetID() != rhs.GetID();
}
//--------------------------------------------------------------
/// Stream the UserID object to a Stream.
//--------------------------------------------------------------
-Stream& operator << (Stream& strm, const UserID& uid);
+Stream &operator<<(Stream &strm, const UserID &uid);
} // namespace lldb_private
-#endif // liblldb_UserID_h_
+#endif // liblldb_UserID_h_
diff --git a/include/lldb/Core/UserSettingsController.h b/include/lldb/Core/UserSettingsController.h
index 6c395c81c37b..a30dfd45121b 100644
--- a/include/lldb/Core/UserSettingsController.h
+++ b/include/lldb/Core/UserSettingsController.h
@@ -1,4 +1,4 @@
-//====-- UserSettingsController.h --------------------------------*- C++ -*-===//
+//====-- UserSettingsController.h --------------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -19,91 +19,73 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/ConstString.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamString.h"
+#include "lldb/Core/StringList.h"
#include "lldb/Interpreter/OptionValue.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class Properties
-{
+class Properties {
public:
- Properties () :
- m_collection_sp ()
- {
- }
-
- Properties (const lldb::OptionValuePropertiesSP &collection_sp) :
- m_collection_sp (collection_sp)
- {
- }
-
- virtual
- ~Properties()
- {
- }
-
- virtual lldb::OptionValuePropertiesSP
- GetValueProperties () const
- {
- // This function is virtual in case subclasses want to lazily
- // implement creating the properties.
- return m_collection_sp;
- }
-
- virtual lldb::OptionValueSP
- GetPropertyValue (const ExecutionContext *exe_ctx,
- const char *property_path,
- bool will_modify,
- Error &error) const;
-
- virtual Error
- SetPropertyValue (const ExecutionContext *exe_ctx,
- VarSetOperationType op,
- const char *property_path,
- const char *value);
-
- virtual Error
- DumpPropertyValue (const ExecutionContext *exe_ctx,
- Stream &strm,
- const char *property_path,
- uint32_t dump_mask);
-
- virtual void
- DumpAllPropertyValues (const ExecutionContext *exe_ctx,
- Stream &strm,
- uint32_t dump_mask);
-
- virtual void
- DumpAllDescriptions (CommandInterpreter &interpreter,
- Stream &strm) const;
-
- size_t
- Apropos (const char *keyword,
- std::vector<const Property *> &matching_properties) const;
-
- lldb::OptionValuePropertiesSP
- GetSubProperty (const ExecutionContext *exe_ctx,
- const ConstString &name);
-
- // We sometimes need to introduce a setting to enable experimental features,
- // but then we don't want the setting for these to cause errors when the setting
- // goes away. Add a sub-topic of the settings using this experimental name, and
- // two things will happen. One is that settings that don't find the name will not
- // be treated as errors. Also, if you decide to keep the settings just move them into
- // the containing properties, and we will auto-forward the experimental settings to the
- // real one.
- static const char *
- GetExperimentalSettingsName();
-
- static bool
- IsSettingExperimental(const char *setting);
+ Properties() : m_collection_sp() {}
+
+ Properties(const lldb::OptionValuePropertiesSP &collection_sp)
+ : m_collection_sp(collection_sp) {}
+
+ virtual ~Properties() {}
+
+ virtual lldb::OptionValuePropertiesSP GetValueProperties() const {
+ // This function is virtual in case subclasses want to lazily
+ // implement creating the properties.
+ return m_collection_sp;
+ }
+
+ virtual lldb::OptionValueSP GetPropertyValue(const ExecutionContext *exe_ctx,
+ llvm::StringRef property_path,
+ bool will_modify,
+ Error &error) const;
+
+ virtual Error SetPropertyValue(const ExecutionContext *exe_ctx,
+ VarSetOperationType op,
+ llvm::StringRef property_path, llvm::StringRef value);
+
+ virtual Error DumpPropertyValue(const ExecutionContext *exe_ctx, Stream &strm,
+ llvm::StringRef property_path,
+ uint32_t dump_mask);
+
+ virtual void DumpAllPropertyValues(const ExecutionContext *exe_ctx,
+ Stream &strm, uint32_t dump_mask);
+
+ virtual void DumpAllDescriptions(CommandInterpreter &interpreter,
+ Stream &strm) const;
+
+ size_t Apropos(llvm::StringRef keyword,
+ std::vector<const Property *> &matching_properties) const;
+
+ lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx,
+ const ConstString &name);
+
+ // We sometimes need to introduce a setting to enable experimental features,
+ // but then we don't want the setting for these to cause errors when the
+ // setting
+ // goes away. Add a sub-topic of the settings using this experimental name,
+ // and
+ // two things will happen. One is that settings that don't find the name will
+ // not
+ // be treated as errors. Also, if you decide to keep the settings just move
+ // them into
+ // the containing properties, and we will auto-forward the experimental
+ // settings to the
+ // real one.
+ static const char *GetExperimentalSettingsName();
+
+ static bool IsSettingExperimental(llvm::StringRef setting);
protected:
- lldb::OptionValuePropertiesSP m_collection_sp;
+ lldb::OptionValuePropertiesSP m_collection_sp;
};
} // namespace lldb_private
diff --git a/include/lldb/Core/VMRange.h b/include/lldb/Core/VMRange.h
index 94c83e730e96..4ec64c997553 100644
--- a/include/lldb/Core/VMRange.h
+++ b/include/lldb/Core/VMRange.h
@@ -19,163 +19,108 @@ namespace lldb_private {
// A vm address range. These can represent offsets ranges or actual
// addresses.
//----------------------------------------------------------------------
-class VMRange
-{
+class VMRange {
public:
+ typedef std::vector<VMRange> collection;
+ typedef collection::iterator iterator;
+ typedef collection::const_iterator const_iterator;
- typedef std::vector<VMRange> collection;
- typedef collection::iterator iterator;
- typedef collection::const_iterator const_iterator;
+ VMRange() : m_base_addr(0), m_byte_size(0) {}
- VMRange() :
- m_base_addr(0),
- m_byte_size(0)
- {
- }
+ VMRange(lldb::addr_t start_addr, lldb::addr_t end_addr)
+ : m_base_addr(start_addr),
+ m_byte_size(end_addr > start_addr ? end_addr - start_addr : 0) {}
- VMRange(lldb::addr_t start_addr, lldb::addr_t end_addr) :
- m_base_addr(start_addr),
- m_byte_size(end_addr > start_addr ? end_addr - start_addr : 0)
- {
- }
+ ~VMRange() {}
- ~VMRange()
- {
- }
+ void Clear() {
+ m_base_addr = 0;
+ m_byte_size = 0;
+ }
- void
- Clear ()
- {
- m_base_addr = 0;
- m_byte_size = 0;
- }
+ // Set the start and end values
+ void Reset(lldb::addr_t start_addr, lldb::addr_t end_addr) {
+ SetBaseAddress(start_addr);
+ SetEndAddress(end_addr);
+ }
- // Set the start and end values
- void
- Reset (lldb::addr_t start_addr, lldb::addr_t end_addr)
- {
- SetBaseAddress (start_addr);
- SetEndAddress (end_addr);
- }
+ // Set the start value for the range, and keep the same size
+ void SetBaseAddress(lldb::addr_t base_addr) { m_base_addr = base_addr; }
- // Set the start value for the range, and keep the same size
- void
- SetBaseAddress (lldb::addr_t base_addr)
- {
- m_base_addr = base_addr;
- }
+ void SetEndAddress(lldb::addr_t end_addr) {
+ const lldb::addr_t base_addr = GetBaseAddress();
+ if (end_addr > base_addr)
+ m_byte_size = end_addr - base_addr;
+ else
+ m_byte_size = 0;
+ }
- void
- SetEndAddress (lldb::addr_t end_addr)
- {
- const lldb::addr_t base_addr = GetBaseAddress();
- if (end_addr > base_addr)
- m_byte_size = end_addr - base_addr;
- else
- m_byte_size = 0;
- }
+ lldb::addr_t GetByteSize() const { return m_byte_size; }
- lldb::addr_t
- GetByteSize () const
- {
- return m_byte_size;
- }
+ void SetByteSize(lldb::addr_t byte_size) { m_byte_size = byte_size; }
- void
- SetByteSize (lldb::addr_t byte_size)
- {
- m_byte_size = byte_size;
- }
+ lldb::addr_t GetBaseAddress() const { return m_base_addr; }
- lldb::addr_t
- GetBaseAddress () const
- {
- return m_base_addr;
- }
+ lldb::addr_t GetEndAddress() const { return GetBaseAddress() + m_byte_size; }
- lldb::addr_t
- GetEndAddress () const
- {
- return GetBaseAddress() + m_byte_size;
- }
+ bool IsValid() const { return m_byte_size > 0; }
- bool
- IsValid() const
- {
- return m_byte_size > 0;
- }
+ bool Contains(lldb::addr_t addr) const {
+ return (GetBaseAddress() <= addr) && (addr < GetEndAddress());
+ }
- bool
- Contains (lldb::addr_t addr) const
- {
- return (GetBaseAddress() <= addr) && (addr < GetEndAddress());
+ bool Contains(const VMRange &range) const {
+ if (Contains(range.GetBaseAddress())) {
+ lldb::addr_t range_end = range.GetEndAddress();
+ return (GetBaseAddress() <= range_end) && (range_end <= GetEndAddress());
}
+ return false;
+ }
- bool
- Contains (const VMRange& range) const
- {
- if (Contains(range.GetBaseAddress()))
- {
- lldb::addr_t range_end = range.GetEndAddress();
- return (GetBaseAddress() <= range_end) && (range_end <= GetEndAddress());
- }
- return false;
+ void Dump(Stream *s, lldb::addr_t base_addr = 0,
+ uint32_t addr_width = 8) const;
+
+ class ValueInRangeUnaryPredicate {
+ public:
+ ValueInRangeUnaryPredicate(lldb::addr_t value) : _value(value) {}
+ bool operator()(const VMRange &range) const {
+ return range.Contains(_value);
+ }
+ lldb::addr_t _value;
+ };
+
+ class RangeInRangeUnaryPredicate {
+ public:
+ RangeInRangeUnaryPredicate(VMRange range) : _range(range) {}
+ bool operator()(const VMRange &range) const {
+ return range.Contains(_range);
}
+ const VMRange &_range;
+ };
+
+ static bool ContainsValue(const VMRange::collection &coll,
+ lldb::addr_t value);
+
+ static bool ContainsRange(const VMRange::collection &coll,
+ const VMRange &range);
- void
- Dump (Stream *s, lldb::addr_t base_addr = 0, uint32_t addr_width = 8) const;
-
- class ValueInRangeUnaryPredicate
- {
- public:
- ValueInRangeUnaryPredicate(lldb::addr_t value) :
- _value(value)
- {
- }
- bool operator()(const VMRange& range) const
- {
- return range.Contains(_value);
- }
- lldb::addr_t _value;
- };
-
- class RangeInRangeUnaryPredicate
- {
- public:
- RangeInRangeUnaryPredicate(VMRange range) :
- _range(range)
- {
- }
- bool operator()(const VMRange& range) const
- {
- return range.Contains(_range);
- }
- const VMRange& _range;
- };
-
- static bool
- ContainsValue(const VMRange::collection& coll, lldb::addr_t value);
-
- static bool
- ContainsRange(const VMRange::collection& coll, const VMRange& range);
-
- // Returns a valid index into coll when a match is found, else UINT32_MAX
- // is returned
- static size_t
- FindRangeIndexThatContainsValue (const VMRange::collection& coll, lldb::addr_t value);
+ // Returns a valid index into coll when a match is found, else UINT32_MAX
+ // is returned
+ static size_t FindRangeIndexThatContainsValue(const VMRange::collection &coll,
+ lldb::addr_t value);
protected:
- lldb::addr_t m_base_addr;
- lldb::addr_t m_byte_size;
+ lldb::addr_t m_base_addr;
+ lldb::addr_t m_byte_size;
};
-bool operator== (const VMRange& lhs, const VMRange& rhs);
-bool operator!= (const VMRange& lhs, const VMRange& rhs);
-bool operator< (const VMRange& lhs, const VMRange& rhs);
-bool operator<= (const VMRange& lhs, const VMRange& rhs);
-bool operator> (const VMRange& lhs, const VMRange& rhs);
-bool operator>= (const VMRange& lhs, const VMRange& rhs);
+bool operator==(const VMRange &lhs, const VMRange &rhs);
+bool operator!=(const VMRange &lhs, const VMRange &rhs);
+bool operator<(const VMRange &lhs, const VMRange &rhs);
+bool operator<=(const VMRange &lhs, const VMRange &rhs);
+bool operator>(const VMRange &lhs, const VMRange &rhs);
+bool operator>=(const VMRange &lhs, const VMRange &rhs);
} // namespace lldb_private
-#endif // liblldb_VMRange_h_
+#endif // liblldb_VMRange_h_
diff --git a/include/lldb/Core/Value.h b/include/lldb/Core/Value.h
index 7539b550dc42..2800c4f20996 100644
--- a/include/lldb/Core/Value.h
+++ b/include/lldb/Core/Value.h
@@ -16,308 +16,232 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Symbol/CompilerType.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class Value
-{
+class Value {
public:
- // Values Less than zero are an error, greater than or equal to zero
- // returns what the Scalar result is.
- enum ValueType
- {
- // m_value contains...
- // ============================
- eValueTypeScalar, // raw scalar value
- eValueTypeVector, // byte array of m_vector.length with endianness of m_vector.byte_order
- eValueTypeFileAddress, // file address value
- eValueTypeLoadAddress, // load address value
- eValueTypeHostAddress // host address value (for memory in the process that is using liblldb)
- };
-
- enum ContextType // Type that describes Value::m_context
- {
- // m_context contains...
- // ====================
- eContextTypeInvalid, // undefined
- eContextTypeRegisterInfo, // RegisterInfo * (can be a scalar or a vector register)
- eContextTypeLLDBType, // lldb_private::Type *
- eContextTypeVariable // lldb_private::Variable *
- };
-
- const static size_t kMaxByteSize = 32u;
-
- struct Vector
- {
- // The byte array must be big enough to hold vector registers for any supported target.
- uint8_t bytes[kMaxByteSize];
- size_t length;
- lldb::ByteOrder byte_order;
-
- Vector() :
- length(0),
- byte_order(lldb::eByteOrderInvalid)
- {
- }
-
- Vector(const Vector& vector)
- { *this = vector;
- }
- const Vector&
- operator=(const Vector& vector)
- {
- SetBytes(vector.bytes, vector.length, vector.byte_order);
- return *this;
- }
-
- void
- Clear ()
- {
- length = 0;
- }
-
- bool
- SetBytes(const void *bytes, size_t length, lldb::ByteOrder byte_order)
- {
- this->length = length;
- this->byte_order = byte_order;
- if (length)
- ::memcpy(this->bytes, bytes, length < kMaxByteSize ? length : kMaxByteSize);
- return IsValid();
- }
-
- bool
- IsValid() const
- {
- return (length > 0 && length < kMaxByteSize && byte_order != lldb::eByteOrderInvalid);
- }
- // Casts a vector, if valid, to an unsigned int of matching or largest supported size.
- // Truncates to the beginning of the vector if required.
- // Returns a default constructed Scalar if the Vector data is internally inconsistent.
- llvm::APInt rhs = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)bytes)->x);
- Scalar
- GetAsScalar() const
- {
- Scalar scalar;
- if (IsValid())
- {
- if (length == 1) scalar = *(const uint8_t *)bytes;
- else if (length == 2) scalar = *(const uint16_t *)bytes;
- else if (length == 4) scalar = *(const uint32_t *)bytes;
- else if (length == 8) scalar = *(const uint64_t *)bytes;
- else if (length >= 16) scalar = rhs;
- }
- return scalar;
- }
- };
-
- Value();
- Value(const Scalar& scalar);
- Value(const Vector& vector);
- Value(const void *bytes, int len);
- Value(const Value &rhs);
-
- void
- SetBytes (const void *bytes, int len);
-
- void
- AppendBytes (const void *bytes, int len);
-
- Value &
- operator=(const Value &rhs);
-
- const CompilerType &
- GetCompilerType();
-
- void
- SetCompilerType (const CompilerType &compiler_type);
-
- ValueType
- GetValueType() const;
-
- AddressType
- GetValueAddressType () const;
-
- ContextType
- GetContextType() const
- {
- return m_context_type;
+ // Values Less than zero are an error, greater than or equal to zero
+ // returns what the Scalar result is.
+ enum ValueType {
+ // m_value contains...
+ // ============================
+ eValueTypeScalar, // raw scalar value
+ eValueTypeVector, // byte array of m_vector.length with endianness of
+ // m_vector.byte_order
+ eValueTypeFileAddress, // file address value
+ eValueTypeLoadAddress, // load address value
+ eValueTypeHostAddress // host address value (for memory in the process that
+ // is using liblldb)
+ };
+
+ enum ContextType // Type that describes Value::m_context
+ {
+ // m_context contains...
+ // ====================
+ eContextTypeInvalid, // undefined
+ eContextTypeRegisterInfo, // RegisterInfo * (can be a scalar or a vector
+ // register)
+ eContextTypeLLDBType, // lldb_private::Type *
+ eContextTypeVariable // lldb_private::Variable *
+ };
+
+ const static size_t kMaxByteSize = 32u;
+
+ struct Vector {
+ // The byte array must be big enough to hold vector registers for any
+ // supported target.
+ uint8_t bytes[kMaxByteSize];
+ size_t length;
+ lldb::ByteOrder byte_order;
+
+ Vector() : length(0), byte_order(lldb::eByteOrderInvalid) {}
+
+ Vector(const Vector &vector) { *this = vector; }
+ const Vector &operator=(const Vector &vector) {
+ SetBytes(vector.bytes, vector.length, vector.byte_order);
+ return *this;
}
- void
- SetValueType (ValueType value_type)
- {
- m_value_type = value_type;
- }
+ void Clear() { length = 0; }
- void
- ClearContext ()
- {
- m_context = nullptr;
- m_context_type = eContextTypeInvalid;
+ bool SetBytes(const void *bytes, size_t length,
+ lldb::ByteOrder byte_order) {
+ this->length = length;
+ this->byte_order = byte_order;
+ if (length)
+ ::memcpy(this->bytes, bytes,
+ length < kMaxByteSize ? length : kMaxByteSize);
+ return IsValid();
}
- void
- SetContext (ContextType context_type, void *p)
- {
- m_context_type = context_type;
- m_context = p;
- if (m_context_type == eContextTypeRegisterInfo) {
- RegisterInfo *reg_info = GetRegisterInfo();
- if (reg_info->encoding == lldb::eEncodingVector &&
- m_vector.byte_order != lldb::eByteOrderInvalid)
- SetValueType(eValueTypeScalar);
- }
+ bool IsValid() const {
+ return (length > 0 && length < kMaxByteSize &&
+ byte_order != lldb::eByteOrderInvalid);
+ }
+ // Casts a vector, if valid, to an unsigned int of matching or largest
+ // supported size.
+ // Truncates to the beginning of the vector if required.
+ // Returns a default constructed Scalar if the Vector data is internally
+ // inconsistent.
+ llvm::APInt rhs = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
+ ((type128 *)bytes)->x);
+ Scalar GetAsScalar() const {
+ Scalar scalar;
+ if (IsValid()) {
+ if (length == 1)
+ scalar = *(const uint8_t *)bytes;
+ else if (length == 2)
+ scalar = *(const uint16_t *)bytes;
+ else if (length == 4)
+ scalar = *(const uint32_t *)bytes;
+ else if (length == 8)
+ scalar = *(const uint64_t *)bytes;
+ else if (length >= 16)
+ scalar = rhs;
+ }
+ return scalar;
}
+ };
- RegisterInfo *
- GetRegisterInfo() const;
+ Value();
+ Value(const Scalar &scalar);
+ Value(const Vector &vector);
+ Value(const void *bytes, int len);
+ Value(const Value &rhs);
- Type *
- GetType();
+ void SetBytes(const void *bytes, int len);
- Scalar &
- ResolveValue (ExecutionContext *exe_ctx);
+ void AppendBytes(const void *bytes, int len);
- const Scalar &
- GetScalar() const
- {
- return m_value;
- }
-
- const Vector &
- GetVector() const
- {
- return m_vector;
- }
-
- Scalar &
- GetScalar()
- {
- return m_value;
- }
-
- Vector &
- GetVector()
- {
- return m_vector;
- }
+ Value &operator=(const Value &rhs);
- bool
- SetVectorBytes(const Vector& vector)
- {
- m_vector = vector;
- return m_vector.IsValid();
- }
-
- bool
- SetVectorBytes(uint8_t *bytes, size_t length, lldb::ByteOrder byte_order)
- {
- return m_vector.SetBytes(bytes, length, byte_order);
- }
+ const CompilerType &GetCompilerType();
- bool
- SetScalarFromVector()
- {
- if (m_vector.IsValid())
- {
- m_value = m_vector.GetAsScalar();
- return true;
- }
- return false;
- }
+ void SetCompilerType(const CompilerType &compiler_type);
+
+ ValueType GetValueType() const;
+
+ AddressType GetValueAddressType() const;
+
+ ContextType GetContextType() const { return m_context_type; }
+
+ void SetValueType(ValueType value_type) { m_value_type = value_type; }
- size_t
- ResizeData(size_t len);
-
- size_t
- AppendDataToHostBuffer (const Value &rhs);
+ void ClearContext() {
+ m_context = nullptr;
+ m_context_type = eContextTypeInvalid;
+ }
- DataBufferHeap &
- GetBuffer ()
- {
- return m_data_buffer;
+ void SetContext(ContextType context_type, void *p) {
+ m_context_type = context_type;
+ m_context = p;
+ if (m_context_type == eContextTypeRegisterInfo) {
+ RegisterInfo *reg_info = GetRegisterInfo();
+ if (reg_info->encoding == lldb::eEncodingVector &&
+ m_vector.byte_order != lldb::eByteOrderInvalid)
+ SetValueType(eValueTypeScalar);
}
+ }
- const DataBufferHeap &
- GetBuffer () const
- {
- return m_data_buffer;
+ RegisterInfo *GetRegisterInfo() const;
+
+ Type *GetType();
+
+ Scalar &ResolveValue(ExecutionContext *exe_ctx);
+
+ const Scalar &GetScalar() const { return m_value; }
+
+ const Vector &GetVector() const { return m_vector; }
+
+ Scalar &GetScalar() { return m_value; }
+
+ Vector &GetVector() { return m_vector; }
+
+ bool SetVectorBytes(const Vector &vector) {
+ m_vector = vector;
+ return m_vector.IsValid();
+ }
+
+ bool SetVectorBytes(uint8_t *bytes, size_t length,
+ lldb::ByteOrder byte_order) {
+ return m_vector.SetBytes(bytes, length, byte_order);
+ }
+
+ bool SetScalarFromVector() {
+ if (m_vector.IsValid()) {
+ m_value = m_vector.GetAsScalar();
+ return true;
}
+ return false;
+ }
+
+ size_t ResizeData(size_t len);
+
+ size_t AppendDataToHostBuffer(const Value &rhs);
- bool
- ValueOf(ExecutionContext *exe_ctx);
+ DataBufferHeap &GetBuffer() { return m_data_buffer; }
- Variable *
- GetVariable();
+ const DataBufferHeap &GetBuffer() const { return m_data_buffer; }
- void
- Dump (Stream* strm);
+ bool ValueOf(ExecutionContext *exe_ctx);
- lldb::Format
- GetValueDefaultFormat ();
+ Variable *GetVariable();
- uint64_t
- GetValueByteSize (Error *error_ptr, ExecutionContext *exe_ctx);
+ void Dump(Stream *strm);
- Error
- GetValueAsData(ExecutionContext *exe_ctx,
- DataExtractor &data,
- uint32_t data_offset,
- Module *module); // Can be nullptr
+ lldb::Format GetValueDefaultFormat();
- static const char *
- GetValueTypeAsCString (ValueType context_type);
+ uint64_t GetValueByteSize(Error *error_ptr, ExecutionContext *exe_ctx);
- static const char *
- GetContextTypeAsCString (ContextType context_type);
+ Error GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data,
+ uint32_t data_offset,
+ Module *module); // Can be nullptr
- bool
- GetData (DataExtractor &data);
+ static const char *GetValueTypeAsCString(ValueType context_type);
- void
- Clear();
+ static const char *GetContextTypeAsCString(ContextType context_type);
+
+ bool GetData(DataExtractor &data);
+
+ void Clear();
protected:
- Scalar m_value;
- Vector m_vector;
- CompilerType m_compiler_type;
- void * m_context;
- ValueType m_value_type;
- ContextType m_context_type;
- DataBufferHeap m_data_buffer;
+ Scalar m_value;
+ Vector m_vector;
+ CompilerType m_compiler_type;
+ void *m_context;
+ ValueType m_value_type;
+ ContextType m_context_type;
+ DataBufferHeap m_data_buffer;
};
-class ValueList
-{
+class ValueList {
public:
- ValueList () :
- m_values()
- {
- }
+ ValueList() : m_values() {}
- ValueList (const ValueList &rhs);
+ ValueList(const ValueList &rhs);
- ~ValueList() = default;
+ ~ValueList() = default;
- const ValueList & operator= (const ValueList &rhs);
+ const ValueList &operator=(const ValueList &rhs);
- // void InsertValue (Value *value, size_t idx);
- void PushValue (const Value &value);
+ // void InsertValue (Value *value, size_t idx);
+ void PushValue(const Value &value);
- size_t GetSize ();
- Value *GetValueAtIndex(size_t idx);
- void Clear();
+ size_t GetSize();
+ Value *GetValueAtIndex(size_t idx);
+ void Clear();
private:
- typedef std::vector<Value> collection;
+ typedef std::vector<Value> collection;
- collection m_values;
+ collection m_values;
};
} // namespace lldb_private
diff --git a/include/lldb/Core/ValueObject.h b/include/lldb/Core/ValueObject.h
index bef158feb39d..84b187e54b6c 100644
--- a/include/lldb/Core/ValueObject.h
+++ b/include/lldb/Core/ValueObject.h
@@ -22,11 +22,10 @@
#include "llvm/ADT/SmallVector.h"
// Project includes
-#include "lldb/lldb-private.h"
+#include "lldb/Core/ConstString.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Flags.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/UserID.h"
#include "lldb/Core/Value.h"
#include "lldb/Symbol/CompilerType.h"
@@ -35,1261 +34,1023 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/StackID.h"
#include "lldb/Utility/SharedCluster.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
/// ValueObject:
///
-/// This abstract class provides an interface to a particular value, be it a register, a local or global variable,
-/// that is evaluated in some particular scope. The ValueObject also has the capability of being the "child" of
-/// some other variable object, and in turn of having children.
-/// If a ValueObject is a root variable object - having no parent - then it must be constructed with respect to some
-/// particular ExecutionContextScope. If it is a child, it inherits the ExecutionContextScope from its parent.
-/// The ValueObject will update itself if necessary before fetching its value, summary, object description, etc.
-/// But it will always update itself in the ExecutionContextScope with which it was originally created.
-
-/// A brief note on life cycle management for ValueObjects. This is a little tricky because a ValueObject can contain
-/// various other ValueObjects - the Dynamic Value, its children, the dereference value, etc. Any one of these can be
-/// handed out as a shared pointer, but for that contained value object to be valid, the root object and potentially other
-/// of the value objects need to stay around.
-/// We solve this problem by handing out shared pointers to the Value Object and any of its dependents using a shared
-/// ClusterManager. This treats each shared pointer handed out for the entire cluster as a reference to the whole
-/// cluster. The whole cluster will stay around until the last reference is released.
+/// This abstract class provides an interface to a particular value, be it a
+/// register, a local or global variable,
+/// that is evaluated in some particular scope. The ValueObject also has the
+/// capability of being the "child" of
+/// some other variable object, and in turn of having children.
+/// If a ValueObject is a root variable object - having no parent - then it must
+/// be constructed with respect to some
+/// particular ExecutionContextScope. If it is a child, it inherits the
+/// ExecutionContextScope from its parent.
+/// The ValueObject will update itself if necessary before fetching its value,
+/// summary, object description, etc.
+/// But it will always update itself in the ExecutionContextScope with which it
+/// was originally created.
+
+/// A brief note on life cycle management for ValueObjects. This is a little
+/// tricky because a ValueObject can contain
+/// various other ValueObjects - the Dynamic Value, its children, the
+/// dereference value, etc. Any one of these can be
+/// handed out as a shared pointer, but for that contained value object to be
+/// valid, the root object and potentially other
+/// of the value objects need to stay around.
+/// We solve this problem by handing out shared pointers to the Value Object and
+/// any of its dependents using a shared
+/// ClusterManager. This treats each shared pointer handed out for the entire
+/// cluster as a reference to the whole
+/// cluster. The whole cluster will stay around until the last reference is
+/// released.
///
-/// The ValueObject mostly handle this automatically, if a value object is made with a Parent ValueObject, then it adds
+/// The ValueObject mostly handle this automatically, if a value object is made
+/// with a Parent ValueObject, then it adds
/// itself to the ClusterManager of the parent.
-/// It does mean that external to the ValueObjects we should only ever make available ValueObjectSP's, never ValueObjects
-/// or pointers to them. So all the "Root level" ValueObject derived constructors should be private, and
-/// should implement a Create function that new's up object and returns a Shared Pointer that it gets from the GetSP() method.
+/// It does mean that external to the ValueObjects we should only ever make
+/// available ValueObjectSP's, never ValueObjects
+/// or pointers to them. So all the "Root level" ValueObject derived
+/// constructors should be private, and
+/// should implement a Create function that new's up object and returns a Shared
+/// Pointer that it gets from the GetSP() method.
///
-/// However, if you are making an derived ValueObject that will be contained in a parent value object, you should just
-/// hold onto a pointer to it internally, and by virtue of passing the parent ValueObject into its constructor, it will
-/// be added to the ClusterManager for the parent. Then if you ever hand out a Shared Pointer to the contained ValueObject,
+/// However, if you are making an derived ValueObject that will be contained in
+/// a parent value object, you should just
+/// hold onto a pointer to it internally, and by virtue of passing the parent
+/// ValueObject into its constructor, it will
+/// be added to the ClusterManager for the parent. Then if you ever hand out a
+/// Shared Pointer to the contained ValueObject,
/// just do so by calling GetSP() on the contained object.
-class ValueObject : public UserID
-{
+class ValueObject : public UserID {
public:
- enum GetExpressionPathFormat
- {
- eGetExpressionPathFormatDereferencePointers = 1,
- eGetExpressionPathFormatHonorPointers
- };
-
- enum ValueObjectRepresentationStyle
- {
- eValueObjectRepresentationStyleValue = 1,
- eValueObjectRepresentationStyleSummary,
- eValueObjectRepresentationStyleLanguageSpecific,
- eValueObjectRepresentationStyleLocation,
- eValueObjectRepresentationStyleChildrenCount,
- eValueObjectRepresentationStyleType,
- eValueObjectRepresentationStyleName,
- eValueObjectRepresentationStyleExpressionPath
- };
-
- enum ExpressionPathScanEndReason
- {
- eExpressionPathScanEndReasonEndOfString = 1, // out of data to parse
- eExpressionPathScanEndReasonNoSuchChild, // child element not found
- eExpressionPathScanEndReasonNoSuchSyntheticChild, // (synthetic) child element not found
- eExpressionPathScanEndReasonEmptyRangeNotAllowed, // [] only allowed for arrays
- eExpressionPathScanEndReasonDotInsteadOfArrow, // . used when -> should be used
- eExpressionPathScanEndReasonArrowInsteadOfDot, // -> used when . should be used
- eExpressionPathScanEndReasonFragileIVarNotAllowed, // ObjC ivar expansion not allowed
- eExpressionPathScanEndReasonRangeOperatorNotAllowed, // [] not allowed by options
- eExpressionPathScanEndReasonRangeOperatorInvalid, // [] not valid on objects other than scalars, pointers or arrays
- eExpressionPathScanEndReasonArrayRangeOperatorMet, // [] is good for arrays, but I cannot parse it
- eExpressionPathScanEndReasonBitfieldRangeOperatorMet, // [] is good for bitfields, but I cannot parse after it
- eExpressionPathScanEndReasonUnexpectedSymbol, // something is malformed in the expression
- eExpressionPathScanEndReasonTakingAddressFailed, // impossible to apply & operator
- eExpressionPathScanEndReasonDereferencingFailed, // impossible to apply * operator
- eExpressionPathScanEndReasonRangeOperatorExpanded, // [] was expanded into a VOList
- eExpressionPathScanEndReasonSyntheticValueMissing, // getting the synthetic children failed
- eExpressionPathScanEndReasonUnknown = 0xFFFF
- };
-
- enum ExpressionPathEndResultType
- {
- eExpressionPathEndResultTypePlain = 1, // anything but...
- eExpressionPathEndResultTypeBitfield, // a bitfield
- eExpressionPathEndResultTypeBoundedRange, // a range [low-high]
- eExpressionPathEndResultTypeUnboundedRange, // a range []
- eExpressionPathEndResultTypeValueObjectList, // several items in a VOList
- eExpressionPathEndResultTypeInvalid = 0xFFFF
- };
-
- enum ExpressionPathAftermath
- {
- eExpressionPathAftermathNothing = 1, // just return it
- eExpressionPathAftermathDereference, // dereference the target
- eExpressionPathAftermathTakeAddress // take target's address
- };
-
- enum ClearUserVisibleDataItems
- {
- eClearUserVisibleDataItemsNothing = 1u << 0,
- eClearUserVisibleDataItemsValue = 1u << 1,
- eClearUserVisibleDataItemsSummary = 1u << 2,
- eClearUserVisibleDataItemsLocation = 1u << 3,
- eClearUserVisibleDataItemsDescription = 1u << 4,
- eClearUserVisibleDataItemsSyntheticChildren = 1u << 5,
- eClearUserVisibleDataItemsValidator = 1u << 6,
- eClearUserVisibleDataItemsAllStrings = eClearUserVisibleDataItemsValue | eClearUserVisibleDataItemsSummary | eClearUserVisibleDataItemsLocation | eClearUserVisibleDataItemsDescription,
- eClearUserVisibleDataItemsAll = 0xFFFF
+ enum GetExpressionPathFormat {
+ eGetExpressionPathFormatDereferencePointers = 1,
+ eGetExpressionPathFormatHonorPointers
+ };
+
+ enum ValueObjectRepresentationStyle {
+ eValueObjectRepresentationStyleValue = 1,
+ eValueObjectRepresentationStyleSummary,
+ eValueObjectRepresentationStyleLanguageSpecific,
+ eValueObjectRepresentationStyleLocation,
+ eValueObjectRepresentationStyleChildrenCount,
+ eValueObjectRepresentationStyleType,
+ eValueObjectRepresentationStyleName,
+ eValueObjectRepresentationStyleExpressionPath
+ };
+
+ enum ExpressionPathScanEndReason {
+ eExpressionPathScanEndReasonEndOfString = 1, // out of data to parse
+ eExpressionPathScanEndReasonNoSuchChild, // child element not found
+ eExpressionPathScanEndReasonNoSuchSyntheticChild, // (synthetic) child
+ // element not found
+ eExpressionPathScanEndReasonEmptyRangeNotAllowed, // [] only allowed for
+ // arrays
+ eExpressionPathScanEndReasonDotInsteadOfArrow, // . used when -> should be
+ // used
+ eExpressionPathScanEndReasonArrowInsteadOfDot, // -> used when . should be
+ // used
+ eExpressionPathScanEndReasonFragileIVarNotAllowed, // ObjC ivar expansion
+ // not allowed
+ eExpressionPathScanEndReasonRangeOperatorNotAllowed, // [] not allowed by
+ // options
+ eExpressionPathScanEndReasonRangeOperatorInvalid, // [] not valid on objects
+ // other than scalars,
+ // pointers or arrays
+ eExpressionPathScanEndReasonArrayRangeOperatorMet, // [] is good for arrays,
+ // but I cannot parse it
+ eExpressionPathScanEndReasonBitfieldRangeOperatorMet, // [] is good for
+ // bitfields, but I
+ // cannot parse after
+ // it
+ eExpressionPathScanEndReasonUnexpectedSymbol, // something is malformed in
+ // the expression
+ eExpressionPathScanEndReasonTakingAddressFailed, // impossible to apply &
+ // operator
+ eExpressionPathScanEndReasonDereferencingFailed, // impossible to apply *
+ // operator
+ eExpressionPathScanEndReasonRangeOperatorExpanded, // [] was expanded into a
+ // VOList
+ eExpressionPathScanEndReasonSyntheticValueMissing, // getting the synthetic
+ // children failed
+ eExpressionPathScanEndReasonUnknown = 0xFFFF
+ };
+
+ enum ExpressionPathEndResultType {
+ eExpressionPathEndResultTypePlain = 1, // anything but...
+ eExpressionPathEndResultTypeBitfield, // a bitfield
+ eExpressionPathEndResultTypeBoundedRange, // a range [low-high]
+ eExpressionPathEndResultTypeUnboundedRange, // a range []
+ eExpressionPathEndResultTypeValueObjectList, // several items in a VOList
+ eExpressionPathEndResultTypeInvalid = 0xFFFF
+ };
+
+ enum ExpressionPathAftermath {
+ eExpressionPathAftermathNothing = 1, // just return it
+ eExpressionPathAftermathDereference, // dereference the target
+ eExpressionPathAftermathTakeAddress // take target's address
+ };
+
+ enum ClearUserVisibleDataItems {
+ eClearUserVisibleDataItemsNothing = 1u << 0,
+ eClearUserVisibleDataItemsValue = 1u << 1,
+ eClearUserVisibleDataItemsSummary = 1u << 2,
+ eClearUserVisibleDataItemsLocation = 1u << 3,
+ eClearUserVisibleDataItemsDescription = 1u << 4,
+ eClearUserVisibleDataItemsSyntheticChildren = 1u << 5,
+ eClearUserVisibleDataItemsValidator = 1u << 6,
+ eClearUserVisibleDataItemsAllStrings =
+ eClearUserVisibleDataItemsValue | eClearUserVisibleDataItemsSummary |
+ eClearUserVisibleDataItemsLocation |
+ eClearUserVisibleDataItemsDescription,
+ eClearUserVisibleDataItemsAll = 0xFFFF
+ };
+
+ struct GetValueForExpressionPathOptions {
+ enum class SyntheticChildrenTraversal {
+ None,
+ ToSynthetic,
+ FromSynthetic,
+ Both
};
-
- struct GetValueForExpressionPathOptions
- {
- enum class SyntheticChildrenTraversal
- {
- None,
- ToSynthetic,
- FromSynthetic,
- Both
- };
-
- bool m_check_dot_vs_arrow_syntax;
- bool m_no_fragile_ivar;
- bool m_allow_bitfields_syntax;
- SyntheticChildrenTraversal m_synthetic_children_traversal;
-
- GetValueForExpressionPathOptions(bool dot = false,
- bool no_ivar = false,
- bool bitfield = true,
- SyntheticChildrenTraversal synth_traverse = SyntheticChildrenTraversal::ToSynthetic) :
- m_check_dot_vs_arrow_syntax(dot),
- m_no_fragile_ivar(no_ivar),
- m_allow_bitfields_syntax(bitfield),
- m_synthetic_children_traversal(synth_traverse)
- {
- }
-
- GetValueForExpressionPathOptions&
- DoCheckDotVsArrowSyntax()
- {
- m_check_dot_vs_arrow_syntax = true;
- return *this;
- }
-
- GetValueForExpressionPathOptions&
- DontCheckDotVsArrowSyntax()
- {
- m_check_dot_vs_arrow_syntax = false;
- return *this;
- }
-
- GetValueForExpressionPathOptions&
- DoAllowFragileIVar()
- {
- m_no_fragile_ivar = false;
- return *this;
- }
-
- GetValueForExpressionPathOptions&
- DontAllowFragileIVar()
- {
- m_no_fragile_ivar = true;
- return *this;
- }
-
- GetValueForExpressionPathOptions&
- DoAllowBitfieldSyntax()
- {
- m_allow_bitfields_syntax = true;
- return *this;
- }
-
- GetValueForExpressionPathOptions&
- DontAllowBitfieldSyntax()
- {
- m_allow_bitfields_syntax = false;
- return *this;
- }
-
- GetValueForExpressionPathOptions&
- SetSyntheticChildrenTraversal(SyntheticChildrenTraversal traverse)
- {
- m_synthetic_children_traversal = traverse;
- return *this;
- }
-
- static const GetValueForExpressionPathOptions
- DefaultOptions()
- {
- static GetValueForExpressionPathOptions g_default_options;
-
- return g_default_options;
- }
- };
-
- class EvaluationPoint
- {
- public:
- EvaluationPoint ();
-
- EvaluationPoint (ExecutionContextScope *exe_scope, bool use_selected = false);
-
- EvaluationPoint (const EvaluationPoint &rhs);
-
- ~EvaluationPoint ();
-
- const ExecutionContextRef &
- GetExecutionContextRef() const
- {
- return m_exe_ctx_ref;
- }
-
- // Set the EvaluationPoint to the values in exe_scope,
- // Return true if the Evaluation Point changed.
- // Since the ExecutionContextScope is always going to be valid currently,
- // the Updated Context will also always be valid.
-
-// bool
-// SetContext (ExecutionContextScope *exe_scope);
-
- void
- SetIsConstant ()
- {
- SetUpdated();
- m_mod_id.SetInvalid();
- }
-
- bool
- IsConstant () const
- {
- return !m_mod_id.IsValid();
- }
-
- ProcessModID
- GetModID () const
- {
- return m_mod_id;
- }
-
- void
- SetUpdateID (ProcessModID new_id)
- {
- m_mod_id = new_id;
- }
-
- void
- SetNeedsUpdate ()
- {
- m_needs_update = true;
- }
-
- void
- SetUpdated ();
-
- bool
- NeedsUpdating(bool accept_invalid_exe_ctx)
- {
- SyncWithProcessState(accept_invalid_exe_ctx);
- return m_needs_update;
- }
-
- bool
- IsValid ()
- {
- const bool accept_invalid_exe_ctx = false;
- if (!m_mod_id.IsValid())
- return false;
- else if (SyncWithProcessState (accept_invalid_exe_ctx))
- {
- if (!m_mod_id.IsValid())
- return false;
- }
- return true;
- }
-
- void
- SetInvalid ()
- {
- // Use the stop id to mark us as invalid, leave the thread id and the stack id around for logging and
- // history purposes.
- m_mod_id.SetInvalid();
-
- // Can't update an invalid state.
- m_needs_update = false;
-
- }
-
- private:
- bool
- SyncWithProcessState (bool accept_invalid_exe_ctx);
-
- ProcessModID m_mod_id; // This is the stop id when this ValueObject was last evaluated.
- ExecutionContextRef m_exe_ctx_ref;
- bool m_needs_update;
- };
-
- virtual ~ValueObject();
- const EvaluationPoint &
- GetUpdatePoint () const
- {
- return m_update_point;
- }
-
- EvaluationPoint &
- GetUpdatePoint ()
- {
- return m_update_point;
- }
-
- const ExecutionContextRef &
- GetExecutionContextRef() const
- {
- return m_update_point.GetExecutionContextRef();
+ bool m_check_dot_vs_arrow_syntax;
+ bool m_no_fragile_ivar;
+ bool m_allow_bitfields_syntax;
+ SyntheticChildrenTraversal m_synthetic_children_traversal;
+
+ GetValueForExpressionPathOptions(
+ bool dot = false, bool no_ivar = false, bool bitfield = true,
+ SyntheticChildrenTraversal synth_traverse =
+ SyntheticChildrenTraversal::ToSynthetic)
+ : m_check_dot_vs_arrow_syntax(dot), m_no_fragile_ivar(no_ivar),
+ m_allow_bitfields_syntax(bitfield),
+ m_synthetic_children_traversal(synth_traverse) {}
+
+ GetValueForExpressionPathOptions &DoCheckDotVsArrowSyntax() {
+ m_check_dot_vs_arrow_syntax = true;
+ return *this;
}
- lldb::TargetSP
- GetTargetSP() const
- {
- return m_update_point.GetExecutionContextRef().GetTargetSP();
+ GetValueForExpressionPathOptions &DontCheckDotVsArrowSyntax() {
+ m_check_dot_vs_arrow_syntax = false;
+ return *this;
}
- lldb::ProcessSP
- GetProcessSP() const
- {
- return m_update_point.GetExecutionContextRef().GetProcessSP();
+ GetValueForExpressionPathOptions &DoAllowFragileIVar() {
+ m_no_fragile_ivar = false;
+ return *this;
}
- lldb::ThreadSP
- GetThreadSP() const
- {
- return m_update_point.GetExecutionContextRef().GetThreadSP();
+ GetValueForExpressionPathOptions &DontAllowFragileIVar() {
+ m_no_fragile_ivar = true;
+ return *this;
}
- lldb::StackFrameSP
- GetFrameSP() const
- {
- return m_update_point.GetExecutionContextRef().GetFrameSP();
+ GetValueForExpressionPathOptions &DoAllowBitfieldSyntax() {
+ m_allow_bitfields_syntax = true;
+ return *this;
}
- void
- SetNeedsUpdate ();
-
- CompilerType
- GetCompilerType ();
-
- // this vends a TypeImpl that is useful at the SB API layer
- virtual TypeImpl
- GetTypeImpl ();
-
- virtual bool
- CanProvideValue ();
-
- //------------------------------------------------------------------
- // Subclasses must implement the functions below.
- //------------------------------------------------------------------
- virtual uint64_t
- GetByteSize() = 0;
-
- virtual lldb::ValueType
- GetValueType() const = 0;
-
- //------------------------------------------------------------------
- // Subclasses can implement the functions below.
- //------------------------------------------------------------------
- virtual ConstString
- GetTypeName();
-
- virtual ConstString
- GetDisplayTypeName();
-
- virtual ConstString
- GetQualifiedTypeName();
-
- virtual lldb::LanguageType
- GetObjectRuntimeLanguage();
-
- virtual uint32_t
- GetTypeInfo(CompilerType *pointee_or_element_compiler_type = nullptr);
-
- virtual bool
- IsPointerType ();
-
- virtual bool
- IsArrayType ();
-
- virtual bool
- IsScalarType ();
-
- virtual bool
- IsPointerOrReferenceType ();
-
- virtual bool
- IsPossibleDynamicType ();
-
- bool
- IsNilReference ();
-
- bool
- IsUninitializedReference ();
-
- virtual bool
- IsBaseClass ()
- {
- return false;
- }
-
- bool
- IsBaseClass (uint32_t& depth);
-
- virtual bool
- IsDereferenceOfParent ()
- {
- return false;
- }
-
- bool
- IsIntegerType (bool &is_signed);
-
- virtual bool
- GetBaseClassPath (Stream &s);
-
- virtual void
- GetExpressionPath (Stream &s, bool qualify_cxx_base_classes, GetExpressionPathFormat = eGetExpressionPathFormatDereferencePointers);
-
- lldb::ValueObjectSP
- GetValueForExpressionPath(const char* expression,
- const char** first_unparsed = nullptr,
- ExpressionPathScanEndReason* reason_to_stop = nullptr,
- ExpressionPathEndResultType* final_value_type = nullptr,
- const GetValueForExpressionPathOptions& options = GetValueForExpressionPathOptions::DefaultOptions(),
- ExpressionPathAftermath* final_task_on_target = nullptr);
-
- int
- GetValuesForExpressionPath(const char* expression,
- lldb::ValueObjectListSP& list,
- const char** first_unparsed = nullptr,
- ExpressionPathScanEndReason* reason_to_stop = nullptr,
- ExpressionPathEndResultType* final_value_type = nullptr,
- const GetValueForExpressionPathOptions& options = GetValueForExpressionPathOptions::DefaultOptions(),
- ExpressionPathAftermath* final_task_on_target = nullptr);
-
- virtual bool
- IsInScope ()
- {
- return true;
+ GetValueForExpressionPathOptions &DontAllowBitfieldSyntax() {
+ m_allow_bitfields_syntax = false;
+ return *this;
}
- virtual lldb::offset_t
- GetByteOffset()
- {
- return 0;
+ GetValueForExpressionPathOptions &
+ SetSyntheticChildrenTraversal(SyntheticChildrenTraversal traverse) {
+ m_synthetic_children_traversal = traverse;
+ return *this;
}
- virtual uint32_t
- GetBitfieldBitSize ()
- {
- return 0;
- }
+ static const GetValueForExpressionPathOptions DefaultOptions() {
+ static GetValueForExpressionPathOptions g_default_options;
- virtual uint32_t
- GetBitfieldBitOffset ()
- {
- return 0;
- }
-
- bool
- IsBitfield ()
- {
- return (GetBitfieldBitSize() != 0) || (GetBitfieldBitOffset() != 0);
+ return g_default_options;
}
-
- virtual bool
- IsArrayItemForPointer()
- {
- return m_is_array_item_for_pointer;
- }
-
- virtual const char *
- GetValueAsCString ();
-
- virtual bool
- GetValueAsCString (const lldb_private::TypeFormatImpl& format,
- std::string& destination);
-
- bool
- GetValueAsCString (lldb::Format format,
- std::string& destination);
-
- virtual uint64_t
- GetValueAsUnsigned(uint64_t fail_value, bool *success = nullptr);
-
- virtual int64_t
- GetValueAsSigned(int64_t fail_value, bool *success = nullptr);
-
- virtual bool
- SetValueFromCString (const char *value_str, Error& error);
-
- // Return the module associated with this value object in case the
- // value is from an executable file and might have its data in
- // sections of the file. This can be used for variables.
- virtual lldb::ModuleSP
- GetModule();
-
- ValueObject*
- GetRoot ();
-
- // Given a ValueObject, loop over itself and its parent, and its parent's parent, ..
- // until either the given callback returns false, or you end up at a null pointer
- ValueObject*
- FollowParentChain (std::function<bool(ValueObject*)>);
-
- virtual bool
- GetDeclaration (Declaration &decl);
-
- //------------------------------------------------------------------
- // The functions below should NOT be modified by subclasses
- //------------------------------------------------------------------
- const Error &
- GetError();
-
- const ConstString &
- GetName() const;
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx, bool can_create);
-
- // this will always create the children if necessary
- lldb::ValueObjectSP
- GetChildAtIndexPath(const std::initializer_list<size_t> &idxs,
- size_t* index_of_error = nullptr);
-
- lldb::ValueObjectSP
- GetChildAtIndexPath(const std::vector<size_t> &idxs,
- size_t* index_of_error = nullptr);
-
- lldb::ValueObjectSP
- GetChildAtIndexPath(const std::initializer_list< std::pair<size_t, bool> > &idxs,
- size_t* index_of_error = nullptr);
-
- lldb::ValueObjectSP
- GetChildAtIndexPath(const std::vector< std::pair<size_t, bool> > &idxs,
- size_t* index_of_error = nullptr);
-
- // this will always create the children if necessary
- lldb::ValueObjectSP
- GetChildAtNamePath(const std::initializer_list<ConstString> &names,
- ConstString* name_of_error = nullptr);
-
- lldb::ValueObjectSP
- GetChildAtNamePath(const std::vector<ConstString> &names,
- ConstString* name_of_error = nullptr);
-
- lldb::ValueObjectSP
- GetChildAtNamePath(const std::initializer_list< std::pair<ConstString, bool> > &names,
- ConstString* name_of_error = nullptr);
-
- lldb::ValueObjectSP
- GetChildAtNamePath(const std::vector< std::pair<ConstString, bool> > &names,
- ConstString* name_of_error = nullptr);
-
- virtual lldb::ValueObjectSP
- GetChildMemberWithName (const ConstString &name, bool can_create);
-
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
-
- size_t
- GetNumChildren (uint32_t max=UINT32_MAX);
-
- const Value &
- GetValue() const;
-
- Value &
- GetValue();
-
- virtual bool
- ResolveValue (Scalar &scalar);
-
- // return 'false' whenever you set the error, otherwise
- // callers may assume true means everything is OK - this will
- // break breakpoint conditions among potentially a few others
- virtual bool
- IsLogicalTrue (Error& error);
-
- virtual const char *
- GetLocationAsCString ();
-
- const char *
- GetSummaryAsCString (lldb::LanguageType lang = lldb::eLanguageTypeUnknown);
-
- bool
- GetSummaryAsCString (TypeSummaryImpl* summary_ptr,
- std::string& destination,
- lldb::LanguageType lang = lldb::eLanguageTypeUnknown);
-
- bool
- GetSummaryAsCString (std::string& destination,
- const TypeSummaryOptions& options);
-
- bool
- GetSummaryAsCString (TypeSummaryImpl* summary_ptr,
- std::string& destination,
- const TypeSummaryOptions& options);
-
- std::pair<TypeValidatorResult, std::string>
- GetValidationStatus ();
-
- const char *
- GetObjectDescription ();
-
- bool
- HasSpecialPrintableRepresentation (ValueObjectRepresentationStyle val_obj_display,
- lldb::Format custom_format);
-
- enum PrintableRepresentationSpecialCases
- {
- ePrintableRepresentationSpecialCasesDisable = 0,
- ePrintableRepresentationSpecialCasesAllow = 1,
- ePrintableRepresentationSpecialCasesOnly = 3
- };
-
- bool
- DumpPrintableRepresentation (Stream& s,
- ValueObjectRepresentationStyle val_obj_display = eValueObjectRepresentationStyleSummary,
- lldb::Format custom_format = lldb::eFormatInvalid,
- PrintableRepresentationSpecialCases special = ePrintableRepresentationSpecialCasesAllow,
- bool do_dump_error = true);
- bool
- GetValueIsValid () const;
-
- // If you call this on a newly created ValueObject, it will always return false.
- bool
- GetValueDidChange ();
-
- bool
- UpdateValueIfNeeded (bool update_format = true);
-
- bool
- UpdateFormatsIfNeeded();
+ };
- lldb::ValueObjectSP
- GetSP ()
- {
- return m_manager->GetSharedPointer(this);
- }
-
- void
- SetName (const ConstString &name);
-
- virtual lldb::addr_t
- GetAddressOf(bool scalar_is_load_address = true,
- AddressType *address_type = nullptr);
-
- lldb::addr_t
- GetPointerValue(AddressType *address_type = nullptr);
-
- lldb::ValueObjectSP
- GetSyntheticChild (const ConstString &key) const;
-
- lldb::ValueObjectSP
- GetSyntheticArrayMember (size_t index, bool can_create);
-
- lldb::ValueObjectSP
- GetSyntheticBitFieldChild (uint32_t from, uint32_t to, bool can_create);
-
- lldb::ValueObjectSP
- GetSyntheticExpressionPathChild(const char* expression, bool can_create);
-
- virtual lldb::ValueObjectSP
- GetSyntheticChildAtOffset(uint32_t offset,
- const CompilerType& type,
- bool can_create,
- ConstString name_const_str = ConstString());
-
- virtual lldb::ValueObjectSP
- GetSyntheticBase (uint32_t offset,
- const CompilerType& type,
- bool can_create,
- ConstString name_const_str = ConstString());
-
- virtual lldb::ValueObjectSP
- GetDynamicValue (lldb::DynamicValueType valueType);
-
- lldb::DynamicValueType
- GetDynamicValueType ();
-
- virtual lldb::ValueObjectSP
- GetStaticValue ();
-
- virtual lldb::ValueObjectSP
- GetNonSyntheticValue ();
-
- lldb::ValueObjectSP
- GetSyntheticValue (bool use_synthetic = true);
-
- virtual bool
- HasSyntheticValue();
-
- virtual bool
- IsSynthetic() { return false; }
-
- lldb::ValueObjectSP
- GetQualifiedRepresentationIfAvailable (lldb::DynamicValueType dynValue,
- bool synthValue);
-
- virtual lldb::ValueObjectSP
- CreateConstantValue (const ConstString &name);
-
- virtual lldb::ValueObjectSP
- Dereference (Error &error);
-
- virtual lldb::ValueObjectSP
- AddressOf (Error &error);
-
- virtual lldb::addr_t
- GetLiveAddress()
- {
- return LLDB_INVALID_ADDRESS;
+ class EvaluationPoint {
+ public:
+ EvaluationPoint();
+
+ EvaluationPoint(ExecutionContextScope *exe_scope,
+ bool use_selected = false);
+
+ EvaluationPoint(const EvaluationPoint &rhs);
+
+ ~EvaluationPoint();
+
+ const ExecutionContextRef &GetExecutionContextRef() const {
+ return m_exe_ctx_ref;
}
-
- virtual void
- SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS,
- AddressType address_type = eAddressTypeLoad)
- {
+
+ // Set the EvaluationPoint to the values in exe_scope,
+ // Return true if the Evaluation Point changed.
+ // Since the ExecutionContextScope is always going to be valid currently,
+ // the Updated Context will also always be valid.
+
+ // bool
+ // SetContext (ExecutionContextScope *exe_scope);
+
+ void SetIsConstant() {
+ SetUpdated();
+ m_mod_id.SetInvalid();
}
- // Find the address of the C++ vtable pointer
- virtual lldb::addr_t
- GetCPPVTableAddress(AddressType &address_type);
-
- virtual lldb::ValueObjectSP
- Cast (const CompilerType &compiler_type);
-
- virtual lldb::ValueObjectSP
- CastPointerType (const char *name,
- CompilerType &ast_type);
-
- virtual lldb::ValueObjectSP
- CastPointerType (const char *name,
- lldb::TypeSP &type_sp);
-
- // The backing bits of this value object were updated, clear any
- // descriptive string, so we know we have to refetch them
- virtual void
- ValueUpdated ()
- {
- ClearUserVisibleData(eClearUserVisibleDataItemsValue |
- eClearUserVisibleDataItemsSummary |
- eClearUserVisibleDataItemsDescription);
+ bool IsConstant() const { return !m_mod_id.IsValid(); }
+
+ ProcessModID GetModID() const { return m_mod_id; }
+
+ void SetUpdateID(ProcessModID new_id) { m_mod_id = new_id; }
+
+ void SetNeedsUpdate() { m_needs_update = true; }
+
+ void SetUpdated();
+
+ bool NeedsUpdating(bool accept_invalid_exe_ctx) {
+ SyncWithProcessState(accept_invalid_exe_ctx);
+ return m_needs_update;
}
- virtual bool
- IsDynamic ()
- {
+ bool IsValid() {
+ const bool accept_invalid_exe_ctx = false;
+ if (!m_mod_id.IsValid())
return false;
+ else if (SyncWithProcessState(accept_invalid_exe_ctx)) {
+ if (!m_mod_id.IsValid())
+ return false;
+ }
+ return true;
}
-
- virtual bool
- DoesProvideSyntheticValue ()
- {
- return false;
+
+ void SetInvalid() {
+ // Use the stop id to mark us as invalid, leave the thread id and the
+ // stack id around for logging and
+ // history purposes.
+ m_mod_id.SetInvalid();
+
+ // Can't update an invalid state.
+ m_needs_update = false;
}
-
- virtual bool
- IsSyntheticChildrenGenerated ();
-
- virtual void
- SetSyntheticChildrenGenerated (bool b);
-
- virtual SymbolContextScope *
- GetSymbolContextScope();
-
- void
- Dump (Stream &s);
-
- void
- Dump (Stream &s,
- const DumpValueObjectOptions& options);
-
- static lldb::ValueObjectSP
- CreateValueObjectFromExpression (const char* name,
- const char* expression,
- const ExecutionContext& exe_ctx);
-
- static lldb::ValueObjectSP
- CreateValueObjectFromExpression (const char* name,
- const char* expression,
- const ExecutionContext& exe_ctx,
- const EvaluateExpressionOptions& options);
-
- static lldb::ValueObjectSP
- CreateValueObjectFromAddress (const char* name,
- uint64_t address,
- const ExecutionContext& exe_ctx,
- CompilerType type);
-
- static lldb::ValueObjectSP
- CreateValueObjectFromData (const char* name,
- const DataExtractor& data,
- const ExecutionContext& exe_ctx,
+
+ private:
+ bool SyncWithProcessState(bool accept_invalid_exe_ctx);
+
+ ProcessModID m_mod_id; // This is the stop id when this ValueObject was last
+ // evaluated.
+ ExecutionContextRef m_exe_ctx_ref;
+ bool m_needs_update;
+ };
+
+ virtual ~ValueObject();
+
+ const EvaluationPoint &GetUpdatePoint() const { return m_update_point; }
+
+ EvaluationPoint &GetUpdatePoint() { return m_update_point; }
+
+ const ExecutionContextRef &GetExecutionContextRef() const {
+ return m_update_point.GetExecutionContextRef();
+ }
+
+ lldb::TargetSP GetTargetSP() const {
+ return m_update_point.GetExecutionContextRef().GetTargetSP();
+ }
+
+ lldb::ProcessSP GetProcessSP() const {
+ return m_update_point.GetExecutionContextRef().GetProcessSP();
+ }
+
+ lldb::ThreadSP GetThreadSP() const {
+ return m_update_point.GetExecutionContextRef().GetThreadSP();
+ }
+
+ lldb::StackFrameSP GetFrameSP() const {
+ return m_update_point.GetExecutionContextRef().GetFrameSP();
+ }
+
+ void SetNeedsUpdate();
+
+ CompilerType GetCompilerType();
+
+ // this vends a TypeImpl that is useful at the SB API layer
+ virtual TypeImpl GetTypeImpl();
+
+ virtual bool CanProvideValue();
+
+ //------------------------------------------------------------------
+ // Subclasses must implement the functions below.
+ //------------------------------------------------------------------
+ virtual uint64_t GetByteSize() = 0;
+
+ virtual lldb::ValueType GetValueType() const = 0;
+
+ //------------------------------------------------------------------
+ // Subclasses can implement the functions below.
+ //------------------------------------------------------------------
+ virtual ConstString GetTypeName();
+
+ virtual ConstString GetDisplayTypeName();
+
+ virtual ConstString GetQualifiedTypeName();
+
+ virtual lldb::LanguageType GetObjectRuntimeLanguage();
+
+ virtual uint32_t
+ GetTypeInfo(CompilerType *pointee_or_element_compiler_type = nullptr);
+
+ virtual bool IsPointerType();
+
+ virtual bool IsArrayType();
+
+ virtual bool IsScalarType();
+
+ virtual bool IsPointerOrReferenceType();
+
+ virtual bool IsPossibleDynamicType();
+
+ bool IsNilReference();
+
+ bool IsUninitializedReference();
+
+ virtual bool IsBaseClass() { return false; }
+
+ bool IsBaseClass(uint32_t &depth);
+
+ virtual bool IsDereferenceOfParent() { return false; }
+
+ bool IsIntegerType(bool &is_signed);
+
+ virtual bool GetBaseClassPath(Stream &s);
+
+ virtual void GetExpressionPath(
+ Stream &s, bool qualify_cxx_base_classes,
+ GetExpressionPathFormat = eGetExpressionPathFormatDereferencePointers);
+
+ lldb::ValueObjectSP GetValueForExpressionPath(
+ llvm::StringRef expression,
+ ExpressionPathScanEndReason *reason_to_stop = nullptr,
+ ExpressionPathEndResultType *final_value_type = nullptr,
+ const GetValueForExpressionPathOptions &options =
+ GetValueForExpressionPathOptions::DefaultOptions(),
+ ExpressionPathAftermath *final_task_on_target = nullptr);
+
+ virtual bool IsInScope() { return true; }
+
+ virtual lldb::offset_t GetByteOffset() { return 0; }
+
+ virtual uint32_t GetBitfieldBitSize() { return 0; }
+
+ virtual uint32_t GetBitfieldBitOffset() { return 0; }
+
+ bool IsBitfield() {
+ return (GetBitfieldBitSize() != 0) || (GetBitfieldBitOffset() != 0);
+ }
+
+ virtual bool IsArrayItemForPointer() { return m_is_array_item_for_pointer; }
+
+ virtual const char *GetValueAsCString();
+
+ virtual bool GetValueAsCString(const lldb_private::TypeFormatImpl &format,
+ std::string &destination);
+
+ bool GetValueAsCString(lldb::Format format, std::string &destination);
+
+ virtual uint64_t GetValueAsUnsigned(uint64_t fail_value,
+ bool *success = nullptr);
+
+ virtual int64_t GetValueAsSigned(int64_t fail_value, bool *success = nullptr);
+
+ virtual bool SetValueFromCString(const char *value_str, Error &error);
+
+ // Return the module associated with this value object in case the
+ // value is from an executable file and might have its data in
+ // sections of the file. This can be used for variables.
+ virtual lldb::ModuleSP GetModule();
+
+ ValueObject *GetRoot();
+
+ // Given a ValueObject, loop over itself and its parent, and its parent's
+ // parent, ..
+ // until either the given callback returns false, or you end up at a null
+ // pointer
+ ValueObject *FollowParentChain(std::function<bool(ValueObject *)>);
+
+ virtual bool GetDeclaration(Declaration &decl);
+
+ //------------------------------------------------------------------
+ // The functions below should NOT be modified by subclasses
+ //------------------------------------------------------------------
+ const Error &GetError();
+
+ const ConstString &GetName() const;
+
+ virtual lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create);
+
+ // this will always create the children if necessary
+ lldb::ValueObjectSP
+ GetChildAtIndexPath(const std::initializer_list<size_t> &idxs,
+ size_t *index_of_error = nullptr);
+
+ lldb::ValueObjectSP GetChildAtIndexPath(const std::vector<size_t> &idxs,
+ size_t *index_of_error = nullptr);
+
+ lldb::ValueObjectSP GetChildAtIndexPath(
+ const std::initializer_list<std::pair<size_t, bool>> &idxs,
+ size_t *index_of_error = nullptr);
+
+ lldb::ValueObjectSP
+ GetChildAtIndexPath(const std::vector<std::pair<size_t, bool>> &idxs,
+ size_t *index_of_error = nullptr);
+
+ // this will always create the children if necessary
+ lldb::ValueObjectSP
+ GetChildAtNamePath(const std::initializer_list<ConstString> &names,
+ ConstString *name_of_error = nullptr);
+
+ lldb::ValueObjectSP GetChildAtNamePath(const std::vector<ConstString> &names,
+ ConstString *name_of_error = nullptr);
+
+ lldb::ValueObjectSP GetChildAtNamePath(
+ const std::initializer_list<std::pair<ConstString, bool>> &names,
+ ConstString *name_of_error = nullptr);
+
+ lldb::ValueObjectSP
+ GetChildAtNamePath(const std::vector<std::pair<ConstString, bool>> &names,
+ ConstString *name_of_error = nullptr);
+
+ virtual lldb::ValueObjectSP GetChildMemberWithName(const ConstString &name,
+ bool can_create);
+
+ virtual size_t GetIndexOfChildWithName(const ConstString &name);
+
+ size_t GetNumChildren(uint32_t max = UINT32_MAX);
+
+ const Value &GetValue() const;
+
+ Value &GetValue();
+
+ virtual bool ResolveValue(Scalar &scalar);
+
+ // return 'false' whenever you set the error, otherwise
+ // callers may assume true means everything is OK - this will
+ // break breakpoint conditions among potentially a few others
+ virtual bool IsLogicalTrue(Error &error);
+
+ virtual const char *GetLocationAsCString();
+
+ const char *
+ GetSummaryAsCString(lldb::LanguageType lang = lldb::eLanguageTypeUnknown);
+
+ bool
+ GetSummaryAsCString(TypeSummaryImpl *summary_ptr, std::string &destination,
+ lldb::LanguageType lang = lldb::eLanguageTypeUnknown);
+
+ bool GetSummaryAsCString(std::string &destination,
+ const TypeSummaryOptions &options);
+
+ bool GetSummaryAsCString(TypeSummaryImpl *summary_ptr,
+ std::string &destination,
+ const TypeSummaryOptions &options);
+
+ std::pair<TypeValidatorResult, std::string> GetValidationStatus();
+
+ const char *GetObjectDescription();
+
+ bool HasSpecialPrintableRepresentation(
+ ValueObjectRepresentationStyle val_obj_display,
+ lldb::Format custom_format);
+
+ enum class PrintableRepresentationSpecialCases : bool {
+ eDisable = false,
+ eAllow = true
+ };
+
+ bool
+ DumpPrintableRepresentation(Stream &s,
+ ValueObjectRepresentationStyle val_obj_display =
+ eValueObjectRepresentationStyleSummary,
+ lldb::Format custom_format = lldb::eFormatInvalid,
+ PrintableRepresentationSpecialCases special =
+ PrintableRepresentationSpecialCases::eAllow,
+ bool do_dump_error = true);
+ bool GetValueIsValid() const;
+
+ // If you call this on a newly created ValueObject, it will always return
+ // false.
+ bool GetValueDidChange();
+
+ bool UpdateValueIfNeeded(bool update_format = true);
+
+ bool UpdateFormatsIfNeeded();
+
+ lldb::ValueObjectSP GetSP() { return m_manager->GetSharedPointer(this); }
+
+ void SetName(const ConstString &name);
+
+ virtual lldb::addr_t GetAddressOf(bool scalar_is_load_address = true,
+ AddressType *address_type = nullptr);
+
+ lldb::addr_t GetPointerValue(AddressType *address_type = nullptr);
+
+ lldb::ValueObjectSP GetSyntheticChild(const ConstString &key) const;
+
+ lldb::ValueObjectSP GetSyntheticArrayMember(size_t index, bool can_create);
+
+ lldb::ValueObjectSP GetSyntheticBitFieldChild(uint32_t from, uint32_t to,
+ bool can_create);
+
+ lldb::ValueObjectSP GetSyntheticExpressionPathChild(const char *expression,
+ bool can_create);
+
+ virtual lldb::ValueObjectSP
+ GetSyntheticChildAtOffset(uint32_t offset, const CompilerType &type,
+ bool can_create,
+ ConstString name_const_str = ConstString());
+
+ virtual lldb::ValueObjectSP
+ GetSyntheticBase(uint32_t offset, const CompilerType &type, bool can_create,
+ ConstString name_const_str = ConstString());
+
+ virtual lldb::ValueObjectSP GetDynamicValue(lldb::DynamicValueType valueType);
+
+ lldb::DynamicValueType GetDynamicValueType();
+
+ virtual lldb::ValueObjectSP GetStaticValue();
+
+ virtual lldb::ValueObjectSP GetNonSyntheticValue();
+
+ lldb::ValueObjectSP GetSyntheticValue(bool use_synthetic = true);
+
+ virtual bool HasSyntheticValue();
+
+ virtual bool IsSynthetic() { return false; }
+
+ lldb::ValueObjectSP
+ GetQualifiedRepresentationIfAvailable(lldb::DynamicValueType dynValue,
+ bool synthValue);
+
+ virtual lldb::ValueObjectSP CreateConstantValue(const ConstString &name);
+
+ virtual lldb::ValueObjectSP Dereference(Error &error);
+
+ virtual lldb::ValueObjectSP AddressOf(Error &error);
+
+ virtual lldb::addr_t GetLiveAddress() { return LLDB_INVALID_ADDRESS; }
+
+ virtual void SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS,
+ AddressType address_type = eAddressTypeLoad) {}
+
+ // Find the address of the C++ vtable pointer
+ virtual lldb::addr_t GetCPPVTableAddress(AddressType &address_type);
+
+ virtual lldb::ValueObjectSP Cast(const CompilerType &compiler_type);
+
+ virtual lldb::ValueObjectSP CastPointerType(const char *name,
+ CompilerType &ast_type);
+
+ virtual lldb::ValueObjectSP CastPointerType(const char *name,
+ lldb::TypeSP &type_sp);
+
+ // The backing bits of this value object were updated, clear any
+ // descriptive string, so we know we have to refetch them
+ virtual void ValueUpdated() {
+ ClearUserVisibleData(eClearUserVisibleDataItemsValue |
+ eClearUserVisibleDataItemsSummary |
+ eClearUserVisibleDataItemsDescription);
+ }
+
+ virtual bool IsDynamic() { return false; }
+
+ virtual bool DoesProvideSyntheticValue() { return false; }
+
+ virtual bool IsSyntheticChildrenGenerated();
+
+ virtual void SetSyntheticChildrenGenerated(bool b);
+
+ virtual SymbolContextScope *GetSymbolContextScope();
+
+ void Dump(Stream &s);
+
+ void Dump(Stream &s, const DumpValueObjectOptions &options);
+
+ static lldb::ValueObjectSP
+ CreateValueObjectFromExpression(llvm::StringRef name,
+ llvm::StringRef expression,
+ const ExecutionContext &exe_ctx);
+
+ static lldb::ValueObjectSP
+ CreateValueObjectFromExpression(llvm::StringRef name,
+ llvm::StringRef expression,
+ const ExecutionContext &exe_ctx,
+ const EvaluateExpressionOptions &options);
+
+ static lldb::ValueObjectSP
+ CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address,
+ const ExecutionContext &exe_ctx,
CompilerType type);
-
- void
- LogValueObject (Log *log);
-
- void
- LogValueObject (Log *log,
- const DumpValueObjectOptions& options);
-
-
- lldb::ValueObjectSP
- Persist ();
-
- // returns true if this is a char* or a char[]
- // if it is a char* and check_pointer is true,
- // it also checks that the pointer is valid
- bool
- IsCStringContainer (bool check_pointer = false);
-
- std::pair<size_t,bool>
- ReadPointedString (lldb::DataBufferSP& buffer_sp,
- Error& error,
- uint32_t max_length = 0,
- bool honor_array = true,
- lldb::Format item_format = lldb::eFormatCharArray);
-
- virtual size_t
- GetPointeeData (DataExtractor& data,
- uint32_t item_idx = 0,
- uint32_t item_count = 1);
-
- virtual uint64_t
- GetData (DataExtractor& data, Error &error);
-
- virtual bool
- SetData (DataExtractor &data, Error &error);
-
- virtual bool
- GetIsConstant () const
- {
- return m_update_point.IsConstant();
- }
-
- bool
- NeedsUpdating ()
- {
- const bool accept_invalid_exe_ctx = (CanUpdateWithInvalidExecutionContext() == eLazyBoolYes);
- return m_update_point.NeedsUpdating(accept_invalid_exe_ctx);
- }
-
- void
- SetIsConstant ()
- {
- m_update_point.SetIsConstant();
- }
- lldb::Format
- GetFormat () const;
-
- virtual void
- SetFormat (lldb::Format format)
- {
- if (format != m_format)
- ClearUserVisibleData(eClearUserVisibleDataItemsValue);
- m_format = format;
- }
+ static lldb::ValueObjectSP
+ CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data,
+ const ExecutionContext &exe_ctx, CompilerType type);
- virtual lldb::LanguageType
- GetPreferredDisplayLanguage ();
-
- void
- SetPreferredDisplayLanguage (lldb::LanguageType);
-
- lldb::TypeSummaryImplSP
- GetSummaryFormat()
- {
- UpdateFormatsIfNeeded();
- return m_type_summary_sp;
- }
-
- void
- SetSummaryFormat(lldb::TypeSummaryImplSP format)
- {
- m_type_summary_sp = format;
- ClearUserVisibleData(eClearUserVisibleDataItemsSummary);
- }
-
- lldb::TypeValidatorImplSP
- GetValidator()
- {
- UpdateFormatsIfNeeded();
- return m_type_validator_sp;
- }
-
- void
- SetValidator(lldb::TypeValidatorImplSP format)
- {
- m_type_validator_sp = format;
- ClearUserVisibleData(eClearUserVisibleDataItemsValidator);
- }
-
- void
- SetValueFormat(lldb::TypeFormatImplSP format)
- {
- m_type_format_sp = format;
- ClearUserVisibleData(eClearUserVisibleDataItemsValue);
- }
-
- lldb::TypeFormatImplSP
- GetValueFormat()
- {
- UpdateFormatsIfNeeded();
- return m_type_format_sp;
- }
-
- void
- SetSyntheticChildren(const lldb::SyntheticChildrenSP &synth_sp)
- {
- if (synth_sp.get() == m_synthetic_children_sp.get())
- return;
- ClearUserVisibleData(eClearUserVisibleDataItemsSyntheticChildren);
- m_synthetic_children_sp = synth_sp;
- }
-
- lldb::SyntheticChildrenSP
- GetSyntheticChildren()
- {
- UpdateFormatsIfNeeded();
- return m_synthetic_children_sp;
- }
+ void LogValueObject(Log *log);
- // Use GetParent for display purposes, but if you want to tell the parent to update itself
- // then use m_parent. The ValueObjectDynamicValue's parent is not the correct parent for
- // displaying, they are really siblings, so for display it needs to route through to its grandparent.
- virtual ValueObject *
- GetParent()
- {
- return m_parent;
- }
+ void LogValueObject(Log *log, const DumpValueObjectOptions &options);
- virtual const ValueObject *
- GetParent() const
- {
- return m_parent;
- }
+ lldb::ValueObjectSP Persist();
- ValueObject *
- GetNonBaseClassParent();
+ // returns true if this is a char* or a char[]
+ // if it is a char* and check_pointer is true,
+ // it also checks that the pointer is valid
+ bool IsCStringContainer(bool check_pointer = false);
- void
- SetAddressTypeOfChildren(AddressType at)
- {
- m_address_type_of_ptr_or_ref_children = at;
- }
-
- AddressType
- GetAddressTypeOfChildren();
-
- void
- SetHasCompleteType()
- {
- m_did_calculate_complete_objc_class_type = true;
- }
-
- //------------------------------------------------------------------
- /// Find out if a ValueObject might have children.
- ///
- /// This call is much more efficient than CalculateNumChildren() as
- /// it doesn't need to complete the underlying type. This is designed
- /// to be used in a UI environment in order to detect if the
- /// disclosure triangle should be displayed or not.
- ///
- /// This function returns true for class, union, structure,
- /// pointers, references, arrays and more. Again, it does so without
- /// doing any expensive type completion.
- ///
- /// @return
- /// Returns \b true if the ValueObject might have children, or \b
- /// false otherwise.
- //------------------------------------------------------------------
- virtual bool
- MightHaveChildren();
-
- virtual lldb::VariableSP
- GetVariable ()
- {
- return nullptr;
- }
+ std::pair<size_t, bool>
+ ReadPointedString(lldb::DataBufferSP &buffer_sp, Error &error,
+ uint32_t max_length = 0, bool honor_array = true,
+ lldb::Format item_format = lldb::eFormatCharArray);
+
+ virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
+ uint32_t item_count = 1);
- virtual bool
- IsRuntimeSupportValue ();
-
- virtual uint64_t
- GetLanguageFlags ();
-
- virtual void
- SetLanguageFlags (uint64_t flags);
+ virtual uint64_t GetData(DataExtractor &data, Error &error);
+
+ virtual bool SetData(DataExtractor &data, Error &error);
+
+ virtual bool GetIsConstant() const { return m_update_point.IsConstant(); }
+
+ bool NeedsUpdating() {
+ const bool accept_invalid_exe_ctx =
+ (CanUpdateWithInvalidExecutionContext() == eLazyBoolYes);
+ return m_update_point.NeedsUpdating(accept_invalid_exe_ctx);
+ }
+
+ void SetIsConstant() { m_update_point.SetIsConstant(); }
+
+ lldb::Format GetFormat() const;
+
+ virtual void SetFormat(lldb::Format format) {
+ if (format != m_format)
+ ClearUserVisibleData(eClearUserVisibleDataItemsValue);
+ m_format = format;
+ }
+
+ virtual lldb::LanguageType GetPreferredDisplayLanguage();
+
+ void SetPreferredDisplayLanguage(lldb::LanguageType);
+
+ lldb::TypeSummaryImplSP GetSummaryFormat() {
+ UpdateFormatsIfNeeded();
+ return m_type_summary_sp;
+ }
+
+ void SetSummaryFormat(lldb::TypeSummaryImplSP format) {
+ m_type_summary_sp = format;
+ ClearUserVisibleData(eClearUserVisibleDataItemsSummary);
+ }
+
+ lldb::TypeValidatorImplSP GetValidator() {
+ UpdateFormatsIfNeeded();
+ return m_type_validator_sp;
+ }
+
+ void SetValidator(lldb::TypeValidatorImplSP format) {
+ m_type_validator_sp = format;
+ ClearUserVisibleData(eClearUserVisibleDataItemsValidator);
+ }
+
+ void SetValueFormat(lldb::TypeFormatImplSP format) {
+ m_type_format_sp = format;
+ ClearUserVisibleData(eClearUserVisibleDataItemsValue);
+ }
+
+ lldb::TypeFormatImplSP GetValueFormat() {
+ UpdateFormatsIfNeeded();
+ return m_type_format_sp;
+ }
+
+ void SetSyntheticChildren(const lldb::SyntheticChildrenSP &synth_sp) {
+ if (synth_sp.get() == m_synthetic_children_sp.get())
+ return;
+ ClearUserVisibleData(eClearUserVisibleDataItemsSyntheticChildren);
+ m_synthetic_children_sp = synth_sp;
+ }
+
+ lldb::SyntheticChildrenSP GetSyntheticChildren() {
+ UpdateFormatsIfNeeded();
+ return m_synthetic_children_sp;
+ }
+
+ // Use GetParent for display purposes, but if you want to tell the parent to
+ // update itself
+ // then use m_parent. The ValueObjectDynamicValue's parent is not the correct
+ // parent for
+ // displaying, they are really siblings, so for display it needs to route
+ // through to its grandparent.
+ virtual ValueObject *GetParent() { return m_parent; }
+
+ virtual const ValueObject *GetParent() const { return m_parent; }
+
+ ValueObject *GetNonBaseClassParent();
+
+ void SetAddressTypeOfChildren(AddressType at) {
+ m_address_type_of_ptr_or_ref_children = at;
+ }
+
+ AddressType GetAddressTypeOfChildren();
+
+ void SetHasCompleteType() { m_did_calculate_complete_objc_class_type = true; }
+
+ //------------------------------------------------------------------
+ /// Find out if a ValueObject might have children.
+ ///
+ /// This call is much more efficient than CalculateNumChildren() as
+ /// it doesn't need to complete the underlying type. This is designed
+ /// to be used in a UI environment in order to detect if the
+ /// disclosure triangle should be displayed or not.
+ ///
+ /// This function returns true for class, union, structure,
+ /// pointers, references, arrays and more. Again, it does so without
+ /// doing any expensive type completion.
+ ///
+ /// @return
+ /// Returns \b true if the ValueObject might have children, or \b
+ /// false otherwise.
+ //------------------------------------------------------------------
+ virtual bool MightHaveChildren();
+
+ virtual lldb::VariableSP GetVariable() { return nullptr; }
+
+ virtual bool IsRuntimeSupportValue();
+
+ virtual uint64_t GetLanguageFlags();
+
+ virtual void SetLanguageFlags(uint64_t flags);
protected:
- typedef ClusterManager<ValueObject> ValueObjectManager;
-
- class ChildrenManager
- {
- public:
- ChildrenManager() : m_mutex(), m_children(), m_children_count(0) {}
-
- bool
- HasChildAtIndex(size_t idx)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return (m_children.find(idx) != m_children.end());
- }
-
- ValueObject *
- GetChildAtIndex(size_t idx)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- const auto iter = m_children.find(idx);
- return ((iter == m_children.end()) ? nullptr : iter->second);
- }
-
- void
- SetChildAtIndex(size_t idx, ValueObject *valobj)
- {
- // we do not need to be mutex-protected to make a pair
- ChildrenPair pair(idx, valobj);
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- m_children.insert(pair);
- }
-
- void
- SetChildrenCount (size_t count)
- {
- Clear(count);
- }
-
- size_t
- GetChildrenCount ()
- {
- return m_children_count;
- }
-
- void
- Clear(size_t new_count = 0)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- m_children_count = new_count;
- m_children.clear();
- }
-
- private:
- typedef std::map<size_t, ValueObject*> ChildrenMap;
- typedef ChildrenMap::iterator ChildrenIterator;
- typedef ChildrenMap::value_type ChildrenPair;
- std::recursive_mutex m_mutex;
- ChildrenMap m_children;
- size_t m_children_count;
- };
+ typedef ClusterManager<ValueObject> ValueObjectManager;
- //------------------------------------------------------------------
- // Classes that inherit from ValueObject can see and modify these
- //------------------------------------------------------------------
- ValueObject * m_parent; // The parent value object, or nullptr if this has no parent
- ValueObject * m_root; // The root of the hierarchy for this ValueObject (or nullptr if never calculated)
- EvaluationPoint m_update_point; // Stores both the stop id and the full context at which this value was last
- // updated. When we are asked to update the value object, we check whether
- // the context & stop id are the same before updating.
- ConstString m_name; // The name of this object
- DataExtractor m_data; // A data extractor that can be used to extract the value.
- Value m_value;
- Error m_error; // An error object that can describe any errors that occur when updating values.
- std::string m_value_str; // Cached value string that will get cleared if/when the value is updated.
- std::string m_old_value_str;// Cached old value string from the last time the value was gotten
- std::string m_location_str; // Cached location string that will get cleared if/when the value is updated.
- std::string m_summary_str; // Cached summary string that will get cleared if/when the value is updated.
- std::string m_object_desc_str; // Cached result of the "object printer". This differs from the summary
- // in that the summary is consed up by us, the object_desc_string is builtin.
-
- llvm::Optional<std::pair<TypeValidatorResult, std::string>> m_validation_result;
-
- CompilerType m_override_type;// If the type of the value object should be overridden, the type to impose.
-
- ValueObjectManager *m_manager; // This object is managed by the root object (any ValueObject that gets created
- // without a parent.) The manager gets passed through all the generations of
- // dependent objects, and will keep the whole cluster of objects alive as long
- // as a shared pointer to any of them has been handed out. Shared pointers to
- // value objects must always be made with the GetSP method.
-
- ChildrenManager m_children;
- std::map<ConstString, ValueObject *> m_synthetic_children;
-
- ValueObject* m_dynamic_value;
- ValueObject* m_synthetic_value;
- ValueObject* m_deref_valobj;
-
- lldb::ValueObjectSP m_addr_of_valobj_sp; // We have to hold onto a shared pointer to this one because it is created
- // as an independent ValueObjectConstResult, which isn't managed by us.
-
- lldb::Format m_format;
- lldb::Format m_last_format;
- uint32_t m_last_format_mgr_revision;
- lldb::TypeSummaryImplSP m_type_summary_sp;
- lldb::TypeFormatImplSP m_type_format_sp;
- lldb::SyntheticChildrenSP m_synthetic_children_sp;
- lldb::TypeValidatorImplSP m_type_validator_sp;
- ProcessModID m_user_id_of_forced_summary;
- AddressType m_address_type_of_ptr_or_ref_children;
-
- llvm::SmallVector<uint8_t, 16> m_value_checksum;
-
- lldb::LanguageType m_preferred_display_language;
-
- uint64_t m_language_flags;
-
- bool m_value_is_valid:1,
- m_value_did_change:1,
- m_children_count_valid:1,
- m_old_value_valid:1,
- m_is_deref_of_parent:1,
- m_is_array_item_for_pointer:1,
- m_is_bitfield_for_scalar:1,
- m_is_child_at_offset:1,
- m_is_getting_summary:1,
- m_did_calculate_complete_objc_class_type:1,
- m_is_synthetic_children_generated:1;
-
- friend class ValueObjectChild;
- friend class ClangExpressionDeclMap; // For GetValue
- friend class ExpressionVariable; // For SetName
- friend class Target; // For SetName
- friend class ValueObjectConstResultImpl;
- friend class ValueObjectSynthetic; // For ClearUserVisibleData
-
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
-
- // Use the no-argument constructor to make a constant variable object (with no ExecutionContextScope.)
-
- ValueObject();
-
- // Use this constructor to create a "root variable object". The ValueObject will be locked to this context
- // through-out its lifespan.
-
- ValueObject (ExecutionContextScope *exe_scope,
- AddressType child_ptr_or_ref_addr_type = eAddressTypeLoad);
-
- // Use this constructor to create a ValueObject owned by another ValueObject. It will inherit the ExecutionContext
- // of its parent.
-
- ValueObject (ValueObject &parent);
-
- ValueObjectManager *
- GetManager()
- {
- return m_manager;
+ class ChildrenManager {
+ public:
+ ChildrenManager() : m_mutex(), m_children(), m_children_count(0) {}
+
+ bool HasChildAtIndex(size_t idx) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return (m_children.find(idx) != m_children.end());
}
-
- virtual bool
- UpdateValue () = 0;
-
- virtual LazyBool
- CanUpdateWithInvalidExecutionContext ()
- {
- return eLazyBoolCalculate;
+
+ ValueObject *GetChildAtIndex(size_t idx) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ const auto iter = m_children.find(idx);
+ return ((iter == m_children.end()) ? nullptr : iter->second);
}
-
- virtual void
- CalculateDynamicValue (lldb::DynamicValueType use_dynamic);
-
- virtual lldb::DynamicValueType
- GetDynamicValueTypeImpl ()
- {
- return lldb::eNoDynamicValues;
+
+ void SetChildAtIndex(size_t idx, ValueObject *valobj) {
+ // we do not need to be mutex-protected to make a pair
+ ChildrenPair pair(idx, valobj);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ m_children.insert(pair);
}
-
- virtual bool
- HasDynamicValueTypeInfo ()
- {
- return false;
+
+ void SetChildrenCount(size_t count) { Clear(count); }
+
+ size_t GetChildrenCount() { return m_children_count; }
+
+ void Clear(size_t new_count = 0) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ m_children_count = new_count;
+ m_children.clear();
}
-
- virtual void
- CalculateSyntheticValue (bool use_synthetic = true);
-
- // Should only be called by ValueObject::GetChildAtIndex()
- // Returns a ValueObject managed by this ValueObject's manager.
- virtual ValueObject *
- CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index);
-
- // Should only be called by ValueObject::GetNumChildren()
- virtual size_t
- CalculateNumChildren(uint32_t max=UINT32_MAX) = 0;
-
- void
- SetNumChildren (size_t num_children);
-
- void
- SetValueDidChange (bool value_changed);
-
- void
- SetValueIsValid (bool valid);
-
- void
- ClearUserVisibleData(uint32_t items = ValueObject::eClearUserVisibleDataItemsAllStrings);
-
- void
- AddSyntheticChild (const ConstString &key,
- ValueObject *valobj);
-
- DataExtractor &
- GetDataExtractor ();
-
- void
- ClearDynamicTypeInformation ();
-
- //------------------------------------------------------------------
- // Subclasses must implement the functions below.
- //------------------------------------------------------------------
-
- virtual CompilerType
- GetCompilerTypeImpl () = 0;
-
- const char *
- GetLocationAsCStringImpl (const Value& value,
- const DataExtractor& data);
-
- bool
- IsChecksumEmpty ();
-
- void
- SetPreferredDisplayLanguageIfNeeded (lldb::LanguageType);
-
+
+ private:
+ typedef std::map<size_t, ValueObject *> ChildrenMap;
+ typedef ChildrenMap::iterator ChildrenIterator;
+ typedef ChildrenMap::value_type ChildrenPair;
+ std::recursive_mutex m_mutex;
+ ChildrenMap m_children;
+ size_t m_children_count;
+ };
+
+ //------------------------------------------------------------------
+ // Classes that inherit from ValueObject can see and modify these
+ //------------------------------------------------------------------
+ ValueObject
+ *m_parent; // The parent value object, or nullptr if this has no parent
+ ValueObject *m_root; // The root of the hierarchy for this ValueObject (or
+ // nullptr if never calculated)
+ EvaluationPoint m_update_point; // Stores both the stop id and the full
+ // context at which this value was last
+ // updated. When we are asked to update the value object, we check whether
+ // the context & stop id are the same before updating.
+ ConstString m_name; // The name of this object
+ DataExtractor
+ m_data; // A data extractor that can be used to extract the value.
+ Value m_value;
+ Error m_error; // An error object that can describe any errors that occur when
+ // updating values.
+ std::string m_value_str; // Cached value string that will get cleared if/when
+ // the value is updated.
+ std::string m_old_value_str; // Cached old value string from the last time the
+ // value was gotten
+ std::string m_location_str; // Cached location string that will get cleared
+ // if/when the value is updated.
+ std::string m_summary_str; // Cached summary string that will get cleared
+ // if/when the value is updated.
+ std::string m_object_desc_str; // Cached result of the "object printer". This
+ // differs from the summary
+ // in that the summary is consed up by us, the object_desc_string is builtin.
+
+ llvm::Optional<std::pair<TypeValidatorResult, std::string>>
+ m_validation_result;
+
+ CompilerType m_override_type; // If the type of the value object should be
+ // overridden, the type to impose.
+
+ ValueObjectManager *m_manager; // This object is managed by the root object
+ // (any ValueObject that gets created
+ // without a parent.) The manager gets passed through all the generations of
+ // dependent objects, and will keep the whole cluster of objects alive as long
+ // as a shared pointer to any of them has been handed out. Shared pointers to
+ // value objects must always be made with the GetSP method.
+
+ ChildrenManager m_children;
+ std::map<ConstString, ValueObject *> m_synthetic_children;
+
+ ValueObject *m_dynamic_value;
+ ValueObject *m_synthetic_value;
+ ValueObject *m_deref_valobj;
+
+ lldb::ValueObjectSP m_addr_of_valobj_sp; // We have to hold onto a shared
+ // pointer to this one because it is
+ // created
+ // as an independent ValueObjectConstResult, which isn't managed by us.
+
+ lldb::Format m_format;
+ lldb::Format m_last_format;
+ uint32_t m_last_format_mgr_revision;
+ lldb::TypeSummaryImplSP m_type_summary_sp;
+ lldb::TypeFormatImplSP m_type_format_sp;
+ lldb::SyntheticChildrenSP m_synthetic_children_sp;
+ lldb::TypeValidatorImplSP m_type_validator_sp;
+ ProcessModID m_user_id_of_forced_summary;
+ AddressType m_address_type_of_ptr_or_ref_children;
+
+ llvm::SmallVector<uint8_t, 16> m_value_checksum;
+
+ lldb::LanguageType m_preferred_display_language;
+
+ uint64_t m_language_flags;
+
+ bool m_value_is_valid : 1, m_value_did_change : 1, m_children_count_valid : 1,
+ m_old_value_valid : 1, m_is_deref_of_parent : 1,
+ m_is_array_item_for_pointer : 1, m_is_bitfield_for_scalar : 1,
+ m_is_child_at_offset : 1, m_is_getting_summary : 1,
+ m_did_calculate_complete_objc_class_type : 1,
+ m_is_synthetic_children_generated : 1;
+
+ friend class ValueObjectChild;
+ friend class ClangExpressionDeclMap; // For GetValue
+ friend class ExpressionVariable; // For SetName
+ friend class Target; // For SetName
+ friend class ValueObjectConstResultImpl;
+ friend class ValueObjectSynthetic; // For ClearUserVisibleData
+
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+
+ // Use the no-argument constructor to make a constant variable object (with no
+ // ExecutionContextScope.)
+
+ ValueObject();
+
+ // Use this constructor to create a "root variable object". The ValueObject
+ // will be locked to this context
+ // through-out its lifespan.
+
+ ValueObject(ExecutionContextScope *exe_scope,
+ AddressType child_ptr_or_ref_addr_type = eAddressTypeLoad);
+
+ // Use this constructor to create a ValueObject owned by another ValueObject.
+ // It will inherit the ExecutionContext
+ // of its parent.
+
+ ValueObject(ValueObject &parent);
+
+ ValueObjectManager *GetManager() { return m_manager; }
+
+ virtual bool UpdateValue() = 0;
+
+ virtual LazyBool CanUpdateWithInvalidExecutionContext() {
+ return eLazyBoolCalculate;
+ }
+
+ virtual void CalculateDynamicValue(lldb::DynamicValueType use_dynamic);
+
+ virtual lldb::DynamicValueType GetDynamicValueTypeImpl() {
+ return lldb::eNoDynamicValues;
+ }
+
+ virtual bool HasDynamicValueTypeInfo() { return false; }
+
+ virtual void CalculateSyntheticValue(bool use_synthetic = true);
+
+ // Should only be called by ValueObject::GetChildAtIndex()
+ // Returns a ValueObject managed by this ValueObject's manager.
+ virtual ValueObject *CreateChildAtIndex(size_t idx,
+ bool synthetic_array_member,
+ int32_t synthetic_index);
+
+ // Should only be called by ValueObject::GetNumChildren()
+ virtual size_t CalculateNumChildren(uint32_t max = UINT32_MAX) = 0;
+
+ void SetNumChildren(size_t num_children);
+
+ void SetValueDidChange(bool value_changed);
+
+ void SetValueIsValid(bool valid);
+
+ void ClearUserVisibleData(
+ uint32_t items = ValueObject::eClearUserVisibleDataItemsAllStrings);
+
+ void AddSyntheticChild(const ConstString &key, ValueObject *valobj);
+
+ DataExtractor &GetDataExtractor();
+
+ void ClearDynamicTypeInformation();
+
+ //------------------------------------------------------------------
+ // Subclasses must implement the functions below.
+ //------------------------------------------------------------------
+
+ virtual CompilerType GetCompilerTypeImpl() = 0;
+
+ const char *GetLocationAsCStringImpl(const Value &value,
+ const DataExtractor &data);
+
+ bool IsChecksumEmpty();
+
+ void SetPreferredDisplayLanguageIfNeeded(lldb::LanguageType);
+
private:
- virtual CompilerType
- MaybeCalculateCompleteType ();
-
- lldb::ValueObjectSP
- GetValueForExpressionPath_Impl(const char* expression_cstr,
- const char** first_unparsed,
- ExpressionPathScanEndReason* reason_to_stop,
- ExpressionPathEndResultType* final_value_type,
- const GetValueForExpressionPathOptions& options,
- ExpressionPathAftermath* final_task_on_target);
-
- // this method will ONLY expand [] expressions into a VOList and return
- // the number of elements it added to the VOList
- // it will NOT loop through expanding the follow-up of the expression_cstr
- // for all objects in the list
- int
- ExpandArraySliceExpression(const char* expression_cstr,
- const char** first_unparsed,
- lldb::ValueObjectSP root,
- lldb::ValueObjectListSP& list,
- ExpressionPathScanEndReason* reason_to_stop,
- ExpressionPathEndResultType* final_value_type,
- const GetValueForExpressionPathOptions& options,
- ExpressionPathAftermath* final_task_on_target);
-
- DISALLOW_COPY_AND_ASSIGN (ValueObject);
+ virtual CompilerType MaybeCalculateCompleteType();
+
+ lldb::ValueObjectSP GetValueForExpressionPath_Impl(
+ llvm::StringRef expression_cstr,
+ ExpressionPathScanEndReason *reason_to_stop,
+ ExpressionPathEndResultType *final_value_type,
+ const GetValueForExpressionPathOptions &options,
+ ExpressionPathAftermath *final_task_on_target);
+
+ DISALLOW_COPY_AND_ASSIGN(ValueObject);
+};
+
+//------------------------------------------------------------------------------
+// A value object manager class that is seeded with the static variable value
+// and it vends the user facing value object. If the type is dynamic it can
+// vend the dynamic type. If this user type also has a synthetic type associated
+// with it, it will vend the synthetic type. The class watches the process' stop
+// ID and will update the user type when needed.
+//------------------------------------------------------------------------------
+class ValueObjectManager {
+ // The root value object is the static typed variable object.
+ lldb::ValueObjectSP m_root_valobj_sp;
+ // The user value object is the value object the user wants to see.
+ lldb::ValueObjectSP m_user_valobj_sp;
+ lldb::DynamicValueType m_use_dynamic;
+ uint32_t m_stop_id; // The stop ID that m_user_valobj_sp is valid for.
+ bool m_use_synthetic;
+
+public:
+ ValueObjectManager() {}
+
+ ValueObjectManager(lldb::ValueObjectSP in_valobj_sp,
+ lldb::DynamicValueType use_dynamic, bool use_synthetic);
+
+ bool IsValid() const;
+
+ lldb::ValueObjectSP GetRootSP() const { return m_root_valobj_sp; }
+
+ // Gets the correct value object from the root object for a given process
+ // stop ID. If dynamic values are enabled, or if synthetic children are
+ // enabled, the value object that the user wants to see might change while
+ // debugging.
+ lldb::ValueObjectSP GetSP();
+
+ void SetUseDynamic(lldb::DynamicValueType use_dynamic);
+ void SetUseSynthetic(bool use_synthetic);
+ lldb::DynamicValueType GetUseDynamic() const { return m_use_dynamic; }
+ bool GetUseSynthetic() const { return m_use_synthetic; }
+ lldb::TargetSP GetTargetSP() const;
+ lldb::ProcessSP GetProcessSP() const;
+ lldb::ThreadSP GetThreadSP() const;
+ lldb::StackFrameSP GetFrameSP() const;
};
} // namespace lldb_private
diff --git a/include/lldb/Core/ValueObjectCast.h b/include/lldb/Core/ValueObjectCast.h
index 8c7ffe5ec5e2..50959b927e70 100644
--- a/include/lldb/Core/ValueObjectCast.h
+++ b/include/lldb/Core/ValueObjectCast.h
@@ -21,55 +21,42 @@ namespace lldb_private {
//---------------------------------------------------------------------------------
// A ValueObject that represents a given value represented as a different type.
//---------------------------------------------------------------------------------
-class ValueObjectCast : public ValueObject
-{
+class ValueObjectCast : public ValueObject {
public:
- ~ValueObjectCast() override;
-
- static lldb::ValueObjectSP
- Create (ValueObject &parent,
- const ConstString &name,
- const CompilerType &cast_type);
-
- uint64_t
- GetByteSize() override;
-
- size_t
- CalculateNumChildren(uint32_t max) override;
-
- lldb::ValueType
- GetValueType() const override;
-
- bool
- IsInScope() override;
-
- ValueObject *
- GetParent() override
- {
- return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
- }
-
- const ValueObject *
- GetParent() const override
- {
- return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
- }
-
+ ~ValueObjectCast() override;
+
+ static lldb::ValueObjectSP Create(ValueObject &parent,
+ const ConstString &name,
+ const CompilerType &cast_type);
+
+ uint64_t GetByteSize() override;
+
+ size_t CalculateNumChildren(uint32_t max) override;
+
+ lldb::ValueType GetValueType() const override;
+
+ bool IsInScope() override;
+
+ ValueObject *GetParent() override {
+ return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
+ }
+
+ const ValueObject *GetParent() const override {
+ return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
+ }
+
protected:
- ValueObjectCast(ValueObject &parent,
- const ConstString &name,
- const CompilerType &cast_type);
-
- bool
- UpdateValue () override;
-
- CompilerType
- GetCompilerTypeImpl () override;
-
- CompilerType m_cast_type;
-
+ ValueObjectCast(ValueObject &parent, const ConstString &name,
+ const CompilerType &cast_type);
+
+ bool UpdateValue() override;
+
+ CompilerType GetCompilerTypeImpl() override;
+
+ CompilerType m_cast_type;
+
private:
- DISALLOW_COPY_AND_ASSIGN (ValueObjectCast);
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectCast);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/ValueObjectChild.h b/include/lldb/Core/ValueObjectChild.h
index 13e26c6ab0c1..b84cb3dfa216 100644
--- a/include/lldb/Core/ValueObjectChild.h
+++ b/include/lldb/Core/ValueObjectChild.h
@@ -23,110 +23,69 @@ namespace lldb_private {
//----------------------------------------------------------------------
// A child of another ValueObject.
//----------------------------------------------------------------------
-class ValueObjectChild : public ValueObject
-{
+class ValueObjectChild : public ValueObject {
public:
- ~ValueObjectChild() override;
-
- uint64_t
- GetByteSize() override
- {
- return m_byte_size;
- }
-
- lldb::offset_t
- GetByteOffset() override
- {
- return m_byte_offset;
- }
-
- uint32_t
- GetBitfieldBitSize() override
- {
- return m_bitfield_bit_size;
- }
-
- uint32_t
- GetBitfieldBitOffset() override
- {
- return m_bitfield_bit_offset;
- }
-
- lldb::ValueType
- GetValueType() const override;
-
- size_t
- CalculateNumChildren(uint32_t max) override;
-
- ConstString
- GetTypeName() override;
-
- ConstString
- GetQualifiedTypeName() override;
-
- ConstString
- GetDisplayTypeName() override;
-
- bool
- IsInScope() override;
-
- bool
- IsBaseClass() override
- {
- return m_is_base_class;
- }
-
- bool
- IsDereferenceOfParent() override
- {
- return m_is_deref_of_parent;
- }
+ ~ValueObjectChild() override;
+
+ uint64_t GetByteSize() override { return m_byte_size; }
+
+ lldb::offset_t GetByteOffset() override { return m_byte_offset; }
+
+ uint32_t GetBitfieldBitSize() override { return m_bitfield_bit_size; }
+
+ uint32_t GetBitfieldBitOffset() override { return m_bitfield_bit_offset; }
+
+ lldb::ValueType GetValueType() const override;
+
+ size_t CalculateNumChildren(uint32_t max) override;
+
+ ConstString GetTypeName() override;
+
+ ConstString GetQualifiedTypeName() override;
+
+ ConstString GetDisplayTypeName() override;
+
+ bool IsInScope() override;
+
+ bool IsBaseClass() override { return m_is_base_class; }
+
+ bool IsDereferenceOfParent() override { return m_is_deref_of_parent; }
protected:
- bool
- UpdateValue() override;
-
- LazyBool
- CanUpdateWithInvalidExecutionContext() override;
-
- CompilerType
- GetCompilerTypeImpl() override
- {
- return m_compiler_type;
- }
-
- CompilerType m_compiler_type;
- ConstString m_type_name;
- uint64_t m_byte_size;
- int32_t m_byte_offset;
- uint8_t m_bitfield_bit_size;
- uint8_t m_bitfield_bit_offset;
- bool m_is_base_class;
- bool m_is_deref_of_parent;
- llvm::Optional<LazyBool> m_can_update_with_invalid_exe_ctx;
+ bool UpdateValue() override;
-//
-// void
-// ReadValueFromMemory (ValueObject* parent, lldb::addr_t address);
+ LazyBool CanUpdateWithInvalidExecutionContext() override;
+
+ CompilerType GetCompilerTypeImpl() override { return m_compiler_type; }
+
+ CompilerType m_compiler_type;
+ ConstString m_type_name;
+ uint64_t m_byte_size;
+ int32_t m_byte_offset;
+ uint8_t m_bitfield_bit_size;
+ uint8_t m_bitfield_bit_offset;
+ bool m_is_base_class;
+ bool m_is_deref_of_parent;
+ llvm::Optional<LazyBool> m_can_update_with_invalid_exe_ctx;
+
+ //
+ // void
+ // ReadValueFromMemory (ValueObject* parent, lldb::addr_t address);
protected:
- friend class ValueObject;
- friend class ValueObjectConstResult;
- friend class ValueObjectConstResultImpl;
-
- ValueObjectChild (ValueObject &parent,
- const CompilerType &compiler_type,
- const ConstString &name,
- uint64_t byte_size,
- int32_t byte_offset,
- uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset,
- bool is_base_class,
- bool is_deref_of_parent,
- AddressType child_ptr_or_ref_addr_type,
- uint64_t language_flags);
-
- DISALLOW_COPY_AND_ASSIGN (ValueObjectChild);
+ friend class ValueObject;
+ friend class ValueObjectConstResult;
+ friend class ValueObjectConstResultImpl;
+
+ ValueObjectChild(ValueObject &parent, const CompilerType &compiler_type,
+ const ConstString &name, uint64_t byte_size,
+ int32_t byte_offset, uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset, bool is_base_class,
+ bool is_deref_of_parent,
+ AddressType child_ptr_or_ref_addr_type,
+ uint64_t language_flags);
+
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectChild);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/ValueObjectConstResult.h b/include/lldb/Core/ValueObjectConstResult.h
index 892df8c62cc5..994ac477bf2e 100644
--- a/include/lldb/Core/ValueObjectConstResult.h
+++ b/include/lldb/Core/ValueObjectConstResult.h
@@ -23,169 +23,123 @@ namespace lldb_private {
//----------------------------------------------------------------------
// A frozen ValueObject copied into host memory
//----------------------------------------------------------------------
-class ValueObjectConstResult : public ValueObject
-{
+class ValueObjectConstResult : public ValueObject {
public:
- ~ValueObjectConstResult() override;
-
- static lldb::ValueObjectSP
- Create (ExecutionContextScope *exe_scope,
- lldb::ByteOrder byte_order,
- uint32_t addr_byte_size,
- lldb::addr_t address = LLDB_INVALID_ADDRESS);
-
- static lldb::ValueObjectSP
- Create (ExecutionContextScope *exe_scope,
- const CompilerType &compiler_type,
- const ConstString &name,
- const DataExtractor &data,
- lldb::addr_t address = LLDB_INVALID_ADDRESS);
-
- static lldb::ValueObjectSP
- Create (ExecutionContextScope *exe_scope,
- const CompilerType &compiler_type,
- const ConstString &name,
- const lldb::DataBufferSP &result_data_sp,
- lldb::ByteOrder byte_order,
- uint32_t addr_size,
- lldb::addr_t address = LLDB_INVALID_ADDRESS);
-
- static lldb::ValueObjectSP
- Create (ExecutionContextScope *exe_scope,
- const CompilerType &compiler_type,
- const ConstString &name,
- lldb::addr_t address,
- AddressType address_type,
- uint32_t addr_byte_size);
-
- static lldb::ValueObjectSP
- Create (ExecutionContextScope *exe_scope,
- Value &value,
- const ConstString &name,
- Module* module = nullptr);
-
- // When an expression fails to evaluate, we return an error
- static lldb::ValueObjectSP
- Create (ExecutionContextScope *exe_scope,
- const Error& error);
-
- uint64_t
- GetByteSize() override;
-
- lldb::ValueType
- GetValueType() const override;
-
- size_t
- CalculateNumChildren(uint32_t max) override;
-
- ConstString
- GetTypeName() override;
-
- ConstString
- GetDisplayTypeName() override;
-
- bool
- IsInScope() override;
-
- void
- SetByteSize (size_t size);
-
- lldb::ValueObjectSP
- Dereference(Error &error) override;
-
- ValueObject *
- CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index) override;
-
- lldb::ValueObjectSP
- GetSyntheticChildAtOffset(uint32_t offset,
- const CompilerType& type,
- bool can_create,
- ConstString name_const_str = ConstString()) override;
-
- lldb::ValueObjectSP
- AddressOf(Error &error) override;
-
- lldb::addr_t
- GetAddressOf(bool scalar_is_load_address = true,
- AddressType *address_type = nullptr) override;
-
- size_t
- GetPointeeData(DataExtractor& data,
- uint32_t item_idx = 0,
- uint32_t item_count = 1) override;
-
- lldb::addr_t
- GetLiveAddress() override
- {
- return m_impl.GetLiveAddress();
- }
-
- void
- SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS,
- AddressType address_type = eAddressTypeLoad) override
- {
- m_impl.SetLiveAddress(addr, address_type);
- }
-
- lldb::ValueObjectSP
- GetDynamicValue(lldb::DynamicValueType valueType) override;
-
- lldb::LanguageType
- GetPreferredDisplayLanguage() override;
-
- lldb::ValueObjectSP
- Cast(const CompilerType &compiler_type) override;
+ ~ValueObjectConstResult() override;
+
+ static lldb::ValueObjectSP
+ Create(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order,
+ uint32_t addr_byte_size, lldb::addr_t address = LLDB_INVALID_ADDRESS);
+
+ static lldb::ValueObjectSP
+ Create(ExecutionContextScope *exe_scope, const CompilerType &compiler_type,
+ const ConstString &name, const DataExtractor &data,
+ lldb::addr_t address = LLDB_INVALID_ADDRESS);
+
+ static lldb::ValueObjectSP
+ Create(ExecutionContextScope *exe_scope, const CompilerType &compiler_type,
+ const ConstString &name, const lldb::DataBufferSP &result_data_sp,
+ lldb::ByteOrder byte_order, uint32_t addr_size,
+ lldb::addr_t address = LLDB_INVALID_ADDRESS);
+
+ static lldb::ValueObjectSP
+ Create(ExecutionContextScope *exe_scope, const CompilerType &compiler_type,
+ const ConstString &name, lldb::addr_t address,
+ AddressType address_type, uint32_t addr_byte_size);
+
+ static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
+ Value &value, const ConstString &name,
+ Module *module = nullptr);
+
+ // When an expression fails to evaluate, we return an error
+ static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
+ const Error &error);
+
+ uint64_t GetByteSize() override;
+
+ lldb::ValueType GetValueType() const override;
+
+ size_t CalculateNumChildren(uint32_t max) override;
+
+ ConstString GetTypeName() override;
+
+ ConstString GetDisplayTypeName() override;
+
+ bool IsInScope() override;
+
+ void SetByteSize(size_t size);
+
+ lldb::ValueObjectSP Dereference(Error &error) override;
+
+ ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
+ int32_t synthetic_index) override;
+
+ lldb::ValueObjectSP GetSyntheticChildAtOffset(
+ uint32_t offset, const CompilerType &type, bool can_create,
+ ConstString name_const_str = ConstString()) override;
+
+ lldb::ValueObjectSP AddressOf(Error &error) override;
+
+ lldb::addr_t GetAddressOf(bool scalar_is_load_address = true,
+ AddressType *address_type = nullptr) override;
+
+ size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
+ uint32_t item_count = 1) override;
+
+ lldb::addr_t GetLiveAddress() override { return m_impl.GetLiveAddress(); }
+
+ void SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS,
+ AddressType address_type = eAddressTypeLoad) override {
+ m_impl.SetLiveAddress(addr, address_type);
+ }
+
+ lldb::ValueObjectSP
+ GetDynamicValue(lldb::DynamicValueType valueType) override;
+
+ lldb::LanguageType GetPreferredDisplayLanguage() override;
+
+ lldb::ValueObjectSP Cast(const CompilerType &compiler_type) override;
protected:
- bool
- UpdateValue() override;
-
- CompilerType
- GetCompilerTypeImpl() override;
+ bool UpdateValue() override;
+
+ CompilerType GetCompilerTypeImpl() override;
- ConstString m_type_name;
- uint64_t m_byte_size;
-
- ValueObjectConstResultImpl m_impl;
+ ConstString m_type_name;
+ uint64_t m_byte_size;
+
+ ValueObjectConstResultImpl m_impl;
private:
- friend class ValueObjectConstResultImpl;
-
- ValueObjectConstResult (ExecutionContextScope *exe_scope,
- lldb::ByteOrder byte_order,
- uint32_t addr_byte_size,
- lldb::addr_t address);
-
- ValueObjectConstResult (ExecutionContextScope *exe_scope,
- const CompilerType &compiler_type,
- const ConstString &name,
- const DataExtractor &data,
- lldb::addr_t address);
-
- ValueObjectConstResult (ExecutionContextScope *exe_scope,
- const CompilerType &compiler_type,
- const ConstString &name,
- const lldb::DataBufferSP &result_data_sp,
- lldb::ByteOrder byte_order,
- uint32_t addr_size,
- lldb::addr_t address);
-
- ValueObjectConstResult (ExecutionContextScope *exe_scope,
- const CompilerType &compiler_type,
- const ConstString &name,
- lldb::addr_t address,
- AddressType address_type,
- uint32_t addr_byte_size);
-
- ValueObjectConstResult (ExecutionContextScope *exe_scope,
- const Value &value,
- const ConstString &name,
- Module* module = nullptr);
-
- ValueObjectConstResult (ExecutionContextScope *exe_scope,
- const Error& error);
-
- DISALLOW_COPY_AND_ASSIGN (ValueObjectConstResult);
+ friend class ValueObjectConstResultImpl;
+
+ ValueObjectConstResult(ExecutionContextScope *exe_scope,
+ lldb::ByteOrder byte_order, uint32_t addr_byte_size,
+ lldb::addr_t address);
+
+ ValueObjectConstResult(ExecutionContextScope *exe_scope,
+ const CompilerType &compiler_type,
+ const ConstString &name, const DataExtractor &data,
+ lldb::addr_t address);
+
+ ValueObjectConstResult(ExecutionContextScope *exe_scope,
+ const CompilerType &compiler_type,
+ const ConstString &name,
+ const lldb::DataBufferSP &result_data_sp,
+ lldb::ByteOrder byte_order, uint32_t addr_size,
+ lldb::addr_t address);
+
+ ValueObjectConstResult(ExecutionContextScope *exe_scope,
+ const CompilerType &compiler_type,
+ const ConstString &name, lldb::addr_t address,
+ AddressType address_type, uint32_t addr_byte_size);
+
+ ValueObjectConstResult(ExecutionContextScope *exe_scope, const Value &value,
+ const ConstString &name, Module *module = nullptr);
+
+ ValueObjectConstResult(ExecutionContextScope *exe_scope, const Error &error);
+
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectConstResult);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/ValueObjectConstResultCast.h b/include/lldb/Core/ValueObjectConstResultCast.h
index 84dd79213d02..4b2a3e2fb9b0 100644
--- a/include/lldb/Core/ValueObjectConstResultCast.h
+++ b/include/lldb/Core/ValueObjectConstResultCast.h
@@ -19,57 +19,43 @@
namespace lldb_private {
-class ValueObjectConstResultCast : public ValueObjectCast
-{
+class ValueObjectConstResultCast : public ValueObjectCast {
public:
- ValueObjectConstResultCast (
- ValueObject &parent,
- const ConstString &name,
- const CompilerType &cast_type,
- lldb::addr_t live_address = LLDB_INVALID_ADDRESS);
+ ValueObjectConstResultCast(ValueObject &parent, const ConstString &name,
+ const CompilerType &cast_type,
+ lldb::addr_t live_address = LLDB_INVALID_ADDRESS);
- ~ValueObjectConstResultCast() override;
+ ~ValueObjectConstResultCast() override;
- lldb::ValueObjectSP
- Dereference(Error &error) override;
+ lldb::ValueObjectSP Dereference(Error &error) override;
- ValueObject *
- CreateChildAtIndex(size_t idx,
- bool synthetic_array_member,
- int32_t synthetic_index) override;
+ ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
+ int32_t synthetic_index) override;
- virtual CompilerType
- GetCompilerType ()
- {
- return ValueObjectCast::GetCompilerType();
- }
+ virtual CompilerType GetCompilerType() {
+ return ValueObjectCast::GetCompilerType();
+ }
- lldb::ValueObjectSP
- GetSyntheticChildAtOffset(uint32_t offset,
- const CompilerType& type,
- bool can_create,
- ConstString name_const_str = ConstString()) override;
+ lldb::ValueObjectSP GetSyntheticChildAtOffset(
+ uint32_t offset, const CompilerType &type, bool can_create,
+ ConstString name_const_str = ConstString()) override;
- lldb::ValueObjectSP
- AddressOf (Error &error) override;
+ lldb::ValueObjectSP AddressOf(Error &error) override;
- size_t
- GetPointeeData (DataExtractor& data,
- uint32_t item_idx = 0,
- uint32_t item_count = 1) override;
+ size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
+ uint32_t item_count = 1) override;
- lldb::ValueObjectSP
- Cast (const CompilerType &compiler_type) override;
+ lldb::ValueObjectSP Cast(const CompilerType &compiler_type) override;
protected:
- ValueObjectConstResultImpl m_impl;
+ ValueObjectConstResultImpl m_impl;
private:
- friend class ValueObject;
- friend class ValueObjectConstResult;
- friend class ValueObjectConstResultImpl;
+ friend class ValueObject;
+ friend class ValueObjectConstResult;
+ friend class ValueObjectConstResultImpl;
- DISALLOW_COPY_AND_ASSIGN (ValueObjectConstResultCast);
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectConstResultCast);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/ValueObjectConstResultChild.h b/include/lldb/Core/ValueObjectConstResultChild.h
index e4a238a96c8f..66127b94b422 100644
--- a/include/lldb/Core/ValueObjectConstResultChild.h
+++ b/include/lldb/Core/ValueObjectConstResultChild.h
@@ -1,4 +1,5 @@
-//===-- ValueObjectConstResultChild.h -------------------------------*- C++ -*-===//
+//===-- ValueObjectConstResultChild.h -------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -22,62 +23,48 @@ namespace lldb_private {
//----------------------------------------------------------------------
// A child of a ValueObjectConstResult.
//----------------------------------------------------------------------
-class ValueObjectConstResultChild : public ValueObjectChild
-{
+class ValueObjectConstResultChild : public ValueObjectChild {
public:
-
- ValueObjectConstResultChild (ValueObject &parent,
- const CompilerType &compiler_type,
- const ConstString &name,
- uint32_t byte_size,
- int32_t byte_offset,
- uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset,
- bool is_base_class,
- bool is_deref_of_parent,
- lldb::addr_t live_address,
- uint64_t language_flags);
-
- ~ValueObjectConstResultChild() override;
-
- lldb::ValueObjectSP
- Dereference(Error &error) override;
-
- ValueObject *
- CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index) override;
-
- virtual CompilerType
- GetCompilerType ()
- {
- return ValueObjectChild::GetCompilerType();
- }
-
- lldb::ValueObjectSP
- GetSyntheticChildAtOffset(uint32_t offset,
- const CompilerType& type,
- bool can_create,
- ConstString name_const_str = ConstString()) override;
-
- lldb::ValueObjectSP
- AddressOf (Error &error) override;
-
- size_t
- GetPointeeData (DataExtractor& data,
- uint32_t item_idx = 0,
- uint32_t item_count = 1) override;
-
- lldb::ValueObjectSP
- Cast (const CompilerType &compiler_type) override;
-
+ ValueObjectConstResultChild(ValueObject &parent,
+ const CompilerType &compiler_type,
+ const ConstString &name, uint32_t byte_size,
+ int32_t byte_offset, uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset, bool is_base_class,
+ bool is_deref_of_parent,
+ lldb::addr_t live_address,
+ uint64_t language_flags);
+
+ ~ValueObjectConstResultChild() override;
+
+ lldb::ValueObjectSP Dereference(Error &error) override;
+
+ ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
+ int32_t synthetic_index) override;
+
+ virtual CompilerType GetCompilerType() {
+ return ValueObjectChild::GetCompilerType();
+ }
+
+ lldb::ValueObjectSP GetSyntheticChildAtOffset(
+ uint32_t offset, const CompilerType &type, bool can_create,
+ ConstString name_const_str = ConstString()) override;
+
+ lldb::ValueObjectSP AddressOf(Error &error) override;
+
+ size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
+ uint32_t item_count = 1) override;
+
+ lldb::ValueObjectSP Cast(const CompilerType &compiler_type) override;
+
protected:
- ValueObjectConstResultImpl m_impl;
-
+ ValueObjectConstResultImpl m_impl;
+
private:
- friend class ValueObject;
- friend class ValueObjectConstResult;
- friend class ValueObjectConstResultImpl;
+ friend class ValueObject;
+ friend class ValueObjectConstResult;
+ friend class ValueObjectConstResultImpl;
- DISALLOW_COPY_AND_ASSIGN (ValueObjectConstResultChild);
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectConstResultChild);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/ValueObjectConstResultImpl.h b/include/lldb/Core/ValueObjectConstResultImpl.h
index 848a221c3d05..c26bf419b18e 100644
--- a/include/lldb/Core/ValueObjectConstResultImpl.h
+++ b/include/lldb/Core/ValueObjectConstResultImpl.h
@@ -23,64 +23,49 @@ namespace lldb_private {
// ValueObjectConstResult ( & Child ) that may need to jump from the host
// memory space into the target's memory space
//----------------------------------------------------------------------
-class ValueObjectConstResultImpl
-{
+class ValueObjectConstResultImpl {
public:
- ValueObjectConstResultImpl (ValueObject* valobj,
- lldb::addr_t live_address = LLDB_INVALID_ADDRESS);
-
- virtual
- ~ValueObjectConstResultImpl() = default;
-
- lldb::ValueObjectSP
- Dereference (Error &error);
-
- ValueObject *
- CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index);
-
- lldb::ValueObjectSP
- GetSyntheticChildAtOffset (uint32_t offset,
- const CompilerType& type,
- bool can_create,
- ConstString name_const_str = ConstString());
-
- lldb::ValueObjectSP
- AddressOf (Error &error);
-
- lldb::addr_t
- GetLiveAddress()
- {
- return m_live_address;
- }
-
- lldb::ValueObjectSP
- Cast (const CompilerType &compiler_type);
-
- void
- SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS,
- AddressType address_type = eAddressTypeLoad)
- {
- m_live_address = addr;
- m_live_address_type = address_type;
- }
-
- virtual lldb::addr_t
- GetAddressOf(bool scalar_is_load_address = true,
- AddressType *address_type = nullptr);
-
- virtual size_t
- GetPointeeData(DataExtractor& data,
- uint32_t item_idx = 0,
- uint32_t item_count = 1);
-
+ ValueObjectConstResultImpl(ValueObject *valobj,
+ lldb::addr_t live_address = LLDB_INVALID_ADDRESS);
+
+ virtual ~ValueObjectConstResultImpl() = default;
+
+ lldb::ValueObjectSP Dereference(Error &error);
+
+ ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
+ int32_t synthetic_index);
+
+ lldb::ValueObjectSP
+ GetSyntheticChildAtOffset(uint32_t offset, const CompilerType &type,
+ bool can_create,
+ ConstString name_const_str = ConstString());
+
+ lldb::ValueObjectSP AddressOf(Error &error);
+
+ lldb::addr_t GetLiveAddress() { return m_live_address; }
+
+ lldb::ValueObjectSP Cast(const CompilerType &compiler_type);
+
+ void SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS,
+ AddressType address_type = eAddressTypeLoad) {
+ m_live_address = addr;
+ m_live_address_type = address_type;
+ }
+
+ virtual lldb::addr_t GetAddressOf(bool scalar_is_load_address = true,
+ AddressType *address_type = nullptr);
+
+ virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
+ uint32_t item_count = 1);
+
private:
- ValueObject *m_impl_backend;
- lldb::addr_t m_live_address;
- AddressType m_live_address_type;
- lldb::ValueObjectSP m_load_addr_backend;
- lldb::ValueObjectSP m_address_of_backend;
-
- DISALLOW_COPY_AND_ASSIGN (ValueObjectConstResultImpl);
+ ValueObject *m_impl_backend;
+ lldb::addr_t m_live_address;
+ AddressType m_live_address_type;
+ lldb::ValueObjectSP m_load_addr_backend;
+ lldb::ValueObjectSP m_address_of_backend;
+
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectConstResultImpl);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/ValueObjectDynamicValue.h b/include/lldb/Core/ValueObjectDynamicValue.h
index 8a045c3b0db1..e58e74f534aa 100644
--- a/include/lldb/Core/ValueObjectDynamicValue.h
+++ b/include/lldb/Core/ValueObjectDynamicValue.h
@@ -20,156 +20,107 @@
namespace lldb_private {
//----------------------------------------------------------------------
-// A ValueObject that represents memory at a given address, viewed as some
+// A ValueObject that represents memory at a given address, viewed as some
// set lldb type.
//----------------------------------------------------------------------
-class ValueObjectDynamicValue : public ValueObject
-{
+class ValueObjectDynamicValue : public ValueObject {
public:
- ~ValueObjectDynamicValue() override;
-
- uint64_t
- GetByteSize() override;
-
- ConstString
- GetTypeName() override;
-
- ConstString
- GetQualifiedTypeName() override;
-
- ConstString
- GetDisplayTypeName() override;
-
- size_t
- CalculateNumChildren(uint32_t max) override;
-
- lldb::ValueType
- GetValueType() const override;
-
- bool
- IsInScope() override;
-
- bool
- IsDynamic() override
- {
- return true;
- }
-
- bool
- IsBaseClass () override
- {
- if (m_parent)
- return m_parent->IsBaseClass();
- return false;
- }
-
- bool
- GetIsConstant() const override
- {
- return false;
- }
-
- ValueObject *
- GetParent() override
- {
- return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
- }
-
- const ValueObject *
- GetParent() const override
- {
- return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
- }
-
- lldb::ValueObjectSP
- GetStaticValue() override
- {
- return m_parent->GetSP();
- }
-
- void
- SetOwningSP (lldb::ValueObjectSP &owning_sp)
- {
- if (m_owning_valobj_sp == owning_sp)
- return;
-
- assert (m_owning_valobj_sp.get() == nullptr);
- m_owning_valobj_sp = owning_sp;
- }
-
- bool
- SetValueFromCString(const char *value_str, Error& error) override;
-
- bool
- SetData(DataExtractor &data, Error &error) override;
-
- TypeImpl
- GetTypeImpl() override;
-
- lldb::VariableSP
- GetVariable () override
- {
- return m_parent ? m_parent->GetVariable() : nullptr;
- }
-
- lldb::LanguageType
- GetPreferredDisplayLanguage() override;
-
- void
- SetPreferredDisplayLanguage (lldb::LanguageType);
-
- bool
- IsSyntheticChildrenGenerated () override;
-
- void
- SetSyntheticChildrenGenerated (bool b) override;
-
- bool
- GetDeclaration(Declaration &decl) override;
-
- uint64_t
- GetLanguageFlags () override;
-
- void
- SetLanguageFlags (uint64_t flags) override;
+ ~ValueObjectDynamicValue() override;
+
+ uint64_t GetByteSize() override;
+
+ ConstString GetTypeName() override;
+
+ ConstString GetQualifiedTypeName() override;
+
+ ConstString GetDisplayTypeName() override;
+
+ size_t CalculateNumChildren(uint32_t max) override;
+
+ lldb::ValueType GetValueType() const override;
+
+ bool IsInScope() override;
+
+ bool IsDynamic() override { return true; }
+
+ bool IsBaseClass() override {
+ if (m_parent)
+ return m_parent->IsBaseClass();
+ return false;
+ }
+
+ bool GetIsConstant() const override { return false; }
+
+ ValueObject *GetParent() override {
+ return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
+ }
+
+ const ValueObject *GetParent() const override {
+ return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
+ }
+
+ lldb::ValueObjectSP GetStaticValue() override { return m_parent->GetSP(); }
+
+ void SetOwningSP(lldb::ValueObjectSP &owning_sp) {
+ if (m_owning_valobj_sp == owning_sp)
+ return;
+
+ assert(m_owning_valobj_sp.get() == nullptr);
+ m_owning_valobj_sp = owning_sp;
+ }
+
+ bool SetValueFromCString(const char *value_str, Error &error) override;
+
+ bool SetData(DataExtractor &data, Error &error) override;
+
+ TypeImpl GetTypeImpl() override;
+
+ lldb::VariableSP GetVariable() override {
+ return m_parent ? m_parent->GetVariable() : nullptr;
+ }
+
+ lldb::LanguageType GetPreferredDisplayLanguage() override;
+
+ void SetPreferredDisplayLanguage(lldb::LanguageType);
+
+ bool IsSyntheticChildrenGenerated() override;
+
+ void SetSyntheticChildrenGenerated(bool b) override;
+
+ bool GetDeclaration(Declaration &decl) override;
+
+ uint64_t GetLanguageFlags() override;
+
+ void SetLanguageFlags(uint64_t flags) override;
protected:
- bool
- UpdateValue() override;
-
- LazyBool
- CanUpdateWithInvalidExecutionContext() override
- {
- return eLazyBoolYes;
- }
-
- lldb::DynamicValueType
- GetDynamicValueTypeImpl() override
- {
- return m_use_dynamic;
- }
-
- bool
- HasDynamicValueTypeInfo() override
- {
- return true;
- }
-
- CompilerType
- GetCompilerTypeImpl() override;
-
- Address m_address; ///< The variable that this value object is based upon
- TypeAndOrName m_dynamic_type_info; // We can have a type_sp or just a name
- lldb::ValueObjectSP m_owning_valobj_sp;
- lldb::DynamicValueType m_use_dynamic;
- TypeImpl m_type_impl;
+ bool UpdateValue() override;
+
+ LazyBool CanUpdateWithInvalidExecutionContext() override {
+ return eLazyBoolYes;
+ }
+
+ lldb::DynamicValueType GetDynamicValueTypeImpl() override {
+ return m_use_dynamic;
+ }
+
+ bool HasDynamicValueTypeInfo() override { return true; }
+
+ CompilerType GetCompilerTypeImpl() override;
+
+ Address m_address; ///< The variable that this value object is based upon
+ TypeAndOrName m_dynamic_type_info; // We can have a type_sp or just a name
+ lldb::ValueObjectSP m_owning_valobj_sp;
+ lldb::DynamicValueType m_use_dynamic;
+ TypeImpl m_type_impl;
private:
- friend class ValueObject;
- friend class ValueObjectConstResult;
- ValueObjectDynamicValue (ValueObject &parent, lldb::DynamicValueType use_dynamic);
+ friend class ValueObject;
+ friend class ValueObjectConstResult;
+ ValueObjectDynamicValue(ValueObject &parent,
+ lldb::DynamicValueType use_dynamic);
- DISALLOW_COPY_AND_ASSIGN (ValueObjectDynamicValue);
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectDynamicValue);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/ValueObjectList.h b/include/lldb/Core/ValueObjectList.h
index 4f5e7b246fbd..c5427c6a846e 100644
--- a/include/lldb/Core/ValueObjectList.h
+++ b/include/lldb/Core/ValueObjectList.h
@@ -16,80 +16,63 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/UserID.h"
#include "lldb/Target/ExecutionContextScope.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
// A collection of ValueObject values that
//----------------------------------------------------------------------
-class ValueObjectList
-{
+class ValueObjectList {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- ValueObjectList ();
-
- ValueObjectList (const ValueObjectList &rhs);
-
- ~ValueObjectList();
-
- const ValueObjectList &
- operator = (const ValueObjectList &rhs);
-
- void
- Append (const lldb::ValueObjectSP &val_obj_sp);
-
- void
- Append (const ValueObjectList &valobj_list);
-
- lldb::ValueObjectSP
- FindValueObjectByPointer (ValueObject *valobj);
-
- size_t
- GetSize () const;
-
- void
- Resize (size_t size);
-
- lldb::ValueObjectSP
- GetValueObjectAtIndex (size_t idx);
-
- lldb::ValueObjectSP
- RemoveValueObjectAtIndex (size_t idx);
-
- void
- SetValueObjectAtIndex (size_t idx,
- const lldb::ValueObjectSP &valobj_sp);
-
- lldb::ValueObjectSP
- FindValueObjectByValueName (const char *name);
-
- lldb::ValueObjectSP
- FindValueObjectByUID (lldb::user_id_t uid);
-
- void
- Swap (ValueObjectList &value_object_list);
-
- void
- Clear ()
- {
- m_value_objects.clear();
- }
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ ValueObjectList();
-protected:
- typedef std::vector<lldb::ValueObjectSP> collection;
- //------------------------------------------------------------------
- // Classes that inherit from ValueObjectList can see and modify these
- //------------------------------------------------------------------
- collection m_value_objects;
+ ValueObjectList(const ValueObjectList &rhs);
-};
+ ~ValueObjectList();
+
+ const ValueObjectList &operator=(const ValueObjectList &rhs);
+
+ void Append(const lldb::ValueObjectSP &val_obj_sp);
+
+ void Append(const ValueObjectList &valobj_list);
+
+ lldb::ValueObjectSP FindValueObjectByPointer(ValueObject *valobj);
+
+ size_t GetSize() const;
+
+ void Resize(size_t size);
+ lldb::ValueObjectSP GetValueObjectAtIndex(size_t idx);
+
+ lldb::ValueObjectSP RemoveValueObjectAtIndex(size_t idx);
+
+ void SetValueObjectAtIndex(size_t idx, const lldb::ValueObjectSP &valobj_sp);
+
+ lldb::ValueObjectSP FindValueObjectByValueName(const char *name);
+
+ lldb::ValueObjectSP FindValueObjectByUID(lldb::user_id_t uid);
+
+ void Swap(ValueObjectList &value_object_list);
+
+ void Clear() { m_value_objects.clear(); }
+
+ const std::vector<lldb::ValueObjectSP> &GetObjects() const {
+ return m_value_objects;
+ }
+protected:
+ typedef std::vector<lldb::ValueObjectSP> collection;
+ //------------------------------------------------------------------
+ // Classes that inherit from ValueObjectList can see and modify these
+ //------------------------------------------------------------------
+ collection m_value_objects;
+};
} // namespace lldb_private
-#endif // liblldb_ValueObjectList_h_
+#endif // liblldb_ValueObjectList_h_
diff --git a/include/lldb/Core/ValueObjectMemory.h b/include/lldb/Core/ValueObjectMemory.h
index 0e12fc7e3f28..f9891c41cec6 100644
--- a/include/lldb/Core/ValueObjectMemory.h
+++ b/include/lldb/Core/ValueObjectMemory.h
@@ -20,72 +20,56 @@
namespace lldb_private {
//----------------------------------------------------------------------
-// A ValueObject that represents memory at a given address, viewed as some
+// A ValueObject that represents memory at a given address, viewed as some
// set lldb type.
//----------------------------------------------------------------------
-class ValueObjectMemory : public ValueObject
-{
+class ValueObjectMemory : public ValueObject {
public:
- ~ValueObjectMemory() override;
+ ~ValueObjectMemory() override;
- static lldb::ValueObjectSP
- Create (ExecutionContextScope *exe_scope,
- const char *name,
- const Address &address,
- lldb::TypeSP &type_sp);
+ static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
+ llvm::StringRef name,
+ const Address &address,
+ lldb::TypeSP &type_sp);
- static lldb::ValueObjectSP
- Create (ExecutionContextScope *exe_scope,
- const char *name,
- const Address &address,
- const CompilerType &ast_type);
+ static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
+ llvm::StringRef name,
+ const Address &address,
+ const CompilerType &ast_type);
- uint64_t
- GetByteSize() override;
+ uint64_t GetByteSize() override;
- ConstString
- GetTypeName() override;
+ ConstString GetTypeName() override;
- ConstString
- GetDisplayTypeName() override;
-
- size_t
- CalculateNumChildren(uint32_t max) override;
+ ConstString GetDisplayTypeName() override;
- lldb::ValueType
- GetValueType() const override;
+ size_t CalculateNumChildren(uint32_t max) override;
- bool
- IsInScope() override;
+ lldb::ValueType GetValueType() const override;
- lldb::ModuleSP
- GetModule() override;
+ bool IsInScope() override;
+
+ lldb::ModuleSP GetModule() override;
protected:
- bool
- UpdateValue() override;
-
- CompilerType
- GetCompilerTypeImpl() override;
+ bool UpdateValue() override;
+
+ CompilerType GetCompilerTypeImpl() override;
- Address m_address; ///< The variable that this value object is based upon
- lldb::TypeSP m_type_sp;
- CompilerType m_compiler_type;
+ Address m_address; ///< The variable that this value object is based upon
+ lldb::TypeSP m_type_sp;
+ CompilerType m_compiler_type;
private:
- ValueObjectMemory (ExecutionContextScope *exe_scope,
- const char *name,
- const Address &address,
- lldb::TypeSP &type_sp);
-
- ValueObjectMemory (ExecutionContextScope *exe_scope,
- const char *name,
- const Address &address,
- const CompilerType &ast_type);
- //------------------------------------------------------------------
- // For ValueObject only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (ValueObjectMemory);
+ ValueObjectMemory(ExecutionContextScope *exe_scope, llvm::StringRef name,
+ const Address &address, lldb::TypeSP &type_sp);
+
+ ValueObjectMemory(ExecutionContextScope *exe_scope, llvm::StringRef name,
+ const Address &address, const CompilerType &ast_type);
+ //------------------------------------------------------------------
+ // For ValueObject only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectMemory);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/ValueObjectRegister.h b/include/lldb/Core/ValueObjectRegister.h
index ac76f9e4280b..11d205430af8 100644
--- a/include/lldb/Core/ValueObjectRegister.h
+++ b/include/lldb/Core/ValueObjectRegister.h
@@ -14,9 +14,9 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/ValueObject.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -24,171 +24,146 @@ namespace lldb_private {
// A ValueObject that contains a root variable that may or may not
// have children.
//----------------------------------------------------------------------
-class ValueObjectRegisterContext : public ValueObject
-{
+class ValueObjectRegisterContext : public ValueObject {
public:
- ~ValueObjectRegisterContext() override;
+ ~ValueObjectRegisterContext() override;
+
+ uint64_t GetByteSize() override;
- uint64_t
- GetByteSize() override;
+ lldb::ValueType GetValueType() const override {
+ return lldb::eValueTypeRegisterSet;
+ }
- lldb::ValueType
- GetValueType() const override
- {
- return lldb::eValueTypeRegisterSet;
- }
+ ConstString GetTypeName() override;
- ConstString
- GetTypeName() override;
-
- ConstString
- GetQualifiedTypeName() override;
-
- ConstString
- GetDisplayTypeName() override;
+ ConstString GetQualifiedTypeName() override;
- size_t
- CalculateNumChildren(uint32_t max) override;
+ ConstString GetDisplayTypeName() override;
- ValueObject *
- CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index) override;
+ size_t CalculateNumChildren(uint32_t max) override;
+
+ ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
+ int32_t synthetic_index) override;
protected:
- bool
- UpdateValue() override;
-
- CompilerType
- GetCompilerTypeImpl() override;
+ bool UpdateValue() override;
+
+ CompilerType GetCompilerTypeImpl() override;
- lldb::RegisterContextSP m_reg_ctx_sp;
+ lldb::RegisterContextSP m_reg_ctx_sp;
private:
- ValueObjectRegisterContext (ValueObject &parent, lldb::RegisterContextSP &reg_ctx_sp);
- //------------------------------------------------------------------
- // For ValueObject only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (ValueObjectRegisterContext);
+ ValueObjectRegisterContext(ValueObject &parent,
+ lldb::RegisterContextSP &reg_ctx_sp);
+ //------------------------------------------------------------------
+ // For ValueObject only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectRegisterContext);
};
-class ValueObjectRegisterSet : public ValueObject
-{
+class ValueObjectRegisterSet : public ValueObject {
public:
- ~ValueObjectRegisterSet() override;
+ ~ValueObjectRegisterSet() override;
+
+ static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
+ lldb::RegisterContextSP &reg_ctx_sp,
+ uint32_t set_idx);
- static lldb::ValueObjectSP
- Create (ExecutionContextScope *exe_scope, lldb::RegisterContextSP &reg_ctx_sp, uint32_t set_idx);
+ uint64_t GetByteSize() override;
- uint64_t
- GetByteSize() override;
+ lldb::ValueType GetValueType() const override {
+ return lldb::eValueTypeRegisterSet;
+ }
- lldb::ValueType
- GetValueType() const override
- {
- return lldb::eValueTypeRegisterSet;
- }
+ ConstString GetTypeName() override;
- ConstString
- GetTypeName() override;
-
- ConstString
- GetQualifiedTypeName() override;
+ ConstString GetQualifiedTypeName() override;
- size_t
- CalculateNumChildren(uint32_t max) override;
+ size_t CalculateNumChildren(uint32_t max) override;
- ValueObject *
- CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index) override;
-
- lldb::ValueObjectSP
- GetChildMemberWithName(const ConstString &name, bool can_create) override;
+ ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
+ int32_t synthetic_index) override;
- size_t
- GetIndexOfChildWithName(const ConstString &name) override;
+ lldb::ValueObjectSP GetChildMemberWithName(const ConstString &name,
+ bool can_create) override;
+
+ size_t GetIndexOfChildWithName(const ConstString &name) override;
protected:
- bool
- UpdateValue() override;
-
- CompilerType
- GetCompilerTypeImpl() override;
+ bool UpdateValue() override;
+
+ CompilerType GetCompilerTypeImpl() override;
- lldb::RegisterContextSP m_reg_ctx_sp;
- const RegisterSet *m_reg_set;
- uint32_t m_reg_set_idx;
+ lldb::RegisterContextSP m_reg_ctx_sp;
+ const RegisterSet *m_reg_set;
+ uint32_t m_reg_set_idx;
private:
- friend class ValueObjectRegisterContext;
+ friend class ValueObjectRegisterContext;
- ValueObjectRegisterSet (ExecutionContextScope *exe_scope, lldb::RegisterContextSP &reg_ctx_sp, uint32_t set_idx);
+ ValueObjectRegisterSet(ExecutionContextScope *exe_scope,
+ lldb::RegisterContextSP &reg_ctx_sp, uint32_t set_idx);
- //------------------------------------------------------------------
- // For ValueObject only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (ValueObjectRegisterSet);
+ //------------------------------------------------------------------
+ // For ValueObject only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectRegisterSet);
};
-class ValueObjectRegister : public ValueObject
-{
+class ValueObjectRegister : public ValueObject {
public:
- ~ValueObjectRegister() override;
-
- static lldb::ValueObjectSP
- Create (ExecutionContextScope *exe_scope, lldb::RegisterContextSP &reg_ctx_sp, uint32_t reg_num);
-
- uint64_t
- GetByteSize() override;
-
- lldb::ValueType
- GetValueType() const override
- {
- return lldb::eValueTypeRegister;
- }
-
- ConstString
- GetTypeName() override;
-
- size_t
- CalculateNumChildren(uint32_t max) override;
-
- bool
- SetValueFromCString(const char *value_str, Error& error) override;
-
- bool
- SetData(DataExtractor &data, Error &error) override;
-
- bool
- ResolveValue(Scalar &scalar) override;
-
- void
- GetExpressionPath(Stream &s, bool qualify_cxx_base_classes,
- GetExpressionPathFormat epformat = eGetExpressionPathFormatDereferencePointers) override;
+ ~ValueObjectRegister() override;
+
+ static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
+ lldb::RegisterContextSP &reg_ctx_sp,
+ uint32_t reg_num);
+
+ uint64_t GetByteSize() override;
+
+ lldb::ValueType GetValueType() const override {
+ return lldb::eValueTypeRegister;
+ }
+
+ ConstString GetTypeName() override;
+
+ size_t CalculateNumChildren(uint32_t max) override;
+
+ bool SetValueFromCString(const char *value_str, Error &error) override;
+
+ bool SetData(DataExtractor &data, Error &error) override;
+
+ bool ResolveValue(Scalar &scalar) override;
+
+ void
+ GetExpressionPath(Stream &s, bool qualify_cxx_base_classes,
+ GetExpressionPathFormat epformat =
+ eGetExpressionPathFormatDereferencePointers) override;
protected:
- bool
- UpdateValue() override;
-
- CompilerType
- GetCompilerTypeImpl() override;
-
- lldb::RegisterContextSP m_reg_ctx_sp;
- RegisterInfo m_reg_info;
- RegisterValue m_reg_value;
- ConstString m_type_name;
- CompilerType m_compiler_type;
+ bool UpdateValue() override;
+
+ CompilerType GetCompilerTypeImpl() override;
+
+ lldb::RegisterContextSP m_reg_ctx_sp;
+ RegisterInfo m_reg_info;
+ RegisterValue m_reg_value;
+ ConstString m_type_name;
+ CompilerType m_compiler_type;
private:
- void
- ConstructObject (uint32_t reg_num);
-
- friend class ValueObjectRegisterSet;
-
- ValueObjectRegister (ValueObject &parent, lldb::RegisterContextSP &reg_ctx_sp, uint32_t reg_num);
- ValueObjectRegister (ExecutionContextScope *exe_scope, lldb::RegisterContextSP &reg_ctx_sp, uint32_t reg_num);
-
- //------------------------------------------------------------------
- // For ValueObject only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (ValueObjectRegister);
+ void ConstructObject(uint32_t reg_num);
+
+ friend class ValueObjectRegisterSet;
+
+ ValueObjectRegister(ValueObject &parent, lldb::RegisterContextSP &reg_ctx_sp,
+ uint32_t reg_num);
+ ValueObjectRegister(ExecutionContextScope *exe_scope,
+ lldb::RegisterContextSP &reg_ctx_sp, uint32_t reg_num);
+
+ //------------------------------------------------------------------
+ // For ValueObject only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectRegister);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/ValueObjectSyntheticFilter.h b/include/lldb/Core/ValueObjectSyntheticFilter.h
index 38d9f7b5ade1..0a5a4d9f7029 100644
--- a/include/lldb/Core/ValueObjectSyntheticFilter.h
+++ b/include/lldb/Core/ValueObjectSyntheticFilter.h
@@ -29,185 +29,134 @@ namespace lldb_private {
// but you can bind it to any source of synthetic information and have
// it behave accordingly
//----------------------------------------------------------------------
-class ValueObjectSynthetic : public ValueObject
-{
+class ValueObjectSynthetic : public ValueObject {
public:
- ~ValueObjectSynthetic() override;
-
- uint64_t
- GetByteSize() override;
-
- ConstString
- GetTypeName() override;
-
- ConstString
- GetQualifiedTypeName() override;
-
- ConstString
- GetDisplayTypeName() override;
-
- bool
- MightHaveChildren() override;
-
- size_t
- CalculateNumChildren(uint32_t max) override;
-
- lldb::ValueType
- GetValueType() const override;
-
- lldb::ValueObjectSP
- GetChildAtIndex(size_t idx, bool can_create) override;
-
- lldb::ValueObjectSP
- GetChildMemberWithName(const ConstString &name, bool can_create) override;
-
- size_t
- GetIndexOfChildWithName(const ConstString &name) override;
-
- lldb::ValueObjectSP
- GetDynamicValue(lldb::DynamicValueType valueType) override;
-
- bool
- IsInScope() override;
-
- bool
- HasSyntheticValue() override
- {
- return false;
- }
-
- bool
- IsSynthetic() override
- {
- return true;
- }
-
- void
- CalculateSyntheticValue(bool use_synthetic) override
- {
- }
-
- bool
- IsDynamic() override
- {
- return ((m_parent != nullptr) ? m_parent->IsDynamic() : false);
- }
-
- lldb::ValueObjectSP
- GetStaticValue() override
- {
- return ((m_parent != nullptr) ? m_parent->GetStaticValue() : GetSP());
- }
-
- virtual lldb::DynamicValueType
- GetDynamicValueType ()
- {
- return ((m_parent != nullptr) ? m_parent->GetDynamicValueType() : lldb::eNoDynamicValues);
- }
-
- ValueObject *
- GetParent() override
- {
- return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
- }
-
- const ValueObject *
- GetParent() const override
- {
- return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
- }
-
- lldb::ValueObjectSP
- GetNonSyntheticValue() override;
-
- bool
- CanProvideValue() override;
-
- bool
- DoesProvideSyntheticValue() override
- {
- return (UpdateValueIfNeeded(), m_provides_value == eLazyBoolYes);
- }
-
- bool
- GetIsConstant() const override
- {
- return false;
- }
-
- bool
- SetValueFromCString(const char *value_str, Error& error) override;
-
- void
- SetFormat(lldb::Format format) override;
-
- lldb::LanguageType
- GetPreferredDisplayLanguage() override;
-
- void
- SetPreferredDisplayLanguage (lldb::LanguageType);
-
- bool
- IsSyntheticChildrenGenerated () override;
-
- void
- SetSyntheticChildrenGenerated (bool b) override;
-
- bool
- GetDeclaration(Declaration &decl) override;
-
- uint64_t
- GetLanguageFlags () override;
-
- void
- SetLanguageFlags (uint64_t flags) override;
-
+ ~ValueObjectSynthetic() override;
+
+ uint64_t GetByteSize() override;
+
+ ConstString GetTypeName() override;
+
+ ConstString GetQualifiedTypeName() override;
+
+ ConstString GetDisplayTypeName() override;
+
+ bool MightHaveChildren() override;
+
+ size_t CalculateNumChildren(uint32_t max) override;
+
+ lldb::ValueType GetValueType() const override;
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create) override;
+
+ lldb::ValueObjectSP GetChildMemberWithName(const ConstString &name,
+ bool can_create) override;
+
+ size_t GetIndexOfChildWithName(const ConstString &name) override;
+
+ lldb::ValueObjectSP
+ GetDynamicValue(lldb::DynamicValueType valueType) override;
+
+ bool IsInScope() override;
+
+ bool HasSyntheticValue() override { return false; }
+
+ bool IsSynthetic() override { return true; }
+
+ void CalculateSyntheticValue(bool use_synthetic) override {}
+
+ bool IsDynamic() override {
+ return ((m_parent != nullptr) ? m_parent->IsDynamic() : false);
+ }
+
+ lldb::ValueObjectSP GetStaticValue() override {
+ return ((m_parent != nullptr) ? m_parent->GetStaticValue() : GetSP());
+ }
+
+ virtual lldb::DynamicValueType GetDynamicValueType() {
+ return ((m_parent != nullptr) ? m_parent->GetDynamicValueType()
+ : lldb::eNoDynamicValues);
+ }
+
+ ValueObject *GetParent() override {
+ return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
+ }
+
+ const ValueObject *GetParent() const override {
+ return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
+ }
+
+ lldb::ValueObjectSP GetNonSyntheticValue() override;
+
+ bool CanProvideValue() override;
+
+ bool DoesProvideSyntheticValue() override {
+ return (UpdateValueIfNeeded(), m_provides_value == eLazyBoolYes);
+ }
+
+ bool GetIsConstant() const override { return false; }
+
+ bool SetValueFromCString(const char *value_str, Error &error) override;
+
+ void SetFormat(lldb::Format format) override;
+
+ lldb::LanguageType GetPreferredDisplayLanguage() override;
+
+ void SetPreferredDisplayLanguage(lldb::LanguageType);
+
+ bool IsSyntheticChildrenGenerated() override;
+
+ void SetSyntheticChildrenGenerated(bool b) override;
+
+ bool GetDeclaration(Declaration &decl) override;
+
+ uint64_t GetLanguageFlags() override;
+
+ void SetLanguageFlags(uint64_t flags) override;
+
protected:
- bool
- UpdateValue() override;
-
- LazyBool
- CanUpdateWithInvalidExecutionContext() override
- {
- return eLazyBoolYes;
- }
-
- CompilerType
- GetCompilerTypeImpl() override;
-
- virtual void
- CreateSynthFilter ();
-
- // we need to hold on to the SyntheticChildren because someone might delete the type binding while we are alive
- lldb::SyntheticChildrenSP m_synth_sp;
- std::unique_ptr<SyntheticChildrenFrontEnd> m_synth_filter_ap;
-
- typedef ThreadSafeSTLMap<uint32_t, ValueObject*> ByIndexMap;
- typedef ThreadSafeSTLMap<const char*, uint32_t> NameToIndexMap;
- typedef ThreadSafeSTLVector<lldb::ValueObjectSP> SyntheticChildrenCache;
-
- typedef ByIndexMap::iterator ByIndexIterator;
- typedef NameToIndexMap::iterator NameToIndexIterator;
-
- ByIndexMap m_children_byindex;
- NameToIndexMap m_name_toindex;
- uint32_t m_synthetic_children_count; // FIXME use the ValueObject's ChildrenManager instead of a special purpose solution
- SyntheticChildrenCache m_synthetic_children_cache;
-
- ConstString m_parent_type_name;
-
- LazyBool m_might_have_children;
-
- LazyBool m_provides_value;
-
+ bool UpdateValue() override;
+
+ LazyBool CanUpdateWithInvalidExecutionContext() override {
+ return eLazyBoolYes;
+ }
+
+ CompilerType GetCompilerTypeImpl() override;
+
+ virtual void CreateSynthFilter();
+
+ // we need to hold on to the SyntheticChildren because someone might delete
+ // the type binding while we are alive
+ lldb::SyntheticChildrenSP m_synth_sp;
+ std::unique_ptr<SyntheticChildrenFrontEnd> m_synth_filter_ap;
+
+ typedef ThreadSafeSTLMap<uint32_t, ValueObject *> ByIndexMap;
+ typedef ThreadSafeSTLMap<const char *, uint32_t> NameToIndexMap;
+ typedef ThreadSafeSTLVector<lldb::ValueObjectSP> SyntheticChildrenCache;
+
+ typedef ByIndexMap::iterator ByIndexIterator;
+ typedef NameToIndexMap::iterator NameToIndexIterator;
+
+ ByIndexMap m_children_byindex;
+ NameToIndexMap m_name_toindex;
+ uint32_t m_synthetic_children_count; // FIXME use the ValueObject's
+ // ChildrenManager instead of a special
+ // purpose solution
+ SyntheticChildrenCache m_synthetic_children_cache;
+
+ ConstString m_parent_type_name;
+
+ LazyBool m_might_have_children;
+
+ LazyBool m_provides_value;
+
private:
- friend class ValueObject;
- ValueObjectSynthetic (ValueObject &parent, lldb::SyntheticChildrenSP filter);
-
- void
- CopyValueData (ValueObject *source);
-
- DISALLOW_COPY_AND_ASSIGN (ValueObjectSynthetic);
+ friend class ValueObject;
+ ValueObjectSynthetic(ValueObject &parent, lldb::SyntheticChildrenSP filter);
+
+ void CopyValueData(ValueObject *source);
+
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectSynthetic);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/ValueObjectVariable.h b/include/lldb/Core/ValueObjectVariable.h
index 4adb6bad0ada..b76c48a24cd9 100644
--- a/include/lldb/Core/ValueObjectVariable.h
+++ b/include/lldb/Core/ValueObjectVariable.h
@@ -22,75 +22,58 @@ namespace lldb_private {
// A ValueObject that contains a root variable that may or may not
// have children.
//----------------------------------------------------------------------
-class ValueObjectVariable : public ValueObject
-{
+class ValueObjectVariable : public ValueObject {
public:
- ~ValueObjectVariable() override;
-
- static lldb::ValueObjectSP
- Create (ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp);
-
- uint64_t
- GetByteSize() override;
-
- ConstString
- GetTypeName() override;
-
- ConstString
- GetQualifiedTypeName() override;
-
- ConstString
- GetDisplayTypeName() override;
-
- size_t
- CalculateNumChildren(uint32_t max) override;
-
- lldb::ValueType
- GetValueType() const override;
-
- bool
- IsInScope() override;
-
- lldb::ModuleSP
- GetModule() override;
-
- SymbolContextScope *
- GetSymbolContextScope() override;
-
- bool
- GetDeclaration(Declaration &decl) override;
-
- const char *
- GetLocationAsCString() override;
-
- bool
- SetValueFromCString(const char *value_str, Error& error) override;
-
- bool
- SetData(DataExtractor &data, Error &error) override;
-
- virtual lldb::VariableSP
- GetVariable () override
- {
- return m_variable_sp;
- }
-
+ ~ValueObjectVariable() override;
+
+ static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
+ const lldb::VariableSP &var_sp);
+
+ uint64_t GetByteSize() override;
+
+ ConstString GetTypeName() override;
+
+ ConstString GetQualifiedTypeName() override;
+
+ ConstString GetDisplayTypeName() override;
+
+ size_t CalculateNumChildren(uint32_t max) override;
+
+ lldb::ValueType GetValueType() const override;
+
+ bool IsInScope() override;
+
+ lldb::ModuleSP GetModule() override;
+
+ SymbolContextScope *GetSymbolContextScope() override;
+
+ bool GetDeclaration(Declaration &decl) override;
+
+ const char *GetLocationAsCString() override;
+
+ bool SetValueFromCString(const char *value_str, Error &error) override;
+
+ bool SetData(DataExtractor &data, Error &error) override;
+
+ virtual lldb::VariableSP GetVariable() override { return m_variable_sp; }
+
protected:
- bool
- UpdateValue() override;
-
- CompilerType
- GetCompilerTypeImpl() override;
-
- lldb::VariableSP m_variable_sp; ///< The variable that this value object is based upon
- Value m_resolved_value; ///< The value that DWARFExpression resolves this variable to before we patch it up
-
+ bool UpdateValue() override;
+
+ CompilerType GetCompilerTypeImpl() override;
+
+ lldb::VariableSP
+ m_variable_sp; ///< The variable that this value object is based upon
+ Value m_resolved_value; ///< The value that DWARFExpression resolves this
+ ///variable to before we patch it up
+
private:
- ValueObjectVariable (ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp);
- //------------------------------------------------------------------
- // For ValueObject only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (ValueObjectVariable);
+ ValueObjectVariable(ExecutionContextScope *exe_scope,
+ const lldb::VariableSP &var_sp);
+ //------------------------------------------------------------------
+ // For ValueObject only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectVariable);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/dwarf.h b/include/lldb/Core/dwarf.h
index 649a93154b3f..4a935d5151e9 100644
--- a/include/lldb/Core/dwarf.h
+++ b/include/lldb/Core/dwarf.h
@@ -20,24 +20,28 @@
// and stuff them in our default namespace
using namespace llvm::dwarf;
-typedef uint32_t dw_uleb128_t;
-typedef int32_t dw_sleb128_t;
-typedef uint16_t dw_attr_t;
-typedef uint16_t dw_form_t;
-typedef uint16_t dw_tag_t;
-typedef uint64_t dw_addr_t; // Dwarf address define that must be big enough for any addresses in the compile units that get parsed
+typedef uint32_t dw_uleb128_t;
+typedef int32_t dw_sleb128_t;
+typedef uint16_t dw_attr_t;
+typedef uint16_t dw_form_t;
+typedef uint16_t dw_tag_t;
+typedef uint64_t dw_addr_t; // Dwarf address define that must be big enough for
+ // any addresses in the compile units that get
+ // parsed
#ifdef DWARFUTILS_DWARF64
-#define DWARF_REF_ADDR_SIZE 8
-typedef uint64_t dw_offset_t; // Dwarf Debug Information Entry offset for any offset into the file
+#define DWARF_REF_ADDR_SIZE 8
+typedef uint64_t dw_offset_t; // Dwarf Debug Information Entry offset for any
+ // offset into the file
#else
-#define DWARF_REF_ADDR_SIZE 4
-typedef uint32_t dw_offset_t; // Dwarf Debug Information Entry offset for any offset into the file
+#define DWARF_REF_ADDR_SIZE 4
+typedef uint32_t dw_offset_t; // Dwarf Debug Information Entry offset for any
+ // offset into the file
#endif
/* Constants */
-#define DW_INVALID_OFFSET (~(dw_offset_t)0)
-#define DW_INVALID_INDEX 0xFFFFFFFFul
+#define DW_INVALID_OFFSET (~(dw_offset_t)0)
+#define DW_INVALID_INDEX 0xFFFFFFFFul
// #define DW_ADDR_none 0x0
@@ -48,20 +52,34 @@ typedef uint32_t dw_offset_t; // Dwarf Debug Information Entry offset for
//// them in executable files anywhere.
//// These constants fit between DW_OP_lo_user (0xe0) and DW_OP_hi_user (0xff).
//
-//#define DW_OP_APPLE_array_ref 0xEE // first pops index, then pops array; pushes array[index]
-//#define DW_OP_APPLE_extern 0xEF // ULEB128 index of external object (i.e., an entity from the program that was used in the expression)
-#define DW_OP_APPLE_uninit 0xF0 // This is actually generated by some apple compilers in locations lists
-//#define DW_OP_APPLE_assign 0xF1 // pops value off and assigns it to second item on stack (2nd item must have assignable context)
-//#define DW_OP_APPLE_address_of 0xF2 // gets the address of the top stack item (top item must be a variable, or have value_type that is an address already)
-//#define DW_OP_APPLE_value_of 0xF3 // pops the value off the stack and pushes the value of that object (top item must be a variable, or expression local)
-//#define DW_OP_APPLE_deref_type 0xF4 // gets the address of the top stack item (top item must be a variable, or a clang type)
+//#define DW_OP_APPLE_array_ref 0xEE // first pops index, then pops array;
+//pushes array[index]
+//#define DW_OP_APPLE_extern 0xEF // ULEB128 index of external object
+//(i.e., an entity from the program that was used in the expression)
+#define DW_OP_APPLE_uninit \
+ 0xF0 // This is actually generated by some apple compilers in locations lists
+//#define DW_OP_APPLE_assign 0xF1 // pops value off and assigns it to
+//second item on stack (2nd item must have assignable context)
+//#define DW_OP_APPLE_address_of 0xF2 // gets the address of the top stack
+//item (top item must be a variable, or have value_type that is an address
+//already)
+//#define DW_OP_APPLE_value_of 0xF3 // pops the value off the stack and
+//pushes the value of that object (top item must be a variable, or expression
+//local)
+//#define DW_OP_APPLE_deref_type 0xF4 // gets the address of the top stack
+//item (top item must be a variable, or a clang type)
//#define DW_OP_APPLE_expr_local 0xF5 // ULEB128 expression local index
-//#define DW_OP_APPLE_constf 0xF6 // 1 byte float size, followed by constant float data
-//#define DW_OP_APPLE_scalar_cast 0xF7 // Cast top of stack to 2nd in stack's type leaving all items in place
-//#define DW_OP_APPLE_clang_cast 0xF8 // pointer size clang::Type * off the stack and cast top stack item to this type
-//#define DW_OP_APPLE_clear 0xFE // clears the entire expression stack, ok if the stack is empty
-//#define DW_OP_APPLE_error 0xFF // Stops expression evaluation and returns an error (no args)
+//#define DW_OP_APPLE_constf 0xF6 // 1 byte float size, followed by
+//constant float data
+//#define DW_OP_APPLE_scalar_cast 0xF7 // Cast top of stack to 2nd in stack's
+//type leaving all items in place
+//#define DW_OP_APPLE_clang_cast 0xF8 // pointer size clang::Type * off the
+//stack and cast top stack item to this type
+//#define DW_OP_APPLE_clear 0xFE // clears the entire expression stack,
+//ok if the stack is empty
+//#define DW_OP_APPLE_error 0xFF // Stops expression evaluation and
+//returns an error (no args)
typedef lldb_private::RangeArray<dw_addr_t, dw_addr_t, 2> DWARFRangeList;
-#endif // DebugBase_dwarf_h_
+#endif // DebugBase_dwarf_h_
diff --git a/include/lldb/DataFormatters/CXXFunctionPointer.h b/include/lldb/DataFormatters/CXXFunctionPointer.h
index eaa39582eaaa..13af2fd9da1c 100644
--- a/include/lldb/DataFormatters/CXXFunctionPointer.h
+++ b/include/lldb/DataFormatters/CXXFunctionPointer.h
@@ -13,11 +13,10 @@
#include "lldb/lldb-forward.h"
namespace lldb_private {
- namespace formatters
- {
- bool
- CXXFunctionPointerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
- } // namespace formatters
+namespace formatters {
+bool CXXFunctionPointerSummaryProvider(ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options);
+} // namespace formatters
} // namespace lldb_private
#endif // liblldb_CXXFunctionPointer_h_
diff --git a/include/lldb/DataFormatters/DataVisualization.h b/include/lldb/DataFormatters/DataVisualization.h
index 856156670c96..7a632d64c8e9 100644
--- a/include/lldb/DataFormatters/DataVisualization.h
+++ b/include/lldb/DataFormatters/DataVisualization.h
@@ -23,151 +23,124 @@ namespace lldb_private {
// this class is the high-level front-end of LLDB Data Visualization
// code in FormatManager.h/cpp is the low-level implementation of this feature
-// clients should refer to this class as the entry-point into the data formatters
+// clients should refer to this class as the entry-point into the data
+// formatters
// unless they have a good reason to bypass this and go to the backend
-class DataVisualization
-{
+class DataVisualization {
public:
- // use this call to force the FM to consider itself updated even when there is no apparent reason for that
- static void
- ForceUpdate();
-
- static uint32_t
- GetCurrentRevision ();
-
- static bool
- ShouldPrintAsOneLiner (ValueObject& valobj);
-
- static lldb::TypeFormatImplSP
- GetFormat (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
-
- static lldb::TypeFormatImplSP
- GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp);
-
- static lldb::TypeSummaryImplSP
- GetSummaryFormat (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
-
- static lldb::TypeSummaryImplSP
- GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp);
-
+ // use this call to force the FM to consider itself updated even when there is
+ // no apparent reason for that
+ static void ForceUpdate();
+
+ static uint32_t GetCurrentRevision();
+
+ static bool ShouldPrintAsOneLiner(ValueObject &valobj);
+
+ static lldb::TypeFormatImplSP GetFormat(ValueObject &valobj,
+ lldb::DynamicValueType use_dynamic);
+
+ static lldb::TypeFormatImplSP
+ GetFormatForType(lldb::TypeNameSpecifierImplSP type_sp);
+
+ static lldb::TypeSummaryImplSP
+ GetSummaryFormat(ValueObject &valobj, lldb::DynamicValueType use_dynamic);
+
+ static lldb::TypeSummaryImplSP
+ GetSummaryForType(lldb::TypeNameSpecifierImplSP type_sp);
+
#ifndef LLDB_DISABLE_PYTHON
- static lldb::SyntheticChildrenSP
- GetSyntheticChildrenForType (lldb::TypeNameSpecifierImplSP type_sp);
+ static lldb::SyntheticChildrenSP
+ GetSyntheticChildrenForType(lldb::TypeNameSpecifierImplSP type_sp);
#endif
-
- static lldb::TypeFilterImplSP
- GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp);
+
+ static lldb::TypeFilterImplSP
+ GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp);
#ifndef LLDB_DISABLE_PYTHON
- static lldb::ScriptedSyntheticChildrenSP
- GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp);
+ static lldb::ScriptedSyntheticChildrenSP
+ GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp);
#endif
-
+
#ifndef LLDB_DISABLE_PYTHON
- static lldb::SyntheticChildrenSP
- GetSyntheticChildren(ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
+ static lldb::SyntheticChildrenSP
+ GetSyntheticChildren(ValueObject &valobj, lldb::DynamicValueType use_dynamic);
#endif
-
- static lldb::TypeValidatorImplSP
- GetValidator (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
-
- static lldb::TypeValidatorImplSP
- GetValidatorForType (lldb::TypeNameSpecifierImplSP type_sp);
-
- static bool
- AnyMatches(ConstString type_name,
- TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES,
- bool only_enabled = true,
- const char** matching_category = nullptr,
- TypeCategoryImpl::FormatCategoryItems* matching_type = nullptr);
-
- class NamedSummaryFormats
- {
- public:
- static bool
- GetSummaryFormat (const ConstString &type, lldb::TypeSummaryImplSP &entry);
-
- static void
- Add (const ConstString &type, const lldb::TypeSummaryImplSP &entry);
-
- static bool
- Delete (const ConstString &type);
-
- static void
- Clear ();
-
- static void
- ForEach (std::function<bool(ConstString, const lldb::TypeSummaryImplSP&)> callback);
-
- static uint32_t
- GetCount ();
- };
-
- class Categories
- {
- public:
- static bool
- GetCategory (const ConstString &category,
- lldb::TypeCategoryImplSP &entry,
- bool allow_create = true);
-
- static bool
- GetCategory (lldb::LanguageType language,
- lldb::TypeCategoryImplSP &entry);
-
- static void
- Add (const ConstString &category);
-
- static bool
- Delete (const ConstString &category);
-
- static void
- Clear ();
-
- static void
- Clear (const ConstString &category);
-
- static void
- Enable (const ConstString& category,
- TypeCategoryMap::Position = TypeCategoryMap::Default);
-
- static void
- Enable (lldb::LanguageType lang_type);
-
- static void
- Disable (const ConstString& category);
-
- static void
- Disable (lldb::LanguageType lang_type);
-
- static void
- Enable (const lldb::TypeCategoryImplSP& category,
- TypeCategoryMap::Position = TypeCategoryMap::Default);
-
- static void
- Disable (const lldb::TypeCategoryImplSP& category);
-
- static void
- EnableStar ();
-
- static void
- DisableStar ();
-
- static void
- ForEach (TypeCategoryMap::ForEachCallback callback);
-
- static uint32_t
- GetCount ();
-
- static lldb::TypeCategoryImplSP
- GetCategoryAtIndex (size_t);
- };
+
+ static lldb::TypeValidatorImplSP
+ GetValidator(ValueObject &valobj, lldb::DynamicValueType use_dynamic);
+
+ static lldb::TypeValidatorImplSP
+ GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp);
+
+ static bool
+ AnyMatches(ConstString type_name,
+ TypeCategoryImpl::FormatCategoryItems items =
+ TypeCategoryImpl::ALL_ITEM_TYPES,
+ bool only_enabled = true, const char **matching_category = nullptr,
+ TypeCategoryImpl::FormatCategoryItems *matching_type = nullptr);
+
+ class NamedSummaryFormats {
+ public:
+ static bool GetSummaryFormat(const ConstString &type,
+ lldb::TypeSummaryImplSP &entry);
+
+ static void Add(const ConstString &type,
+ const lldb::TypeSummaryImplSP &entry);
+
+ static bool Delete(const ConstString &type);
+
+ static void Clear();
+
+ static void
+ ForEach(std::function<bool(ConstString, const lldb::TypeSummaryImplSP &)>
+ callback);
+
+ static uint32_t GetCount();
+ };
+
+ class Categories {
+ public:
+ static bool GetCategory(const ConstString &category,
+ lldb::TypeCategoryImplSP &entry,
+ bool allow_create = true);
+
+ static bool GetCategory(lldb::LanguageType language,
+ lldb::TypeCategoryImplSP &entry);
+
+ static void Add(const ConstString &category);
+
+ static bool Delete(const ConstString &category);
+
+ static void Clear();
+
+ static void Clear(const ConstString &category);
+
+ static void Enable(const ConstString &category,
+ TypeCategoryMap::Position = TypeCategoryMap::Default);
+
+ static void Enable(lldb::LanguageType lang_type);
+
+ static void Disable(const ConstString &category);
+
+ static void Disable(lldb::LanguageType lang_type);
+
+ static void Enable(const lldb::TypeCategoryImplSP &category,
+ TypeCategoryMap::Position = TypeCategoryMap::Default);
+
+ static void Disable(const lldb::TypeCategoryImplSP &category);
+
+ static void EnableStar();
+
+ static void DisableStar();
+
+ static void ForEach(TypeCategoryMap::ForEachCallback callback);
+
+ static uint32_t GetCount();
+
+ static lldb::TypeCategoryImplSP GetCategoryAtIndex(size_t);
+ };
};
} // namespace lldb_private
-#endif// lldb_DataVisualization_h_
+#endif // lldb_DataVisualization_h_
diff --git a/include/lldb/DataFormatters/DumpValueObjectOptions.h b/include/lldb/DataFormatters/DumpValueObjectOptions.h
index e90bd1bcadcd..b510a3c50311 100644
--- a/include/lldb/DataFormatters/DumpValueObjectOptions.h
+++ b/include/lldb/DataFormatters/DumpValueObjectOptions.h
@@ -23,165 +23,144 @@
#include <string>
namespace lldb_private {
-
-class DumpValueObjectOptions
-{
+
+class DumpValueObjectOptions {
public:
- struct PointerDepth
- {
- enum class Mode
- {
- Always,
- Formatters,
- Default,
- Never
- } m_mode;
- uint32_t m_count;
-
- PointerDepth
- operator --() const
- {
- if (m_count > 0)
- return PointerDepth {m_mode,m_count-1};
- return PointerDepth {m_mode,m_count};
- }
-
- bool
- CanAllowExpansion () const;
-
- bool
- CanAllowExpansion (bool is_root,
- TypeSummaryImpl* entry,
- ValueObject *valobj,
- const std::string& summary);
- };
-
- typedef std::function<bool(ConstString,
- ConstString,
- const DumpValueObjectOptions &,
- Stream&)> DeclPrintingHelper;
-
- static const DumpValueObjectOptions
- DefaultOptions()
- {
- static DumpValueObjectOptions g_default_options;
-
- return g_default_options;
+ struct PointerDepth {
+ enum class Mode { Always, Formatters, Default, Never } m_mode;
+ uint32_t m_count;
+
+ PointerDepth operator--() const {
+ if (m_count > 0)
+ return PointerDepth{m_mode, m_count - 1};
+ return PointerDepth{m_mode, m_count};
}
-
- DumpValueObjectOptions();
-
- DumpValueObjectOptions (const DumpValueObjectOptions& rhs) = default;
-
- DumpValueObjectOptions (ValueObject& valobj);
-
- DumpValueObjectOptions&
- SetMaximumPointerDepth(PointerDepth depth = {PointerDepth::Mode::Never,0});
-
- DumpValueObjectOptions&
- SetMaximumDepth(uint32_t depth = 0);
-
- DumpValueObjectOptions&
- SetDeclPrintingHelper(DeclPrintingHelper helper);
-
- DumpValueObjectOptions&
- SetShowTypes(bool show = false);
-
- DumpValueObjectOptions&
- SetShowLocation(bool show = false);
-
- DumpValueObjectOptions&
- SetUseObjectiveC(bool use = false);
-
- DumpValueObjectOptions&
- SetShowSummary(bool show = true);
-
- DumpValueObjectOptions&
- SetUseDynamicType(lldb::DynamicValueType dyn = lldb::eNoDynamicValues);
-
- DumpValueObjectOptions&
- SetUseSyntheticValue(bool use_synthetic = true);
-
- DumpValueObjectOptions&
- SetScopeChecked(bool check = true);
-
- DumpValueObjectOptions&
- SetFlatOutput(bool flat = false);
-
- DumpValueObjectOptions&
- SetOmitSummaryDepth(uint32_t depth = 0);
-
- DumpValueObjectOptions&
- SetIgnoreCap(bool ignore = false);
-
- DumpValueObjectOptions&
- SetRawDisplay();
-
- DumpValueObjectOptions&
- SetFormat (lldb::Format format = lldb::eFormatDefault);
-
- DumpValueObjectOptions&
- SetSummary (lldb::TypeSummaryImplSP summary = lldb::TypeSummaryImplSP());
-
- DumpValueObjectOptions&
- SetRootValueObjectName(const char* name = nullptr);
-
- DumpValueObjectOptions&
- SetHideRootType (bool hide_root_type = false);
-
- DumpValueObjectOptions&
- SetHideName (bool hide_name = false);
-
- DumpValueObjectOptions&
- SetHideValue (bool hide_value = false);
-
- DumpValueObjectOptions&
- SetHidePointerValue (bool hide = false);
-
- DumpValueObjectOptions&
- SetVariableFormatDisplayLanguage (lldb::LanguageType lang = lldb::eLanguageTypeUnknown);
-
- DumpValueObjectOptions&
- SetRunValidator (bool run = true);
-
- DumpValueObjectOptions&
- SetUseTypeDisplayName (bool dis = false);
-
- DumpValueObjectOptions&
- SetAllowOnelinerMode (bool oneliner = false);
-
- DumpValueObjectOptions&
- SetRevealEmptyAggregates (bool reveal = true);
-
- DumpValueObjectOptions&
- SetElementCount (uint32_t element_count = 0);
+
+ bool CanAllowExpansion() const;
+
+ bool CanAllowExpansion(bool is_root, TypeSummaryImpl *entry,
+ ValueObject *valobj, const std::string &summary);
+ };
+
+ struct PointerAsArraySettings {
+ size_t m_element_count;
+ size_t m_base_element;
+ size_t m_stride;
+
+ PointerAsArraySettings()
+ : m_element_count(0), m_base_element(0), m_stride() {}
+
+ PointerAsArraySettings(size_t elem_count, size_t base_elem = 0,
+ size_t stride = 1)
+ : m_element_count(elem_count), m_base_element(base_elem),
+ m_stride(stride) {}
+
+ operator bool() { return m_element_count > 0; }
+ };
+
+ typedef std::function<bool(ConstString, ConstString,
+ const DumpValueObjectOptions &, Stream &)>
+ DeclPrintingHelper;
+
+ static const DumpValueObjectOptions DefaultOptions() {
+ static DumpValueObjectOptions g_default_options;
+
+ return g_default_options;
+ }
+
+ DumpValueObjectOptions();
+
+ DumpValueObjectOptions(const DumpValueObjectOptions &rhs) = default;
+
+ DumpValueObjectOptions(ValueObject &valobj);
+
+ DumpValueObjectOptions &
+ SetMaximumPointerDepth(PointerDepth depth = {PointerDepth::Mode::Never, 0});
+
+ DumpValueObjectOptions &SetMaximumDepth(uint32_t depth = 0);
+
+ DumpValueObjectOptions &SetDeclPrintingHelper(DeclPrintingHelper helper);
+
+ DumpValueObjectOptions &SetShowTypes(bool show = false);
+
+ DumpValueObjectOptions &SetShowLocation(bool show = false);
+
+ DumpValueObjectOptions &SetUseObjectiveC(bool use = false);
+
+ DumpValueObjectOptions &SetShowSummary(bool show = true);
+
+ DumpValueObjectOptions &
+ SetUseDynamicType(lldb::DynamicValueType dyn = lldb::eNoDynamicValues);
+
+ DumpValueObjectOptions &SetUseSyntheticValue(bool use_synthetic = true);
+
+ DumpValueObjectOptions &SetScopeChecked(bool check = true);
+
+ DumpValueObjectOptions &SetFlatOutput(bool flat = false);
+
+ DumpValueObjectOptions &SetOmitSummaryDepth(uint32_t depth = 0);
+
+ DumpValueObjectOptions &SetIgnoreCap(bool ignore = false);
+
+ DumpValueObjectOptions &SetRawDisplay();
+
+ DumpValueObjectOptions &SetFormat(lldb::Format format = lldb::eFormatDefault);
+
+ DumpValueObjectOptions &
+ SetSummary(lldb::TypeSummaryImplSP summary = lldb::TypeSummaryImplSP());
+
+ DumpValueObjectOptions &SetRootValueObjectName(const char *name = nullptr);
+
+ DumpValueObjectOptions &SetHideRootType(bool hide_root_type = false);
+
+ DumpValueObjectOptions &SetHideName(bool hide_name = false);
+
+ DumpValueObjectOptions &SetHideValue(bool hide_value = false);
+
+ DumpValueObjectOptions &SetHidePointerValue(bool hide = false);
+
+ DumpValueObjectOptions &SetVariableFormatDisplayLanguage(
+ lldb::LanguageType lang = lldb::eLanguageTypeUnknown);
+
+ DumpValueObjectOptions &SetRunValidator(bool run = true);
+
+ DumpValueObjectOptions &SetUseTypeDisplayName(bool dis = false);
+
+ DumpValueObjectOptions &SetAllowOnelinerMode(bool oneliner = false);
+
+ DumpValueObjectOptions &SetRevealEmptyAggregates(bool reveal = true);
+
+ DumpValueObjectOptions &SetElementCount(uint32_t element_count = 0);
+
+ DumpValueObjectOptions &
+ SetPointerAsArray(const PointerAsArraySettings &ptr_array);
public:
- uint32_t m_max_depth = UINT32_MAX;
- lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues;
- uint32_t m_omit_summary_depth = 0;
- lldb::Format m_format = lldb::eFormatDefault;
- lldb::TypeSummaryImplSP m_summary_sp;
- std::string m_root_valobj_name;
- lldb::LanguageType m_varformat_language = lldb::eLanguageTypeUnknown;
- PointerDepth m_max_ptr_depth;
- DeclPrintingHelper m_decl_printing_helper;
- uint32_t m_element_count = 0;
- bool m_use_synthetic : 1;
- bool m_scope_already_checked : 1;
- bool m_flat_output : 1;
- bool m_ignore_cap : 1;
- bool m_show_types : 1;
- bool m_show_location : 1;
- bool m_use_objc : 1;
- bool m_hide_root_type : 1;
- bool m_hide_name : 1;
- bool m_hide_value : 1;
- bool m_run_validator : 1;
- bool m_use_type_display_name : 1;
- bool m_allow_oneliner_mode : 1;
- bool m_hide_pointer_value : 1;
- bool m_reveal_empty_aggregates : 1;
+ uint32_t m_max_depth = UINT32_MAX;
+ lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues;
+ uint32_t m_omit_summary_depth = 0;
+ lldb::Format m_format = lldb::eFormatDefault;
+ lldb::TypeSummaryImplSP m_summary_sp;
+ std::string m_root_valobj_name;
+ lldb::LanguageType m_varformat_language = lldb::eLanguageTypeUnknown;
+ PointerDepth m_max_ptr_depth;
+ DeclPrintingHelper m_decl_printing_helper;
+ PointerAsArraySettings m_pointer_as_array;
+ bool m_use_synthetic : 1;
+ bool m_scope_already_checked : 1;
+ bool m_flat_output : 1;
+ bool m_ignore_cap : 1;
+ bool m_show_types : 1;
+ bool m_show_location : 1;
+ bool m_use_objc : 1;
+ bool m_hide_root_type : 1;
+ bool m_hide_name : 1;
+ bool m_hide_value : 1;
+ bool m_run_validator : 1;
+ bool m_use_type_display_name : 1;
+ bool m_allow_oneliner_mode : 1;
+ bool m_hide_pointer_value : 1;
+ bool m_reveal_empty_aggregates : 1;
};
} // namespace lldb_private
diff --git a/include/lldb/DataFormatters/FormatCache.h b/include/lldb/DataFormatters/FormatCache.h
index 645fbc7ddf10..ab369a1f0453 100644
--- a/include/lldb/DataFormatters/FormatCache.h
+++ b/include/lldb/DataFormatters/FormatCache.h
@@ -1,4 +1,5 @@
-//===-- FormatCache.h ---------------------------------------------*- C++ -*-===//
+//===-- FormatCache.h ---------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -17,121 +18,95 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
#include "lldb/Core/ConstString.h"
+#include "lldb/lldb-public.h"
namespace lldb_private {
-class FormatCache
-{
+class FormatCache {
private:
- struct Entry
- {
- private:
- bool m_format_cached : 1;
- bool m_summary_cached : 1;
- bool m_synthetic_cached : 1;
- bool m_validator_cached : 1;
-
- lldb::TypeFormatImplSP m_format_sp;
- lldb::TypeSummaryImplSP m_summary_sp;
- lldb::SyntheticChildrenSP m_synthetic_sp;
- lldb::TypeValidatorImplSP m_validator_sp;
- public:
- Entry ();
- Entry (lldb::TypeFormatImplSP);
- Entry (lldb::TypeSummaryImplSP);
- Entry (lldb::SyntheticChildrenSP);
- Entry (lldb::TypeValidatorImplSP);
- Entry (lldb::TypeFormatImplSP,lldb::TypeSummaryImplSP,lldb::SyntheticChildrenSP,lldb::TypeValidatorImplSP);
-
- bool
- IsFormatCached ();
-
- bool
- IsSummaryCached ();
-
- bool
- IsSyntheticCached ();
-
- bool
- IsValidatorCached ();
-
- lldb::TypeFormatImplSP
- GetFormat ();
-
- lldb::TypeSummaryImplSP
- GetSummary ();
-
- lldb::SyntheticChildrenSP
- GetSynthetic ();
-
- lldb::TypeValidatorImplSP
- GetValidator ();
-
- void
- SetFormat (lldb::TypeFormatImplSP);
-
- void
- SetSummary (lldb::TypeSummaryImplSP);
-
- void
- SetSynthetic (lldb::SyntheticChildrenSP);
-
- void
- SetValidator (lldb::TypeValidatorImplSP);
- };
- typedef std::map<ConstString,Entry> CacheMap;
- CacheMap m_map;
- std::recursive_mutex m_mutex;
-
- uint64_t m_cache_hits;
- uint64_t m_cache_misses;
-
- Entry&
- GetEntry (const ConstString& type);
-
+ struct Entry {
+ private:
+ bool m_format_cached : 1;
+ bool m_summary_cached : 1;
+ bool m_synthetic_cached : 1;
+ bool m_validator_cached : 1;
+
+ lldb::TypeFormatImplSP m_format_sp;
+ lldb::TypeSummaryImplSP m_summary_sp;
+ lldb::SyntheticChildrenSP m_synthetic_sp;
+ lldb::TypeValidatorImplSP m_validator_sp;
+
+ public:
+ Entry();
+ Entry(lldb::TypeFormatImplSP);
+ Entry(lldb::TypeSummaryImplSP);
+ Entry(lldb::SyntheticChildrenSP);
+ Entry(lldb::TypeValidatorImplSP);
+ Entry(lldb::TypeFormatImplSP, lldb::TypeSummaryImplSP,
+ lldb::SyntheticChildrenSP, lldb::TypeValidatorImplSP);
+
+ bool IsFormatCached();
+
+ bool IsSummaryCached();
+
+ bool IsSyntheticCached();
+
+ bool IsValidatorCached();
+
+ lldb::TypeFormatImplSP GetFormat();
+
+ lldb::TypeSummaryImplSP GetSummary();
+
+ lldb::SyntheticChildrenSP GetSynthetic();
+
+ lldb::TypeValidatorImplSP GetValidator();
+
+ void SetFormat(lldb::TypeFormatImplSP);
+
+ void SetSummary(lldb::TypeSummaryImplSP);
+
+ void SetSynthetic(lldb::SyntheticChildrenSP);
+
+ void SetValidator(lldb::TypeValidatorImplSP);
+ };
+ typedef std::map<ConstString, Entry> CacheMap;
+ CacheMap m_map;
+ std::recursive_mutex m_mutex;
+
+ uint64_t m_cache_hits;
+ uint64_t m_cache_misses;
+
+ Entry &GetEntry(const ConstString &type);
+
public:
- FormatCache ();
-
- bool
- GetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp);
-
- bool
- GetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp);
-
- bool
- GetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp);
-
- bool
- GetValidator (const ConstString& type,lldb::TypeValidatorImplSP& summary_sp);
-
- void
- SetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp);
-
- void
- SetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp);
-
- void
- SetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp);
-
- void
- SetValidator (const ConstString& type,lldb::TypeValidatorImplSP& synthetic_sp);
-
- void
- Clear ();
-
- uint64_t
- GetCacheHits ()
- {
- return m_cache_hits;
- }
-
- uint64_t
- GetCacheMisses ()
- {
- return m_cache_misses;
- }
+ FormatCache();
+
+ bool GetFormat(const ConstString &type, lldb::TypeFormatImplSP &format_sp);
+
+ bool GetSummary(const ConstString &type, lldb::TypeSummaryImplSP &summary_sp);
+
+ bool GetSynthetic(const ConstString &type,
+ lldb::SyntheticChildrenSP &synthetic_sp);
+
+ bool GetValidator(const ConstString &type,
+ lldb::TypeValidatorImplSP &summary_sp);
+
+ void SetFormat(const ConstString &type, lldb::TypeFormatImplSP &format_sp);
+
+ void SetSummary(const ConstString &type, lldb::TypeSummaryImplSP &summary_sp);
+
+ void SetSynthetic(const ConstString &type,
+ lldb::SyntheticChildrenSP &synthetic_sp);
+
+ void SetValidator(const ConstString &type,
+ lldb::TypeValidatorImplSP &synthetic_sp);
+
+ void Clear();
+
+ uint64_t GetCacheHits() { return m_cache_hits; }
+
+ uint64_t GetCacheMisses() { return m_cache_misses; }
};
} // namespace lldb_private
-#endif // lldb_FormatCache_h_
+#endif // lldb_FormatCache_h_
diff --git a/include/lldb/DataFormatters/FormatClasses.h b/include/lldb/DataFormatters/FormatClasses.h
index b5ac41c2bd6e..c559c212c2db 100644
--- a/include/lldb/DataFormatters/FormatClasses.h
+++ b/include/lldb/DataFormatters/FormatClasses.h
@@ -19,222 +19,159 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
-#include "lldb/lldb-enumerations.h"
#include "lldb/DataFormatters/TypeFormat.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
#include "lldb/DataFormatters/TypeValidator.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/Type.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-public.h"
namespace lldb_private {
class HardcodedFormatters {
public:
- template <typename FormatterType>
- using HardcodedFormatterFinder = std::function<typename FormatterType::SharedPointer (lldb_private::ValueObject&,
- lldb::DynamicValueType,
- FormatManager&)>;
-
- template <typename FormatterType>
- using HardcodedFormatterFinders = std::vector<HardcodedFormatterFinder<FormatterType>>;
-
- typedef HardcodedFormatterFinders<TypeFormatImpl> HardcodedFormatFinder;
- typedef HardcodedFormatterFinders<TypeSummaryImpl> HardcodedSummaryFinder;
- typedef HardcodedFormatterFinders<SyntheticChildren> HardcodedSyntheticFinder;
- typedef HardcodedFormatterFinders<TypeValidatorImpl> HardcodedValidatorFinder;
+ template <typename FormatterType>
+ using HardcodedFormatterFinder =
+ std::function<typename FormatterType::SharedPointer(
+ lldb_private::ValueObject &, lldb::DynamicValueType,
+ FormatManager &)>;
+
+ template <typename FormatterType>
+ using HardcodedFormatterFinders =
+ std::vector<HardcodedFormatterFinder<FormatterType>>;
+
+ typedef HardcodedFormatterFinders<TypeFormatImpl> HardcodedFormatFinder;
+ typedef HardcodedFormatterFinders<TypeSummaryImpl> HardcodedSummaryFinder;
+ typedef HardcodedFormatterFinders<SyntheticChildren> HardcodedSyntheticFinder;
+ typedef HardcodedFormatterFinders<TypeValidatorImpl> HardcodedValidatorFinder;
};
-class FormattersMatchCandidate
-{
+class FormattersMatchCandidate {
public:
- FormattersMatchCandidate (ConstString name,
- uint32_t reason,
- bool strip_ptr,
- bool strip_ref,
- bool strip_tydef) :
- m_type_name(name),
- m_reason(reason),
- m_stripped_pointer(strip_ptr),
- m_stripped_reference(strip_ref),
- m_stripped_typedef(strip_tydef)
- {
- }
+ FormattersMatchCandidate(ConstString name, uint32_t reason, bool strip_ptr,
+ bool strip_ref, bool strip_tydef)
+ : m_type_name(name), m_reason(reason), m_stripped_pointer(strip_ptr),
+ m_stripped_reference(strip_ref), m_stripped_typedef(strip_tydef) {}
- ~FormattersMatchCandidate() = default;
+ ~FormattersMatchCandidate() = default;
+
+ ConstString GetTypeName() const { return m_type_name; }
+
+ uint32_t GetReason() const { return m_reason; }
+
+ bool DidStripPointer() const { return m_stripped_pointer; }
+
+ bool DidStripReference() const { return m_stripped_reference; }
+
+ bool DidStripTypedef() const { return m_stripped_typedef; }
+
+ template <class Formatter>
+ bool IsMatch(const std::shared_ptr<Formatter> &formatter_sp) const {
+ if (!formatter_sp)
+ return false;
+ if (formatter_sp->Cascades() == false && DidStripTypedef())
+ return false;
+ if (formatter_sp->SkipsPointers() && DidStripPointer())
+ return false;
+ if (formatter_sp->SkipsReferences() && DidStripReference())
+ return false;
+ return true;
+ }
- ConstString
- GetTypeName () const
- {
- return m_type_name;
- }
-
- uint32_t
- GetReason () const
- {
- return m_reason;
- }
-
- bool
- DidStripPointer () const
- {
- return m_stripped_pointer;
- }
-
- bool
- DidStripReference () const
- {
- return m_stripped_reference;
- }
-
- bool
- DidStripTypedef () const
- {
- return m_stripped_typedef;
- }
-
- template <class Formatter>
- bool
- IsMatch (const std::shared_ptr<Formatter>& formatter_sp) const
- {
- if (!formatter_sp)
- return false;
- if (formatter_sp->Cascades() == false && DidStripTypedef())
- return false;
- if (formatter_sp->SkipsPointers() && DidStripPointer())
- return false;
- if (formatter_sp->SkipsReferences() && DidStripReference())
- return false;
- return true;
- }
-
private:
- ConstString m_type_name;
- uint32_t m_reason;
- bool m_stripped_pointer;
- bool m_stripped_reference;
- bool m_stripped_typedef;
+ ConstString m_type_name;
+ uint32_t m_reason;
+ bool m_stripped_pointer;
+ bool m_stripped_reference;
+ bool m_stripped_typedef;
};
typedef std::vector<FormattersMatchCandidate> FormattersMatchVector;
typedef std::vector<lldb::LanguageType> CandidateLanguagesVector;
-class FormattersMatchData
-{
+class FormattersMatchData {
public:
- FormattersMatchData (ValueObject&,
- lldb::DynamicValueType);
-
- FormattersMatchVector
- GetMatchesVector ();
-
- ConstString
- GetTypeForCache ();
-
- CandidateLanguagesVector
- GetCandidateLanguages ();
-
- ValueObject&
- GetValueObject ();
-
- lldb::DynamicValueType
- GetDynamicValueType ();
-
+ FormattersMatchData(ValueObject &, lldb::DynamicValueType);
+
+ FormattersMatchVector GetMatchesVector();
+
+ ConstString GetTypeForCache();
+
+ CandidateLanguagesVector GetCandidateLanguages();
+
+ ValueObject &GetValueObject();
+
+ lldb::DynamicValueType GetDynamicValueType();
+
private:
- ValueObject& m_valobj;
- lldb::DynamicValueType m_dynamic_value_type;
- std::pair<FormattersMatchVector,bool> m_formatters_match_vector;
- ConstString m_type_for_cache;
- CandidateLanguagesVector m_candidate_languages;
+ ValueObject &m_valobj;
+ lldb::DynamicValueType m_dynamic_value_type;
+ std::pair<FormattersMatchVector, bool> m_formatters_match_vector;
+ ConstString m_type_for_cache;
+ CandidateLanguagesVector m_candidate_languages;
};
-
-class TypeNameSpecifierImpl
-{
+
+class TypeNameSpecifierImpl {
public:
- TypeNameSpecifierImpl() :
- m_is_regex(false),
- m_type()
- {
- }
-
- TypeNameSpecifierImpl (const char* name, bool is_regex) :
- m_is_regex(is_regex),
- m_type()
- {
- if (name)
- m_type.m_type_name.assign(name);
- }
-
- // if constructing with a given type, is_regex cannot be true since we are
- // giving an exact type to match
- TypeNameSpecifierImpl (lldb::TypeSP type) :
- m_is_regex(false),
- m_type()
- {
- if (type)
- {
- m_type.m_type_name.assign(type->GetName().GetCString());
- m_type.m_type_pair.SetType(type);
- }
- }
+ TypeNameSpecifierImpl() : m_is_regex(false), m_type() {}
- TypeNameSpecifierImpl (CompilerType type) :
- m_is_regex(false),
- m_type()
- {
- if (type.IsValid())
- {
- m_type.m_type_name.assign(type.GetConstTypeName().GetCString());
- m_type.m_type_pair.SetType(type);
- }
- }
-
- const char*
- GetName()
- {
- if (m_type.m_type_name.size())
- return m_type.m_type_name.c_str();
- return nullptr;
- }
-
- lldb::TypeSP
- GetTypeSP ()
- {
- if (m_type.m_type_pair.IsValid())
- return m_type.m_type_pair.GetTypeSP();
- return lldb::TypeSP();
- }
-
- CompilerType
- GetCompilerType ()
- {
- if (m_type.m_type_pair.IsValid())
- return m_type.m_type_pair.GetCompilerType();
- return CompilerType();
+ TypeNameSpecifierImpl(llvm::StringRef name, bool is_regex)
+ : m_is_regex(is_regex), m_type() {
+ m_type.m_type_name = name;
+ }
+
+ // if constructing with a given type, is_regex cannot be true since we are
+ // giving an exact type to match
+ TypeNameSpecifierImpl(lldb::TypeSP type) : m_is_regex(false), m_type() {
+ if (type) {
+ m_type.m_type_name = type->GetName().GetStringRef();
+ m_type.m_type_pair.SetType(type);
}
-
- bool
- IsRegex()
- {
- return m_is_regex;
+ }
+
+ TypeNameSpecifierImpl(CompilerType type) : m_is_regex(false), m_type() {
+ if (type.IsValid()) {
+ m_type.m_type_name.assign(type.GetConstTypeName().GetCString());
+ m_type.m_type_pair.SetType(type);
}
-
+ }
+
+ const char *GetName() {
+ if (m_type.m_type_name.size())
+ return m_type.m_type_name.c_str();
+ return nullptr;
+ }
+
+ lldb::TypeSP GetTypeSP() {
+ if (m_type.m_type_pair.IsValid())
+ return m_type.m_type_pair.GetTypeSP();
+ return lldb::TypeSP();
+ }
+
+ CompilerType GetCompilerType() {
+ if (m_type.m_type_pair.IsValid())
+ return m_type.m_type_pair.GetCompilerType();
+ return CompilerType();
+ }
+
+ bool IsRegex() { return m_is_regex; }
+
private:
- bool m_is_regex;
- // this works better than TypeAndOrName because the latter only wraps a TypeSP
- // whereas TypePair can also be backed by a CompilerType
- struct TypeOrName
- {
- std::string m_type_name;
- TypePair m_type_pair;
- };
- TypeOrName m_type;
+ bool m_is_regex;
+ // this works better than TypeAndOrName because the latter only wraps a TypeSP
+ // whereas TypePair can also be backed by a CompilerType
+ struct TypeOrName {
+ std::string m_type_name;
+ TypePair m_type_pair;
+ };
+ TypeOrName m_type;
private:
- DISALLOW_COPY_AND_ASSIGN(TypeNameSpecifierImpl);
+ DISALLOW_COPY_AND_ASSIGN(TypeNameSpecifierImpl);
};
-
+
} // namespace lldb_private
#endif // lldb_FormatClasses_h_
diff --git a/include/lldb/DataFormatters/FormatManager.h b/include/lldb/DataFormatters/FormatManager.h
index 27dc31d259d0..924ef0cdf6b4 100644
--- a/include/lldb/DataFormatters/FormatManager.h
+++ b/include/lldb/DataFormatters/FormatManager.h
@@ -20,8 +20,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-public.h"
#include "lldb/DataFormatters/FormatCache.h"
#include "lldb/DataFormatters/FormatClasses.h"
@@ -31,306 +31,240 @@
#include "lldb/DataFormatters/TypeCategoryMap.h"
namespace lldb_private {
-
-// this file (and its. cpp) contain the low-level implementation of LLDB Data Visualization
+
+// this file (and its. cpp) contain the low-level implementation of LLDB Data
+// Visualization
// class DataVisualization is the high-level front-end of this feature
-// clients should refer to that class as the entry-point into the data formatters
-// unless they have a good reason to bypass it and prefer to use this file's objects directly
+// clients should refer to that class as the entry-point into the data
+// formatters
+// unless they have a good reason to bypass it and prefer to use this file's
+// objects directly
+
+class FormatManager : public IFormatChangeListener {
+ typedef FormatMap<ConstString, TypeSummaryImpl> NamedSummariesMap;
+ typedef TypeCategoryMap::MapType::iterator CategoryMapIterator;
-class FormatManager : public IFormatChangeListener
-{
- typedef FormatMap<ConstString, TypeSummaryImpl> NamedSummariesMap;
- typedef TypeCategoryMap::MapType::iterator CategoryMapIterator;
public:
- typedef std::map<lldb::LanguageType, LanguageCategory::UniquePointer> LanguageCategories;
-
- FormatManager();
-
- ~FormatManager() override = default;
-
- NamedSummariesMap&
- GetNamedSummaryContainer ()
- {
- return m_named_summaries_map;
- }
-
- void
- EnableCategory (const ConstString& category_name,
- TypeCategoryMap::Position pos = TypeCategoryMap::Default)
- {
- EnableCategory(category_name,
- pos,
- std::initializer_list<lldb::LanguageType>());
- }
+ typedef std::map<lldb::LanguageType, LanguageCategory::UniquePointer>
+ LanguageCategories;
- void
- EnableCategory (const ConstString& category_name,
- TypeCategoryMap::Position pos,
- lldb::LanguageType lang)
- {
- std::initializer_list<lldb::LanguageType> langs = {lang};
- EnableCategory(category_name,
- pos,
- langs);
- }
-
- void
- EnableCategory (const ConstString& category_name,
- TypeCategoryMap::Position pos = TypeCategoryMap::Default,
- std::initializer_list<lldb::LanguageType> langs = {})
- {
- TypeCategoryMap::ValueSP category_sp;
- if (m_categories_map.Get(category_name, category_sp) && category_sp)
- {
- m_categories_map.Enable(category_sp, pos);
- for (const lldb::LanguageType lang : langs)
- category_sp->AddLanguage(lang);
- }
- }
-
- void
- DisableCategory (const ConstString& category_name)
- {
- m_categories_map.Disable(category_name);
- }
-
- void
- EnableCategory (const lldb::TypeCategoryImplSP& category,
- TypeCategoryMap::Position pos = TypeCategoryMap::Default)
- {
- m_categories_map.Enable(category,
- pos);
- }
-
- void
- DisableCategory (const lldb::TypeCategoryImplSP& category)
- {
- m_categories_map.Disable(category);
- }
-
- void
- EnableAllCategories ();
-
- void
- DisableAllCategories ();
-
- bool
- DeleteCategory (const ConstString& category_name)
- {
- return m_categories_map.Delete(category_name);
- }
-
- void
- ClearCategories ()
- {
- return m_categories_map.Clear();
- }
-
- uint32_t
- GetCategoriesCount ()
- {
- return m_categories_map.GetCount();
- }
-
- lldb::TypeCategoryImplSP
- GetCategoryAtIndex (size_t index)
- {
- return m_categories_map.GetAtIndex(index);
- }
-
- void
- ForEachCategory (TypeCategoryMap::ForEachCallback callback);
-
- lldb::TypeCategoryImplSP
- GetCategory(const char* category_name = nullptr,
- bool can_create = true)
- {
- if (!category_name)
- return GetCategory(m_default_category_name);
- return GetCategory(ConstString(category_name));
+ FormatManager();
+
+ ~FormatManager() override = default;
+
+ NamedSummariesMap &GetNamedSummaryContainer() {
+ return m_named_summaries_map;
+ }
+
+ void
+ EnableCategory(const ConstString &category_name,
+ TypeCategoryMap::Position pos = TypeCategoryMap::Default) {
+ EnableCategory(category_name, pos,
+ std::initializer_list<lldb::LanguageType>());
+ }
+
+ void EnableCategory(const ConstString &category_name,
+ TypeCategoryMap::Position pos, lldb::LanguageType lang) {
+ std::initializer_list<lldb::LanguageType> langs = {lang};
+ EnableCategory(category_name, pos, langs);
+ }
+
+ void EnableCategory(const ConstString &category_name,
+ TypeCategoryMap::Position pos = TypeCategoryMap::Default,
+ std::initializer_list<lldb::LanguageType> langs = {}) {
+ TypeCategoryMap::ValueSP category_sp;
+ if (m_categories_map.Get(category_name, category_sp) && category_sp) {
+ m_categories_map.Enable(category_sp, pos);
+ for (const lldb::LanguageType lang : langs)
+ category_sp->AddLanguage(lang);
}
-
- lldb::TypeCategoryImplSP
- GetCategory (const ConstString& category_name,
- bool can_create = true);
+ }
+
+ void DisableCategory(const ConstString &category_name) {
+ m_categories_map.Disable(category_name);
+ }
+
+ void
+ EnableCategory(const lldb::TypeCategoryImplSP &category,
+ TypeCategoryMap::Position pos = TypeCategoryMap::Default) {
+ m_categories_map.Enable(category, pos);
+ }
+
+ void DisableCategory(const lldb::TypeCategoryImplSP &category) {
+ m_categories_map.Disable(category);
+ }
+
+ void EnableAllCategories();
+
+ void DisableAllCategories();
+
+ bool DeleteCategory(const ConstString &category_name) {
+ return m_categories_map.Delete(category_name);
+ }
+
+ void ClearCategories() { return m_categories_map.Clear(); }
+
+ uint32_t GetCategoriesCount() { return m_categories_map.GetCount(); }
+
+ lldb::TypeCategoryImplSP GetCategoryAtIndex(size_t index) {
+ return m_categories_map.GetAtIndex(index);
+ }
+
+ void ForEachCategory(TypeCategoryMap::ForEachCallback callback);
+
+ lldb::TypeCategoryImplSP GetCategory(const char *category_name = nullptr,
+ bool can_create = true) {
+ if (!category_name)
+ return GetCategory(m_default_category_name);
+ return GetCategory(ConstString(category_name));
+ }
+
+ lldb::TypeCategoryImplSP GetCategory(const ConstString &category_name,
+ bool can_create = true);
+
+ lldb::TypeFormatImplSP
+ GetFormatForType(lldb::TypeNameSpecifierImplSP type_sp);
- lldb::TypeFormatImplSP
- GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp);
-
- lldb::TypeSummaryImplSP
- GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp);
+ lldb::TypeSummaryImplSP
+ GetSummaryForType(lldb::TypeNameSpecifierImplSP type_sp);
- lldb::TypeFilterImplSP
- GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp);
+ lldb::TypeFilterImplSP
+ GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp);
#ifndef LLDB_DISABLE_PYTHON
- lldb::ScriptedSyntheticChildrenSP
- GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp);
+ lldb::ScriptedSyntheticChildrenSP
+ GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp);
#endif
-
+
#ifndef LLDB_DISABLE_PYTHON
- lldb::SyntheticChildrenSP
- GetSyntheticChildrenForType (lldb::TypeNameSpecifierImplSP type_sp);
+ lldb::SyntheticChildrenSP
+ GetSyntheticChildrenForType(lldb::TypeNameSpecifierImplSP type_sp);
#endif
-
- lldb::TypeValidatorImplSP
- GetValidatorForType (lldb::TypeNameSpecifierImplSP type_sp);
-
- lldb::TypeFormatImplSP
- GetFormat (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
-
- lldb::TypeSummaryImplSP
- GetSummaryFormat (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
+
+ lldb::TypeValidatorImplSP
+ GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp);
+
+ lldb::TypeFormatImplSP GetFormat(ValueObject &valobj,
+ lldb::DynamicValueType use_dynamic);
+
+ lldb::TypeSummaryImplSP GetSummaryFormat(ValueObject &valobj,
+ lldb::DynamicValueType use_dynamic);
#ifndef LLDB_DISABLE_PYTHON
- lldb::SyntheticChildrenSP
- GetSyntheticChildren (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
+ lldb::SyntheticChildrenSP
+ GetSyntheticChildren(ValueObject &valobj, lldb::DynamicValueType use_dynamic);
#endif
-
- lldb::TypeValidatorImplSP
- GetValidator (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
-
- bool
- AnyMatches(ConstString type_name,
- TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES,
- bool only_enabled = true,
- const char** matching_category = nullptr,
- TypeCategoryImpl::FormatCategoryItems* matching_type = nullptr)
- {
- return m_categories_map.AnyMatches(type_name,
- items,
- only_enabled,
- matching_category,
- matching_type);
- }
- static bool
- GetFormatFromCString (const char *format_cstr,
- bool partial_match_ok,
- lldb::Format &format);
-
- static char
- GetFormatAsFormatChar (lldb::Format format);
-
- static const char *
- GetFormatAsCString (lldb::Format format);
-
- // if the user tries to add formatters for, say, "struct Foo"
- // those will not match any type because of the way we strip qualifiers from typenames
- // this method looks for the case where the user is adding a "class","struct","enum" or "union" Foo
- // and strips the unnecessary qualifier
- static ConstString
- GetValidTypeName (const ConstString& type);
-
- // when DataExtractor dumps a vectorOfT, it uses a predefined format for each item
- // this method returns it, or eFormatInvalid if vector_format is not a vectorOf
- static lldb::Format
- GetSingleItemFormat (lldb::Format vector_format);
-
- // this returns true if the ValueObjectPrinter is *highly encouraged*
- // to actually represent this ValueObject in one-liner format
- // If this object has a summary formatter, however, we should not
- // try and do one-lining, just let the summary do the right thing
- bool
- ShouldPrintAsOneLiner (ValueObject& valobj);
-
- void
- Changed () override;
-
- uint32_t
- GetCurrentRevision () override
- {
- return m_last_revision;
- }
+ lldb::TypeValidatorImplSP GetValidator(ValueObject &valobj,
+ lldb::DynamicValueType use_dynamic);
- static FormattersMatchVector
- GetPossibleMatches (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
- {
- FormattersMatchVector matches;
- GetPossibleMatches (valobj,
- valobj.GetCompilerType(),
- lldb_private::eFormatterChoiceCriterionDirectChoice,
- use_dynamic,
- matches,
- false,
- false,
- false,
- true);
- return matches;
- }
-
- static ConstString
- GetTypeForCache (ValueObject&, lldb::DynamicValueType);
-
- LanguageCategory*
- GetCategoryForLanguage (lldb::LanguageType lang_type);
+ bool
+ AnyMatches(ConstString type_name,
+ TypeCategoryImpl::FormatCategoryItems items =
+ TypeCategoryImpl::ALL_ITEM_TYPES,
+ bool only_enabled = true, const char **matching_category = nullptr,
+ TypeCategoryImpl::FormatCategoryItems *matching_type = nullptr) {
+ return m_categories_map.AnyMatches(type_name, items, only_enabled,
+ matching_category, matching_type);
+ }
+
+ static bool GetFormatFromCString(const char *format_cstr,
+ bool partial_match_ok, lldb::Format &format);
+
+ static char GetFormatAsFormatChar(lldb::Format format);
+
+ static const char *GetFormatAsCString(lldb::Format format);
+
+ // if the user tries to add formatters for, say, "struct Foo"
+ // those will not match any type because of the way we strip qualifiers from
+ // typenames
+ // this method looks for the case where the user is adding a
+ // "class","struct","enum" or "union" Foo
+ // and strips the unnecessary qualifier
+ static ConstString GetValidTypeName(const ConstString &type);
+
+ // when DataExtractor dumps a vectorOfT, it uses a predefined format for each
+ // item
+ // this method returns it, or eFormatInvalid if vector_format is not a
+ // vectorOf
+ static lldb::Format GetSingleItemFormat(lldb::Format vector_format);
+
+ // this returns true if the ValueObjectPrinter is *highly encouraged*
+ // to actually represent this ValueObject in one-liner format
+ // If this object has a summary formatter, however, we should not
+ // try and do one-lining, just let the summary do the right thing
+ bool ShouldPrintAsOneLiner(ValueObject &valobj);
+
+ void Changed() override;
+
+ uint32_t GetCurrentRevision() override { return m_last_revision; }
+
+ static FormattersMatchVector
+ GetPossibleMatches(ValueObject &valobj, lldb::DynamicValueType use_dynamic) {
+ FormattersMatchVector matches;
+ GetPossibleMatches(valobj, valobj.GetCompilerType(),
+ lldb_private::eFormatterChoiceCriterionDirectChoice,
+ use_dynamic, matches, false, false, false, true);
+ return matches;
+ }
- static std::vector<lldb::LanguageType>
- GetCandidateLanguages (lldb::LanguageType lang_type);
+ static ConstString GetTypeForCache(ValueObject &, lldb::DynamicValueType);
+
+ LanguageCategory *GetCategoryForLanguage(lldb::LanguageType lang_type);
+
+ static std::vector<lldb::LanguageType>
+ GetCandidateLanguages(lldb::LanguageType lang_type);
private:
- static std::vector<lldb::LanguageType>
- GetCandidateLanguages (ValueObject& valobj);
-
- static void
- GetPossibleMatches (ValueObject& valobj,
- CompilerType compiler_type,
- uint32_t reason,
- lldb::DynamicValueType use_dynamic,
- FormattersMatchVector& entries,
- bool did_strip_ptr,
- bool did_strip_ref,
- bool did_strip_typedef,
- bool root_level = false);
-
- std::atomic<uint32_t> m_last_revision;
- FormatCache m_format_cache;
- std::recursive_mutex m_language_categories_mutex;
- LanguageCategories m_language_categories_map;
- NamedSummariesMap m_named_summaries_map;
- TypeCategoryMap m_categories_map;
-
- ConstString m_default_category_name;
- ConstString m_system_category_name;
- ConstString m_vectortypes_category_name;
-
- lldb::TypeFormatImplSP
- GetHardcodedFormat (FormattersMatchData&);
-
- lldb::TypeSummaryImplSP
- GetHardcodedSummaryFormat (FormattersMatchData&);
-
- lldb::SyntheticChildrenSP
- GetHardcodedSyntheticChildren (FormattersMatchData&);
-
- lldb::TypeValidatorImplSP
- GetHardcodedValidator (FormattersMatchData&);
-
- TypeCategoryMap&
- GetCategories ()
- {
- return m_categories_map;
- }
-
- // These functions are meant to initialize formatters that are very low-level/global in nature
- // and do not naturally belong in any language. The intent is that most formatters go in
- // language-specific categories. Eventually, the runtimes should also be allowed to vend their
- // own formatters, and then one could put formatters that depend on specific library load events
- // in the language runtimes, on an as-needed basis
- void
- LoadSystemFormatters ();
-
- void
- LoadVectorFormatters ();
-
- friend class FormattersMatchData;
+ static std::vector<lldb::LanguageType>
+ GetCandidateLanguages(ValueObject &valobj);
+
+ static void GetPossibleMatches(ValueObject &valobj,
+ CompilerType compiler_type, uint32_t reason,
+ lldb::DynamicValueType use_dynamic,
+ FormattersMatchVector &entries,
+ bool did_strip_ptr, bool did_strip_ref,
+ bool did_strip_typedef,
+ bool root_level = false);
+
+ std::atomic<uint32_t> m_last_revision;
+ FormatCache m_format_cache;
+ std::recursive_mutex m_language_categories_mutex;
+ LanguageCategories m_language_categories_map;
+ NamedSummariesMap m_named_summaries_map;
+ TypeCategoryMap m_categories_map;
+
+ ConstString m_default_category_name;
+ ConstString m_system_category_name;
+ ConstString m_vectortypes_category_name;
+
+ lldb::TypeFormatImplSP GetHardcodedFormat(FormattersMatchData &);
+
+ lldb::TypeSummaryImplSP GetHardcodedSummaryFormat(FormattersMatchData &);
+
+ lldb::SyntheticChildrenSP
+ GetHardcodedSyntheticChildren(FormattersMatchData &);
+
+ lldb::TypeValidatorImplSP GetHardcodedValidator(FormattersMatchData &);
+
+ TypeCategoryMap &GetCategories() { return m_categories_map; }
+
+ // These functions are meant to initialize formatters that are very
+ // low-level/global in nature
+ // and do not naturally belong in any language. The intent is that most
+ // formatters go in
+ // language-specific categories. Eventually, the runtimes should also be
+ // allowed to vend their
+ // own formatters, and then one could put formatters that depend on specific
+ // library load events
+ // in the language runtimes, on an as-needed basis
+ void LoadSystemFormatters();
+
+ void LoadVectorFormatters();
+
+ friend class FormattersMatchData;
};
-
+
} // namespace lldb_private
-
+
#endif // lldb_FormatManager_h_
diff --git a/include/lldb/DataFormatters/FormattersContainer.h b/include/lldb/DataFormatters/FormattersContainer.h
index c4694463b676..e43209969dd0 100644
--- a/include/lldb/DataFormatters/FormattersContainer.h
+++ b/include/lldb/DataFormatters/FormattersContainer.h
@@ -33,411 +33,316 @@
#include "lldb/Utility/StringLexer.h"
namespace lldb_private {
-
-class IFormatChangeListener
-{
+
+class IFormatChangeListener {
public:
- virtual
- ~IFormatChangeListener() = default;
+ virtual ~IFormatChangeListener() = default;
- virtual void
- Changed () = 0;
+ virtual void Changed() = 0;
- virtual uint32_t
- GetCurrentRevision () = 0;
+ virtual uint32_t GetCurrentRevision() = 0;
};
-
+
// if the user tries to add formatters for, say, "struct Foo"
-// those will not match any type because of the way we strip qualifiers from typenames
-// this method looks for the case where the user is adding a "class","struct","enum" or "union" Foo
+// those will not match any type because of the way we strip qualifiers from
+// typenames
+// this method looks for the case where the user is adding a
+// "class","struct","enum" or "union" Foo
// and strips the unnecessary qualifier
-static inline ConstString
-GetValidTypeName_Impl (const ConstString& type)
-{
- if (type.IsEmpty())
- return type;
-
- std::string type_cstr(type.AsCString());
- lldb_utility::StringLexer type_lexer(type_cstr);
-
- type_lexer.AdvanceIf("class ");
- type_lexer.AdvanceIf("enum ");
- type_lexer.AdvanceIf("struct ");
- type_lexer.AdvanceIf("union ");
-
- while (type_lexer.NextIf({' ','\t','\v','\f'}).first)
- ;
-
- return ConstString(type_lexer.GetUnlexed());
-}
-
-template<typename KeyType, typename ValueType>
-class FormattersContainer;
-
-template<typename KeyType, typename ValueType>
-class FormatMap
-{
-public:
- typedef typename ValueType::SharedPointer ValueSP;
- typedef std::map<KeyType, ValueSP> MapType;
- typedef typename MapType::iterator MapIterator;
- typedef std::function<bool(KeyType, const ValueSP&)> ForEachCallback;
-
- FormatMap(IFormatChangeListener *lst) : m_map(), m_map_mutex(), listener(lst) {}
-
- void
- Add(KeyType name, const ValueSP &entry)
- {
- if (listener)
- entry->GetRevision() = listener->GetCurrentRevision();
- else
- entry->GetRevision() = 0;
-
- std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
- m_map[name] = entry;
- if (listener)
- listener->Changed();
- }
-
- bool
- Delete(KeyType name)
- {
- std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
- MapIterator iter = m_map.find(name);
- if (iter == m_map.end())
- return false;
- m_map.erase(name);
- if (listener)
- listener->Changed();
- return true;
- }
-
- void
- Clear()
- {
- std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
- m_map.clear();
- if (listener)
- listener->Changed();
- }
-
- bool
- Get(KeyType name, ValueSP &entry)
- {
- std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
- MapIterator iter = m_map.find(name);
- if (iter == m_map.end())
- return false;
- entry = iter->second;
- return true;
- }
-
- void
- ForEach(ForEachCallback callback)
- {
- if (callback)
- {
- std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
- MapIterator pos, end = m_map.end();
- for (pos = m_map.begin(); pos != end; pos++)
- {
- KeyType type = pos->first;
- if (!callback(type, pos->second))
- break;
- }
- }
- }
+static inline ConstString GetValidTypeName_Impl(const ConstString &type) {
+ if (type.IsEmpty())
+ return type;
- uint32_t
- GetCount ()
- {
- return m_map.size();
- }
+ std::string type_cstr(type.AsCString());
+ lldb_utility::StringLexer type_lexer(type_cstr);
- ValueSP
- GetValueAtIndex(size_t index)
- {
- std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
- MapIterator iter = m_map.begin();
- MapIterator end = m_map.end();
- while (index > 0)
- {
- iter++;
- index--;
- if (end == iter)
- return ValueSP();
- }
- return iter->second;
- }
+ type_lexer.AdvanceIf("class ");
+ type_lexer.AdvanceIf("enum ");
+ type_lexer.AdvanceIf("struct ");
+ type_lexer.AdvanceIf("union ");
- KeyType
- GetKeyAtIndex(size_t index)
- {
- std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
- MapIterator iter = m_map.begin();
- MapIterator end = m_map.end();
- while (index > 0)
- {
- iter++;
- index--;
- if (end == iter)
- return KeyType();
- }
- return iter->first;
- }
+ while (type_lexer.NextIf({' ', '\t', '\v', '\f'}).first)
+ ;
-protected:
- MapType m_map;
- std::recursive_mutex m_map_mutex;
- IFormatChangeListener* listener;
-
- MapType&
- map ()
- {
- return m_map;
- }
+ return ConstString(type_lexer.GetUnlexed());
+}
- std::recursive_mutex &
- mutex()
- {
- return m_map_mutex;
- }
+template <typename KeyType, typename ValueType> class FormattersContainer;
- friend class FormattersContainer<KeyType, ValueType>;
- friend class FormatManager;
-};
-
-template<typename KeyType, typename ValueType>
-class FormattersContainer
-{
-protected:
- typedef FormatMap<KeyType,ValueType> BackEndType;
-
+template <typename KeyType, typename ValueType> class FormatMap {
public:
- typedef typename BackEndType::MapType MapType;
- typedef typename MapType::iterator MapIterator;
- typedef typename MapType::key_type MapKeyType;
- typedef typename MapType::mapped_type MapValueType;
- typedef typename BackEndType::ForEachCallback ForEachCallback;
- typedef typename std::shared_ptr<FormattersContainer<KeyType, ValueType> > SharedPointer;
-
- friend class TypeCategoryImpl;
-
- FormattersContainer(std::string name,
- IFormatChangeListener* lst) :
- m_format_map(lst),
- m_name(name)
- {
- }
-
- void
- Add (const MapKeyType &type, const MapValueType& entry)
- {
- Add_Impl(type, entry, static_cast<KeyType*>(nullptr));
- }
-
- bool
- Delete (ConstString type)
- {
- return Delete_Impl(type, static_cast<KeyType*>(nullptr));
- }
-
- bool
- Get(ValueObject& valobj,
- MapValueType& entry,
- lldb::DynamicValueType use_dynamic,
- uint32_t* why = nullptr)
- {
- uint32_t value = lldb_private::eFormatterChoiceCriterionDirectChoice;
- CompilerType ast_type(valobj.GetCompilerType());
- bool ret = Get(valobj, ast_type, entry, use_dynamic, value);
- if (ret)
- entry = MapValueType(entry);
- else
- entry = MapValueType();
- if (why)
- *why = value;
- return ret;
- }
-
- bool
- Get (ConstString type, MapValueType& entry)
- {
- return Get_Impl(type, entry, static_cast<KeyType*>(nullptr));
- }
-
- bool
- GetExact (ConstString type, MapValueType& entry)
- {
- return GetExact_Impl(type, entry, static_cast<KeyType*>(nullptr));
- }
-
- MapValueType
- GetAtIndex (size_t index)
- {
- return m_format_map.GetValueAtIndex(index);
- }
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierAtIndex (size_t index)
- {
- return GetTypeNameSpecifierAtIndex_Impl(index, static_cast<KeyType*>(nullptr));
- }
-
- void
- Clear ()
- {
- m_format_map.Clear();
- }
-
- void
- ForEach (ForEachCallback callback)
- {
- m_format_map.ForEach(callback);
- }
-
- uint32_t
- GetCount ()
- {
- return m_format_map.GetCount();
- }
-
-protected:
- BackEndType m_format_map;
- std::string m_name;
-
- DISALLOW_COPY_AND_ASSIGN(FormattersContainer);
-
- void
- Add_Impl (const MapKeyType &type, const MapValueType& entry, lldb::RegularExpressionSP *dummy)
- {
- m_format_map.Add(type,entry);
- }
+ typedef typename ValueType::SharedPointer ValueSP;
+ typedef std::map<KeyType, ValueSP> MapType;
+ typedef typename MapType::iterator MapIterator;
+ typedef std::function<bool(KeyType, const ValueSP &)> ForEachCallback;
+
+ FormatMap(IFormatChangeListener *lst)
+ : m_map(), m_map_mutex(), listener(lst) {}
+
+ void Add(KeyType name, const ValueSP &entry) {
+ if (listener)
+ entry->GetRevision() = listener->GetCurrentRevision();
+ else
+ entry->GetRevision() = 0;
+
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
+ m_map[name] = entry;
+ if (listener)
+ listener->Changed();
+ }
+
+ bool Delete(KeyType name) {
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
+ MapIterator iter = m_map.find(name);
+ if (iter == m_map.end())
+ return false;
+ m_map.erase(name);
+ if (listener)
+ listener->Changed();
+ return true;
+ }
+
+ void Clear() {
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
+ m_map.clear();
+ if (listener)
+ listener->Changed();
+ }
+
+ bool Get(KeyType name, ValueSP &entry) {
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
+ MapIterator iter = m_map.find(name);
+ if (iter == m_map.end())
+ return false;
+ entry = iter->second;
+ return true;
+ }
+
+ void ForEach(ForEachCallback callback) {
+ if (callback) {
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
+ MapIterator pos, end = m_map.end();
+ for (pos = m_map.begin(); pos != end; pos++) {
+ KeyType type = pos->first;
+ if (!callback(type, pos->second))
+ break;
+ }
+ }
+ }
+
+ uint32_t GetCount() { return m_map.size(); }
+
+ ValueSP GetValueAtIndex(size_t index) {
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
+ MapIterator iter = m_map.begin();
+ MapIterator end = m_map.end();
+ while (index > 0) {
+ iter++;
+ index--;
+ if (end == iter)
+ return ValueSP();
+ }
+ return iter->second;
+ }
+
+ KeyType GetKeyAtIndex(size_t index) {
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
+ MapIterator iter = m_map.begin();
+ MapIterator end = m_map.end();
+ while (index > 0) {
+ iter++;
+ index--;
+ if (end == iter)
+ return KeyType();
+ }
+ return iter->first;
+ }
- void Add_Impl (const ConstString &type, const MapValueType& entry, ConstString *dummy)
- {
- m_format_map.Add(GetValidTypeName_Impl(type), entry);
- }
+protected:
+ MapType m_map;
+ std::recursive_mutex m_map_mutex;
+ IFormatChangeListener *listener;
- bool
- Delete_Impl (ConstString type, ConstString *dummy)
- {
- return m_format_map.Delete(type);
- }
+ MapType &map() { return m_map; }
- bool
- Delete_Impl(ConstString type, lldb::RegularExpressionSP *dummy)
- {
- std::lock_guard<std::recursive_mutex> guard(m_format_map.mutex());
- MapIterator pos, end = m_format_map.map().end();
- for (pos = m_format_map.map().begin(); pos != end; pos++)
- {
- lldb::RegularExpressionSP regex = pos->first;
- if (::strcmp(type.AsCString(), regex->GetText()) == 0)
- {
- m_format_map.map().erase(pos);
- if (m_format_map.listener)
- m_format_map.listener->Changed();
- return true;
- }
- }
- return false;
- }
+ std::recursive_mutex &mutex() { return m_map_mutex; }
- bool
- Get_Impl (ConstString type, MapValueType& entry, ConstString *dummy)
- {
- return m_format_map.Get(type, entry);
- }
-
- bool
- GetExact_Impl (ConstString type, MapValueType& entry, ConstString *dummy)
- {
- return Get_Impl(type, entry, static_cast<KeyType*>(nullptr));
- }
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierAtIndex_Impl (size_t index, ConstString *dummy)
- {
- ConstString key = m_format_map.GetKeyAtIndex(index);
- if (key)
- return lldb::TypeNameSpecifierImplSP(new TypeNameSpecifierImpl(key.AsCString(),
- false));
- else
- return lldb::TypeNameSpecifierImplSP();
- }
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierAtIndex_Impl (size_t index, lldb::RegularExpressionSP *dummy)
- {
- lldb::RegularExpressionSP regex = m_format_map.GetKeyAtIndex(index);
- if (regex.get() == nullptr)
- return lldb::TypeNameSpecifierImplSP();
- return lldb::TypeNameSpecifierImplSP(new TypeNameSpecifierImpl(regex->GetText(),
- true));
- }
+ friend class FormattersContainer<KeyType, ValueType>;
+ friend class FormatManager;
+};
- bool
- Get_Impl(ConstString key, MapValueType &value, lldb::RegularExpressionSP *dummy)
- {
- const char *key_cstr = key.AsCString();
- if (!key_cstr)
- return false;
- std::lock_guard<std::recursive_mutex> guard(m_format_map.mutex());
- MapIterator pos, end = m_format_map.map().end();
- for (pos = m_format_map.map().begin(); pos != end; pos++)
- {
- lldb::RegularExpressionSP regex = pos->first;
- if (regex->Execute(key_cstr))
- {
- value = pos->second;
- return true;
- }
- }
- return false;
- }
+template <typename KeyType, typename ValueType> class FormattersContainer {
+protected:
+ typedef FormatMap<KeyType, ValueType> BackEndType;
- bool
- GetExact_Impl(ConstString key, MapValueType &value, lldb::RegularExpressionSP *dummy)
- {
- std::lock_guard<std::recursive_mutex> guard(m_format_map.mutex());
- MapIterator pos, end = m_format_map.map().end();
- for (pos = m_format_map.map().begin(); pos != end; pos++)
- {
- lldb::RegularExpressionSP regex = pos->first;
- if (strcmp(regex->GetText(), key.AsCString()) == 0)
- {
- value = pos->second;
- return true;
- }
- }
- return false;
- }
+public:
+ typedef typename BackEndType::MapType MapType;
+ typedef typename MapType::iterator MapIterator;
+ typedef typename MapType::key_type MapKeyType;
+ typedef typename MapType::mapped_type MapValueType;
+ typedef typename BackEndType::ForEachCallback ForEachCallback;
+ typedef typename std::shared_ptr<FormattersContainer<KeyType, ValueType>>
+ SharedPointer;
+
+ friend class TypeCategoryImpl;
+
+ FormattersContainer(std::string name, IFormatChangeListener *lst)
+ : m_format_map(lst), m_name(name) {}
+
+ void Add(const MapKeyType &type, const MapValueType &entry) {
+ Add_Impl(type, entry, static_cast<KeyType *>(nullptr));
+ }
+
+ bool Delete(ConstString type) {
+ return Delete_Impl(type, static_cast<KeyType *>(nullptr));
+ }
+
+ bool Get(ValueObject &valobj, MapValueType &entry,
+ lldb::DynamicValueType use_dynamic, uint32_t *why = nullptr) {
+ uint32_t value = lldb_private::eFormatterChoiceCriterionDirectChoice;
+ CompilerType ast_type(valobj.GetCompilerType());
+ bool ret = Get(valobj, ast_type, entry, use_dynamic, value);
+ if (ret)
+ entry = MapValueType(entry);
+ else
+ entry = MapValueType();
+ if (why)
+ *why = value;
+ return ret;
+ }
+
+ bool Get(ConstString type, MapValueType &entry) {
+ return Get_Impl(type, entry, static_cast<KeyType *>(nullptr));
+ }
+
+ bool GetExact(ConstString type, MapValueType &entry) {
+ return GetExact_Impl(type, entry, static_cast<KeyType *>(nullptr));
+ }
+
+ MapValueType GetAtIndex(size_t index) {
+ return m_format_map.GetValueAtIndex(index);
+ }
+
+ lldb::TypeNameSpecifierImplSP GetTypeNameSpecifierAtIndex(size_t index) {
+ return GetTypeNameSpecifierAtIndex_Impl(index,
+ static_cast<KeyType *>(nullptr));
+ }
+
+ void Clear() { m_format_map.Clear(); }
+
+ void ForEach(ForEachCallback callback) { m_format_map.ForEach(callback); }
+
+ uint32_t GetCount() { return m_format_map.GetCount(); }
- bool
- Get (const FormattersMatchVector& candidates,
- MapValueType& entry,
- uint32_t *reason)
- {
- for (const FormattersMatchCandidate& candidate : candidates)
- {
- if (Get(candidate.GetTypeName(),entry))
- {
- if (candidate.IsMatch(entry) == false)
- {
- entry.reset();
- continue;
- }
- else
- {
- if(reason)
- *reason = candidate.GetReason();
- return true;
- }
- }
+protected:
+ BackEndType m_format_map;
+ std::string m_name;
+
+ DISALLOW_COPY_AND_ASSIGN(FormattersContainer);
+
+ void Add_Impl(const MapKeyType &type, const MapValueType &entry,
+ lldb::RegularExpressionSP *dummy) {
+ m_format_map.Add(type, entry);
+ }
+
+ void Add_Impl(const ConstString &type, const MapValueType &entry,
+ ConstString *dummy) {
+ m_format_map.Add(GetValidTypeName_Impl(type), entry);
+ }
+
+ bool Delete_Impl(ConstString type, ConstString *dummy) {
+ return m_format_map.Delete(type);
+ }
+
+ bool Delete_Impl(ConstString type, lldb::RegularExpressionSP *dummy) {
+ std::lock_guard<std::recursive_mutex> guard(m_format_map.mutex());
+ MapIterator pos, end = m_format_map.map().end();
+ for (pos = m_format_map.map().begin(); pos != end; pos++) {
+ lldb::RegularExpressionSP regex = pos->first;
+ if (type.GetStringRef() == regex->GetText()) {
+ m_format_map.map().erase(pos);
+ if (m_format_map.listener)
+ m_format_map.listener->Changed();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ bool Get_Impl(ConstString type, MapValueType &entry, ConstString *dummy) {
+ return m_format_map.Get(type, entry);
+ }
+
+ bool GetExact_Impl(ConstString type, MapValueType &entry,
+ ConstString *dummy) {
+ return Get_Impl(type, entry, static_cast<KeyType *>(nullptr));
+ }
+
+ lldb::TypeNameSpecifierImplSP
+ GetTypeNameSpecifierAtIndex_Impl(size_t index, ConstString *dummy) {
+ ConstString key = m_format_map.GetKeyAtIndex(index);
+ if (key)
+ return lldb::TypeNameSpecifierImplSP(
+ new TypeNameSpecifierImpl(key.AsCString(), false));
+ else
+ return lldb::TypeNameSpecifierImplSP();
+ }
+
+ lldb::TypeNameSpecifierImplSP
+ GetTypeNameSpecifierAtIndex_Impl(size_t index,
+ lldb::RegularExpressionSP *dummy) {
+ lldb::RegularExpressionSP regex = m_format_map.GetKeyAtIndex(index);
+ if (regex.get() == nullptr)
+ return lldb::TypeNameSpecifierImplSP();
+ return lldb::TypeNameSpecifierImplSP(
+ new TypeNameSpecifierImpl(regex->GetText().str().c_str(), true));
+ }
+
+ bool Get_Impl(ConstString key, MapValueType &value,
+ lldb::RegularExpressionSP *dummy) {
+ llvm::StringRef key_str = key.GetStringRef();
+ std::lock_guard<std::recursive_mutex> guard(m_format_map.mutex());
+ MapIterator pos, end = m_format_map.map().end();
+ for (pos = m_format_map.map().begin(); pos != end; pos++) {
+ lldb::RegularExpressionSP regex = pos->first;
+ if (regex->Execute(key_str)) {
+ value = pos->second;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ bool GetExact_Impl(ConstString key, MapValueType &value,
+ lldb::RegularExpressionSP *dummy) {
+ std::lock_guard<std::recursive_mutex> guard(m_format_map.mutex());
+ MapIterator pos, end = m_format_map.map().end();
+ for (pos = m_format_map.map().begin(); pos != end; pos++) {
+ lldb::RegularExpressionSP regex = pos->first;
+ if (regex->GetText() == key.GetStringRef()) {
+ value = pos->second;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ bool Get(const FormattersMatchVector &candidates, MapValueType &entry,
+ uint32_t *reason) {
+ for (const FormattersMatchCandidate &candidate : candidates) {
+ if (Get(candidate.GetTypeName(), entry)) {
+ if (candidate.IsMatch(entry) == false) {
+ entry.reset();
+ continue;
+ } else {
+ if (reason)
+ *reason = candidate.GetReason();
+ return true;
}
- return false;
+ }
}
+ return false;
+ }
};
} // namespace lldb_private
diff --git a/include/lldb/DataFormatters/FormattersHelpers.h b/include/lldb/DataFormatters/FormattersHelpers.h
index 0622230f6797..14ba5e48feb4 100644
--- a/include/lldb/DataFormatters/FormattersHelpers.h
+++ b/include/lldb/DataFormatters/FormattersHelpers.h
@@ -1,4 +1,5 @@
-//===-- FormattersHelpers.h --------------------------------------*- C++ -*-===//
+//===-- FormattersHelpers.h --------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,8 +15,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-forward.h"
#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-forward.h"
#include "lldb/DataFormatters/TypeCategory.h"
#include "lldb/DataFormatters/TypeFormat.h"
@@ -23,229 +24,171 @@
#include "lldb/DataFormatters/TypeSynthetic.h"
namespace lldb_private {
- namespace formatters {
- void
- AddFormat (TypeCategoryImpl::SharedPointer category_sp,
- lldb::Format format,
- ConstString type_name,
- TypeFormatImpl::Flags flags,
- bool regex = false);
-
- void
- AddSummary(TypeCategoryImpl::SharedPointer category_sp,
- lldb::TypeSummaryImplSP summary_sp,
- ConstString type_name,
- bool regex = false);
-
- void
- AddStringSummary(TypeCategoryImpl::SharedPointer category_sp,
- const char* string,
- ConstString type_name,
- TypeSummaryImpl::Flags flags,
- bool regex = false);
-
- void
- AddOneLineSummary (TypeCategoryImpl::SharedPointer category_sp,
- ConstString type_name,
- TypeSummaryImpl::Flags flags,
- bool regex = false);
+namespace formatters {
+void AddFormat(TypeCategoryImpl::SharedPointer category_sp, lldb::Format format,
+ ConstString type_name, TypeFormatImpl::Flags flags,
+ bool regex = false);
-#ifndef LLDB_DISABLE_PYTHON
- void
- AddCXXSummary (TypeCategoryImpl::SharedPointer category_sp,
- CXXFunctionSummaryFormat::Callback funct,
- const char* description,
- ConstString type_name,
- TypeSummaryImpl::Flags flags,
+void AddSummary(TypeCategoryImpl::SharedPointer category_sp,
+ lldb::TypeSummaryImplSP summary_sp, ConstString type_name,
+ bool regex = false);
+
+void AddStringSummary(TypeCategoryImpl::SharedPointer category_sp,
+ const char *string, ConstString type_name,
+ TypeSummaryImpl::Flags flags, bool regex = false);
+
+void AddOneLineSummary(TypeCategoryImpl::SharedPointer category_sp,
+ ConstString type_name, TypeSummaryImpl::Flags flags,
bool regex = false);
- void
- AddCXXSynthetic (TypeCategoryImpl::SharedPointer category_sp,
- CXXSyntheticChildren::CreateFrontEndCallback generator,
- const char* description,
- ConstString type_name,
- ScriptedSyntheticChildren::Flags flags,
- bool regex = false);
-
- void
- AddFilter (TypeCategoryImpl::SharedPointer category_sp,
- std::vector<std::string> children,
- const char* description,
- ConstString type_name,
- ScriptedSyntheticChildren::Flags flags,
- bool regex = false);
+#ifndef LLDB_DISABLE_PYTHON
+void AddCXXSummary(TypeCategoryImpl::SharedPointer category_sp,
+ CXXFunctionSummaryFormat::Callback funct,
+ const char *description, ConstString type_name,
+ TypeSummaryImpl::Flags flags, bool regex = false);
+
+void AddCXXSynthetic(TypeCategoryImpl::SharedPointer category_sp,
+ CXXSyntheticChildren::CreateFrontEndCallback generator,
+ const char *description, ConstString type_name,
+ ScriptedSyntheticChildren::Flags flags,
+ bool regex = false);
+
+void AddFilter(TypeCategoryImpl::SharedPointer category_sp,
+ std::vector<std::string> children, const char *description,
+ ConstString type_name, ScriptedSyntheticChildren::Flags flags,
+ bool regex = false);
#endif
- size_t
- ExtractIndexFromString (const char* item_name);
-
- lldb::addr_t
- GetArrayAddressOrPointerValue (ValueObject& valobj);
-
- time_t
- GetOSXEpoch ();
-
- struct InferiorSizedWord {
-
- InferiorSizedWord(const InferiorSizedWord& word) : ptr_size(word.ptr_size)
- {
- if (ptr_size == 4)
- thirty_two = word.thirty_two;
- else
- sixty_four = word.sixty_four;
- }
-
- InferiorSizedWord
- operator = (const InferiorSizedWord& word)
- {
- ptr_size = word.ptr_size;
- if (ptr_size == 4)
- thirty_two = word.thirty_two;
- else
- sixty_four = word.sixty_four;
- return *this;
- }
-
- InferiorSizedWord(uint64_t val, Process& process) : ptr_size(process.GetAddressByteSize())
- {
- if (ptr_size == 4)
- thirty_two = (uint32_t)val;
- else if (ptr_size == 8)
- sixty_four = val;
- else
- assert (false && "new pointer size is unknown");
- }
-
- bool
- IsNegative () const
- {
- if (ptr_size == 4)
- return ((int32_t)thirty_two) < 0;
- else
- return ((int64_t)sixty_four) < 0;
- }
-
- bool
- IsZero () const
- {
- if (ptr_size == 4)
- return thirty_two == 0;
- else
- return sixty_four == 0;
- }
-
- static InferiorSizedWord
- GetMaximum (Process& process)
- {
- if (process.GetAddressByteSize() == 4)
- return InferiorSizedWord(UINT32_MAX,4);
- else
- return InferiorSizedWord(UINT64_MAX,8);
- }
-
- InferiorSizedWord
- operator >> (int rhs) const
- {
- if (ptr_size == 4)
- return InferiorSizedWord(thirty_two >> rhs,4);
- return InferiorSizedWord(sixty_four>>rhs,8);
- }
-
- InferiorSizedWord
- operator << (int rhs) const
- {
- if (ptr_size == 4)
- return InferiorSizedWord(thirty_two << rhs,4);
- return InferiorSizedWord(sixty_four << rhs,8);
- }
-
- InferiorSizedWord
- operator & (const InferiorSizedWord& word) const
- {
- if (ptr_size != word.ptr_size)
- return InferiorSizedWord(0,ptr_size);
- if (ptr_size == 4)
- return InferiorSizedWord(thirty_two & word.thirty_two,4);
- return InferiorSizedWord(sixty_four & word.sixty_four,8);
- }
-
- InferiorSizedWord
- operator & (int x) const
- {
- if (ptr_size == 4)
- return InferiorSizedWord(thirty_two & x,4);
- return InferiorSizedWord(sixty_four & x,8);
- }
-
- size_t
- GetBitSize () const
- {
- return ptr_size << 3;
- }
-
- size_t
- GetByteSize () const
- {
- return ptr_size;
- }
-
- uint64_t
- GetValue () const
- {
- if (ptr_size == 4)
- return (uint64_t)thirty_two;
- return sixty_four;
- }
-
- InferiorSizedWord
- SignExtend () const
- {
- if (ptr_size == 4)
- return InferiorSizedWord ((int32_t)thirty_two,4);
- return InferiorSizedWord((int64_t)sixty_four,8);
- }
-
- uint8_t*
- CopyToBuffer (uint8_t* buffer) const
- {
- if (ptr_size == 4)
- {
- memcpy(buffer, &thirty_two, 4);
- return buffer + 4;
- }
- else
- {
- memcpy(buffer, &sixty_four, 8);
- return buffer + 8;
- }
- }
-
- DataExtractor
- GetAsData (lldb::ByteOrder byte_order = lldb::eByteOrderInvalid) const
- {
- if (ptr_size == 4)
- return DataExtractor(&thirty_two, 4, byte_order, 4);
- else
- return DataExtractor(&sixty_four, 8, byte_order, 8);
- }
-
- private:
-
- InferiorSizedWord(uint64_t val, size_t psz) : ptr_size(psz)
- {
- if (ptr_size == 4)
- thirty_two = (uint32_t)val;
- else
- sixty_four = val;
- }
-
- size_t ptr_size;
- union {
- uint32_t thirty_two;
- uint64_t sixty_four;
- };
- };
- } // namespace formatters
+size_t ExtractIndexFromString(const char *item_name);
+
+lldb::addr_t GetArrayAddressOrPointerValue(ValueObject &valobj);
+
+time_t GetOSXEpoch();
+
+struct InferiorSizedWord {
+
+ InferiorSizedWord(const InferiorSizedWord &word) : ptr_size(word.ptr_size) {
+ if (ptr_size == 4)
+ thirty_two = word.thirty_two;
+ else
+ sixty_four = word.sixty_four;
+ }
+
+ InferiorSizedWord operator=(const InferiorSizedWord &word) {
+ ptr_size = word.ptr_size;
+ if (ptr_size == 4)
+ thirty_two = word.thirty_two;
+ else
+ sixty_four = word.sixty_four;
+ return *this;
+ }
+
+ InferiorSizedWord(uint64_t val, Process &process)
+ : ptr_size(process.GetAddressByteSize()) {
+ if (ptr_size == 4)
+ thirty_two = (uint32_t)val;
+ else if (ptr_size == 8)
+ sixty_four = val;
+ else
+ assert(false && "new pointer size is unknown");
+ }
+
+ bool IsNegative() const {
+ if (ptr_size == 4)
+ return ((int32_t)thirty_two) < 0;
+ else
+ return ((int64_t)sixty_four) < 0;
+ }
+
+ bool IsZero() const {
+ if (ptr_size == 4)
+ return thirty_two == 0;
+ else
+ return sixty_four == 0;
+ }
+
+ static InferiorSizedWord GetMaximum(Process &process) {
+ if (process.GetAddressByteSize() == 4)
+ return InferiorSizedWord(UINT32_MAX, 4);
+ else
+ return InferiorSizedWord(UINT64_MAX, 8);
+ }
+
+ InferiorSizedWord operator>>(int rhs) const {
+ if (ptr_size == 4)
+ return InferiorSizedWord(thirty_two >> rhs, 4);
+ return InferiorSizedWord(sixty_four >> rhs, 8);
+ }
+
+ InferiorSizedWord operator<<(int rhs) const {
+ if (ptr_size == 4)
+ return InferiorSizedWord(thirty_two << rhs, 4);
+ return InferiorSizedWord(sixty_four << rhs, 8);
+ }
+
+ InferiorSizedWord operator&(const InferiorSizedWord &word) const {
+ if (ptr_size != word.ptr_size)
+ return InferiorSizedWord(0, ptr_size);
+ if (ptr_size == 4)
+ return InferiorSizedWord(thirty_two & word.thirty_two, 4);
+ return InferiorSizedWord(sixty_four & word.sixty_four, 8);
+ }
+
+ InferiorSizedWord operator&(int x) const {
+ if (ptr_size == 4)
+ return InferiorSizedWord(thirty_two & x, 4);
+ return InferiorSizedWord(sixty_four & x, 8);
+ }
+
+ size_t GetBitSize() const { return ptr_size << 3; }
+
+ size_t GetByteSize() const { return ptr_size; }
+
+ uint64_t GetValue() const {
+ if (ptr_size == 4)
+ return (uint64_t)thirty_two;
+ return sixty_four;
+ }
+
+ InferiorSizedWord SignExtend() const {
+ if (ptr_size == 4)
+ return InferiorSizedWord((int32_t)thirty_two, 4);
+ return InferiorSizedWord((int64_t)sixty_four, 8);
+ }
+
+ uint8_t *CopyToBuffer(uint8_t *buffer) const {
+ if (ptr_size == 4) {
+ memcpy(buffer, &thirty_two, 4);
+ return buffer + 4;
+ } else {
+ memcpy(buffer, &sixty_four, 8);
+ return buffer + 8;
+ }
+ }
+
+ DataExtractor
+ GetAsData(lldb::ByteOrder byte_order = lldb::eByteOrderInvalid) const {
+ if (ptr_size == 4)
+ return DataExtractor(&thirty_two, 4, byte_order, 4);
+ else
+ return DataExtractor(&sixty_four, 8, byte_order, 8);
+ }
+
+private:
+ InferiorSizedWord(uint64_t val, size_t psz) : ptr_size(psz) {
+ if (ptr_size == 4)
+ thirty_two = (uint32_t)val;
+ else
+ sixty_four = val;
+ }
+
+ size_t ptr_size;
+ union {
+ uint32_t thirty_two;
+ uint64_t sixty_four;
+ };
+};
+} // namespace formatters
} // namespace lldb_private
-#endif // lldb_FormattersHelpers_h_
+#endif // lldb_FormattersHelpers_h_
diff --git a/include/lldb/DataFormatters/LanguageCategory.h b/include/lldb/DataFormatters/LanguageCategory.h
index a7040099f213..e94429407837 100644
--- a/include/lldb/DataFormatters/LanguageCategory.h
+++ b/include/lldb/DataFormatters/LanguageCategory.h
@@ -1,4 +1,5 @@
-//===-- LanguageCategory.h----------------------------------------*- C++ -*-===//
+//===-- LanguageCategory.h----------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -15,85 +16,65 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
#include "lldb/DataFormatters/FormatCache.h"
#include "lldb/DataFormatters/FormatClasses.h"
+#include "lldb/lldb-public.h"
#include <memory>
namespace lldb_private {
-class LanguageCategory
-{
+class LanguageCategory {
public:
- typedef std::unique_ptr<LanguageCategory> UniquePointer;
-
- LanguageCategory (lldb::LanguageType lang_type);
-
- bool
- Get (FormattersMatchData& match_data,
- lldb::TypeFormatImplSP& format_sp);
-
- bool
- Get (FormattersMatchData& match_data,
- lldb::TypeSummaryImplSP& format_sp);
-
- bool
- Get (FormattersMatchData& match_data,
- lldb::SyntheticChildrenSP& format_sp);
-
- bool
- Get (FormattersMatchData& match_data,
- lldb::TypeValidatorImplSP& format_sp);
-
- bool
- GetHardcoded (FormatManager& fmt_mgr,
- FormattersMatchData& match_data,
- lldb::TypeFormatImplSP& format_sp);
-
- bool
- GetHardcoded (FormatManager& fmt_mgr,
- FormattersMatchData& match_data,
- lldb::TypeSummaryImplSP& format_sp);
-
- bool
- GetHardcoded (FormatManager& fmt_mgr,
- FormattersMatchData& match_data,
- lldb::SyntheticChildrenSP& format_sp);
-
- bool
- GetHardcoded (FormatManager& fmt_mgr,
- FormattersMatchData& match_data,
- lldb::TypeValidatorImplSP& format_sp);
-
- lldb::TypeCategoryImplSP
- GetCategory () const;
-
- FormatCache&
- GetFormatCache ();
-
- void
- Enable ();
-
- void
- Disable ();
-
- bool
- IsEnabled ();
-
+ typedef std::unique_ptr<LanguageCategory> UniquePointer;
+
+ LanguageCategory(lldb::LanguageType lang_type);
+
+ bool Get(FormattersMatchData &match_data, lldb::TypeFormatImplSP &format_sp);
+
+ bool Get(FormattersMatchData &match_data, lldb::TypeSummaryImplSP &format_sp);
+
+ bool Get(FormattersMatchData &match_data,
+ lldb::SyntheticChildrenSP &format_sp);
+
+ bool Get(FormattersMatchData &match_data,
+ lldb::TypeValidatorImplSP &format_sp);
+
+ bool GetHardcoded(FormatManager &fmt_mgr, FormattersMatchData &match_data,
+ lldb::TypeFormatImplSP &format_sp);
+
+ bool GetHardcoded(FormatManager &fmt_mgr, FormattersMatchData &match_data,
+ lldb::TypeSummaryImplSP &format_sp);
+
+ bool GetHardcoded(FormatManager &fmt_mgr, FormattersMatchData &match_data,
+ lldb::SyntheticChildrenSP &format_sp);
+
+ bool GetHardcoded(FormatManager &fmt_mgr, FormattersMatchData &match_data,
+ lldb::TypeValidatorImplSP &format_sp);
+
+ lldb::TypeCategoryImplSP GetCategory() const;
+
+ FormatCache &GetFormatCache();
+
+ void Enable();
+
+ void Disable();
+
+ bool IsEnabled();
+
private:
- lldb::TypeCategoryImplSP m_category_sp;
-
- HardcodedFormatters::HardcodedFormatFinder m_hardcoded_formats;
- HardcodedFormatters::HardcodedSummaryFinder m_hardcoded_summaries;
- HardcodedFormatters::HardcodedSyntheticFinder m_hardcoded_synthetics;
- HardcodedFormatters::HardcodedValidatorFinder m_hardcoded_validators;
-
- lldb_private::FormatCache m_format_cache;
-
- bool m_enabled;
+ lldb::TypeCategoryImplSP m_category_sp;
+
+ HardcodedFormatters::HardcodedFormatFinder m_hardcoded_formats;
+ HardcodedFormatters::HardcodedSummaryFinder m_hardcoded_summaries;
+ HardcodedFormatters::HardcodedSyntheticFinder m_hardcoded_synthetics;
+ HardcodedFormatters::HardcodedValidatorFinder m_hardcoded_validators;
+
+ lldb_private::FormatCache m_format_cache;
+
+ bool m_enabled;
};
-
+
} // namespace lldb_private
#endif // lldb_LanguageCategory_h_
diff --git a/include/lldb/DataFormatters/StringPrinter.h b/include/lldb/DataFormatters/StringPrinter.h
index a849c4e01109..43329466a9a4 100644
--- a/include/lldb/DataFormatters/StringPrinter.h
+++ b/include/lldb/DataFormatters/StringPrinter.h
@@ -22,508 +22,327 @@
#include "lldb/Core/DataExtractor.h"
namespace lldb_private {
- namespace formatters
+namespace formatters {
+class StringPrinter {
+public:
+ enum class StringElementType { ASCII, UTF8, UTF16, UTF32 };
+
+ enum class GetPrintableElementType { ASCII, UTF8 };
+
+ class ReadStringAndDumpToStreamOptions {
+ public:
+ ReadStringAndDumpToStreamOptions()
+ : m_location(0), m_process_sp(), m_stream(nullptr), m_prefix_token(),
+ m_suffix_token(), m_quote('"'), m_source_size(0),
+ m_needs_zero_termination(true), m_escape_non_printables(true),
+ m_ignore_max_length(false), m_zero_is_terminator(true),
+ m_language_type(lldb::eLanguageTypeUnknown) {}
+
+ ReadStringAndDumpToStreamOptions(ValueObject &valobj);
+
+ ReadStringAndDumpToStreamOptions &SetLocation(uint64_t l) {
+ m_location = l;
+ return *this;
+ }
+
+ uint64_t GetLocation() const { return m_location; }
+
+ ReadStringAndDumpToStreamOptions &SetProcessSP(lldb::ProcessSP p) {
+ m_process_sp = p;
+ return *this;
+ }
+
+ lldb::ProcessSP GetProcessSP() const { return m_process_sp; }
+
+ ReadStringAndDumpToStreamOptions &SetStream(Stream *s) {
+ m_stream = s;
+ return *this;
+ }
+
+ Stream *GetStream() const { return m_stream; }
+
+ ReadStringAndDumpToStreamOptions &SetPrefixToken(const std::string &p) {
+ m_prefix_token = p;
+ return *this;
+ }
+
+ ReadStringAndDumpToStreamOptions &SetPrefixToken(std::nullptr_t) {
+ m_prefix_token.clear();
+ return *this;
+ }
+
+ const char *GetPrefixToken() const { return m_prefix_token.c_str(); }
+
+ ReadStringAndDumpToStreamOptions &SetSuffixToken(const std::string &p) {
+ m_suffix_token = p;
+ return *this;
+ }
+
+ ReadStringAndDumpToStreamOptions &SetSuffixToken(std::nullptr_t) {
+ m_suffix_token.clear();
+ return *this;
+ }
+
+ const char *GetSuffixToken() const { return m_suffix_token.c_str(); }
+
+ ReadStringAndDumpToStreamOptions &SetQuote(char q) {
+ m_quote = q;
+ return *this;
+ }
+
+ char GetQuote() const { return m_quote; }
+
+ ReadStringAndDumpToStreamOptions &SetSourceSize(uint32_t s) {
+ m_source_size = s;
+ return *this;
+ }
+
+ uint32_t GetSourceSize() const { return m_source_size; }
+
+ ReadStringAndDumpToStreamOptions &SetNeedsZeroTermination(bool z) {
+ m_needs_zero_termination = z;
+ return *this;
+ }
+
+ bool GetNeedsZeroTermination() const { return m_needs_zero_termination; }
+
+ ReadStringAndDumpToStreamOptions &SetBinaryZeroIsTerminator(bool e) {
+ m_zero_is_terminator = e;
+ return *this;
+ }
+
+ bool GetBinaryZeroIsTerminator() const { return m_zero_is_terminator; }
+
+ ReadStringAndDumpToStreamOptions &SetEscapeNonPrintables(bool e) {
+ m_escape_non_printables = e;
+ return *this;
+ }
+
+ bool GetEscapeNonPrintables() const { return m_escape_non_printables; }
+
+ ReadStringAndDumpToStreamOptions &SetIgnoreMaxLength(bool e) {
+ m_ignore_max_length = e;
+ return *this;
+ }
+
+ bool GetIgnoreMaxLength() const { return m_ignore_max_length; }
+
+ ReadStringAndDumpToStreamOptions &SetLanguage(lldb::LanguageType l) {
+ m_language_type = l;
+ return *this;
+ }
+
+ lldb::LanguageType GetLanguage() const
+
{
- class StringPrinter
- {
- public:
- enum class StringElementType
- {
- ASCII,
- UTF8,
- UTF16,
- UTF32
- };
-
- enum class GetPrintableElementType
- {
- ASCII,
- UTF8
- };
-
- class ReadStringAndDumpToStreamOptions
- {
- public:
- ReadStringAndDumpToStreamOptions () :
- m_location(0),
- m_process_sp(),
- m_stream(nullptr),
- m_prefix_token(),
- m_suffix_token(),
- m_quote('"'),
- m_source_size(0),
- m_needs_zero_termination(true),
- m_escape_non_printables(true),
- m_ignore_max_length(false),
- m_zero_is_terminator(true),
- m_language_type(lldb::eLanguageTypeUnknown)
- {
- }
-
- ReadStringAndDumpToStreamOptions (ValueObject& valobj);
-
- ReadStringAndDumpToStreamOptions&
- SetLocation (uint64_t l)
- {
- m_location = l;
- return *this;
- }
-
- uint64_t
- GetLocation () const
- {
- return m_location;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetProcessSP (lldb::ProcessSP p)
- {
- m_process_sp = p;
- return *this;
- }
-
- lldb::ProcessSP
- GetProcessSP () const
- {
- return m_process_sp;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetStream (Stream* s)
- {
- m_stream = s;
- return *this;
- }
-
- Stream*
- GetStream () const
- {
- return m_stream;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetPrefixToken (const std::string& p)
- {
- m_prefix_token = p;
- return *this;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetPrefixToken (std::nullptr_t)
- {
- m_prefix_token.clear();
- return *this;
- }
-
- const char*
- GetPrefixToken () const
- {
- return m_prefix_token.c_str();
- }
-
- ReadStringAndDumpToStreamOptions&
- SetSuffixToken (const std::string& p)
- {
- m_suffix_token = p;
- return *this;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetSuffixToken (std::nullptr_t)
- {
- m_suffix_token.clear();
- return *this;
- }
-
- const char*
- GetSuffixToken () const
- {
- return m_suffix_token.c_str();
- }
-
- ReadStringAndDumpToStreamOptions&
- SetQuote (char q)
- {
- m_quote = q;
- return *this;
- }
-
- char
- GetQuote () const
- {
- return m_quote;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetSourceSize (uint32_t s)
- {
- m_source_size = s;
- return *this;
- }
-
- uint32_t
- GetSourceSize () const
- {
- return m_source_size;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetNeedsZeroTermination (bool z)
- {
- m_needs_zero_termination = z;
- return *this;
- }
-
- bool
- GetNeedsZeroTermination () const
- {
- return m_needs_zero_termination;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetBinaryZeroIsTerminator (bool e)
- {
- m_zero_is_terminator = e;
- return *this;
- }
-
- bool
- GetBinaryZeroIsTerminator () const
- {
- return m_zero_is_terminator;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetEscapeNonPrintables (bool e)
- {
- m_escape_non_printables = e;
- return *this;
- }
-
- bool
- GetEscapeNonPrintables () const
- {
- return m_escape_non_printables;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetIgnoreMaxLength (bool e)
- {
- m_ignore_max_length = e;
- return *this;
- }
-
- bool
- GetIgnoreMaxLength () const
- {
- return m_ignore_max_length;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetLanguage (lldb::LanguageType l)
- {
- m_language_type = l;
- return *this;
- }
-
- lldb::LanguageType
- GetLanguage () const
-
- {
- return m_language_type;
- }
-
- private:
- uint64_t m_location;
- lldb::ProcessSP m_process_sp;
- Stream* m_stream;
- std::string m_prefix_token;
- std::string m_suffix_token;
- char m_quote;
- uint32_t m_source_size;
- bool m_needs_zero_termination;
- bool m_escape_non_printables;
- bool m_ignore_max_length;
- bool m_zero_is_terminator;
- lldb::LanguageType m_language_type;
- };
-
- class ReadBufferAndDumpToStreamOptions
- {
- public:
- ReadBufferAndDumpToStreamOptions () :
- m_data(),
- m_stream(nullptr),
- m_prefix_token(),
- m_suffix_token(),
- m_quote('"'),
- m_source_size(0),
- m_escape_non_printables(true),
- m_zero_is_terminator(true),
- m_is_truncated(false),
- m_language_type(lldb::eLanguageTypeUnknown)
- {
- }
-
- ReadBufferAndDumpToStreamOptions (ValueObject& valobj);
-
- ReadBufferAndDumpToStreamOptions (const ReadStringAndDumpToStreamOptions& options);
-
- ReadBufferAndDumpToStreamOptions&
- SetData (DataExtractor d)
- {
- m_data = d;
- return *this;
- }
-
- lldb_private::DataExtractor
- GetData () const
- {
- return m_data;
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetStream (Stream* s)
- {
- m_stream = s;
- return *this;
- }
-
- Stream*
- GetStream () const
- {
- return m_stream;
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetPrefixToken (const std::string& p)
- {
- m_prefix_token = p;
- return *this;
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetPrefixToken (std::nullptr_t)
- {
- m_prefix_token.clear();
- return *this;
- }
-
- const char*
- GetPrefixToken () const
- {
- return m_prefix_token.c_str();
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetSuffixToken (const std::string& p)
- {
- m_suffix_token = p;
- return *this;
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetSuffixToken (std::nullptr_t)
- {
- m_suffix_token.clear();
- return *this;
- }
-
- const char*
- GetSuffixToken () const
- {
- return m_suffix_token.c_str();
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetQuote (char q)
- {
- m_quote = q;
- return *this;
- }
-
- char
- GetQuote () const
- {
- return m_quote;
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetSourceSize (uint32_t s)
- {
- m_source_size = s;
- return *this;
- }
-
- uint32_t
- GetSourceSize () const
- {
- return m_source_size;
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetEscapeNonPrintables (bool e)
- {
- m_escape_non_printables = e;
- return *this;
- }
-
- bool
- GetEscapeNonPrintables () const
- {
- return m_escape_non_printables;
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetBinaryZeroIsTerminator (bool e)
- {
- m_zero_is_terminator = e;
- return *this;
- }
-
- bool
- GetBinaryZeroIsTerminator () const
- {
- return m_zero_is_terminator;
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetIsTruncated (bool t)
- {
- m_is_truncated = t;
- return *this;
- }
-
- bool
- GetIsTruncated () const
- {
- return m_is_truncated;
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetLanguage (lldb::LanguageType l)
- {
- m_language_type = l;
- return *this;
- }
-
- lldb::LanguageType
- GetLanguage () const
-
- {
- return m_language_type;
- }
-
- private:
- DataExtractor m_data;
- Stream* m_stream;
- std::string m_prefix_token;
- std::string m_suffix_token;
- char m_quote;
- uint32_t m_source_size;
- bool m_escape_non_printables;
- bool m_zero_is_terminator;
- bool m_is_truncated;
- lldb::LanguageType m_language_type;
- };
-
- // I can't use a std::unique_ptr for this because the Deleter is a template argument there
- // and I want the same type to represent both pointers I want to free and pointers I don't need
- // to free - which is what this class essentially is
- // It's very specialized to the needs of this file, and not suggested for general use
- template <typename T = uint8_t, typename U = char, typename S = size_t>
- struct StringPrinterBufferPointer
- {
- public:
- typedef std::function<void(const T*)> Deleter;
-
- StringPrinterBufferPointer (std::nullptr_t ptr) :
- m_data(nullptr),
- m_size(0),
- m_deleter()
- {}
-
- StringPrinterBufferPointer(const T* bytes, S size, Deleter deleter = nullptr) :
- m_data(bytes),
- m_size(size),
- m_deleter(deleter)
- {}
-
- StringPrinterBufferPointer(const U* bytes, S size, Deleter deleter = nullptr) :
- m_data(reinterpret_cast<const T*>(bytes)),
- m_size(size),
- m_deleter(deleter)
- {}
-
- StringPrinterBufferPointer(StringPrinterBufferPointer&& rhs) :
- m_data(rhs.m_data),
- m_size(rhs.m_size),
- m_deleter(rhs.m_deleter)
- {
- rhs.m_data = nullptr;
- }
-
- StringPrinterBufferPointer(const StringPrinterBufferPointer& rhs) :
- m_data(rhs.m_data),
- m_size(rhs.m_size),
- m_deleter(rhs.m_deleter)
- {
- rhs.m_data = nullptr; // this is why m_data has to be mutable
- }
-
- ~StringPrinterBufferPointer()
- {
- if (m_data && m_deleter)
- m_deleter(m_data);
- m_data = nullptr;
- }
-
- const T*
- GetBytes () const
- {
- return m_data;
- }
-
- const S
- GetSize () const
- {
- return m_size;
- }
-
- StringPrinterBufferPointer&
- operator = (const StringPrinterBufferPointer& rhs)
- {
- if (m_data && m_deleter)
- m_deleter(m_data);
- m_data = rhs.m_data;
- m_size = rhs.m_size;
- m_deleter = rhs.m_deleter;
- rhs.m_data = nullptr;
- return *this;
- }
-
- private:
- mutable const T* m_data;
- size_t m_size;
- Deleter m_deleter;
- };
-
- typedef std::function<StringPrinter::StringPrinterBufferPointer<uint8_t,char,size_t>(uint8_t*, uint8_t*, uint8_t*&)> EscapingHelper;
- typedef std::function<EscapingHelper(GetPrintableElementType)> EscapingHelperGenerator;
-
- static EscapingHelper
- GetDefaultEscapingHelper (GetPrintableElementType elem_type);
-
- template <StringElementType element_type>
- static bool
- ReadStringAndDumpToStream (const ReadStringAndDumpToStreamOptions& options);
-
- template <StringElementType element_type>
- static bool
- ReadBufferAndDumpToStream (const ReadBufferAndDumpToStreamOptions& options);
- };
-
- } // namespace formatters
+ return m_language_type;
+ }
+
+ private:
+ uint64_t m_location;
+ lldb::ProcessSP m_process_sp;
+ Stream *m_stream;
+ std::string m_prefix_token;
+ std::string m_suffix_token;
+ char m_quote;
+ uint32_t m_source_size;
+ bool m_needs_zero_termination;
+ bool m_escape_non_printables;
+ bool m_ignore_max_length;
+ bool m_zero_is_terminator;
+ lldb::LanguageType m_language_type;
+ };
+
+ class ReadBufferAndDumpToStreamOptions {
+ public:
+ ReadBufferAndDumpToStreamOptions()
+ : m_data(), m_stream(nullptr), m_prefix_token(), m_suffix_token(),
+ m_quote('"'), m_source_size(0), m_escape_non_printables(true),
+ m_zero_is_terminator(true), m_is_truncated(false),
+ m_language_type(lldb::eLanguageTypeUnknown) {}
+
+ ReadBufferAndDumpToStreamOptions(ValueObject &valobj);
+
+ ReadBufferAndDumpToStreamOptions(
+ const ReadStringAndDumpToStreamOptions &options);
+
+ ReadBufferAndDumpToStreamOptions &SetData(DataExtractor d) {
+ m_data = d;
+ return *this;
+ }
+
+ lldb_private::DataExtractor GetData() const { return m_data; }
+
+ ReadBufferAndDumpToStreamOptions &SetStream(Stream *s) {
+ m_stream = s;
+ return *this;
+ }
+
+ Stream *GetStream() const { return m_stream; }
+
+ ReadBufferAndDumpToStreamOptions &SetPrefixToken(const std::string &p) {
+ m_prefix_token = p;
+ return *this;
+ }
+
+ ReadBufferAndDumpToStreamOptions &SetPrefixToken(std::nullptr_t) {
+ m_prefix_token.clear();
+ return *this;
+ }
+
+ const char *GetPrefixToken() const { return m_prefix_token.c_str(); }
+
+ ReadBufferAndDumpToStreamOptions &SetSuffixToken(const std::string &p) {
+ m_suffix_token = p;
+ return *this;
+ }
+
+ ReadBufferAndDumpToStreamOptions &SetSuffixToken(std::nullptr_t) {
+ m_suffix_token.clear();
+ return *this;
+ }
+
+ const char *GetSuffixToken() const { return m_suffix_token.c_str(); }
+
+ ReadBufferAndDumpToStreamOptions &SetQuote(char q) {
+ m_quote = q;
+ return *this;
+ }
+
+ char GetQuote() const { return m_quote; }
+
+ ReadBufferAndDumpToStreamOptions &SetSourceSize(uint32_t s) {
+ m_source_size = s;
+ return *this;
+ }
+
+ uint32_t GetSourceSize() const { return m_source_size; }
+
+ ReadBufferAndDumpToStreamOptions &SetEscapeNonPrintables(bool e) {
+ m_escape_non_printables = e;
+ return *this;
+ }
+
+ bool GetEscapeNonPrintables() const { return m_escape_non_printables; }
+
+ ReadBufferAndDumpToStreamOptions &SetBinaryZeroIsTerminator(bool e) {
+ m_zero_is_terminator = e;
+ return *this;
+ }
+
+ bool GetBinaryZeroIsTerminator() const { return m_zero_is_terminator; }
+
+ ReadBufferAndDumpToStreamOptions &SetIsTruncated(bool t) {
+ m_is_truncated = t;
+ return *this;
+ }
+
+ bool GetIsTruncated() const { return m_is_truncated; }
+
+ ReadBufferAndDumpToStreamOptions &SetLanguage(lldb::LanguageType l) {
+ m_language_type = l;
+ return *this;
+ }
+
+ lldb::LanguageType GetLanguage() const
+
+ {
+ return m_language_type;
+ }
+
+ private:
+ DataExtractor m_data;
+ Stream *m_stream;
+ std::string m_prefix_token;
+ std::string m_suffix_token;
+ char m_quote;
+ uint32_t m_source_size;
+ bool m_escape_non_printables;
+ bool m_zero_is_terminator;
+ bool m_is_truncated;
+ lldb::LanguageType m_language_type;
+ };
+
+ // I can't use a std::unique_ptr for this because the Deleter is a template
+ // argument there
+ // and I want the same type to represent both pointers I want to free and
+ // pointers I don't need
+ // to free - which is what this class essentially is
+ // It's very specialized to the needs of this file, and not suggested for
+ // general use
+ template <typename T = uint8_t, typename U = char, typename S = size_t>
+ struct StringPrinterBufferPointer {
+ public:
+ typedef std::function<void(const T *)> Deleter;
+
+ StringPrinterBufferPointer(std::nullptr_t ptr)
+ : m_data(nullptr), m_size(0), m_deleter() {}
+
+ StringPrinterBufferPointer(const T *bytes, S size,
+ Deleter deleter = nullptr)
+ : m_data(bytes), m_size(size), m_deleter(deleter) {}
+
+ StringPrinterBufferPointer(const U *bytes, S size,
+ Deleter deleter = nullptr)
+ : m_data(reinterpret_cast<const T *>(bytes)), m_size(size),
+ m_deleter(deleter) {}
+
+ StringPrinterBufferPointer(StringPrinterBufferPointer &&rhs)
+ : m_data(rhs.m_data), m_size(rhs.m_size), m_deleter(rhs.m_deleter) {
+ rhs.m_data = nullptr;
+ }
+
+ StringPrinterBufferPointer(const StringPrinterBufferPointer &rhs)
+ : m_data(rhs.m_data), m_size(rhs.m_size), m_deleter(rhs.m_deleter) {
+ rhs.m_data = nullptr; // this is why m_data has to be mutable
+ }
+
+ ~StringPrinterBufferPointer() {
+ if (m_data && m_deleter)
+ m_deleter(m_data);
+ m_data = nullptr;
+ }
+
+ const T *GetBytes() const { return m_data; }
+
+ const S GetSize() const { return m_size; }
+
+ StringPrinterBufferPointer &
+ operator=(const StringPrinterBufferPointer &rhs) {
+ if (m_data && m_deleter)
+ m_deleter(m_data);
+ m_data = rhs.m_data;
+ m_size = rhs.m_size;
+ m_deleter = rhs.m_deleter;
+ rhs.m_data = nullptr;
+ return *this;
+ }
+
+ private:
+ mutable const T *m_data;
+ size_t m_size;
+ Deleter m_deleter;
+ };
+
+ typedef std::function<StringPrinter::StringPrinterBufferPointer<
+ uint8_t, char, size_t>(uint8_t *, uint8_t *, uint8_t *&)>
+ EscapingHelper;
+ typedef std::function<EscapingHelper(GetPrintableElementType)>
+ EscapingHelperGenerator;
+
+ static EscapingHelper
+ GetDefaultEscapingHelper(GetPrintableElementType elem_type);
+
+ template <StringElementType element_type>
+ static bool
+ ReadStringAndDumpToStream(const ReadStringAndDumpToStreamOptions &options);
+
+ template <StringElementType element_type>
+ static bool
+ ReadBufferAndDumpToStream(const ReadBufferAndDumpToStreamOptions &options);
+};
+
+} // namespace formatters
} // namespace lldb_private
#endif // liblldb_StringPrinter_h_
diff --git a/include/lldb/DataFormatters/TypeCategory.h b/include/lldb/DataFormatters/TypeCategory.h
index c6d7d7b0f878..0a5b09baa624 100644
--- a/include/lldb/DataFormatters/TypeCategory.h
+++ b/include/lldb/DataFormatters/TypeCategory.h
@@ -20,561 +20,433 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-public.h"
#include "lldb/DataFormatters/FormatClasses.h"
#include "lldb/DataFormatters/FormattersContainer.h"
namespace lldb_private {
-
- template <typename FormatterImpl>
- class FormatterContainerPair
- {
- public:
- typedef FormattersContainer<ConstString, FormatterImpl> ExactMatchContainer;
- typedef FormattersContainer<lldb::RegularExpressionSP, FormatterImpl> RegexMatchContainer;
-
- typedef typename ExactMatchContainer::MapType ExactMatchMap;
- typedef typename RegexMatchContainer::MapType RegexMatchMap;
-
- typedef typename ExactMatchContainer::MapValueType MapValueType;
-
- typedef typename ExactMatchContainer::SharedPointer ExactMatchContainerSP;
- typedef typename RegexMatchContainer::SharedPointer RegexMatchContainerSP;
-
- typedef typename ExactMatchContainer::ForEachCallback ExactMatchForEachCallback;
- typedef typename RegexMatchContainer::ForEachCallback RegexMatchForEachCallback;
-
- FormatterContainerPair (const char* exact_name,
- const char* regex_name,
- IFormatChangeListener* clist) :
- m_exact_sp(new ExactMatchContainer(std::string(exact_name),clist)),
- m_regex_sp(new RegexMatchContainer(std::string(regex_name),clist))
- {
- }
-
- ~FormatterContainerPair () = default;
-
- ExactMatchContainerSP
- GetExactMatch () const
- {
- return m_exact_sp;
- }
-
- RegexMatchContainerSP
- GetRegexMatch () const
- {
- return m_regex_sp;
- }
-
- uint32_t
- GetCount ()
- {
- return GetExactMatch()->GetCount() + GetRegexMatch()->GetCount();
- }
-
- private:
- ExactMatchContainerSP m_exact_sp;
- RegexMatchContainerSP m_regex_sp;
- };
-
- class TypeCategoryImpl
- {
- private:
- typedef FormatterContainerPair<TypeFormatImpl> FormatContainer;
- typedef FormatterContainerPair<TypeSummaryImpl> SummaryContainer;
- typedef FormatterContainerPair<TypeFilterImpl> FilterContainer;
- typedef FormatterContainerPair<TypeValidatorImpl> ValidatorContainer;
-
+
+template <typename FormatterImpl> class FormatterContainerPair {
+public:
+ typedef FormattersContainer<ConstString, FormatterImpl> ExactMatchContainer;
+ typedef FormattersContainer<lldb::RegularExpressionSP, FormatterImpl>
+ RegexMatchContainer;
+
+ typedef typename ExactMatchContainer::MapType ExactMatchMap;
+ typedef typename RegexMatchContainer::MapType RegexMatchMap;
+
+ typedef typename ExactMatchContainer::MapValueType MapValueType;
+
+ typedef typename ExactMatchContainer::SharedPointer ExactMatchContainerSP;
+ typedef typename RegexMatchContainer::SharedPointer RegexMatchContainerSP;
+
+ typedef
+ typename ExactMatchContainer::ForEachCallback ExactMatchForEachCallback;
+ typedef
+ typename RegexMatchContainer::ForEachCallback RegexMatchForEachCallback;
+
+ FormatterContainerPair(const char *exact_name, const char *regex_name,
+ IFormatChangeListener *clist)
+ : m_exact_sp(new ExactMatchContainer(std::string(exact_name), clist)),
+ m_regex_sp(new RegexMatchContainer(std::string(regex_name), clist)) {}
+
+ ~FormatterContainerPair() = default;
+
+ ExactMatchContainerSP GetExactMatch() const { return m_exact_sp; }
+
+ RegexMatchContainerSP GetRegexMatch() const { return m_regex_sp; }
+
+ uint32_t GetCount() {
+ return GetExactMatch()->GetCount() + GetRegexMatch()->GetCount();
+ }
+
+private:
+ ExactMatchContainerSP m_exact_sp;
+ RegexMatchContainerSP m_regex_sp;
+};
+
+class TypeCategoryImpl {
+private:
+ typedef FormatterContainerPair<TypeFormatImpl> FormatContainer;
+ typedef FormatterContainerPair<TypeSummaryImpl> SummaryContainer;
+ typedef FormatterContainerPair<TypeFilterImpl> FilterContainer;
+ typedef FormatterContainerPair<TypeValidatorImpl> ValidatorContainer;
+
#ifndef LLDB_DISABLE_PYTHON
- typedef FormatterContainerPair<SyntheticChildren> SynthContainer;
+ typedef FormatterContainerPair<SyntheticChildren> SynthContainer;
#endif // LLDB_DISABLE_PYTHON
- public:
- typedef uint16_t FormatCategoryItems;
- static const uint16_t ALL_ITEM_TYPES = UINT16_MAX;
+public:
+ typedef uint16_t FormatCategoryItems;
+ static const uint16_t ALL_ITEM_TYPES = UINT16_MAX;
+
+ typedef FormatContainer::ExactMatchContainerSP FormatContainerSP;
+ typedef FormatContainer::RegexMatchContainerSP RegexFormatContainerSP;
- typedef FormatContainer::ExactMatchContainerSP FormatContainerSP;
- typedef FormatContainer::RegexMatchContainerSP RegexFormatContainerSP;
-
- typedef SummaryContainer::ExactMatchContainerSP SummaryContainerSP;
- typedef SummaryContainer::RegexMatchContainerSP RegexSummaryContainerSP;
+ typedef SummaryContainer::ExactMatchContainerSP SummaryContainerSP;
+ typedef SummaryContainer::RegexMatchContainerSP RegexSummaryContainerSP;
- typedef FilterContainer::ExactMatchContainerSP FilterContainerSP;
- typedef FilterContainer::RegexMatchContainerSP RegexFilterContainerSP;
+ typedef FilterContainer::ExactMatchContainerSP FilterContainerSP;
+ typedef FilterContainer::RegexMatchContainerSP RegexFilterContainerSP;
#ifndef LLDB_DISABLE_PYTHON
- typedef SynthContainer::ExactMatchContainerSP SynthContainerSP;
- typedef SynthContainer::RegexMatchContainerSP RegexSynthContainerSP;
+ typedef SynthContainer::ExactMatchContainerSP SynthContainerSP;
+ typedef SynthContainer::RegexMatchContainerSP RegexSynthContainerSP;
#endif // LLDB_DISABLE_PYTHON
-
- typedef ValidatorContainer::ExactMatchContainerSP ValidatorContainerSP;
- typedef ValidatorContainer::RegexMatchContainerSP RegexValidatorContainerSP;
-
- template <typename T>
- class ForEachCallbacks
- {
- public:
- ForEachCallbacks () = default;
- ~ForEachCallbacks () = default;
-
- template<typename U = TypeFormatImpl>
- typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
- SetExact (FormatContainer::ExactMatchForEachCallback callback)
- {
- m_format_exact = callback;
- return *this;
- }
- template<typename U = TypeFormatImpl>
- typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
- SetWithRegex (FormatContainer::RegexMatchForEachCallback callback)
- {
- m_format_regex = callback;
- return *this;
- }
-
- template<typename U = TypeSummaryImpl>
- typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
- SetExact (SummaryContainer::ExactMatchForEachCallback callback)
- {
- m_summary_exact = callback;
- return *this;
- }
- template<typename U = TypeSummaryImpl>
- typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
- SetWithRegex (SummaryContainer::RegexMatchForEachCallback callback)
- {
- m_summary_regex = callback;
- return *this;
- }
-
- template<typename U = TypeFilterImpl>
- typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
- SetExact (FilterContainer::ExactMatchForEachCallback callback)
- {
- m_filter_exact = callback;
- return *this;
- }
- template<typename U = TypeFilterImpl>
- typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
- SetWithRegex (FilterContainer::RegexMatchForEachCallback callback)
- {
- m_filter_regex = callback;
- return *this;
- }
+
+ typedef ValidatorContainer::ExactMatchContainerSP ValidatorContainerSP;
+ typedef ValidatorContainer::RegexMatchContainerSP RegexValidatorContainerSP;
+
+ template <typename T> class ForEachCallbacks {
+ public:
+ ForEachCallbacks() = default;
+ ~ForEachCallbacks() = default;
+
+ template <typename U = TypeFormatImpl>
+ typename std::enable_if<std::is_same<U, T>::value, ForEachCallbacks &>::type
+ SetExact(FormatContainer::ExactMatchForEachCallback callback) {
+ m_format_exact = callback;
+ return *this;
+ }
+ template <typename U = TypeFormatImpl>
+ typename std::enable_if<std::is_same<U, T>::value, ForEachCallbacks &>::type
+ SetWithRegex(FormatContainer::RegexMatchForEachCallback callback) {
+ m_format_regex = callback;
+ return *this;
+ }
+
+ template <typename U = TypeSummaryImpl>
+ typename std::enable_if<std::is_same<U, T>::value, ForEachCallbacks &>::type
+ SetExact(SummaryContainer::ExactMatchForEachCallback callback) {
+ m_summary_exact = callback;
+ return *this;
+ }
+ template <typename U = TypeSummaryImpl>
+ typename std::enable_if<std::is_same<U, T>::value, ForEachCallbacks &>::type
+ SetWithRegex(SummaryContainer::RegexMatchForEachCallback callback) {
+ m_summary_regex = callback;
+ return *this;
+ }
+
+ template <typename U = TypeFilterImpl>
+ typename std::enable_if<std::is_same<U, T>::value, ForEachCallbacks &>::type
+ SetExact(FilterContainer::ExactMatchForEachCallback callback) {
+ m_filter_exact = callback;
+ return *this;
+ }
+ template <typename U = TypeFilterImpl>
+ typename std::enable_if<std::is_same<U, T>::value, ForEachCallbacks &>::type
+ SetWithRegex(FilterContainer::RegexMatchForEachCallback callback) {
+ m_filter_regex = callback;
+ return *this;
+ }
#ifndef LLDB_DISABLE_PYTHON
- template<typename U = SyntheticChildren>
- typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
- SetExact (SynthContainer::ExactMatchForEachCallback callback)
- {
- m_synth_exact = callback;
- return *this;
- }
- template<typename U = SyntheticChildren>
- typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
- SetWithRegex (SynthContainer::RegexMatchForEachCallback callback)
- {
- m_synth_regex = callback;
- return *this;
- }
+ template <typename U = SyntheticChildren>
+ typename std::enable_if<std::is_same<U, T>::value, ForEachCallbacks &>::type
+ SetExact(SynthContainer::ExactMatchForEachCallback callback) {
+ m_synth_exact = callback;
+ return *this;
+ }
+ template <typename U = SyntheticChildren>
+ typename std::enable_if<std::is_same<U, T>::value, ForEachCallbacks &>::type
+ SetWithRegex(SynthContainer::RegexMatchForEachCallback callback) {
+ m_synth_regex = callback;
+ return *this;
+ }
#endif // LLDB_DISABLE_PYTHON
- template<typename U = TypeValidatorImpl>
- typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
- SetExact (ValidatorContainer::ExactMatchForEachCallback callback)
- {
- m_validator_exact = callback;
- return *this;
- }
- template<typename U = TypeValidatorImpl>
- typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
- SetWithRegex (ValidatorContainer::RegexMatchForEachCallback callback)
- {
- m_validator_regex = callback;
- return *this;
- }
-
- FormatContainer::ExactMatchForEachCallback
- GetFormatExactCallback () const
- {
- return m_format_exact;
- }
- FormatContainer::RegexMatchForEachCallback
- GetFormatRegexCallback () const
- {
- return m_format_regex;
- }
-
- SummaryContainer::ExactMatchForEachCallback
- GetSummaryExactCallback () const
- {
- return m_summary_exact;
- }
- SummaryContainer::RegexMatchForEachCallback
- GetSummaryRegexCallback () const
- {
- return m_summary_regex;
- }
-
- FilterContainer::ExactMatchForEachCallback
- GetFilterExactCallback () const
- {
- return m_filter_exact;
- }
- FilterContainer::RegexMatchForEachCallback
- GetFilterRegexCallback () const
- {
- return m_filter_regex;
- }
+ template <typename U = TypeValidatorImpl>
+ typename std::enable_if<std::is_same<U, T>::value, ForEachCallbacks &>::type
+ SetExact(ValidatorContainer::ExactMatchForEachCallback callback) {
+ m_validator_exact = callback;
+ return *this;
+ }
+ template <typename U = TypeValidatorImpl>
+ typename std::enable_if<std::is_same<U, T>::value, ForEachCallbacks &>::type
+ SetWithRegex(ValidatorContainer::RegexMatchForEachCallback callback) {
+ m_validator_regex = callback;
+ return *this;
+ }
+
+ FormatContainer::ExactMatchForEachCallback GetFormatExactCallback() const {
+ return m_format_exact;
+ }
+ FormatContainer::RegexMatchForEachCallback GetFormatRegexCallback() const {
+ return m_format_regex;
+ }
+
+ SummaryContainer::ExactMatchForEachCallback
+ GetSummaryExactCallback() const {
+ return m_summary_exact;
+ }
+ SummaryContainer::RegexMatchForEachCallback
+ GetSummaryRegexCallback() const {
+ return m_summary_regex;
+ }
+
+ FilterContainer::ExactMatchForEachCallback GetFilterExactCallback() const {
+ return m_filter_exact;
+ }
+ FilterContainer::RegexMatchForEachCallback GetFilterRegexCallback() const {
+ return m_filter_regex;
+ }
#ifndef LLDB_DISABLE_PYTHON
- SynthContainer::ExactMatchForEachCallback
- GetSynthExactCallback () const
- {
- return m_synth_exact;
- }
- SynthContainer::RegexMatchForEachCallback
- GetSynthRegexCallback () const
- {
- return m_synth_regex;
- }
+ SynthContainer::ExactMatchForEachCallback GetSynthExactCallback() const {
+ return m_synth_exact;
+ }
+ SynthContainer::RegexMatchForEachCallback GetSynthRegexCallback() const {
+ return m_synth_regex;
+ }
#endif // LLDB_DISABLE_PYTHON
- ValidatorContainer::ExactMatchForEachCallback
- GetValidatorExactCallback () const
- {
- return m_validator_exact;
- }
- ValidatorContainer::RegexMatchForEachCallback
- GetValidatorRegexCallback () const
- {
- return m_validator_regex;
- }
-
- private:
- FormatContainer::ExactMatchForEachCallback m_format_exact;
- FormatContainer::RegexMatchForEachCallback m_format_regex;
-
- SummaryContainer::ExactMatchForEachCallback m_summary_exact;
- SummaryContainer::RegexMatchForEachCallback m_summary_regex;
-
- FilterContainer::ExactMatchForEachCallback m_filter_exact;
- FilterContainer::RegexMatchForEachCallback m_filter_regex;
+ ValidatorContainer::ExactMatchForEachCallback
+ GetValidatorExactCallback() const {
+ return m_validator_exact;
+ }
+ ValidatorContainer::RegexMatchForEachCallback
+ GetValidatorRegexCallback() const {
+ return m_validator_regex;
+ }
+
+ private:
+ FormatContainer::ExactMatchForEachCallback m_format_exact;
+ FormatContainer::RegexMatchForEachCallback m_format_regex;
+
+ SummaryContainer::ExactMatchForEachCallback m_summary_exact;
+ SummaryContainer::RegexMatchForEachCallback m_summary_regex;
+
+ FilterContainer::ExactMatchForEachCallback m_filter_exact;
+ FilterContainer::RegexMatchForEachCallback m_filter_regex;
#ifndef LLDB_DISABLE_PYTHON
- SynthContainer::ExactMatchForEachCallback m_synth_exact;
- SynthContainer::RegexMatchForEachCallback m_synth_regex;
+ SynthContainer::ExactMatchForEachCallback m_synth_exact;
+ SynthContainer::RegexMatchForEachCallback m_synth_regex;
#endif // LLDB_DISABLE_PYTHON
- ValidatorContainer::ExactMatchForEachCallback m_validator_exact;
- ValidatorContainer::RegexMatchForEachCallback m_validator_regex;
- };
-
- TypeCategoryImpl (IFormatChangeListener* clist,
- ConstString name,
- std::initializer_list<lldb::LanguageType> langs = {});
-
- template <typename T>
- void
- ForEach (const ForEachCallbacks<T> &foreach)
- {
- GetTypeFormatsContainer()->ForEach(foreach.GetFormatExactCallback());
- GetRegexTypeFormatsContainer()->ForEach(foreach.GetFormatRegexCallback());
-
- GetTypeSummariesContainer()->ForEach(foreach.GetSummaryExactCallback());
- GetRegexTypeSummariesContainer()->ForEach(foreach.GetSummaryRegexCallback());
-
- GetTypeFiltersContainer()->ForEach(foreach.GetFilterExactCallback());
- GetRegexTypeFiltersContainer()->ForEach(foreach.GetFilterRegexCallback());
-
+ ValidatorContainer::ExactMatchForEachCallback m_validator_exact;
+ ValidatorContainer::RegexMatchForEachCallback m_validator_regex;
+ };
+
+ TypeCategoryImpl(IFormatChangeListener *clist, ConstString name,
+ std::initializer_list<lldb::LanguageType> langs = {});
+
+ template <typename T> void ForEach(const ForEachCallbacks<T> &foreach) {
+ GetTypeFormatsContainer()->ForEach(foreach.GetFormatExactCallback());
+ GetRegexTypeFormatsContainer()->ForEach(foreach.GetFormatRegexCallback());
+
+ GetTypeSummariesContainer()->ForEach(foreach.GetSummaryExactCallback());
+ GetRegexTypeSummariesContainer()->ForEach(
+ foreach.GetSummaryRegexCallback());
+
+ GetTypeFiltersContainer()->ForEach(foreach.GetFilterExactCallback());
+ GetRegexTypeFiltersContainer()->ForEach(foreach.GetFilterRegexCallback());
+
#ifndef LLDB_DISABLE_PYTHON
- GetTypeSyntheticsContainer()->ForEach(foreach.GetSynthExactCallback());
- GetRegexTypeSyntheticsContainer()->ForEach(foreach.GetSynthRegexCallback());
+ GetTypeSyntheticsContainer()->ForEach(foreach.GetSynthExactCallback());
+ GetRegexTypeSyntheticsContainer()->ForEach(foreach.GetSynthRegexCallback());
#endif // LLDB_DISABLE_PYTHON
-
- GetTypeValidatorsContainer()->ForEach(foreach.GetValidatorExactCallback());
- GetRegexTypeValidatorsContainer()->ForEach(foreach.GetValidatorRegexCallback());
- }
-
- FormatContainerSP
- GetTypeFormatsContainer ()
- {
- return m_format_cont.GetExactMatch();
- }
-
- RegexFormatContainerSP
- GetRegexTypeFormatsContainer ()
- {
- return m_format_cont.GetRegexMatch();
- }
-
- FormatContainer&
- GetFormatContainer ()
- {
- return m_format_cont;
- }
-
- SummaryContainerSP
- GetTypeSummariesContainer ()
- {
- return m_summary_cont.GetExactMatch();
- }
-
- RegexSummaryContainerSP
- GetRegexTypeSummariesContainer ()
- {
- return m_summary_cont.GetRegexMatch();
- }
-
- SummaryContainer&
- GetSummaryContainer ()
- {
- return m_summary_cont;
- }
-
- FilterContainerSP
- GetTypeFiltersContainer ()
- {
- return m_filter_cont.GetExactMatch();
- }
-
- RegexFilterContainerSP
- GetRegexTypeFiltersContainer ()
- {
- return m_filter_cont.GetRegexMatch();
- }
-
- FilterContainer&
- GetFilterContainer ()
- {
- return m_filter_cont;
- }
-
- FormatContainer::MapValueType
- GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp);
-
- SummaryContainer::MapValueType
- GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp);
-
- FilterContainer::MapValueType
- GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp);
-
+
+ GetTypeValidatorsContainer()->ForEach(foreach.GetValidatorExactCallback());
+ GetRegexTypeValidatorsContainer()->ForEach(
+ foreach.GetValidatorRegexCallback());
+ }
+
+ FormatContainerSP GetTypeFormatsContainer() {
+ return m_format_cont.GetExactMatch();
+ }
+
+ RegexFormatContainerSP GetRegexTypeFormatsContainer() {
+ return m_format_cont.GetRegexMatch();
+ }
+
+ FormatContainer &GetFormatContainer() { return m_format_cont; }
+
+ SummaryContainerSP GetTypeSummariesContainer() {
+ return m_summary_cont.GetExactMatch();
+ }
+
+ RegexSummaryContainerSP GetRegexTypeSummariesContainer() {
+ return m_summary_cont.GetRegexMatch();
+ }
+
+ SummaryContainer &GetSummaryContainer() { return m_summary_cont; }
+
+ FilterContainerSP GetTypeFiltersContainer() {
+ return m_filter_cont.GetExactMatch();
+ }
+
+ RegexFilterContainerSP GetRegexTypeFiltersContainer() {
+ return m_filter_cont.GetRegexMatch();
+ }
+
+ FilterContainer &GetFilterContainer() { return m_filter_cont; }
+
+ FormatContainer::MapValueType
+ GetFormatForType(lldb::TypeNameSpecifierImplSP type_sp);
+
+ SummaryContainer::MapValueType
+ GetSummaryForType(lldb::TypeNameSpecifierImplSP type_sp);
+
+ FilterContainer::MapValueType
+ GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp);
+
#ifndef LLDB_DISABLE_PYTHON
- SynthContainer::MapValueType
- GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp);
+ SynthContainer::MapValueType
+ GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp);
#endif
-
- ValidatorContainer::MapValueType
- GetValidatorForType (lldb::TypeNameSpecifierImplSP type_sp);
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierForFormatAtIndex (size_t index);
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierForSummaryAtIndex (size_t index);
-
- FormatContainer::MapValueType
- GetFormatAtIndex (size_t index);
-
- SummaryContainer::MapValueType
- GetSummaryAtIndex (size_t index);
-
- FilterContainer::MapValueType
- GetFilterAtIndex (size_t index);
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierForFilterAtIndex (size_t index);
-
+
+ ValidatorContainer::MapValueType
+ GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp);
+
+ lldb::TypeNameSpecifierImplSP
+ GetTypeNameSpecifierForFormatAtIndex(size_t index);
+
+ lldb::TypeNameSpecifierImplSP
+ GetTypeNameSpecifierForSummaryAtIndex(size_t index);
+
+ FormatContainer::MapValueType GetFormatAtIndex(size_t index);
+
+ SummaryContainer::MapValueType GetSummaryAtIndex(size_t index);
+
+ FilterContainer::MapValueType GetFilterAtIndex(size_t index);
+
+ lldb::TypeNameSpecifierImplSP
+ GetTypeNameSpecifierForFilterAtIndex(size_t index);
+
#ifndef LLDB_DISABLE_PYTHON
- SynthContainerSP
- GetTypeSyntheticsContainer ()
- {
- return m_synth_cont.GetExactMatch();
- }
-
- RegexSynthContainerSP
- GetRegexTypeSyntheticsContainer ()
- {
- return m_synth_cont.GetRegexMatch();
- }
-
- SynthContainer&
- GetSyntheticsContainer ()
- {
- return m_synth_cont;
- }
-
- SynthContainer::MapValueType
- GetSyntheticAtIndex (size_t index);
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierForSyntheticAtIndex (size_t index);
+ SynthContainerSP GetTypeSyntheticsContainer() {
+ return m_synth_cont.GetExactMatch();
+ }
+
+ RegexSynthContainerSP GetRegexTypeSyntheticsContainer() {
+ return m_synth_cont.GetRegexMatch();
+ }
+
+ SynthContainer &GetSyntheticsContainer() { return m_synth_cont; }
+
+ SynthContainer::MapValueType GetSyntheticAtIndex(size_t index);
+
+ lldb::TypeNameSpecifierImplSP
+ GetTypeNameSpecifierForSyntheticAtIndex(size_t index);
#endif // LLDB_DISABLE_PYTHON
-
- ValidatorContainerSP
- GetTypeValidatorsContainer ()
- {
- return m_validator_cont.GetExactMatch();
- }
-
- RegexValidatorContainerSP
- GetRegexTypeValidatorsContainer ()
- {
- return m_validator_cont.GetRegexMatch();
- }
-
- ValidatorContainer::MapValueType
- GetValidatorAtIndex (size_t index);
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierForValidatorAtIndex (size_t index);
-
- bool
- IsEnabled () const
- {
- return m_enabled;
- }
-
- uint32_t
- GetEnabledPosition()
- {
- if (m_enabled == false)
- return UINT32_MAX;
- else
- return m_enabled_position;
- }
-
- bool
- Get(ValueObject& valobj,
- const FormattersMatchVector& candidates,
- lldb::TypeFormatImplSP& entry,
- uint32_t* reason = nullptr);
-
- bool
- Get(ValueObject& valobj,
- const FormattersMatchVector& candidates,
- lldb::TypeSummaryImplSP& entry,
- uint32_t* reason = nullptr);
-
- bool
- Get(ValueObject& valobj,
- const FormattersMatchVector& candidates,
- lldb::SyntheticChildrenSP& entry,
- uint32_t* reason = nullptr);
-
- bool
- Get(ValueObject& valobj,
- const FormattersMatchVector& candidates,
- lldb::TypeValidatorImplSP& entry,
- uint32_t* reason = nullptr);
-
- void
- Clear (FormatCategoryItems items = ALL_ITEM_TYPES);
-
- bool
- Delete (ConstString name,
- FormatCategoryItems items = ALL_ITEM_TYPES);
-
- uint32_t
- GetCount (FormatCategoryItems items = ALL_ITEM_TYPES);
-
- const char*
- GetName ()
- {
- return m_name.GetCString();
- }
-
- size_t
- GetNumLanguages ();
-
- lldb::LanguageType
- GetLanguageAtIndex (size_t idx);
-
- void
- AddLanguage (lldb::LanguageType lang);
-
- bool
- HasLanguage (lldb::LanguageType lang);
-
- std::string
- GetDescription ();
-
- bool
- AnyMatches(ConstString type_name,
- FormatCategoryItems items = ALL_ITEM_TYPES,
- bool only_enabled = true,
- const char** matching_category = nullptr,
- FormatCategoryItems* matching_type = nullptr);
-
- typedef std::shared_ptr<TypeCategoryImpl> SharedPointer;
-
- private:
- FormatContainer m_format_cont;
- SummaryContainer m_summary_cont;
- FilterContainer m_filter_cont;
+
+ ValidatorContainerSP GetTypeValidatorsContainer() {
+ return m_validator_cont.GetExactMatch();
+ }
+
+ RegexValidatorContainerSP GetRegexTypeValidatorsContainer() {
+ return m_validator_cont.GetRegexMatch();
+ }
+
+ ValidatorContainer::MapValueType GetValidatorAtIndex(size_t index);
+
+ lldb::TypeNameSpecifierImplSP
+ GetTypeNameSpecifierForValidatorAtIndex(size_t index);
+
+ bool IsEnabled() const { return m_enabled; }
+
+ uint32_t GetEnabledPosition() {
+ if (m_enabled == false)
+ return UINT32_MAX;
+ else
+ return m_enabled_position;
+ }
+
+ bool Get(ValueObject &valobj, const FormattersMatchVector &candidates,
+ lldb::TypeFormatImplSP &entry, uint32_t *reason = nullptr);
+
+ bool Get(ValueObject &valobj, const FormattersMatchVector &candidates,
+ lldb::TypeSummaryImplSP &entry, uint32_t *reason = nullptr);
+
+ bool Get(ValueObject &valobj, const FormattersMatchVector &candidates,
+ lldb::SyntheticChildrenSP &entry, uint32_t *reason = nullptr);
+
+ bool Get(ValueObject &valobj, const FormattersMatchVector &candidates,
+ lldb::TypeValidatorImplSP &entry, uint32_t *reason = nullptr);
+
+ void Clear(FormatCategoryItems items = ALL_ITEM_TYPES);
+
+ bool Delete(ConstString name, FormatCategoryItems items = ALL_ITEM_TYPES);
+
+ uint32_t GetCount(FormatCategoryItems items = ALL_ITEM_TYPES);
+
+ const char *GetName() { return m_name.GetCString(); }
+
+ size_t GetNumLanguages();
+
+ lldb::LanguageType GetLanguageAtIndex(size_t idx);
+
+ void AddLanguage(lldb::LanguageType lang);
+
+ bool HasLanguage(lldb::LanguageType lang);
+
+ std::string GetDescription();
+
+ bool AnyMatches(ConstString type_name,
+ FormatCategoryItems items = ALL_ITEM_TYPES,
+ bool only_enabled = true,
+ const char **matching_category = nullptr,
+ FormatCategoryItems *matching_type = nullptr);
+
+ typedef std::shared_ptr<TypeCategoryImpl> SharedPointer;
+
+private:
+ FormatContainer m_format_cont;
+ SummaryContainer m_summary_cont;
+ FilterContainer m_filter_cont;
#ifndef LLDB_DISABLE_PYTHON
- SynthContainer m_synth_cont;
+ SynthContainer m_synth_cont;
#endif // LLDB_DISABLE_PYTHON
- ValidatorContainer m_validator_cont;
-
- bool m_enabled;
-
- IFormatChangeListener* m_change_listener;
-
- std::recursive_mutex m_mutex;
-
- ConstString m_name;
-
- std::vector<lldb::LanguageType> m_languages;
-
- uint32_t m_enabled_position;
-
- void
- Enable (bool value, uint32_t position);
-
- void
- Disable ()
- {
- Enable(false, UINT32_MAX);
- }
-
- bool
- IsApplicable (ValueObject& valobj);
-
- uint32_t
- GetLastEnabledPosition ()
- {
- return m_enabled_position;
- }
-
- void
- SetEnabledPosition (uint32_t p)
- {
- m_enabled_position = p;
- }
-
- friend class FormatManager;
- friend class LanguageCategory;
- friend class TypeCategoryMap;
-
- friend class FormattersContainer<ConstString, TypeFormatImpl>;
- friend class FormattersContainer<lldb::RegularExpressionSP, TypeFormatImpl>;
-
- friend class FormattersContainer<ConstString, TypeSummaryImpl>;
- friend class FormattersContainer<lldb::RegularExpressionSP, TypeSummaryImpl>;
-
- friend class FormattersContainer<ConstString, TypeFilterImpl>;
- friend class FormattersContainer<lldb::RegularExpressionSP, TypeFilterImpl>;
-
+ ValidatorContainer m_validator_cont;
+
+ bool m_enabled;
+
+ IFormatChangeListener *m_change_listener;
+
+ std::recursive_mutex m_mutex;
+
+ ConstString m_name;
+
+ std::vector<lldb::LanguageType> m_languages;
+
+ uint32_t m_enabled_position;
+
+ void Enable(bool value, uint32_t position);
+
+ void Disable() { Enable(false, UINT32_MAX); }
+
+ bool IsApplicable(ValueObject &valobj);
+
+ uint32_t GetLastEnabledPosition() { return m_enabled_position; }
+
+ void SetEnabledPosition(uint32_t p) { m_enabled_position = p; }
+
+ friend class FormatManager;
+ friend class LanguageCategory;
+ friend class TypeCategoryMap;
+
+ friend class FormattersContainer<ConstString, TypeFormatImpl>;
+ friend class FormattersContainer<lldb::RegularExpressionSP, TypeFormatImpl>;
+
+ friend class FormattersContainer<ConstString, TypeSummaryImpl>;
+ friend class FormattersContainer<lldb::RegularExpressionSP, TypeSummaryImpl>;
+
+ friend class FormattersContainer<ConstString, TypeFilterImpl>;
+ friend class FormattersContainer<lldb::RegularExpressionSP, TypeFilterImpl>;
+
#ifndef LLDB_DISABLE_PYTHON
- friend class FormattersContainer<ConstString, ScriptedSyntheticChildren>;
- friend class FormattersContainer<lldb::RegularExpressionSP, ScriptedSyntheticChildren>;
+ friend class FormattersContainer<ConstString, ScriptedSyntheticChildren>;
+ friend class FormattersContainer<lldb::RegularExpressionSP,
+ ScriptedSyntheticChildren>;
#endif // LLDB_DISABLE_PYTHON
-
- friend class FormattersContainer<ConstString, TypeValidatorImpl>;
- friend class FormattersContainer<lldb::RegularExpressionSP, TypeValidatorImpl>;
- };
-
+
+ friend class FormattersContainer<ConstString, TypeValidatorImpl>;
+ friend class FormattersContainer<lldb::RegularExpressionSP,
+ TypeValidatorImpl>;
+};
+
} // namespace lldb_private
#endif // lldb_TypeCategory_h_
diff --git a/include/lldb/DataFormatters/TypeCategoryMap.h b/include/lldb/DataFormatters/TypeCategoryMap.h
index 2cc589809a7c..f767c985ff34 100644
--- a/include/lldb/DataFormatters/TypeCategoryMap.h
+++ b/include/lldb/DataFormatters/TypeCategoryMap.h
@@ -19,145 +19,107 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-public.h"
#include "lldb/DataFormatters/FormattersContainer.h"
#include "lldb/DataFormatters/TypeCategory.h"
namespace lldb_private {
- class TypeCategoryMap
- {
- private:
- typedef ConstString KeyType;
- typedef TypeCategoryImpl ValueType;
- typedef ValueType::SharedPointer ValueSP;
- typedef std::list<lldb::TypeCategoryImplSP> ActiveCategoriesList;
- typedef ActiveCategoriesList::iterator ActiveCategoriesIterator;
-
- public:
- typedef std::map<KeyType, ValueSP> MapType;
- typedef MapType::iterator MapIterator;
- typedef std::function<bool(const ValueSP&)> ForEachCallback;
-
- typedef uint32_t Position;
-
- static const Position First = 0;
- static const Position Default = 1;
- static const Position Last = UINT32_MAX;
-
- TypeCategoryMap (IFormatChangeListener* lst);
-
- void
- Add (KeyType name,
- const ValueSP& entry);
-
- bool
- Delete (KeyType name);
-
- bool
- Enable (KeyType category_name,
- Position pos = Default);
-
- bool
- Disable (KeyType category_name);
-
- bool
- Enable (ValueSP category,
- Position pos = Default);
-
- bool
- Disable (ValueSP category);
-
- void
- EnableAllCategories ();
-
- void
- DisableAllCategories ();
-
- void
- Clear ();
-
- bool
- Get (KeyType name,
- ValueSP& entry);
-
- bool
- Get (uint32_t pos,
- ValueSP& entry);
-
- void
- ForEach (ForEachCallback callback);
-
- lldb::TypeCategoryImplSP
- GetAtIndex (uint32_t);
-
- bool
- AnyMatches(ConstString type_name,
- TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES,
- bool only_enabled = true,
- const char** matching_category = nullptr,
- TypeCategoryImpl::FormatCategoryItems* matching_type = nullptr);
-
- uint32_t
- GetCount ()
- {
- return m_map.size();
- }
-
- lldb::TypeFormatImplSP
- GetFormat (FormattersMatchData& match_data);
-
- lldb::TypeSummaryImplSP
- GetSummaryFormat (FormattersMatchData& match_data);
-
+class TypeCategoryMap {
+private:
+ typedef ConstString KeyType;
+ typedef TypeCategoryImpl ValueType;
+ typedef ValueType::SharedPointer ValueSP;
+ typedef std::list<lldb::TypeCategoryImplSP> ActiveCategoriesList;
+ typedef ActiveCategoriesList::iterator ActiveCategoriesIterator;
+
+public:
+ typedef std::map<KeyType, ValueSP> MapType;
+ typedef MapType::iterator MapIterator;
+ typedef std::function<bool(const ValueSP &)> ForEachCallback;
+
+ typedef uint32_t Position;
+
+ static const Position First = 0;
+ static const Position Default = 1;
+ static const Position Last = UINT32_MAX;
+
+ TypeCategoryMap(IFormatChangeListener *lst);
+
+ void Add(KeyType name, const ValueSP &entry);
+
+ bool Delete(KeyType name);
+
+ bool Enable(KeyType category_name, Position pos = Default);
+
+ bool Disable(KeyType category_name);
+
+ bool Enable(ValueSP category, Position pos = Default);
+
+ bool Disable(ValueSP category);
+
+ void EnableAllCategories();
+
+ void DisableAllCategories();
+
+ void Clear();
+
+ bool Get(KeyType name, ValueSP &entry);
+
+ bool Get(uint32_t pos, ValueSP &entry);
+
+ void ForEach(ForEachCallback callback);
+
+ lldb::TypeCategoryImplSP GetAtIndex(uint32_t);
+
+ bool
+ AnyMatches(ConstString type_name,
+ TypeCategoryImpl::FormatCategoryItems items =
+ TypeCategoryImpl::ALL_ITEM_TYPES,
+ bool only_enabled = true, const char **matching_category = nullptr,
+ TypeCategoryImpl::FormatCategoryItems *matching_type = nullptr);
+
+ uint32_t GetCount() { return m_map.size(); }
+
+ lldb::TypeFormatImplSP GetFormat(FormattersMatchData &match_data);
+
+ lldb::TypeSummaryImplSP GetSummaryFormat(FormattersMatchData &match_data);
+
#ifndef LLDB_DISABLE_PYTHON
- lldb::SyntheticChildrenSP
- GetSyntheticChildren (FormattersMatchData& match_data);
+ lldb::SyntheticChildrenSP
+ GetSyntheticChildren(FormattersMatchData &match_data);
#endif
-
- lldb::TypeValidatorImplSP
- GetValidator(FormattersMatchData& match_data);
-
- private:
- class delete_matching_categories
- {
- lldb::TypeCategoryImplSP ptr;
- public:
- delete_matching_categories(lldb::TypeCategoryImplSP p) : ptr(p)
- {}
-
- bool operator()(const lldb::TypeCategoryImplSP& other)
- {
- return ptr.get() == other.get();
- }
- };
-
- std::recursive_mutex m_map_mutex;
- IFormatChangeListener* listener;
-
- MapType m_map;
- ActiveCategoriesList m_active_categories;
-
- MapType& map ()
- {
- return m_map;
- }
-
- ActiveCategoriesList& active_list ()
- {
- return m_active_categories;
- }
-
- std::recursive_mutex &
- mutex()
- {
- return m_map_mutex;
- }
-
- friend class FormattersContainer<KeyType, ValueType>;
- friend class FormatManager;
- };
+
+ lldb::TypeValidatorImplSP GetValidator(FormattersMatchData &match_data);
+
+private:
+ class delete_matching_categories {
+ lldb::TypeCategoryImplSP ptr;
+
+ public:
+ delete_matching_categories(lldb::TypeCategoryImplSP p) : ptr(p) {}
+
+ bool operator()(const lldb::TypeCategoryImplSP &other) {
+ return ptr.get() == other.get();
+ }
+ };
+
+ std::recursive_mutex m_map_mutex;
+ IFormatChangeListener *listener;
+
+ MapType m_map;
+ ActiveCategoriesList m_active_categories;
+
+ MapType &map() { return m_map; }
+
+ ActiveCategoriesList &active_list() { return m_active_categories; }
+
+ std::recursive_mutex &mutex() { return m_map_mutex; }
+
+ friend class FormattersContainer<KeyType, ValueType>;
+ friend class FormatManager;
+};
} // namespace lldb_private
#endif // lldb_TypeCategoryMap_h_
diff --git a/include/lldb/DataFormatters/TypeFormat.h b/include/lldb/DataFormatters/TypeFormat.h
index 4ed28b692061..8cfe021da3e0 100644
--- a/include/lldb/DataFormatters/TypeFormat.h
+++ b/include/lldb/DataFormatters/TypeFormat.h
@@ -1,4 +1,5 @@
-//===-- TypeFormat.h ----------------------------------------------*- C++ -*-===//
+//===-- TypeFormat.h ----------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -20,321 +21,203 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-public.h"
#include "lldb/Core/ValueObject.h"
namespace lldb_private {
- class TypeFormatImpl
- {
- public:
- class Flags
- {
- public:
-
- Flags () :
- m_flags (lldb::eTypeOptionCascade)
- {}
-
- Flags (const Flags& other) :
- m_flags (other.m_flags)
- {}
-
- Flags (uint32_t value) :
- m_flags (value)
- {}
-
- Flags&
- operator = (const Flags& rhs)
- {
- if (&rhs != this)
- m_flags = rhs.m_flags;
-
- return *this;
- }
-
- Flags&
- operator = (const uint32_t& rhs)
- {
- m_flags = rhs;
- return *this;
- }
-
- Flags&
- Clear()
- {
- m_flags = 0;
- return *this;
- }
-
- bool
- GetCascades () const
- {
- return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade;
- }
-
- Flags&
- SetCascades (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionCascade;
- else
- m_flags &= ~lldb::eTypeOptionCascade;
- return *this;
- }
-
- bool
- GetSkipPointers () const
- {
- return (m_flags & lldb::eTypeOptionSkipPointers) == lldb::eTypeOptionSkipPointers;
- }
-
- Flags&
- SetSkipPointers (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionSkipPointers;
- else
- m_flags &= ~lldb::eTypeOptionSkipPointers;
- return *this;
- }
-
- bool
- GetSkipReferences () const
- {
- return (m_flags & lldb::eTypeOptionSkipReferences) == lldb::eTypeOptionSkipReferences;
- }
-
- Flags&
- SetSkipReferences (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionSkipReferences;
- else
- m_flags &= ~lldb::eTypeOptionSkipReferences;
- return *this;
- }
-
- bool
- GetNonCacheable () const
- {
- return (m_flags & lldb::eTypeOptionNonCacheable) == lldb::eTypeOptionNonCacheable;
- }
-
- Flags&
- SetNonCacheable (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionNonCacheable;
- else
- m_flags &= ~lldb::eTypeOptionNonCacheable;
- return *this;
- }
-
- uint32_t
- GetValue ()
- {
- return m_flags;
- }
-
- void
- SetValue (uint32_t value)
- {
- m_flags = value;
- }
-
- private:
- uint32_t m_flags;
- };
-
- TypeFormatImpl (const Flags& flags = Flags());
-
- typedef std::shared_ptr<TypeFormatImpl> SharedPointer;
-
- virtual ~TypeFormatImpl ();
-
- bool
- Cascades () const
- {
- return m_flags.GetCascades();
- }
-
- bool
- SkipsPointers () const
- {
- return m_flags.GetSkipPointers();
- }
-
- bool
- SkipsReferences () const
- {
- return m_flags.GetSkipReferences();
- }
-
- bool
- NonCacheable () const
- {
- return m_flags.GetNonCacheable();
- }
-
- void
- SetCascades (bool value)
- {
- m_flags.SetCascades(value);
- }
-
- void
- SetSkipsPointers (bool value)
- {
- m_flags.SetSkipPointers(value);
- }
-
- void
- SetSkipsReferences (bool value)
- {
- m_flags.SetSkipReferences(value);
- }
-
- void
- SetNonCacheable (bool value)
- {
- m_flags.SetNonCacheable(value);
- }
-
- uint32_t
- GetOptions ()
- {
- return m_flags.GetValue();
- }
-
- void
- SetOptions (uint32_t value)
- {
- m_flags.SetValue(value);
- }
-
- uint32_t&
- GetRevision ()
- {
- return m_my_revision;
- }
-
- enum class Type
- {
- eTypeUnknown,
- eTypeFormat,
- eTypeEnum
- };
-
- virtual Type
- GetType ()
- {
- return Type::eTypeUnknown;
- }
-
- // we are using a ValueObject* instead of a ValueObjectSP because we do not need to hold on to this for
- // extended periods of time and we trust the ValueObject to stay around for as long as it is required
- // for us to generate its value
- virtual bool
- FormatObject (ValueObject *valobj,
- std::string& dest) const = 0;
-
- virtual std::string
- GetDescription() = 0;
-
- protected:
- Flags m_flags;
- uint32_t m_my_revision;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl);
- };
-
- class TypeFormatImpl_Format : public TypeFormatImpl
- {
- public:
- TypeFormatImpl_Format (lldb::Format f = lldb::eFormatInvalid,
- const TypeFormatImpl::Flags& flags = Flags());
-
- typedef std::shared_ptr<TypeFormatImpl_Format> SharedPointer;
-
- ~TypeFormatImpl_Format() override;
-
- lldb::Format
- GetFormat () const
- {
- return m_format;
- }
-
- void
- SetFormat (lldb::Format fmt)
- {
- m_format = fmt;
- }
-
- TypeFormatImpl::Type
- GetType() override
- {
- return TypeFormatImpl::Type::eTypeFormat;
- }
-
- bool
- FormatObject(ValueObject *valobj,
- std::string& dest) const override;
-
- std::string
- GetDescription() override;
-
- protected:
- lldb::Format m_format;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl_Format);
- };
-
- class TypeFormatImpl_EnumType : public TypeFormatImpl
- {
- public:
- TypeFormatImpl_EnumType (ConstString type_name = ConstString(""),
- const TypeFormatImpl::Flags& flags = Flags());
-
- typedef std::shared_ptr<TypeFormatImpl_EnumType> SharedPointer;
-
- ~TypeFormatImpl_EnumType() override;
-
- ConstString
- GetTypeName ()
- {
- return m_enum_type;
- }
-
- void
- SetTypeName (ConstString enum_type)
- {
- m_enum_type = enum_type;
- }
-
- TypeFormatImpl::Type
- GetType() override
- {
- return TypeFormatImpl::Type::eTypeEnum;
- }
-
- bool
- FormatObject(ValueObject *valobj,
- std::string& dest) const override;
-
- std::string
- GetDescription() override;
-
- protected:
- ConstString m_enum_type;
- mutable std::unordered_map<void*,CompilerType> m_types;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl_EnumType);
- };
+class TypeFormatImpl {
+public:
+ class Flags {
+ public:
+ Flags() : m_flags(lldb::eTypeOptionCascade) {}
+
+ Flags(const Flags &other) : m_flags(other.m_flags) {}
+
+ Flags(uint32_t value) : m_flags(value) {}
+
+ Flags &operator=(const Flags &rhs) {
+ if (&rhs != this)
+ m_flags = rhs.m_flags;
+
+ return *this;
+ }
+
+ Flags &operator=(const uint32_t &rhs) {
+ m_flags = rhs;
+ return *this;
+ }
+
+ Flags &Clear() {
+ m_flags = 0;
+ return *this;
+ }
+
+ bool GetCascades() const {
+ return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade;
+ }
+
+ Flags &SetCascades(bool value = true) {
+ if (value)
+ m_flags |= lldb::eTypeOptionCascade;
+ else
+ m_flags &= ~lldb::eTypeOptionCascade;
+ return *this;
+ }
+
+ bool GetSkipPointers() const {
+ return (m_flags & lldb::eTypeOptionSkipPointers) ==
+ lldb::eTypeOptionSkipPointers;
+ }
+
+ Flags &SetSkipPointers(bool value = true) {
+ if (value)
+ m_flags |= lldb::eTypeOptionSkipPointers;
+ else
+ m_flags &= ~lldb::eTypeOptionSkipPointers;
+ return *this;
+ }
+
+ bool GetSkipReferences() const {
+ return (m_flags & lldb::eTypeOptionSkipReferences) ==
+ lldb::eTypeOptionSkipReferences;
+ }
+
+ Flags &SetSkipReferences(bool value = true) {
+ if (value)
+ m_flags |= lldb::eTypeOptionSkipReferences;
+ else
+ m_flags &= ~lldb::eTypeOptionSkipReferences;
+ return *this;
+ }
+
+ bool GetNonCacheable() const {
+ return (m_flags & lldb::eTypeOptionNonCacheable) ==
+ lldb::eTypeOptionNonCacheable;
+ }
+
+ Flags &SetNonCacheable(bool value = true) {
+ if (value)
+ m_flags |= lldb::eTypeOptionNonCacheable;
+ else
+ m_flags &= ~lldb::eTypeOptionNonCacheable;
+ return *this;
+ }
+
+ uint32_t GetValue() { return m_flags; }
+
+ void SetValue(uint32_t value) { m_flags = value; }
+
+ private:
+ uint32_t m_flags;
+ };
+
+ TypeFormatImpl(const Flags &flags = Flags());
+
+ typedef std::shared_ptr<TypeFormatImpl> SharedPointer;
+
+ virtual ~TypeFormatImpl();
+
+ bool Cascades() const { return m_flags.GetCascades(); }
+
+ bool SkipsPointers() const { return m_flags.GetSkipPointers(); }
+
+ bool SkipsReferences() const { return m_flags.GetSkipReferences(); }
+
+ bool NonCacheable() const { return m_flags.GetNonCacheable(); }
+
+ void SetCascades(bool value) { m_flags.SetCascades(value); }
+
+ void SetSkipsPointers(bool value) { m_flags.SetSkipPointers(value); }
+
+ void SetSkipsReferences(bool value) { m_flags.SetSkipReferences(value); }
+
+ void SetNonCacheable(bool value) { m_flags.SetNonCacheable(value); }
+
+ uint32_t GetOptions() { return m_flags.GetValue(); }
+
+ void SetOptions(uint32_t value) { m_flags.SetValue(value); }
+
+ uint32_t &GetRevision() { return m_my_revision; }
+
+ enum class Type { eTypeUnknown, eTypeFormat, eTypeEnum };
+
+ virtual Type GetType() { return Type::eTypeUnknown; }
+
+ // we are using a ValueObject* instead of a ValueObjectSP because we do not
+ // need to hold on to this for
+ // extended periods of time and we trust the ValueObject to stay around for as
+ // long as it is required
+ // for us to generate its value
+ virtual bool FormatObject(ValueObject *valobj, std::string &dest) const = 0;
+
+ virtual std::string GetDescription() = 0;
+
+protected:
+ Flags m_flags;
+ uint32_t m_my_revision;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl);
+};
+
+class TypeFormatImpl_Format : public TypeFormatImpl {
+public:
+ TypeFormatImpl_Format(lldb::Format f = lldb::eFormatInvalid,
+ const TypeFormatImpl::Flags &flags = Flags());
+
+ typedef std::shared_ptr<TypeFormatImpl_Format> SharedPointer;
+
+ ~TypeFormatImpl_Format() override;
+
+ lldb::Format GetFormat() const { return m_format; }
+
+ void SetFormat(lldb::Format fmt) { m_format = fmt; }
+
+ TypeFormatImpl::Type GetType() override {
+ return TypeFormatImpl::Type::eTypeFormat;
+ }
+
+ bool FormatObject(ValueObject *valobj, std::string &dest) const override;
+
+ std::string GetDescription() override;
+
+protected:
+ lldb::Format m_format;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl_Format);
+};
+
+class TypeFormatImpl_EnumType : public TypeFormatImpl {
+public:
+ TypeFormatImpl_EnumType(ConstString type_name = ConstString(""),
+ const TypeFormatImpl::Flags &flags = Flags());
+
+ typedef std::shared_ptr<TypeFormatImpl_EnumType> SharedPointer;
+
+ ~TypeFormatImpl_EnumType() override;
+
+ ConstString GetTypeName() { return m_enum_type; }
+
+ void SetTypeName(ConstString enum_type) { m_enum_type = enum_type; }
+
+ TypeFormatImpl::Type GetType() override {
+ return TypeFormatImpl::Type::eTypeEnum;
+ }
+
+ bool FormatObject(ValueObject *valobj, std::string &dest) const override;
+
+ std::string GetDescription() override;
+
+protected:
+ ConstString m_enum_type;
+ mutable std::unordered_map<void *, CompilerType> m_types;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl_EnumType);
+};
} // namespace lldb_private
#endif // lldb_TypeFormat_h_
diff --git a/include/lldb/DataFormatters/TypeSummary.h b/include/lldb/DataFormatters/TypeSummary.h
index e5bf4ecadfdf..7b2feeb8fc22 100644
--- a/include/lldb/DataFormatters/TypeSummary.h
+++ b/include/lldb/DataFormatters/TypeSummary.h
@@ -20,569 +20,384 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-public.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/FormatEntity.h"
#include "lldb/Core/StructuredData.h"
namespace lldb_private {
- class TypeSummaryOptions
- {
- public:
- TypeSummaryOptions ();
- TypeSummaryOptions (const TypeSummaryOptions& rhs);
-
- ~TypeSummaryOptions() = default;
-
- TypeSummaryOptions&
- operator = (const TypeSummaryOptions& rhs);
-
- lldb::LanguageType
- GetLanguage () const;
-
- lldb::TypeSummaryCapping
- GetCapping () const;
-
- TypeSummaryOptions&
- SetLanguage (lldb::LanguageType);
-
- TypeSummaryOptions&
- SetCapping (lldb::TypeSummaryCapping);
-
- private:
- lldb::LanguageType m_lang;
- lldb::TypeSummaryCapping m_capping;
- };
-
- class TypeSummaryImpl
- {
- public:
- enum class Kind
- {
- eSummaryString,
- eScript,
- eCallback,
- eInternal
- };
-
- virtual
- ~TypeSummaryImpl() = default;
-
- Kind
- GetKind () const
- {
- return m_kind;
- }
-
- class Flags
- {
- public:
- Flags () :
- m_flags (lldb::eTypeOptionCascade)
- {}
-
- Flags (const Flags& other) :
- m_flags (other.m_flags)
- {}
-
- Flags (uint32_t value) :
- m_flags (value)
- {}
-
- Flags&
- operator = (const Flags& rhs)
- {
- if (&rhs != this)
- m_flags = rhs.m_flags;
-
- return *this;
- }
-
- Flags&
- operator = (const uint32_t& rhs)
- {
- m_flags = rhs;
- return *this;
- }
-
- Flags&
- Clear()
- {
- m_flags = 0;
- return *this;
- }
-
- bool
- GetCascades () const
- {
- return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade;
- }
-
- Flags&
- SetCascades (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionCascade;
- else
- m_flags &= ~lldb::eTypeOptionCascade;
- return *this;
- }
-
- bool
- GetSkipPointers () const
- {
- return (m_flags & lldb::eTypeOptionSkipPointers) == lldb::eTypeOptionSkipPointers;
- }
-
- Flags&
- SetSkipPointers (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionSkipPointers;
- else
- m_flags &= ~lldb::eTypeOptionSkipPointers;
- return *this;
- }
-
- bool
- GetSkipReferences () const
- {
- return (m_flags & lldb::eTypeOptionSkipReferences) == lldb::eTypeOptionSkipReferences;
- }
-
- Flags&
- SetSkipReferences (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionSkipReferences;
- else
- m_flags &= ~lldb::eTypeOptionSkipReferences;
- return *this;
- }
-
- bool
- GetDontShowChildren () const
- {
- return (m_flags & lldb::eTypeOptionHideChildren) == lldb::eTypeOptionHideChildren;
- }
-
- Flags&
- SetDontShowChildren (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionHideChildren;
- else
- m_flags &= ~lldb::eTypeOptionHideChildren;
- return *this;
- }
-
- bool
- GetHideEmptyAggregates () const
- {
- return (m_flags & lldb::eTypeOptionHideEmptyAggregates) == lldb::eTypeOptionHideEmptyAggregates;
- }
-
- Flags&
- SetHideEmptyAggregates (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionHideEmptyAggregates;
- else
- m_flags &= ~lldb::eTypeOptionHideEmptyAggregates;
- return *this;
- }
-
- bool
- GetDontShowValue () const
- {
- return (m_flags & lldb::eTypeOptionHideValue) == lldb::eTypeOptionHideValue;
- }
-
- Flags&
- SetDontShowValue (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionHideValue;
- else
- m_flags &= ~lldb::eTypeOptionHideValue;
- return *this;
- }
-
- bool
- GetShowMembersOneLiner () const
- {
- return (m_flags & lldb::eTypeOptionShowOneLiner) == lldb::eTypeOptionShowOneLiner;
- }
-
- Flags&
- SetShowMembersOneLiner (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionShowOneLiner;
- else
- m_flags &= ~lldb::eTypeOptionShowOneLiner;
- return *this;
- }
-
- bool
- GetHideItemNames () const
- {
- return (m_flags & lldb::eTypeOptionHideNames) == lldb::eTypeOptionHideNames;
- }
-
- Flags&
- SetHideItemNames (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionHideNames;
- else
- m_flags &= ~lldb::eTypeOptionHideNames;
- return *this;
- }
-
- bool
- GetNonCacheable () const
- {
- return (m_flags & lldb::eTypeOptionNonCacheable) == lldb::eTypeOptionNonCacheable;
- }
-
- Flags&
- SetNonCacheable (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionNonCacheable;
- else
- m_flags &= ~lldb::eTypeOptionNonCacheable;
- return *this;
- }
-
- uint32_t
- GetValue ()
- {
- return m_flags;
- }
-
- void
- SetValue (uint32_t value)
- {
- m_flags = value;
- }
-
- private:
- uint32_t m_flags;
- };
-
- bool
- Cascades () const
- {
- return m_flags.GetCascades();
- }
-
- bool
- SkipsPointers () const
- {
- return m_flags.GetSkipPointers();
- }
-
- bool
- SkipsReferences () const
- {
- return m_flags.GetSkipReferences();
- }
-
- bool
- NonCacheable () const
- {
- return m_flags.GetNonCacheable();
- }
-
- virtual bool
- DoesPrintChildren (ValueObject* valobj) const
- {
- return !m_flags.GetDontShowChildren();
- }
-
- virtual bool
- DoesPrintEmptyAggregates () const
- {
- return !m_flags.GetHideEmptyAggregates();
- }
-
- virtual bool
- DoesPrintValue (ValueObject* valobj) const
- {
- return !m_flags.GetDontShowValue();
- }
-
- bool
- IsOneLiner () const
- {
- return m_flags.GetShowMembersOneLiner();
- }
-
- virtual bool
- HideNames (ValueObject* valobj) const
- {
- return m_flags.GetHideItemNames();
- }
-
- void
- SetCascades (bool value)
- {
- m_flags.SetCascades(value);
- }
-
- void
- SetSkipsPointers (bool value)
- {
- m_flags.SetSkipPointers(value);
- }
-
- void
- SetSkipsReferences (bool value)
- {
- m_flags.SetSkipReferences(value);
- }
-
- virtual void
- SetDoesPrintChildren (bool value)
- {
- m_flags.SetDontShowChildren(!value);
- }
-
- virtual void
- SetDoesPrintValue (bool value)
- {
- m_flags.SetDontShowValue(!value);
- }
-
- void
- SetIsOneLiner (bool value)
- {
- m_flags.SetShowMembersOneLiner(value);
- }
-
- virtual void
- SetHideNames (bool value)
- {
- m_flags.SetHideItemNames(value);
- }
-
- virtual void
- SetNonCacheable (bool value)
- {
- m_flags.SetNonCacheable(value);
- }
-
- uint32_t
- GetOptions ()
- {
- return m_flags.GetValue();
- }
-
- void
- SetOptions (uint32_t value)
- {
- m_flags.SetValue(value);
- }
-
- // we are using a ValueObject* instead of a ValueObjectSP because we do not need to hold on to this for
- // extended periods of time and we trust the ValueObject to stay around for as long as it is required
- // for us to generate its summary
- virtual bool
- FormatObject (ValueObject *valobj,
- std::string& dest,
- const TypeSummaryOptions& options) = 0;
-
- virtual std::string
- GetDescription () = 0;
-
- uint32_t&
- GetRevision ()
- {
- return m_my_revision;
- }
-
- typedef std::shared_ptr<TypeSummaryImpl> SharedPointer;
-
- protected:
- uint32_t m_my_revision;
- Flags m_flags;
-
- TypeSummaryImpl (Kind kind,
- const TypeSummaryImpl::Flags& flags);
-
- private:
- Kind m_kind;
- DISALLOW_COPY_AND_ASSIGN(TypeSummaryImpl);
- };
-
- // simple string-based summaries, using ${var to show data
- struct StringSummaryFormat : public TypeSummaryImpl
- {
- std::string m_format_str;
- FormatEntity::Entry m_format;
- Error m_error;
-
- StringSummaryFormat(const TypeSummaryImpl::Flags& flags,
- const char* f);
-
- ~StringSummaryFormat() override = default;
-
- const char*
- GetSummaryString () const
- {
- return m_format_str.c_str();
- }
-
- void
- SetSummaryString (const char* f);
-
- bool
- FormatObject(ValueObject *valobj,
- std::string& dest,
- const TypeSummaryOptions& options) override;
-
- std::string
- GetDescription() override;
-
- static bool classof(const TypeSummaryImpl* S)
- {
- return S->GetKind() == Kind::eSummaryString;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(StringSummaryFormat);
- };
-
- // summaries implemented via a C++ function
- struct CXXFunctionSummaryFormat : public TypeSummaryImpl
- {
- // we should convert these to SBValue and SBStream if we ever cross
- // the boundary towards the external world
- typedef std::function<bool(ValueObject&,
- Stream&,
- const TypeSummaryOptions&)> Callback;
-
- Callback m_impl;
- std::string m_description;
-
- CXXFunctionSummaryFormat (const TypeSummaryImpl::Flags& flags,
- Callback impl,
- const char* description);
-
- ~CXXFunctionSummaryFormat() override = default;
-
- Callback
- GetBackendFunction () const
- {
- return m_impl;
- }
-
- const char*
- GetTextualInfo () const
- {
- return m_description.c_str();
- }
-
- void
- SetBackendFunction (Callback cb_func)
- {
- m_impl = cb_func;
- }
-
- void
- SetTextualInfo (const char* descr)
- {
- if (descr)
- m_description.assign(descr);
- else
- m_description.clear();
- }
-
- bool
- FormatObject(ValueObject *valobj,
- std::string& dest,
- const TypeSummaryOptions& options) override;
-
- std::string
- GetDescription() override;
-
- static bool classof(const TypeSummaryImpl* S)
- {
- return S->GetKind() == Kind::eCallback;
- }
-
- typedef std::shared_ptr<CXXFunctionSummaryFormat> SharedPointer;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(CXXFunctionSummaryFormat);
- };
-
- // Python-based summaries, running script code to show data
- struct ScriptSummaryFormat : public TypeSummaryImpl
- {
- std::string m_function_name;
- std::string m_python_script;
- StructuredData::ObjectSP m_script_function_sp;
-
- ScriptSummaryFormat(const TypeSummaryImpl::Flags& flags,
- const char *function_name,
- const char* python_script = nullptr);
-
- ~ScriptSummaryFormat() override = default;
-
- const char*
- GetFunctionName () const
- {
- return m_function_name.c_str();
- }
-
- const char*
- GetPythonScript () const
- {
- return m_python_script.c_str();
- }
-
- void
- SetFunctionName (const char* function_name)
- {
- if (function_name)
- m_function_name.assign(function_name);
- else
- m_function_name.clear();
- m_python_script.clear();
- }
-
- void
- SetPythonScript (const char* script)
- {
- if (script)
- m_python_script.assign(script);
- else
- m_python_script.clear();
- }
-
- bool
- FormatObject(ValueObject *valobj,
- std::string& dest,
- const TypeSummaryOptions& options) override;
-
- std::string
- GetDescription() override;
-
- static bool classof(const TypeSummaryImpl* S)
- {
- return S->GetKind() == Kind::eScript;
- }
-
- typedef std::shared_ptr<ScriptSummaryFormat> SharedPointer;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ScriptSummaryFormat);
- };
+class TypeSummaryOptions {
+public:
+ TypeSummaryOptions();
+ TypeSummaryOptions(const TypeSummaryOptions &rhs);
+
+ ~TypeSummaryOptions() = default;
+
+ TypeSummaryOptions &operator=(const TypeSummaryOptions &rhs);
+
+ lldb::LanguageType GetLanguage() const;
+
+ lldb::TypeSummaryCapping GetCapping() const;
+
+ TypeSummaryOptions &SetLanguage(lldb::LanguageType);
+
+ TypeSummaryOptions &SetCapping(lldb::TypeSummaryCapping);
+
+private:
+ lldb::LanguageType m_lang;
+ lldb::TypeSummaryCapping m_capping;
+};
+
+class TypeSummaryImpl {
+public:
+ enum class Kind { eSummaryString, eScript, eCallback, eInternal };
+
+ virtual ~TypeSummaryImpl() = default;
+
+ Kind GetKind() const { return m_kind; }
+
+ class Flags {
+ public:
+ Flags() : m_flags(lldb::eTypeOptionCascade) {}
+
+ Flags(const Flags &other) : m_flags(other.m_flags) {}
+
+ Flags(uint32_t value) : m_flags(value) {}
+
+ Flags &operator=(const Flags &rhs) {
+ if (&rhs != this)
+ m_flags = rhs.m_flags;
+
+ return *this;
+ }
+
+ Flags &operator=(const uint32_t &rhs) {
+ m_flags = rhs;
+ return *this;
+ }
+
+ Flags &Clear() {
+ m_flags = 0;
+ return *this;
+ }
+
+ bool GetCascades() const {
+ return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade;
+ }
+
+ Flags &SetCascades(bool value = true) {
+ if (value)
+ m_flags |= lldb::eTypeOptionCascade;
+ else
+ m_flags &= ~lldb::eTypeOptionCascade;
+ return *this;
+ }
+
+ bool GetSkipPointers() const {
+ return (m_flags & lldb::eTypeOptionSkipPointers) ==
+ lldb::eTypeOptionSkipPointers;
+ }
+
+ Flags &SetSkipPointers(bool value = true) {
+ if (value)
+ m_flags |= lldb::eTypeOptionSkipPointers;
+ else
+ m_flags &= ~lldb::eTypeOptionSkipPointers;
+ return *this;
+ }
+
+ bool GetSkipReferences() const {
+ return (m_flags & lldb::eTypeOptionSkipReferences) ==
+ lldb::eTypeOptionSkipReferences;
+ }
+
+ Flags &SetSkipReferences(bool value = true) {
+ if (value)
+ m_flags |= lldb::eTypeOptionSkipReferences;
+ else
+ m_flags &= ~lldb::eTypeOptionSkipReferences;
+ return *this;
+ }
+
+ bool GetDontShowChildren() const {
+ return (m_flags & lldb::eTypeOptionHideChildren) ==
+ lldb::eTypeOptionHideChildren;
+ }
+
+ Flags &SetDontShowChildren(bool value = true) {
+ if (value)
+ m_flags |= lldb::eTypeOptionHideChildren;
+ else
+ m_flags &= ~lldb::eTypeOptionHideChildren;
+ return *this;
+ }
+
+ bool GetHideEmptyAggregates() const {
+ return (m_flags & lldb::eTypeOptionHideEmptyAggregates) ==
+ lldb::eTypeOptionHideEmptyAggregates;
+ }
+
+ Flags &SetHideEmptyAggregates(bool value = true) {
+ if (value)
+ m_flags |= lldb::eTypeOptionHideEmptyAggregates;
+ else
+ m_flags &= ~lldb::eTypeOptionHideEmptyAggregates;
+ return *this;
+ }
+
+ bool GetDontShowValue() const {
+ return (m_flags & lldb::eTypeOptionHideValue) ==
+ lldb::eTypeOptionHideValue;
+ }
+
+ Flags &SetDontShowValue(bool value = true) {
+ if (value)
+ m_flags |= lldb::eTypeOptionHideValue;
+ else
+ m_flags &= ~lldb::eTypeOptionHideValue;
+ return *this;
+ }
+
+ bool GetShowMembersOneLiner() const {
+ return (m_flags & lldb::eTypeOptionShowOneLiner) ==
+ lldb::eTypeOptionShowOneLiner;
+ }
+
+ Flags &SetShowMembersOneLiner(bool value = true) {
+ if (value)
+ m_flags |= lldb::eTypeOptionShowOneLiner;
+ else
+ m_flags &= ~lldb::eTypeOptionShowOneLiner;
+ return *this;
+ }
+
+ bool GetHideItemNames() const {
+ return (m_flags & lldb::eTypeOptionHideNames) ==
+ lldb::eTypeOptionHideNames;
+ }
+
+ Flags &SetHideItemNames(bool value = true) {
+ if (value)
+ m_flags |= lldb::eTypeOptionHideNames;
+ else
+ m_flags &= ~lldb::eTypeOptionHideNames;
+ return *this;
+ }
+
+ bool GetNonCacheable() const {
+ return (m_flags & lldb::eTypeOptionNonCacheable) ==
+ lldb::eTypeOptionNonCacheable;
+ }
+
+ Flags &SetNonCacheable(bool value = true) {
+ if (value)
+ m_flags |= lldb::eTypeOptionNonCacheable;
+ else
+ m_flags &= ~lldb::eTypeOptionNonCacheable;
+ return *this;
+ }
+
+ uint32_t GetValue() { return m_flags; }
+
+ void SetValue(uint32_t value) { m_flags = value; }
+
+ private:
+ uint32_t m_flags;
+ };
+
+ bool Cascades() const { return m_flags.GetCascades(); }
+
+ bool SkipsPointers() const { return m_flags.GetSkipPointers(); }
+
+ bool SkipsReferences() const { return m_flags.GetSkipReferences(); }
+
+ bool NonCacheable() const { return m_flags.GetNonCacheable(); }
+
+ virtual bool DoesPrintChildren(ValueObject *valobj) const {
+ return !m_flags.GetDontShowChildren();
+ }
+
+ virtual bool DoesPrintEmptyAggregates() const {
+ return !m_flags.GetHideEmptyAggregates();
+ }
+
+ virtual bool DoesPrintValue(ValueObject *valobj) const {
+ return !m_flags.GetDontShowValue();
+ }
+
+ bool IsOneLiner() const { return m_flags.GetShowMembersOneLiner(); }
+
+ virtual bool HideNames(ValueObject *valobj) const {
+ return m_flags.GetHideItemNames();
+ }
+
+ void SetCascades(bool value) { m_flags.SetCascades(value); }
+
+ void SetSkipsPointers(bool value) { m_flags.SetSkipPointers(value); }
+
+ void SetSkipsReferences(bool value) { m_flags.SetSkipReferences(value); }
+
+ virtual void SetDoesPrintChildren(bool value) {
+ m_flags.SetDontShowChildren(!value);
+ }
+
+ virtual void SetDoesPrintValue(bool value) {
+ m_flags.SetDontShowValue(!value);
+ }
+
+ void SetIsOneLiner(bool value) { m_flags.SetShowMembersOneLiner(value); }
+
+ virtual void SetHideNames(bool value) { m_flags.SetHideItemNames(value); }
+
+ virtual void SetNonCacheable(bool value) { m_flags.SetNonCacheable(value); }
+
+ uint32_t GetOptions() { return m_flags.GetValue(); }
+
+ void SetOptions(uint32_t value) { m_flags.SetValue(value); }
+
+ // we are using a ValueObject* instead of a ValueObjectSP because we do not
+ // need to hold on to this for
+ // extended periods of time and we trust the ValueObject to stay around for as
+ // long as it is required
+ // for us to generate its summary
+ virtual bool FormatObject(ValueObject *valobj, std::string &dest,
+ const TypeSummaryOptions &options) = 0;
+
+ virtual std::string GetDescription() = 0;
+
+ uint32_t &GetRevision() { return m_my_revision; }
+
+ typedef std::shared_ptr<TypeSummaryImpl> SharedPointer;
+
+protected:
+ uint32_t m_my_revision;
+ Flags m_flags;
+
+ TypeSummaryImpl(Kind kind, const TypeSummaryImpl::Flags &flags);
+
+private:
+ Kind m_kind;
+ DISALLOW_COPY_AND_ASSIGN(TypeSummaryImpl);
+};
+
+// simple string-based summaries, using ${var to show data
+struct StringSummaryFormat : public TypeSummaryImpl {
+ std::string m_format_str;
+ FormatEntity::Entry m_format;
+ Error m_error;
+
+ StringSummaryFormat(const TypeSummaryImpl::Flags &flags, const char *f);
+
+ ~StringSummaryFormat() override = default;
+
+ const char *GetSummaryString() const { return m_format_str.c_str(); }
+
+ void SetSummaryString(const char *f);
+
+ bool FormatObject(ValueObject *valobj, std::string &dest,
+ const TypeSummaryOptions &options) override;
+
+ std::string GetDescription() override;
+
+ static bool classof(const TypeSummaryImpl *S) {
+ return S->GetKind() == Kind::eSummaryString;
+ }
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(StringSummaryFormat);
+};
+
+// summaries implemented via a C++ function
+struct CXXFunctionSummaryFormat : public TypeSummaryImpl {
+ // we should convert these to SBValue and SBStream if we ever cross
+ // the boundary towards the external world
+ typedef std::function<bool(ValueObject &, Stream &,
+ const TypeSummaryOptions &)>
+ Callback;
+
+ Callback m_impl;
+ std::string m_description;
+
+ CXXFunctionSummaryFormat(const TypeSummaryImpl::Flags &flags, Callback impl,
+ const char *description);
+
+ ~CXXFunctionSummaryFormat() override = default;
+
+ Callback GetBackendFunction() const { return m_impl; }
+
+ const char *GetTextualInfo() const { return m_description.c_str(); }
+
+ void SetBackendFunction(Callback cb_func) { m_impl = cb_func; }
+
+ void SetTextualInfo(const char *descr) {
+ if (descr)
+ m_description.assign(descr);
+ else
+ m_description.clear();
+ }
+
+ bool FormatObject(ValueObject *valobj, std::string &dest,
+ const TypeSummaryOptions &options) override;
+
+ std::string GetDescription() override;
+
+ static bool classof(const TypeSummaryImpl *S) {
+ return S->GetKind() == Kind::eCallback;
+ }
+
+ typedef std::shared_ptr<CXXFunctionSummaryFormat> SharedPointer;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(CXXFunctionSummaryFormat);
+};
+
+// Python-based summaries, running script code to show data
+struct ScriptSummaryFormat : public TypeSummaryImpl {
+ std::string m_function_name;
+ std::string m_python_script;
+ StructuredData::ObjectSP m_script_function_sp;
+
+ ScriptSummaryFormat(const TypeSummaryImpl::Flags &flags,
+ const char *function_name,
+ const char *python_script = nullptr);
+
+ ~ScriptSummaryFormat() override = default;
+
+ const char *GetFunctionName() const { return m_function_name.c_str(); }
+
+ const char *GetPythonScript() const { return m_python_script.c_str(); }
+
+ void SetFunctionName(const char *function_name) {
+ if (function_name)
+ m_function_name.assign(function_name);
+ else
+ m_function_name.clear();
+ m_python_script.clear();
+ }
+
+ void SetPythonScript(const char *script) {
+ if (script)
+ m_python_script.assign(script);
+ else
+ m_python_script.clear();
+ }
+
+ bool FormatObject(ValueObject *valobj, std::string &dest,
+ const TypeSummaryOptions &options) override;
+
+ std::string GetDescription() override;
+
+ static bool classof(const TypeSummaryImpl *S) {
+ return S->GetKind() == Kind::eScript;
+ }
+
+ typedef std::shared_ptr<ScriptSummaryFormat> SharedPointer;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(ScriptSummaryFormat);
+};
} // namespace lldb_private
#endif // lldb_TypeSummary_h_
diff --git a/include/lldb/DataFormatters/TypeSynthetic.h b/include/lldb/DataFormatters/TypeSynthetic.h
index ceb600aed69a..6f5a8df585b6 100644
--- a/include/lldb/DataFormatters/TypeSynthetic.h
+++ b/include/lldb/DataFormatters/TypeSynthetic.h
@@ -14,629 +14,439 @@
#include <stdint.h>
// C++ Includes
-#include <initializer_list>
#include <functional>
+#include <initializer_list>
#include <memory>
#include <string>
#include <vector>
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-public.h"
#include "lldb/Core/StructuredData.h"
#include "lldb/Core/ValueObject.h"
namespace lldb_private {
- class SyntheticChildrenFrontEnd
- {
- protected:
- ValueObject &m_backend;
-
- void
- SetValid (bool valid)
- {
- m_valid = valid;
- }
-
- bool
- IsValid ()
- {
- return m_valid;
- }
-
- public:
- SyntheticChildrenFrontEnd (ValueObject &backend) :
- m_backend(backend),
- m_valid(true)
- {}
-
- virtual
- ~SyntheticChildrenFrontEnd() = default;
-
- virtual size_t
- CalculateNumChildren () = 0;
-
- virtual size_t
- CalculateNumChildren (uint32_t max)
- {
- auto count = CalculateNumChildren ();
- return count <= max ? count : max;
- }
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx) = 0;
-
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name) = 0;
-
- // this function is assumed to always succeed and it if fails, the front-end should know to deal
- // with it in the correct way (most probably, by refusing to return any children)
- // the return value of Update() should actually be interpreted as "ValueObjectSyntheticFilter cache is good/bad"
- // if =true, ValueObjectSyntheticFilter is allowed to use the children it fetched previously and cached
- // if =false, ValueObjectSyntheticFilter must throw away its cache, and query again for children
- virtual bool
- Update () = 0;
-
- // if this function returns false, then CalculateNumChildren() MUST return 0 since UI frontends
- // might validly decide not to inquire for children given a false return value from this call
- // if it returns true, then CalculateNumChildren() can return any number >= 0 (0 being valid)
- // it should if at all possible be more efficient than CalculateNumChildren()
- virtual bool
- MightHaveChildren () = 0;
-
- // if this function returns a non-null ValueObject, then the returned ValueObject will stand
- // for this ValueObject whenever a "value" request is made to this ValueObject
- virtual lldb::ValueObjectSP
- GetSyntheticValue () { return nullptr; }
-
- // if this function returns a non-empty ConstString, then clients are expected to use the return
- // as the name of the type of this ValueObject for display purposes
- virtual ConstString
- GetSyntheticTypeName () { return ConstString(); }
-
- typedef std::shared_ptr<SyntheticChildrenFrontEnd> SharedPointer;
- typedef std::unique_ptr<SyntheticChildrenFrontEnd> AutoPointer;
-
- protected:
- lldb::ValueObjectSP
- CreateValueObjectFromExpression (const char* name,
- const char* expression,
- const ExecutionContext& exe_ctx);
-
- lldb::ValueObjectSP
- CreateValueObjectFromAddress (const char* name,
- uint64_t address,
- const ExecutionContext& exe_ctx,
- CompilerType type);
-
- lldb::ValueObjectSP
- CreateValueObjectFromData (const char* name,
- const DataExtractor& data,
- const ExecutionContext& exe_ctx,
- CompilerType type);
-
- private:
- bool m_valid;
- DISALLOW_COPY_AND_ASSIGN(SyntheticChildrenFrontEnd);
- };
-
- class SyntheticValueProviderFrontEnd : public SyntheticChildrenFrontEnd
- {
- public:
- SyntheticValueProviderFrontEnd (ValueObject &backend) :
- SyntheticChildrenFrontEnd(backend)
- {}
-
- ~SyntheticValueProviderFrontEnd() override = default;
-
- size_t
- CalculateNumChildren() override { return 0; }
-
- lldb::ValueObjectSP
- GetChildAtIndex(size_t idx) override { return nullptr; }
-
- size_t
- GetIndexOfChildWithName(const ConstString &name) override { return UINT32_MAX; }
-
- bool
- Update() override { return false; }
-
- bool
- MightHaveChildren () override { return false; }
-
- lldb::ValueObjectSP
- GetSyntheticValue() override = 0;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(SyntheticValueProviderFrontEnd);
- };
-
- class SyntheticChildren
- {
- public:
- class Flags
- {
- public:
-
- Flags () :
- m_flags (lldb::eTypeOptionCascade)
- {}
-
- Flags (const Flags& other) :
- m_flags (other.m_flags)
- {}
-
- Flags (uint32_t value) :
- m_flags (value)
- {}
-
- Flags&
- operator = (const Flags& rhs)
- {
- if (&rhs != this)
- m_flags = rhs.m_flags;
-
- return *this;
- }
-
- Flags&
- operator = (const uint32_t& rhs)
- {
- m_flags = rhs;
- return *this;
- }
-
- Flags&
- Clear()
- {
- m_flags = 0;
- return *this;
- }
-
- bool
- GetCascades () const
- {
- return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade;
- }
-
- Flags&
- SetCascades (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionCascade;
- else
- m_flags &= ~lldb::eTypeOptionCascade;
- return *this;
- }
-
- bool
- GetSkipPointers () const
- {
- return (m_flags & lldb::eTypeOptionSkipPointers) == lldb::eTypeOptionSkipPointers;
- }
-
- Flags&
- SetSkipPointers (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionSkipPointers;
- else
- m_flags &= ~lldb::eTypeOptionSkipPointers;
- return *this;
- }
-
- bool
- GetSkipReferences () const
- {
- return (m_flags & lldb::eTypeOptionSkipReferences) == lldb::eTypeOptionSkipReferences;
- }
-
- Flags&
- SetSkipReferences (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionSkipReferences;
- else
- m_flags &= ~lldb::eTypeOptionSkipReferences;
- return *this;
- }
-
- bool
- GetNonCacheable () const
- {
- return (m_flags & lldb::eTypeOptionNonCacheable) == lldb::eTypeOptionNonCacheable;
- }
-
- Flags&
- SetNonCacheable (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionNonCacheable;
- else
- m_flags &= ~lldb::eTypeOptionNonCacheable;
- return *this;
- }
-
- uint32_t
- GetValue ()
- {
- return m_flags;
- }
-
- void
- SetValue (uint32_t value)
- {
- m_flags = value;
- }
-
- private:
- uint32_t m_flags;
- };
-
- SyntheticChildren (const Flags& flags) :
- m_flags(flags)
- {
- }
-
- virtual
- ~SyntheticChildren() = default;
-
- bool
- Cascades () const
- {
- return m_flags.GetCascades();
- }
-
- bool
- SkipsPointers () const
- {
- return m_flags.GetSkipPointers();
- }
-
- bool
- SkipsReferences () const
- {
- return m_flags.GetSkipReferences();
- }
-
- bool
- NonCacheable () const
- {
- return m_flags.GetNonCacheable();
- }
-
- void
- SetCascades (bool value)
- {
- m_flags.SetCascades(value);
- }
-
- void
- SetSkipsPointers (bool value)
- {
- m_flags.SetSkipPointers(value);
- }
-
- void
- SetSkipsReferences (bool value)
- {
- m_flags.SetSkipReferences(value);
- }
-
- void
- SetNonCacheable (bool value)
- {
- m_flags.SetNonCacheable(value);
- }
-
- uint32_t
- GetOptions ()
- {
- return m_flags.GetValue();
- }
-
- void
- SetOptions (uint32_t value)
- {
- m_flags.SetValue(value);
- }
-
- virtual bool
- IsScripted () = 0;
-
- virtual std::string
- GetDescription () = 0;
-
- virtual SyntheticChildrenFrontEnd::AutoPointer
- GetFrontEnd (ValueObject &backend) = 0;
-
- typedef std::shared_ptr<SyntheticChildren> SharedPointer;
-
- uint32_t&
- GetRevision ()
- {
- return m_my_revision;
- }
-
- protected:
- uint32_t m_my_revision;
- Flags m_flags;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(SyntheticChildren);
- };
-
- class TypeFilterImpl : public SyntheticChildren
- {
- std::vector<std::string> m_expression_paths;
- public:
- TypeFilterImpl(const SyntheticChildren::Flags& flags) :
- SyntheticChildren(flags),
- m_expression_paths()
- {
- }
-
- TypeFilterImpl(const SyntheticChildren::Flags& flags,
- const std::initializer_list<const char*> items) :
- SyntheticChildren(flags),
- m_expression_paths()
- {
- for (auto path : items)
- AddExpressionPath (path);
- }
-
- void
- AddExpressionPath (const char* path)
- {
- AddExpressionPath(std::string(path));
- }
-
- void
- Clear()
- {
- m_expression_paths.clear();
- }
-
- size_t
- GetCount() const
- {
- return m_expression_paths.size();
- }
-
- const char*
- GetExpressionPathAtIndex(size_t i) const
- {
- return m_expression_paths[i].c_str();
- }
-
- bool
- SetExpressionPathAtIndex (size_t i, const char* path)
- {
- return SetExpressionPathAtIndex(i, std::string(path));
- }
-
- void
- AddExpressionPath (const std::string& path);
-
- bool
- SetExpressionPathAtIndex (size_t i, const std::string& path);
-
- bool
- IsScripted() override
- {
- return false;
- }
-
- std::string
- GetDescription() override;
-
- class FrontEnd : public SyntheticChildrenFrontEnd
- {
- public:
- FrontEnd(TypeFilterImpl* flt,
- ValueObject &backend) :
- SyntheticChildrenFrontEnd(backend),
- filter(flt)
- {}
-
- ~FrontEnd() override = default;
-
- size_t
- CalculateNumChildren() override
- {
- return filter->GetCount();
- }
-
- lldb::ValueObjectSP
- GetChildAtIndex(size_t idx) override
- {
- if (idx >= filter->GetCount())
- return lldb::ValueObjectSP();
- return m_backend.GetSyntheticExpressionPathChild(filter->GetExpressionPathAtIndex(idx), true);
- }
-
- bool
- Update() override { return false; }
-
- bool
- MightHaveChildren() override
- {
- return filter->GetCount() > 0;
- }
-
- size_t
- GetIndexOfChildWithName(const ConstString &name) override;
-
- typedef std::shared_ptr<SyntheticChildrenFrontEnd> SharedPointer;
-
- private:
- TypeFilterImpl* filter;
-
- DISALLOW_COPY_AND_ASSIGN(FrontEnd);
- };
-
- SyntheticChildrenFrontEnd::AutoPointer
- GetFrontEnd(ValueObject &backend) override
- {
- return SyntheticChildrenFrontEnd::AutoPointer(new FrontEnd(this, backend));
- }
-
- typedef std::shared_ptr<TypeFilterImpl> SharedPointer;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TypeFilterImpl);
- };
-
- class CXXSyntheticChildren : public SyntheticChildren
- {
- public:
- typedef std::function<SyntheticChildrenFrontEnd*(CXXSyntheticChildren*, lldb::ValueObjectSP)> CreateFrontEndCallback;
- CXXSyntheticChildren (const SyntheticChildren::Flags& flags,
- const char* description,
- CreateFrontEndCallback callback) :
- SyntheticChildren(flags),
- m_create_callback(callback),
- m_description(description ? description : "")
- {
- }
-
- bool
- IsScripted() override
- {
- return false;
- }
-
- std::string
- GetDescription() override;
-
- SyntheticChildrenFrontEnd::AutoPointer
- GetFrontEnd(ValueObject &backend) override
- {
- return SyntheticChildrenFrontEnd::AutoPointer(m_create_callback(this, backend.GetSP()));
- }
-
- protected:
- CreateFrontEndCallback m_create_callback;
- std::string m_description;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(CXXSyntheticChildren);
- };
-
+class SyntheticChildrenFrontEnd {
+protected:
+ ValueObject &m_backend;
+
+ void SetValid(bool valid) { m_valid = valid; }
+
+ bool IsValid() { return m_valid; }
+
+public:
+ SyntheticChildrenFrontEnd(ValueObject &backend)
+ : m_backend(backend), m_valid(true) {}
+
+ virtual ~SyntheticChildrenFrontEnd() = default;
+
+ virtual size_t CalculateNumChildren() = 0;
+
+ virtual size_t CalculateNumChildren(uint32_t max) {
+ auto count = CalculateNumChildren();
+ return count <= max ? count : max;
+ }
+
+ virtual lldb::ValueObjectSP GetChildAtIndex(size_t idx) = 0;
+
+ virtual size_t GetIndexOfChildWithName(const ConstString &name) = 0;
+
+ // this function is assumed to always succeed and it if fails, the front-end
+ // should know to deal
+ // with it in the correct way (most probably, by refusing to return any
+ // children)
+ // the return value of Update() should actually be interpreted as
+ // "ValueObjectSyntheticFilter cache is good/bad"
+ // if =true, ValueObjectSyntheticFilter is allowed to use the children it
+ // fetched previously and cached
+ // if =false, ValueObjectSyntheticFilter must throw away its cache, and query
+ // again for children
+ virtual bool Update() = 0;
+
+ // if this function returns false, then CalculateNumChildren() MUST return 0
+ // since UI frontends
+ // might validly decide not to inquire for children given a false return value
+ // from this call
+ // if it returns true, then CalculateNumChildren() can return any number >= 0
+ // (0 being valid)
+ // it should if at all possible be more efficient than CalculateNumChildren()
+ virtual bool MightHaveChildren() = 0;
+
+ // if this function returns a non-null ValueObject, then the returned
+ // ValueObject will stand
+ // for this ValueObject whenever a "value" request is made to this ValueObject
+ virtual lldb::ValueObjectSP GetSyntheticValue() { return nullptr; }
+
+ // if this function returns a non-empty ConstString, then clients are expected
+ // to use the return
+ // as the name of the type of this ValueObject for display purposes
+ virtual ConstString GetSyntheticTypeName() { return ConstString(); }
+
+ typedef std::shared_ptr<SyntheticChildrenFrontEnd> SharedPointer;
+ typedef std::unique_ptr<SyntheticChildrenFrontEnd> AutoPointer;
+
+protected:
+ lldb::ValueObjectSP
+ CreateValueObjectFromExpression(llvm::StringRef name,
+ llvm::StringRef expression,
+ const ExecutionContext &exe_ctx);
+
+ lldb::ValueObjectSP
+ CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address,
+ const ExecutionContext &exe_ctx,
+ CompilerType type);
+
+ lldb::ValueObjectSP CreateValueObjectFromData(llvm::StringRef name,
+ const DataExtractor &data,
+ const ExecutionContext &exe_ctx,
+ CompilerType type);
+
+private:
+ bool m_valid;
+ DISALLOW_COPY_AND_ASSIGN(SyntheticChildrenFrontEnd);
+};
+
+class SyntheticValueProviderFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+ SyntheticValueProviderFrontEnd(ValueObject &backend)
+ : SyntheticChildrenFrontEnd(backend) {}
+
+ ~SyntheticValueProviderFrontEnd() override = default;
+
+ size_t CalculateNumChildren() override { return 0; }
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override { return nullptr; }
+
+ size_t GetIndexOfChildWithName(const ConstString &name) override {
+ return UINT32_MAX;
+ }
+
+ bool Update() override { return false; }
+
+ bool MightHaveChildren() override { return false; }
+
+ lldb::ValueObjectSP GetSyntheticValue() override = 0;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(SyntheticValueProviderFrontEnd);
+};
+
+class SyntheticChildren {
+public:
+ class Flags {
+ public:
+ Flags() : m_flags(lldb::eTypeOptionCascade) {}
+
+ Flags(const Flags &other) : m_flags(other.m_flags) {}
+
+ Flags(uint32_t value) : m_flags(value) {}
+
+ Flags &operator=(const Flags &rhs) {
+ if (&rhs != this)
+ m_flags = rhs.m_flags;
+
+ return *this;
+ }
+
+ Flags &operator=(const uint32_t &rhs) {
+ m_flags = rhs;
+ return *this;
+ }
+
+ Flags &Clear() {
+ m_flags = 0;
+ return *this;
+ }
+
+ bool GetCascades() const {
+ return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade;
+ }
+
+ Flags &SetCascades(bool value = true) {
+ if (value)
+ m_flags |= lldb::eTypeOptionCascade;
+ else
+ m_flags &= ~lldb::eTypeOptionCascade;
+ return *this;
+ }
+
+ bool GetSkipPointers() const {
+ return (m_flags & lldb::eTypeOptionSkipPointers) ==
+ lldb::eTypeOptionSkipPointers;
+ }
+
+ Flags &SetSkipPointers(bool value = true) {
+ if (value)
+ m_flags |= lldb::eTypeOptionSkipPointers;
+ else
+ m_flags &= ~lldb::eTypeOptionSkipPointers;
+ return *this;
+ }
+
+ bool GetSkipReferences() const {
+ return (m_flags & lldb::eTypeOptionSkipReferences) ==
+ lldb::eTypeOptionSkipReferences;
+ }
+
+ Flags &SetSkipReferences(bool value = true) {
+ if (value)
+ m_flags |= lldb::eTypeOptionSkipReferences;
+ else
+ m_flags &= ~lldb::eTypeOptionSkipReferences;
+ return *this;
+ }
+
+ bool GetNonCacheable() const {
+ return (m_flags & lldb::eTypeOptionNonCacheable) ==
+ lldb::eTypeOptionNonCacheable;
+ }
+
+ Flags &SetNonCacheable(bool value = true) {
+ if (value)
+ m_flags |= lldb::eTypeOptionNonCacheable;
+ else
+ m_flags &= ~lldb::eTypeOptionNonCacheable;
+ return *this;
+ }
+
+ uint32_t GetValue() { return m_flags; }
+
+ void SetValue(uint32_t value) { m_flags = value; }
+
+ private:
+ uint32_t m_flags;
+ };
+
+ SyntheticChildren(const Flags &flags) : m_flags(flags) {}
+
+ virtual ~SyntheticChildren() = default;
+
+ bool Cascades() const { return m_flags.GetCascades(); }
+
+ bool SkipsPointers() const { return m_flags.GetSkipPointers(); }
+
+ bool SkipsReferences() const { return m_flags.GetSkipReferences(); }
+
+ bool NonCacheable() const { return m_flags.GetNonCacheable(); }
+
+ void SetCascades(bool value) { m_flags.SetCascades(value); }
+
+ void SetSkipsPointers(bool value) { m_flags.SetSkipPointers(value); }
+
+ void SetSkipsReferences(bool value) { m_flags.SetSkipReferences(value); }
+
+ void SetNonCacheable(bool value) { m_flags.SetNonCacheable(value); }
+
+ uint32_t GetOptions() { return m_flags.GetValue(); }
+
+ void SetOptions(uint32_t value) { m_flags.SetValue(value); }
+
+ virtual bool IsScripted() = 0;
+
+ virtual std::string GetDescription() = 0;
+
+ virtual SyntheticChildrenFrontEnd::AutoPointer
+ GetFrontEnd(ValueObject &backend) = 0;
+
+ typedef std::shared_ptr<SyntheticChildren> SharedPointer;
+
+ uint32_t &GetRevision() { return m_my_revision; }
+
+protected:
+ uint32_t m_my_revision;
+ Flags m_flags;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(SyntheticChildren);
+};
+
+class TypeFilterImpl : public SyntheticChildren {
+ std::vector<std::string> m_expression_paths;
+
+public:
+ TypeFilterImpl(const SyntheticChildren::Flags &flags)
+ : SyntheticChildren(flags), m_expression_paths() {}
+
+ TypeFilterImpl(const SyntheticChildren::Flags &flags,
+ const std::initializer_list<const char *> items)
+ : SyntheticChildren(flags), m_expression_paths() {
+ for (auto path : items)
+ AddExpressionPath(path);
+ }
+
+ void AddExpressionPath(const char *path) {
+ AddExpressionPath(std::string(path));
+ }
+
+ void Clear() { m_expression_paths.clear(); }
+
+ size_t GetCount() const { return m_expression_paths.size(); }
+
+ const char *GetExpressionPathAtIndex(size_t i) const {
+ return m_expression_paths[i].c_str();
+ }
+
+ bool SetExpressionPathAtIndex(size_t i, const char *path) {
+ return SetExpressionPathAtIndex(i, std::string(path));
+ }
+
+ void AddExpressionPath(const std::string &path);
+
+ bool SetExpressionPathAtIndex(size_t i, const std::string &path);
+
+ bool IsScripted() override { return false; }
+
+ std::string GetDescription() override;
+
+ class FrontEnd : public SyntheticChildrenFrontEnd {
+ public:
+ FrontEnd(TypeFilterImpl *flt, ValueObject &backend)
+ : SyntheticChildrenFrontEnd(backend), filter(flt) {}
+
+ ~FrontEnd() override = default;
+
+ size_t CalculateNumChildren() override { return filter->GetCount(); }
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override {
+ if (idx >= filter->GetCount())
+ return lldb::ValueObjectSP();
+ return m_backend.GetSyntheticExpressionPathChild(
+ filter->GetExpressionPathAtIndex(idx), true);
+ }
+
+ bool Update() override { return false; }
+
+ bool MightHaveChildren() override { return filter->GetCount() > 0; }
+
+ size_t GetIndexOfChildWithName(const ConstString &name) override;
+
+ typedef std::shared_ptr<SyntheticChildrenFrontEnd> SharedPointer;
+
+ private:
+ TypeFilterImpl *filter;
+
+ DISALLOW_COPY_AND_ASSIGN(FrontEnd);
+ };
+
+ SyntheticChildrenFrontEnd::AutoPointer
+ GetFrontEnd(ValueObject &backend) override {
+ return SyntheticChildrenFrontEnd::AutoPointer(new FrontEnd(this, backend));
+ }
+
+ typedef std::shared_ptr<TypeFilterImpl> SharedPointer;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(TypeFilterImpl);
+};
+
+class CXXSyntheticChildren : public SyntheticChildren {
+public:
+ typedef std::function<SyntheticChildrenFrontEnd *(CXXSyntheticChildren *,
+ lldb::ValueObjectSP)>
+ CreateFrontEndCallback;
+ CXXSyntheticChildren(const SyntheticChildren::Flags &flags,
+ const char *description, CreateFrontEndCallback callback)
+ : SyntheticChildren(flags), m_create_callback(callback),
+ m_description(description ? description : "") {}
+
+ bool IsScripted() override { return false; }
+
+ std::string GetDescription() override;
+
+ SyntheticChildrenFrontEnd::AutoPointer
+ GetFrontEnd(ValueObject &backend) override {
+ return SyntheticChildrenFrontEnd::AutoPointer(
+ m_create_callback(this, backend.GetSP()));
+ }
+
+protected:
+ CreateFrontEndCallback m_create_callback;
+ std::string m_description;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(CXXSyntheticChildren);
+};
+
#ifndef LLDB_DISABLE_PYTHON
-
- class ScriptedSyntheticChildren : public SyntheticChildren
- {
- std::string m_python_class;
- std::string m_python_code;
- public:
-
- ScriptedSyntheticChildren(const SyntheticChildren::Flags& flags,
- const char* pclass,
- const char* pcode = nullptr) :
- SyntheticChildren(flags),
- m_python_class(),
- m_python_code()
- {
- if (pclass)
- m_python_class = pclass;
- if (pcode)
- m_python_code = pcode;
- }
-
- const char*
- GetPythonClassName ()
- {
- return m_python_class.c_str();
- }
-
- const char*
- GetPythonCode ()
- {
- return m_python_code.c_str();
- }
-
- void
- SetPythonClassName (const char* fname)
- {
- m_python_class.assign(fname);
- m_python_code.clear();
- }
-
- void
- SetPythonCode (const char* script)
- {
- m_python_code.assign(script);
- }
-
- std::string
- GetDescription() override;
-
- bool
- IsScripted() override
- {
- return true;
- }
-
- class FrontEnd : public SyntheticChildrenFrontEnd
- {
- public:
- FrontEnd (std::string pclass,
- ValueObject &backend);
-
- ~FrontEnd() override;
-
- bool
- IsValid ();
-
- size_t
- CalculateNumChildren() override;
-
- size_t
- CalculateNumChildren(uint32_t max) override;
-
- lldb::ValueObjectSP
- GetChildAtIndex(size_t idx) override;
-
- bool
- Update() override;
-
- bool
- MightHaveChildren() override;
-
- size_t
- GetIndexOfChildWithName(const ConstString &name) override;
-
- lldb::ValueObjectSP
- GetSyntheticValue() override;
-
- ConstString
- GetSyntheticTypeName () override;
-
- typedef std::shared_ptr<SyntheticChildrenFrontEnd> SharedPointer;
-
- private:
- std::string m_python_class;
- StructuredData::ObjectSP m_wrapper_sp;
- ScriptInterpreter *m_interpreter;
-
- DISALLOW_COPY_AND_ASSIGN(FrontEnd);
- };
-
- SyntheticChildrenFrontEnd::AutoPointer
- GetFrontEnd(ValueObject &backend) override
- {
- auto synth_ptr = SyntheticChildrenFrontEnd::AutoPointer(new FrontEnd(m_python_class, backend));
- if (synth_ptr && ((FrontEnd*)synth_ptr.get())->IsValid())
- return synth_ptr;
- return nullptr;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ScriptedSyntheticChildren);
- };
+
+class ScriptedSyntheticChildren : public SyntheticChildren {
+ std::string m_python_class;
+ std::string m_python_code;
+
+public:
+ ScriptedSyntheticChildren(const SyntheticChildren::Flags &flags,
+ const char *pclass, const char *pcode = nullptr)
+ : SyntheticChildren(flags), m_python_class(), m_python_code() {
+ if (pclass)
+ m_python_class = pclass;
+ if (pcode)
+ m_python_code = pcode;
+ }
+
+ const char *GetPythonClassName() { return m_python_class.c_str(); }
+
+ const char *GetPythonCode() { return m_python_code.c_str(); }
+
+ void SetPythonClassName(const char *fname) {
+ m_python_class.assign(fname);
+ m_python_code.clear();
+ }
+
+ void SetPythonCode(const char *script) { m_python_code.assign(script); }
+
+ std::string GetDescription() override;
+
+ bool IsScripted() override { return true; }
+
+ class FrontEnd : public SyntheticChildrenFrontEnd {
+ public:
+ FrontEnd(std::string pclass, ValueObject &backend);
+
+ ~FrontEnd() override;
+
+ bool IsValid();
+
+ size_t CalculateNumChildren() override;
+
+ size_t CalculateNumChildren(uint32_t max) override;
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+ bool Update() override;
+
+ bool MightHaveChildren() override;
+
+ size_t GetIndexOfChildWithName(const ConstString &name) override;
+
+ lldb::ValueObjectSP GetSyntheticValue() override;
+
+ ConstString GetSyntheticTypeName() override;
+
+ typedef std::shared_ptr<SyntheticChildrenFrontEnd> SharedPointer;
+
+ private:
+ std::string m_python_class;
+ StructuredData::ObjectSP m_wrapper_sp;
+ ScriptInterpreter *m_interpreter;
+
+ DISALLOW_COPY_AND_ASSIGN(FrontEnd);
+ };
+
+ SyntheticChildrenFrontEnd::AutoPointer
+ GetFrontEnd(ValueObject &backend) override {
+ auto synth_ptr = SyntheticChildrenFrontEnd::AutoPointer(
+ new FrontEnd(m_python_class, backend));
+ if (synth_ptr && ((FrontEnd *)synth_ptr.get())->IsValid())
+ return synth_ptr;
+ return nullptr;
+ }
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(ScriptedSyntheticChildren);
+};
#endif
} // namespace lldb_private
diff --git a/include/lldb/DataFormatters/TypeValidator.h b/include/lldb/DataFormatters/TypeValidator.h
index f1f9a11049db..3c414e39353f 100644
--- a/include/lldb/DataFormatters/TypeValidator.h
+++ b/include/lldb/DataFormatters/TypeValidator.h
@@ -1,4 +1,5 @@
-//===-- TypeValidator.h ------------------------------------------*- C++ -*-===//
+//===-- TypeValidator.h ------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -19,287 +20,188 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-private-enumerations.h"
+#include "lldb/lldb-public.h"
namespace lldb_private {
-
-class TypeValidatorImpl
-{
+
+class TypeValidatorImpl {
public:
- class Flags
- {
- public:
-
- Flags () :
- m_flags (lldb::eTypeOptionCascade)
- {}
-
- Flags (const Flags& other) :
- m_flags (other.m_flags)
- {}
-
- Flags (uint32_t value) :
- m_flags (value)
- {}
-
- Flags&
- operator = (const Flags& rhs)
- {
- if (&rhs != this)
- m_flags = rhs.m_flags;
-
- return *this;
- }
-
- Flags&
- operator = (const uint32_t& rhs)
- {
- m_flags = rhs;
- return *this;
- }
-
- Flags&
- Clear()
- {
- m_flags = 0;
- return *this;
- }
-
- bool
- GetCascades () const
- {
- return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade;
- }
-
- Flags&
- SetCascades (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionCascade;
- else
- m_flags &= ~lldb::eTypeOptionCascade;
- return *this;
- }
-
- bool
- GetSkipPointers () const
- {
- return (m_flags & lldb::eTypeOptionSkipPointers) == lldb::eTypeOptionSkipPointers;
- }
-
- Flags&
- SetSkipPointers (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionSkipPointers;
- else
- m_flags &= ~lldb::eTypeOptionSkipPointers;
- return *this;
- }
-
- bool
- GetSkipReferences () const
- {
- return (m_flags & lldb::eTypeOptionSkipReferences) == lldb::eTypeOptionSkipReferences;
- }
-
- Flags&
- SetSkipReferences (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionSkipReferences;
- else
- m_flags &= ~lldb::eTypeOptionSkipReferences;
- return *this;
- }
-
- bool
- GetNonCacheable () const
- {
- return (m_flags & lldb::eTypeOptionNonCacheable) == lldb::eTypeOptionNonCacheable;
- }
-
- Flags&
- SetNonCacheable (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionNonCacheable;
- else
- m_flags &= ~lldb::eTypeOptionNonCacheable;
- return *this;
- }
-
- uint32_t
- GetValue ()
- {
- return m_flags;
- }
-
- void
- SetValue (uint32_t value)
- {
- m_flags = value;
- }
-
- private:
- uint32_t m_flags;
- };
-
- TypeValidatorImpl (const Flags& flags = Flags());
-
- typedef std::shared_ptr<TypeValidatorImpl> SharedPointer;
-
- virtual ~TypeValidatorImpl ();
-
- bool
- Cascades () const
- {
- return m_flags.GetCascades();
- }
- bool
- SkipsPointers () const
- {
- return m_flags.GetSkipPointers();
+ class Flags {
+ public:
+ Flags() : m_flags(lldb::eTypeOptionCascade) {}
+
+ Flags(const Flags &other) : m_flags(other.m_flags) {}
+
+ Flags(uint32_t value) : m_flags(value) {}
+
+ Flags &operator=(const Flags &rhs) {
+ if (&rhs != this)
+ m_flags = rhs.m_flags;
+
+ return *this;
}
- bool
- SkipsReferences () const
- {
- return m_flags.GetSkipReferences();
+
+ Flags &operator=(const uint32_t &rhs) {
+ m_flags = rhs;
+ return *this;
}
- bool
- NonCacheable () const
- {
- return m_flags.GetNonCacheable();
+
+ Flags &Clear() {
+ m_flags = 0;
+ return *this;
}
-
- void
- SetCascades (bool value)
- {
- m_flags.SetCascades(value);
+
+ bool GetCascades() const {
+ return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade;
}
-
- void
- SetSkipsPointers (bool value)
- {
- m_flags.SetSkipPointers(value);
+
+ Flags &SetCascades(bool value = true) {
+ if (value)
+ m_flags |= lldb::eTypeOptionCascade;
+ else
+ m_flags &= ~lldb::eTypeOptionCascade;
+ return *this;
}
-
- void
- SetSkipsReferences (bool value)
- {
- m_flags.SetSkipReferences(value);
+
+ bool GetSkipPointers() const {
+ return (m_flags & lldb::eTypeOptionSkipPointers) ==
+ lldb::eTypeOptionSkipPointers;
}
-
- void
- SetNonCacheable (bool value)
- {
- m_flags.SetNonCacheable(value);
+
+ Flags &SetSkipPointers(bool value = true) {
+ if (value)
+ m_flags |= lldb::eTypeOptionSkipPointers;
+ else
+ m_flags &= ~lldb::eTypeOptionSkipPointers;
+ return *this;
}
-
- uint32_t
- GetOptions ()
- {
- return m_flags.GetValue();
+
+ bool GetSkipReferences() const {
+ return (m_flags & lldb::eTypeOptionSkipReferences) ==
+ lldb::eTypeOptionSkipReferences;
}
-
- void
- SetOptions (uint32_t value)
- {
- m_flags.SetValue(value);
+
+ Flags &SetSkipReferences(bool value = true) {
+ if (value)
+ m_flags |= lldb::eTypeOptionSkipReferences;
+ else
+ m_flags &= ~lldb::eTypeOptionSkipReferences;
+ return *this;
}
-
- uint32_t&
- GetRevision ()
- {
- return m_my_revision;
+
+ bool GetNonCacheable() const {
+ return (m_flags & lldb::eTypeOptionNonCacheable) ==
+ lldb::eTypeOptionNonCacheable;
}
-
- enum class Type
- {
- eTypeUnknown,
- eTypeCXX
- };
-
- struct ValidationResult {
- TypeValidatorResult m_result;
- std::string m_message;
- };
-
- virtual Type
- GetType ()
- {
- return Type::eTypeUnknown;
+
+ Flags &SetNonCacheable(bool value = true) {
+ if (value)
+ m_flags |= lldb::eTypeOptionNonCacheable;
+ else
+ m_flags &= ~lldb::eTypeOptionNonCacheable;
+ return *this;
}
-
- // we are using a ValueObject* instead of a ValueObjectSP because we do not need to hold on to this for
- // extended periods of time and we trust the ValueObject to stay around for as long as it is required
- // for us to generate its value
- virtual ValidationResult
- FormatObject (ValueObject *valobj) const = 0;
-
- virtual std::string
- GetDescription() = 0;
-
- static ValidationResult
- Success ();
-
- static ValidationResult
- Failure (std::string message);
-
+
+ uint32_t GetValue() { return m_flags; }
+
+ void SetValue(uint32_t value) { m_flags = value; }
+
+ private:
+ uint32_t m_flags;
+ };
+
+ TypeValidatorImpl(const Flags &flags = Flags());
+
+ typedef std::shared_ptr<TypeValidatorImpl> SharedPointer;
+
+ virtual ~TypeValidatorImpl();
+
+ bool Cascades() const { return m_flags.GetCascades(); }
+ bool SkipsPointers() const { return m_flags.GetSkipPointers(); }
+ bool SkipsReferences() const { return m_flags.GetSkipReferences(); }
+ bool NonCacheable() const { return m_flags.GetNonCacheable(); }
+
+ void SetCascades(bool value) { m_flags.SetCascades(value); }
+
+ void SetSkipsPointers(bool value) { m_flags.SetSkipPointers(value); }
+
+ void SetSkipsReferences(bool value) { m_flags.SetSkipReferences(value); }
+
+ void SetNonCacheable(bool value) { m_flags.SetNonCacheable(value); }
+
+ uint32_t GetOptions() { return m_flags.GetValue(); }
+
+ void SetOptions(uint32_t value) { m_flags.SetValue(value); }
+
+ uint32_t &GetRevision() { return m_my_revision; }
+
+ enum class Type { eTypeUnknown, eTypeCXX };
+
+ struct ValidationResult {
+ TypeValidatorResult m_result;
+ std::string m_message;
+ };
+
+ virtual Type GetType() { return Type::eTypeUnknown; }
+
+ // we are using a ValueObject* instead of a ValueObjectSP because we do not
+ // need to hold on to this for
+ // extended periods of time and we trust the ValueObject to stay around for as
+ // long as it is required
+ // for us to generate its value
+ virtual ValidationResult FormatObject(ValueObject *valobj) const = 0;
+
+ virtual std::string GetDescription() = 0;
+
+ static ValidationResult Success();
+
+ static ValidationResult Failure(std::string message);
+
protected:
- Flags m_flags;
- uint32_t m_my_revision;
-
+ Flags m_flags;
+ uint32_t m_my_revision;
+
private:
- DISALLOW_COPY_AND_ASSIGN(TypeValidatorImpl);
+ DISALLOW_COPY_AND_ASSIGN(TypeValidatorImpl);
};
-
-class TypeValidatorImpl_CXX : public TypeValidatorImpl
-{
+
+class TypeValidatorImpl_CXX : public TypeValidatorImpl {
public:
- typedef std::function<TypeValidatorImpl::ValidationResult(ValueObject* valobj)> ValidatorFunction;
-
- TypeValidatorImpl_CXX (ValidatorFunction f, std::string d, const TypeValidatorImpl::Flags& flags = Flags());
-
- typedef std::shared_ptr<TypeValidatorImpl_CXX> SharedPointer;
-
- ~TypeValidatorImpl_CXX() override;
-
- ValidatorFunction
- GetValidatorFunction () const
- {
- return m_validator_function;
- }
-
- void
- SetValidatorFunction (ValidatorFunction f)
- {
- m_validator_function = f;
- }
-
- TypeValidatorImpl::Type
- GetType() override
- {
- return TypeValidatorImpl::Type::eTypeCXX;
- }
-
- ValidationResult
- FormatObject(ValueObject *valobj) const override;
-
- std::string
- GetDescription() override;
-
+ typedef std::function<TypeValidatorImpl::ValidationResult(
+ ValueObject *valobj)>
+ ValidatorFunction;
+
+ TypeValidatorImpl_CXX(ValidatorFunction f, std::string d,
+ const TypeValidatorImpl::Flags &flags = Flags());
+
+ typedef std::shared_ptr<TypeValidatorImpl_CXX> SharedPointer;
+
+ ~TypeValidatorImpl_CXX() override;
+
+ ValidatorFunction GetValidatorFunction() const {
+ return m_validator_function;
+ }
+
+ void SetValidatorFunction(ValidatorFunction f) { m_validator_function = f; }
+
+ TypeValidatorImpl::Type GetType() override {
+ return TypeValidatorImpl::Type::eTypeCXX;
+ }
+
+ ValidationResult FormatObject(ValueObject *valobj) const override;
+
+ std::string GetDescription() override;
+
protected:
- std::string m_description;
- ValidatorFunction m_validator_function;
-
+ std::string m_description;
+ ValidatorFunction m_validator_function;
+
private:
- DISALLOW_COPY_AND_ASSIGN(TypeValidatorImpl_CXX);
+ DISALLOW_COPY_AND_ASSIGN(TypeValidatorImpl_CXX);
};
-
} // namespace lldb_private
#endif // lldb_TypeValidator_h_
diff --git a/include/lldb/DataFormatters/ValueObjectPrinter.h b/include/lldb/DataFormatters/ValueObjectPrinter.h
index c7591b019685..f0d09ac01632 100644
--- a/include/lldb/DataFormatters/ValueObjectPrinter.h
+++ b/include/lldb/DataFormatters/ValueObjectPrinter.h
@@ -1,4 +1,5 @@
-//===-- ValueObjectPrinter.h ---------------------------------------*- C++ -*-===//
+//===-- ValueObjectPrinter.h ---------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -28,183 +29,137 @@
namespace lldb_private {
-class ValueObjectPrinter
-{
+class ValueObjectPrinter {
public:
+ ValueObjectPrinter(ValueObject *valobj, Stream *s);
+
+ ValueObjectPrinter(ValueObject *valobj, Stream *s,
+ const DumpValueObjectOptions &options);
+
+ ~ValueObjectPrinter() {}
+
+ bool PrintValueObject();
- ValueObjectPrinter (ValueObject* valobj,
- Stream* s);
-
- ValueObjectPrinter (ValueObject* valobj,
- Stream* s,
- const DumpValueObjectOptions& options);
-
- ~ValueObjectPrinter () {}
-
- bool
- PrintValueObject ();
-
protected:
- typedef std::set<uint64_t> InstancePointersSet;
- typedef std::shared_ptr<InstancePointersSet> InstancePointersSetSP;
-
- InstancePointersSetSP m_printed_instance_pointers;
-
- // only this class (and subclasses, if any) should ever be concerned with
- // the depth mechanism
- ValueObjectPrinter (ValueObject* valobj,
- Stream* s,
- const DumpValueObjectOptions& options,
- const DumpValueObjectOptions::PointerDepth& ptr_depth,
- uint32_t curr_depth,
- InstancePointersSetSP printed_instance_pointers);
-
- // we should actually be using delegating constructors here
- // but some versions of GCC still have trouble with those
- void
- Init (ValueObject* valobj,
- Stream* s,
- const DumpValueObjectOptions& options,
- const DumpValueObjectOptions::PointerDepth& ptr_depth,
- uint32_t curr_depth,
- InstancePointersSetSP printed_instance_pointers);
-
- bool
- GetMostSpecializedValue ();
-
- const char*
- GetDescriptionForDisplay ();
-
- const char*
- GetRootNameForDisplay (const char* if_fail = nullptr);
-
- bool
- ShouldPrintValueObject ();
-
- bool
- ShouldPrintValidation ();
-
- bool
- IsNil ();
-
- bool
- IsUninitialized ();
-
- bool
- IsPtr ();
-
- bool
- IsRef ();
-
- bool
- IsInstancePointer ();
-
- bool
- IsAggregate ();
-
- bool
- PrintValidationMarkerIfNeeded ();
-
- bool
- PrintValidationErrorIfNeeded ();
-
- bool
- PrintLocationIfNeeded ();
-
- void
- PrintDecl ();
-
- bool
- CheckScopeIfNeeded ();
-
- bool
- ShouldPrintEmptyBrackets (bool value_printed,
- bool summary_printed);
-
- TypeSummaryImpl*
- GetSummaryFormatter (bool null_if_omitted = true);
-
- void
- GetValueSummaryError (std::string& value,
- std::string& summary,
- std::string& error);
-
- bool
- PrintValueAndSummaryIfNeeded (bool& value_printed,
- bool& summary_printed);
-
- bool
- PrintObjectDescriptionIfNeeded (bool value_printed,
- bool summary_printed);
-
- bool
- ShouldPrintChildren (bool is_failed_description,
- DumpValueObjectOptions::PointerDepth& curr_ptr_depth);
-
- bool
- ShouldExpandEmptyAggregates ();
-
- ValueObject*
- GetValueObjectForChildrenGeneration ();
-
- void
- PrintChildrenPreamble ();
-
- void
- PrintChildrenPostamble (bool print_dotdotdot);
-
- lldb::ValueObjectSP
- GenerateChild (ValueObject* synth_valobj,
- size_t idx);
-
- void
- PrintChild (lldb::ValueObjectSP child_sp,
- const DumpValueObjectOptions::PointerDepth& curr_ptr_depth);
-
- uint32_t
- GetMaxNumChildrenToPrint (bool& print_dotdotdot);
-
- void
- PrintChildren (bool value_printed,
- bool summary_printed,
- const DumpValueObjectOptions::PointerDepth& curr_ptr_depth);
-
- void
- PrintChildrenIfNeeded (bool value_printed,
- bool summary_printed);
-
- bool
- PrintChildrenOneLiner (bool hide_names);
-
+ typedef std::set<uint64_t> InstancePointersSet;
+ typedef std::shared_ptr<InstancePointersSet> InstancePointersSetSP;
+
+ InstancePointersSetSP m_printed_instance_pointers;
+
+ // only this class (and subclasses, if any) should ever be concerned with
+ // the depth mechanism
+ ValueObjectPrinter(ValueObject *valobj, Stream *s,
+ const DumpValueObjectOptions &options,
+ const DumpValueObjectOptions::PointerDepth &ptr_depth,
+ uint32_t curr_depth,
+ InstancePointersSetSP printed_instance_pointers);
+
+ // we should actually be using delegating constructors here
+ // but some versions of GCC still have trouble with those
+ void Init(ValueObject *valobj, Stream *s,
+ const DumpValueObjectOptions &options,
+ const DumpValueObjectOptions::PointerDepth &ptr_depth,
+ uint32_t curr_depth,
+ InstancePointersSetSP printed_instance_pointers);
+
+ bool GetMostSpecializedValue();
+
+ const char *GetDescriptionForDisplay();
+
+ const char *GetRootNameForDisplay(const char *if_fail = nullptr);
+
+ bool ShouldPrintValueObject();
+
+ bool ShouldPrintValidation();
+
+ bool IsNil();
+
+ bool IsUninitialized();
+
+ bool IsPtr();
+
+ bool IsRef();
+
+ bool IsInstancePointer();
+
+ bool IsAggregate();
+
+ bool PrintValidationMarkerIfNeeded();
+
+ bool PrintValidationErrorIfNeeded();
+
+ bool PrintLocationIfNeeded();
+
+ void PrintDecl();
+
+ bool CheckScopeIfNeeded();
+
+ bool ShouldPrintEmptyBrackets(bool value_printed, bool summary_printed);
+
+ TypeSummaryImpl *GetSummaryFormatter(bool null_if_omitted = true);
+
+ void GetValueSummaryError(std::string &value, std::string &summary,
+ std::string &error);
+
+ bool PrintValueAndSummaryIfNeeded(bool &value_printed, bool &summary_printed);
+
+ bool PrintObjectDescriptionIfNeeded(bool value_printed, bool summary_printed);
+
+ bool
+ ShouldPrintChildren(bool is_failed_description,
+ DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
+
+ bool ShouldExpandEmptyAggregates();
+
+ ValueObject *GetValueObjectForChildrenGeneration();
+
+ void PrintChildrenPreamble();
+
+ void PrintChildrenPostamble(bool print_dotdotdot);
+
+ lldb::ValueObjectSP GenerateChild(ValueObject *synth_valobj, size_t idx);
+
+ void PrintChild(lldb::ValueObjectSP child_sp,
+ const DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
+
+ uint32_t GetMaxNumChildrenToPrint(bool &print_dotdotdot);
+
+ void
+ PrintChildren(bool value_printed, bool summary_printed,
+ const DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
+
+ void PrintChildrenIfNeeded(bool value_printed, bool summary_printed);
+
+ bool PrintChildrenOneLiner(bool hide_names);
+
private:
-
- ValueObject *m_orig_valobj;
- ValueObject *m_valobj;
- Stream *m_stream;
- DumpValueObjectOptions m_options;
- Flags m_type_flags;
- CompilerType m_compiler_type;
- DumpValueObjectOptions::PointerDepth m_ptr_depth;
- uint32_t m_curr_depth;
- LazyBool m_should_print;
- LazyBool m_is_nil;
- LazyBool m_is_uninit;
- LazyBool m_is_ptr;
- LazyBool m_is_ref;
- LazyBool m_is_aggregate;
- LazyBool m_is_instance_ptr;
- std::pair<TypeSummaryImpl*,bool> m_summary_formatter;
- std::string m_value;
- std::string m_summary;
- std::string m_error;
- bool m_val_summary_ok;
- std::pair<TypeValidatorResult,std::string> m_validation;
-
- friend struct StringSummaryFormat;
-
- DISALLOW_COPY_AND_ASSIGN(ValueObjectPrinter);
+ ValueObject *m_orig_valobj;
+ ValueObject *m_valobj;
+ Stream *m_stream;
+ DumpValueObjectOptions m_options;
+ Flags m_type_flags;
+ CompilerType m_compiler_type;
+ DumpValueObjectOptions::PointerDepth m_ptr_depth;
+ uint32_t m_curr_depth;
+ LazyBool m_should_print;
+ LazyBool m_is_nil;
+ LazyBool m_is_uninit;
+ LazyBool m_is_ptr;
+ LazyBool m_is_ref;
+ LazyBool m_is_aggregate;
+ LazyBool m_is_instance_ptr;
+ std::pair<TypeSummaryImpl *, bool> m_summary_formatter;
+ std::string m_value;
+ std::string m_summary;
+ std::string m_error;
+ bool m_val_summary_ok;
+ std::pair<TypeValidatorResult, std::string> m_validation;
+
+ friend struct StringSummaryFormat;
+
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectPrinter);
};
-
+
} // namespace lldb_private
-#endif // lldb_ValueObjectPrinter_h_
+#endif // lldb_ValueObjectPrinter_h_
diff --git a/include/lldb/DataFormatters/VectorIterator.h b/include/lldb/DataFormatters/VectorIterator.h
index 0bacd51ca63e..38bcfe9fe4a8 100644
--- a/include/lldb/DataFormatters/VectorIterator.h
+++ b/include/lldb/DataFormatters/VectorIterator.h
@@ -1,4 +1,5 @@
-//===-- VectorIterator.h ----------------------------------------------*- C++ -*-===//
+//===-- VectorIterator.h ----------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,36 +17,29 @@
#include "lldb/Target/ExecutionContext.h"
namespace lldb_private {
- namespace formatters
- {
- class VectorIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd
- {
- public:
- VectorIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp,
- ConstString item_name);
-
- size_t
- CalculateNumChildren() override;
-
- lldb::ValueObjectSP
- GetChildAtIndex(size_t idx) override;
-
- bool
- Update() override;
-
- bool
- MightHaveChildren() override;
-
- size_t
- GetIndexOfChildWithName(const ConstString &name) override;
-
- private:
- ExecutionContextRef m_exe_ctx_ref;
- ConstString m_item_name;
- lldb::ValueObjectSP m_item_sp;
- };
-
- } // namespace formatters
+namespace formatters {
+class VectorIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+ VectorIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp,
+ ConstString item_name);
+
+ size_t CalculateNumChildren() override;
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+ bool Update() override;
+
+ bool MightHaveChildren() override;
+
+ size_t GetIndexOfChildWithName(const ConstString &name) override;
+
+private:
+ ExecutionContextRef m_exe_ctx_ref;
+ ConstString m_item_name;
+ lldb::ValueObjectSP m_item_sp;
+};
+
+} // namespace formatters
} // namespace lldb_private
#endif // liblldb_CF_h_
diff --git a/include/lldb/DataFormatters/VectorType.h b/include/lldb/DataFormatters/VectorType.h
index 56d0c6d90ecd..4ca0c4519f9f 100644
--- a/include/lldb/DataFormatters/VectorType.h
+++ b/include/lldb/DataFormatters/VectorType.h
@@ -13,16 +13,13 @@
#include "lldb/lldb-forward.h"
namespace lldb_private {
- namespace formatters
- {
- bool
- VectorTypeSummaryProvider (ValueObject&,
- Stream&,
- const TypeSummaryOptions&);
+namespace formatters {
+bool VectorTypeSummaryProvider(ValueObject &, Stream &,
+ const TypeSummaryOptions &);
- SyntheticChildrenFrontEnd*
- VectorTypeSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
- } // namespace formatters
+SyntheticChildrenFrontEnd *
+VectorTypeSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP);
+} // namespace formatters
} // namespace lldb_private
#endif // liblldb_VectorType_h_
diff --git a/include/lldb/Expression/DWARFExpression.h b/include/lldb/Expression/DWARFExpression.h
index d984a419c5c9..ea3f5cc03db1 100644
--- a/include/lldb/Expression/DWARFExpression.h
+++ b/include/lldb/Expression/DWARFExpression.h
@@ -12,6 +12,7 @@
#include "lldb/Core/Address.h"
#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/Disassembler.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Scalar.h"
#include "lldb/lldb-private.h"
@@ -20,17 +21,16 @@
class DWARFCompileUnit;
namespace lldb_private {
-
+
class ClangExpressionDeclMap;
class ClangExpressionVariable;
class ClangExpressionVariableList;
-
//----------------------------------------------------------------------
/// @class DWARFExpression DWARFExpression.h "lldb/Expression/DWARFExpression.h"
/// @brief Encapsulates a DWARF location expression and interprets it.
///
-/// DWARF location expressions are used in two ways by LLDB. The first
+/// DWARF location expressions are used in two ways by LLDB. The first
/// use is to find entities specified in the debug information, since
/// their locations are specified in precisely this language. The second
/// is to interpret expressions without having to run the target in cases
@@ -39,458 +39,406 @@ class ClangExpressionVariableList;
/// a single DWARF location expression or a location list and interprets
/// it.
//----------------------------------------------------------------------
-class DWARFExpression
-{
+class DWARFExpression {
public:
- enum LocationListFormat : uint8_t
- {
- NonLocationList, // Not a location list
- RegularLocationList, // Location list format used in non-split dwarf files
- SplitDwarfLocationList, // Location list format used in split dwarf files
- };
-
- //------------------------------------------------------------------
- /// Constructor
- //------------------------------------------------------------------
- explicit DWARFExpression(DWARFCompileUnit* dwarf_cu);
-
- //------------------------------------------------------------------
- /// Constructor
- ///
- /// @param[in] data
- /// A data extractor configured to read the DWARF location expression's
- /// bytecode.
- ///
- /// @param[in] data_offset
- /// The offset of the location expression in the extractor.
- ///
- /// @param[in] data_length
- /// The byte length of the location expression.
- //------------------------------------------------------------------
- DWARFExpression(lldb::ModuleSP module,
- const DataExtractor& data,
- DWARFCompileUnit* dwarf_cu,
- lldb::offset_t data_offset,
- lldb::offset_t data_length);
-
- //------------------------------------------------------------------
- /// Copy constructor
- //------------------------------------------------------------------
- DWARFExpression(const DWARFExpression& rhs);
-
- //------------------------------------------------------------------
- /// Destructor
- //------------------------------------------------------------------
- virtual
- ~DWARFExpression();
-
- //------------------------------------------------------------------
- /// Print the description of the expression to a stream
- ///
- /// @param[in] s
- /// The stream to print to.
- ///
- /// @param[in] level
- /// The level of verbosity to use.
- ///
- /// @param[in] location_list_base_addr
- /// If this is a location list based expression, this is the
- /// address of the object that owns it. NOTE: this value is
- /// different from the DWARF version of the location list base
- /// address which is compile unit relative. This base address
- /// is the address of the object that owns the location list.
- ///
- /// @param[in] abi
- /// An optional ABI plug-in that can be used to resolve register
- /// names.
- //------------------------------------------------------------------
- void
- GetDescription (Stream *s,
- lldb::DescriptionLevel level,
- lldb::addr_t location_list_base_addr,
- ABI *abi) const;
-
- //------------------------------------------------------------------
- /// Return true if the location expression contains data
- //------------------------------------------------------------------
- bool
- IsValid() const;
-
- //------------------------------------------------------------------
- /// Return true if a location list was provided
- //------------------------------------------------------------------
- bool
- IsLocationList() const;
-
- //------------------------------------------------------------------
- /// Search for a load address in the location list
- ///
- /// @param[in] process
- /// The process to use when resolving the load address
- ///
- /// @param[in] addr
- /// The address to resolve
- ///
- /// @return
- /// True if IsLocationList() is true and the address was found;
- /// false otherwise.
- //------------------------------------------------------------------
-// bool
-// LocationListContainsLoadAddress (Process* process, const Address &addr) const;
-//
- bool
- LocationListContainsAddress (lldb::addr_t loclist_base_addr, lldb::addr_t addr) const;
-
- //------------------------------------------------------------------
- /// If a location is not a location list, return true if the location
- /// contains a DW_OP_addr () opcode in the stream that matches \a
- /// file_addr. If file_addr is LLDB_INVALID_ADDRESS, the this
- /// function will return true if the variable there is any DW_OP_addr
- /// in a location that (yet still is NOT a location list). This helps
- /// us detect if a variable is a global or static variable since
- /// there is no other indication from DWARF debug info.
- ///
- /// @param[in] op_addr_idx
- /// The DW_OP_addr index to retrieve in case there is more than
- /// one DW_OP_addr opcode in the location byte stream.
- ///
- /// @param[out] error
- /// If the location stream contains unknown DW_OP opcodes or the
- /// data is missing, \a error will be set to \b true.
- ///
- /// @return
- /// LLDB_INVALID_ADDRESS if the location doesn't contain a
- /// DW_OP_addr for \a op_addr_idx, otherwise a valid file address
- //------------------------------------------------------------------
- lldb::addr_t
- GetLocation_DW_OP_addr (uint32_t op_addr_idx, bool &error) const;
-
- bool
- Update_DW_OP_addr (lldb::addr_t file_addr);
-
- bool
- ContainsThreadLocalStorage() const;
-
- bool
- LinkThreadLocalStorage(lldb::ModuleSP new_module_sp,
- std::function<lldb::addr_t(lldb::addr_t file_addr)> const &link_address_callback);
-
- //------------------------------------------------------------------
- /// Make the expression parser read its location information from a
- /// given data source. Does not change the offset and length
- ///
- /// @param[in] data
- /// A data extractor configured to read the DWARF location expression's
- /// bytecode.
- //------------------------------------------------------------------
- void
- SetOpcodeData(const DataExtractor& data);
-
- //------------------------------------------------------------------
- /// Make the expression parser read its location information from a
- /// given data source
- ///
- /// @param[in] module_sp
- /// The module that defines the DWARF expression.
- ///
- /// @param[in] data
- /// A data extractor configured to read the DWARF location expression's
- /// bytecode.
- ///
- /// @param[in] data_offset
- /// The offset of the location expression in the extractor.
- ///
- /// @param[in] data_length
- /// The byte length of the location expression.
- //------------------------------------------------------------------
- void
- SetOpcodeData(lldb::ModuleSP module_sp, const DataExtractor& data, lldb::offset_t data_offset, lldb::offset_t data_length);
-
- //------------------------------------------------------------------
- /// Copy the DWARF location expression into a local buffer.
- ///
- /// It is a good idea to copy the data so we don't keep the entire
- /// object file worth of data around just for a few bytes of location
- /// expression. LLDB typically will mmap the entire contents of debug
- /// information files, and if we use SetOpcodeData, it will get a
- /// shared reference to all of this data for the and cause the object
- /// file to have to stay around. Even worse, a very very large ".a"
- /// that contains one or more .o files could end up being referenced.
- /// Location lists are typically small so even though we are copying
- /// the data, it shouldn't amount to that much for the variables we
- /// end up parsing.
- ///
- /// @param[in] module_sp
- /// The module that defines the DWARF expression.
- ///
- /// @param[in] data
- /// A data extractor configured to read and copy the DWARF
- /// location expression's bytecode.
- ///
- /// @param[in] data_offset
- /// The offset of the location expression in the extractor.
- ///
- /// @param[in] data_length
- /// The byte length of the location expression.
- //------------------------------------------------------------------
- void
- CopyOpcodeData (lldb::ModuleSP module_sp,
- const DataExtractor& data,
- lldb::offset_t data_offset,
- lldb::offset_t data_length);
-
- void
- CopyOpcodeData (const void *data,
- lldb::offset_t data_length,
- lldb::ByteOrder byte_order,
- uint8_t addr_byte_size);
-
- void
- CopyOpcodeData (uint64_t const_value,
- lldb::offset_t const_value_byte_size,
- uint8_t addr_byte_size);
-
-
- //------------------------------------------------------------------
- /// Tells the expression that it refers to a location list.
- ///
- /// @param[in] slide
- /// This value should be a slide that is applied to any values
- /// in the location list data so the values become zero based
- /// offsets into the object that owns the location list. We need
- /// to make location lists relative to the objects that own them
- /// so we can relink addresses on the fly.
- //------------------------------------------------------------------
- void
- SetLocationListSlide (lldb::addr_t slide);
-
- //------------------------------------------------------------------
- /// Return the call-frame-info style register kind
- //------------------------------------------------------------------
- int
- GetRegisterKind ();
-
- //------------------------------------------------------------------
- /// Set the call-frame-info style register kind
- ///
- /// @param[in] reg_kind
- /// The register kind.
- //------------------------------------------------------------------
- void
- SetRegisterKind (lldb::RegisterKind reg_kind);
-
- //------------------------------------------------------------------
- /// Wrapper for the static evaluate function that accepts an
- /// ExecutionContextScope instead of an ExecutionContext and uses
- /// member variables to populate many operands
- //------------------------------------------------------------------
- bool
- Evaluate (ExecutionContextScope *exe_scope,
- ClangExpressionVariableList *expr_locals,
- ClangExpressionDeclMap *decl_map,
- lldb::addr_t loclist_base_load_addr,
- const Value* initial_value_ptr,
- const Value* object_address_ptr,
- Value& result,
- Error *error_ptr) const;
-
- //------------------------------------------------------------------
- /// Wrapper for the static evaluate function that uses member
- /// variables to populate many operands
- //------------------------------------------------------------------
- bool
- Evaluate (ExecutionContext *exe_ctx,
- ClangExpressionVariableList *expr_locals,
- ClangExpressionDeclMap *decl_map,
- RegisterContext *reg_ctx,
- lldb::addr_t loclist_base_load_addr,
- const Value* initial_value_ptr,
- const Value* object_address_ptr,
- Value& result,
- Error *error_ptr) const;
-
- //------------------------------------------------------------------
- /// Evaluate a DWARF location expression in a particular context
- ///
- /// @param[in] exe_ctx
- /// The execution context in which to evaluate the location
- /// expression. The location expression may access the target's
- /// memory, especially if it comes from the expression parser.
- ///
- /// @param[in] opcode_ctx
- /// The module which defined the expression.
- ///
- /// @param[in] opcodes
- /// This is a static method so the opcodes need to be provided
- /// explicitly.
- ///
- /// @param[in] expr_locals
- /// If the location expression was produced by the expression parser,
- /// the list of local variables referenced by the DWARF expression.
- /// This list should already have been populated during parsing;
- /// the DWARF expression refers to variables by index. Can be NULL if
- /// the location expression uses no locals.
- ///
- /// @param[in] decl_map
- /// If the location expression was produced by the expression parser,
- /// the list of external variables referenced by the location
- /// expression. Can be NULL if the location expression uses no
- /// external variables.
- ///
- /// @param[in] reg_ctx
- /// An optional parameter which provides a RegisterContext for use
- /// when evaluating the expression (i.e. for fetching register values).
- /// Normally this will come from the ExecutionContext's StackFrame but
- /// in the case where an expression needs to be evaluated while building
- /// the stack frame list, this short-cut is available.
- ///
- /// @param[in] offset
- /// The offset of the location expression in the data extractor.
- ///
- /// @param[in] length
- /// The length in bytes of the location expression.
- ///
- /// @param[in] reg_set
- /// The call-frame-info style register kind.
- ///
- /// @param[in] initial_value_ptr
- /// A value to put on top of the interpreter stack before evaluating
- /// the expression, if the expression is parametrized. Can be NULL.
- ///
- /// @param[in] result
- /// A value into which the result of evaluating the expression is
- /// to be placed.
- ///
- /// @param[in] error_ptr
- /// If non-NULL, used to report errors in expression evaluation.
- ///
- /// @return
- /// True on success; false otherwise. If error_ptr is non-NULL,
- /// details of the failure are provided through it.
- //------------------------------------------------------------------
- static bool
- Evaluate (ExecutionContext *exe_ctx,
- ClangExpressionVariableList *expr_locals,
- ClangExpressionDeclMap *decl_map,
- RegisterContext *reg_ctx,
- lldb::ModuleSP opcode_ctx,
- const DataExtractor& opcodes,
- DWARFCompileUnit* dwarf_cu,
- const lldb::offset_t offset,
- const lldb::offset_t length,
- const lldb::RegisterKind reg_set,
- const Value* initial_value_ptr,
- const Value* object_address_ptr,
- Value& result,
- Error *error_ptr);
-
- //------------------------------------------------------------------
- /// Loads a ClangExpressionVariableList into the object
- ///
- /// @param[in] locals
- /// If non-NULL, the list of locals used by this expression.
- /// See Evaluate().
- //------------------------------------------------------------------
- void
- SetExpressionLocalVariableList (ClangExpressionVariableList *locals);
-
- //------------------------------------------------------------------
- /// Loads a ClangExpressionDeclMap into the object
- ///
- /// @param[in] locals
- /// If non-NULL, the list of external variables used by this
- /// expression. See Evaluate().
- //------------------------------------------------------------------
- void
- SetExpressionDeclMap (ClangExpressionDeclMap *decl_map);
-
- bool
- GetExpressionData (DataExtractor &data) const
- {
- data = m_data;
- return data.GetByteSize() > 0;
- }
-
- bool
- DumpLocationForAddress (Stream *s,
- lldb::DescriptionLevel level,
- lldb::addr_t loclist_base_load_addr,
- lldb::addr_t address,
- ABI *abi);
-
- static size_t
- LocationListSize(const DWARFCompileUnit* dwarf_cu,
- const DataExtractor& debug_loc_data,
- lldb::offset_t offset);
-
- static bool
- PrintDWARFExpression(Stream &s,
- const DataExtractor& data,
- int address_size,
- int dwarf_ref_size,
- bool location_expression);
-
- static void
- PrintDWARFLocationList(Stream &s,
- const DWARFCompileUnit* cu,
- const DataExtractor& debug_loc_data,
- lldb::offset_t offset);
+ enum LocationListFormat : uint8_t {
+ NonLocationList, // Not a location list
+ RegularLocationList, // Location list format used in non-split dwarf files
+ SplitDwarfLocationList, // Location list format used in split dwarf files
+ };
+
+ //------------------------------------------------------------------
+ /// Constructor
+ //------------------------------------------------------------------
+ explicit DWARFExpression(DWARFCompileUnit *dwarf_cu);
+
+ //------------------------------------------------------------------
+ /// Constructor
+ ///
+ /// @param[in] data
+ /// A data extractor configured to read the DWARF location expression's
+ /// bytecode.
+ ///
+ /// @param[in] data_offset
+ /// The offset of the location expression in the extractor.
+ ///
+ /// @param[in] data_length
+ /// The byte length of the location expression.
+ //------------------------------------------------------------------
+ DWARFExpression(lldb::ModuleSP module, const DataExtractor &data,
+ DWARFCompileUnit *dwarf_cu, lldb::offset_t data_offset,
+ lldb::offset_t data_length);
+
+ //------------------------------------------------------------------
+ /// Copy constructor
+ //------------------------------------------------------------------
+ DWARFExpression(const DWARFExpression &rhs);
+
+ //------------------------------------------------------------------
+ /// Destructor
+ //------------------------------------------------------------------
+ virtual ~DWARFExpression();
+
+ //------------------------------------------------------------------
+ /// Print the description of the expression to a stream
+ ///
+ /// @param[in] s
+ /// The stream to print to.
+ ///
+ /// @param[in] level
+ /// The level of verbosity to use.
+ ///
+ /// @param[in] location_list_base_addr
+ /// If this is a location list based expression, this is the
+ /// address of the object that owns it. NOTE: this value is
+ /// different from the DWARF version of the location list base
+ /// address which is compile unit relative. This base address
+ /// is the address of the object that owns the location list.
+ ///
+ /// @param[in] abi
+ /// An optional ABI plug-in that can be used to resolve register
+ /// names.
+ //------------------------------------------------------------------
+ void GetDescription(Stream *s, lldb::DescriptionLevel level,
+ lldb::addr_t location_list_base_addr, ABI *abi) const;
+
+ //------------------------------------------------------------------
+ /// Return true if the location expression contains data
+ //------------------------------------------------------------------
+ bool IsValid() const;
+
+ //------------------------------------------------------------------
+ /// Return true if a location list was provided
+ //------------------------------------------------------------------
+ bool IsLocationList() const;
+
+ //------------------------------------------------------------------
+ /// Search for a load address in the location list
+ ///
+ /// @param[in] process
+ /// The process to use when resolving the load address
+ ///
+ /// @param[in] addr
+ /// The address to resolve
+ ///
+ /// @return
+ /// True if IsLocationList() is true and the address was found;
+ /// false otherwise.
+ //------------------------------------------------------------------
+ // bool
+ // LocationListContainsLoadAddress (Process* process, const Address &addr)
+ // const;
+ //
+ bool LocationListContainsAddress(lldb::addr_t loclist_base_addr,
+ lldb::addr_t addr) const;
+
+ //------------------------------------------------------------------
+ /// If a location is not a location list, return true if the location
+ /// contains a DW_OP_addr () opcode in the stream that matches \a
+ /// file_addr. If file_addr is LLDB_INVALID_ADDRESS, the this
+ /// function will return true if the variable there is any DW_OP_addr
+ /// in a location that (yet still is NOT a location list). This helps
+ /// us detect if a variable is a global or static variable since
+ /// there is no other indication from DWARF debug info.
+ ///
+ /// @param[in] op_addr_idx
+ /// The DW_OP_addr index to retrieve in case there is more than
+ /// one DW_OP_addr opcode in the location byte stream.
+ ///
+ /// @param[out] error
+ /// If the location stream contains unknown DW_OP opcodes or the
+ /// data is missing, \a error will be set to \b true.
+ ///
+ /// @return
+ /// LLDB_INVALID_ADDRESS if the location doesn't contain a
+ /// DW_OP_addr for \a op_addr_idx, otherwise a valid file address
+ //------------------------------------------------------------------
+ lldb::addr_t GetLocation_DW_OP_addr(uint32_t op_addr_idx, bool &error) const;
+
+ bool Update_DW_OP_addr(lldb::addr_t file_addr);
+
+ bool ContainsThreadLocalStorage() const;
+
+ bool LinkThreadLocalStorage(
+ lldb::ModuleSP new_module_sp,
+ std::function<lldb::addr_t(lldb::addr_t file_addr)> const
+ &link_address_callback);
+
+ //------------------------------------------------------------------
+ /// Make the expression parser read its location information from a
+ /// given data source. Does not change the offset and length
+ ///
+ /// @param[in] data
+ /// A data extractor configured to read the DWARF location expression's
+ /// bytecode.
+ //------------------------------------------------------------------
+ void SetOpcodeData(const DataExtractor &data);
+
+ //------------------------------------------------------------------
+ /// Make the expression parser read its location information from a
+ /// given data source
+ ///
+ /// @param[in] module_sp
+ /// The module that defines the DWARF expression.
+ ///
+ /// @param[in] data
+ /// A data extractor configured to read the DWARF location expression's
+ /// bytecode.
+ ///
+ /// @param[in] data_offset
+ /// The offset of the location expression in the extractor.
+ ///
+ /// @param[in] data_length
+ /// The byte length of the location expression.
+ //------------------------------------------------------------------
+ void SetOpcodeData(lldb::ModuleSP module_sp, const DataExtractor &data,
+ lldb::offset_t data_offset, lldb::offset_t data_length);
+
+ //------------------------------------------------------------------
+ /// Copy the DWARF location expression into a local buffer.
+ ///
+ /// It is a good idea to copy the data so we don't keep the entire
+ /// object file worth of data around just for a few bytes of location
+ /// expression. LLDB typically will mmap the entire contents of debug
+ /// information files, and if we use SetOpcodeData, it will get a
+ /// shared reference to all of this data for the and cause the object
+ /// file to have to stay around. Even worse, a very very large ".a"
+ /// that contains one or more .o files could end up being referenced.
+ /// Location lists are typically small so even though we are copying
+ /// the data, it shouldn't amount to that much for the variables we
+ /// end up parsing.
+ ///
+ /// @param[in] module_sp
+ /// The module that defines the DWARF expression.
+ ///
+ /// @param[in] data
+ /// A data extractor configured to read and copy the DWARF
+ /// location expression's bytecode.
+ ///
+ /// @param[in] data_offset
+ /// The offset of the location expression in the extractor.
+ ///
+ /// @param[in] data_length
+ /// The byte length of the location expression.
+ //------------------------------------------------------------------
+ void CopyOpcodeData(lldb::ModuleSP module_sp, const DataExtractor &data,
+ lldb::offset_t data_offset, lldb::offset_t data_length);
+
+ void CopyOpcodeData(const void *data, lldb::offset_t data_length,
+ lldb::ByteOrder byte_order, uint8_t addr_byte_size);
+
+ void CopyOpcodeData(uint64_t const_value,
+ lldb::offset_t const_value_byte_size,
+ uint8_t addr_byte_size);
+
+ //------------------------------------------------------------------
+ /// Tells the expression that it refers to a location list.
+ ///
+ /// @param[in] slide
+ /// This value should be a slide that is applied to any values
+ /// in the location list data so the values become zero based
+ /// offsets into the object that owns the location list. We need
+ /// to make location lists relative to the objects that own them
+ /// so we can relink addresses on the fly.
+ //------------------------------------------------------------------
+ void SetLocationListSlide(lldb::addr_t slide);
+
+ //------------------------------------------------------------------
+ /// Return the call-frame-info style register kind
+ //------------------------------------------------------------------
+ int GetRegisterKind();
+
+ //------------------------------------------------------------------
+ /// Set the call-frame-info style register kind
+ ///
+ /// @param[in] reg_kind
+ /// The register kind.
+ //------------------------------------------------------------------
+ void SetRegisterKind(lldb::RegisterKind reg_kind);
+
+ //------------------------------------------------------------------
+ /// Wrapper for the static evaluate function that accepts an
+ /// ExecutionContextScope instead of an ExecutionContext and uses
+ /// member variables to populate many operands
+ //------------------------------------------------------------------
+ bool Evaluate(ExecutionContextScope *exe_scope,
+ ClangExpressionVariableList *expr_locals,
+ ClangExpressionDeclMap *decl_map,
+ lldb::addr_t loclist_base_load_addr,
+ const Value *initial_value_ptr, const Value *object_address_ptr,
+ Value &result, Error *error_ptr) const;
+
+ //------------------------------------------------------------------
+ /// Wrapper for the static evaluate function that uses member
+ /// variables to populate many operands
+ //------------------------------------------------------------------
+ bool Evaluate(ExecutionContext *exe_ctx,
+ ClangExpressionVariableList *expr_locals,
+ ClangExpressionDeclMap *decl_map, RegisterContext *reg_ctx,
+ lldb::addr_t loclist_base_load_addr,
+ const Value *initial_value_ptr, const Value *object_address_ptr,
+ Value &result, Error *error_ptr) const;
+
+ //------------------------------------------------------------------
+ /// Evaluate a DWARF location expression in a particular context
+ ///
+ /// @param[in] exe_ctx
+ /// The execution context in which to evaluate the location
+ /// expression. The location expression may access the target's
+ /// memory, especially if it comes from the expression parser.
+ ///
+ /// @param[in] opcode_ctx
+ /// The module which defined the expression.
+ ///
+ /// @param[in] opcodes
+ /// This is a static method so the opcodes need to be provided
+ /// explicitly.
+ ///
+ /// @param[in] expr_locals
+ /// If the location expression was produced by the expression parser,
+ /// the list of local variables referenced by the DWARF expression.
+ /// This list should already have been populated during parsing;
+ /// the DWARF expression refers to variables by index. Can be NULL if
+ /// the location expression uses no locals.
+ ///
+ /// @param[in] decl_map
+ /// If the location expression was produced by the expression parser,
+ /// the list of external variables referenced by the location
+ /// expression. Can be NULL if the location expression uses no
+ /// external variables.
+ ///
+ /// @param[in] reg_ctx
+ /// An optional parameter which provides a RegisterContext for use
+ /// when evaluating the expression (i.e. for fetching register values).
+ /// Normally this will come from the ExecutionContext's StackFrame but
+ /// in the case where an expression needs to be evaluated while building
+ /// the stack frame list, this short-cut is available.
+ ///
+ /// @param[in] offset
+ /// The offset of the location expression in the data extractor.
+ ///
+ /// @param[in] length
+ /// The length in bytes of the location expression.
+ ///
+ /// @param[in] reg_set
+ /// The call-frame-info style register kind.
+ ///
+ /// @param[in] initial_value_ptr
+ /// A value to put on top of the interpreter stack before evaluating
+ /// the expression, if the expression is parametrized. Can be NULL.
+ ///
+ /// @param[in] result
+ /// A value into which the result of evaluating the expression is
+ /// to be placed.
+ ///
+ /// @param[in] error_ptr
+ /// If non-NULL, used to report errors in expression evaluation.
+ ///
+ /// @return
+ /// True on success; false otherwise. If error_ptr is non-NULL,
+ /// details of the failure are provided through it.
+ //------------------------------------------------------------------
+ static bool
+ Evaluate(ExecutionContext *exe_ctx, ClangExpressionVariableList *expr_locals,
+ ClangExpressionDeclMap *decl_map, RegisterContext *reg_ctx,
+ lldb::ModuleSP opcode_ctx, const DataExtractor &opcodes,
+ DWARFCompileUnit *dwarf_cu, const lldb::offset_t offset,
+ const lldb::offset_t length, const lldb::RegisterKind reg_set,
+ const Value *initial_value_ptr, const Value *object_address_ptr,
+ Value &result, Error *error_ptr);
+
+ //------------------------------------------------------------------
+ /// Loads a ClangExpressionVariableList into the object
+ ///
+ /// @param[in] locals
+ /// If non-NULL, the list of locals used by this expression.
+ /// See Evaluate().
+ //------------------------------------------------------------------
+ void SetExpressionLocalVariableList(ClangExpressionVariableList *locals);
+
+ //------------------------------------------------------------------
+ /// Loads a ClangExpressionDeclMap into the object
+ ///
+ /// @param[in] locals
+ /// If non-NULL, the list of external variables used by this
+ /// expression. See Evaluate().
+ //------------------------------------------------------------------
+ void SetExpressionDeclMap(ClangExpressionDeclMap *decl_map);
+
+ bool GetExpressionData(DataExtractor &data) const {
+ data = m_data;
+ return data.GetByteSize() > 0;
+ }
+
+ bool DumpLocationForAddress(Stream *s, lldb::DescriptionLevel level,
+ lldb::addr_t loclist_base_load_addr,
+ lldb::addr_t address, ABI *abi);
+
+ static size_t LocationListSize(const DWARFCompileUnit *dwarf_cu,
+ const DataExtractor &debug_loc_data,
+ lldb::offset_t offset);
+
+ static bool PrintDWARFExpression(Stream &s, const DataExtractor &data,
+ int address_size, int dwarf_ref_size,
+ bool location_expression);
+
+ static void PrintDWARFLocationList(Stream &s, const DWARFCompileUnit *cu,
+ const DataExtractor &debug_loc_data,
+ lldb::offset_t offset);
+
+ bool MatchesOperand(StackFrame &frame, const Instruction::Operand &op);
protected:
- //------------------------------------------------------------------
- /// Pretty-prints the location expression to a stream
- ///
- /// @param[in] stream
- /// The stream to use for pretty-printing.
- ///
- /// @param[in] offset
- /// The offset into the data buffer of the opcodes to be printed.
- ///
- /// @param[in] length
- /// The length in bytes of the opcodes to be printed.
- ///
- /// @param[in] level
- /// The level of detail to use in pretty-printing.
- ///
- /// @param[in] abi
- /// An optional ABI plug-in that can be used to resolve register
- /// names.
- //------------------------------------------------------------------
- void
- DumpLocation(Stream *s,
- lldb::offset_t offset,
- lldb::offset_t length,
- lldb::DescriptionLevel level,
- ABI *abi) const;
-
- bool
- GetLocation (lldb::addr_t base_addr,
- lldb::addr_t pc,
- lldb::offset_t &offset,
- lldb::offset_t &len);
-
- static bool
- AddressRangeForLocationListEntry(const DWARFCompileUnit* dwarf_cu,
- const DataExtractor& debug_loc_data,
- lldb::offset_t* offset_ptr,
- lldb::addr_t& low_pc,
- lldb::addr_t& high_pc);
-
- //------------------------------------------------------------------
- /// Classes that inherit from DWARFExpression can see and modify these
- //------------------------------------------------------------------
-
- lldb::ModuleWP m_module_wp; ///< Module which defined this expression.
- DataExtractor m_data; ///< A data extractor capable of reading opcode bytes
- DWARFCompileUnit* m_dwarf_cu; ///< The DWARF compile unit this expression belongs to. It is used
- ///< to evaluate values indexing into the .debug_addr section (e.g.
- ///< DW_OP_GNU_addr_index, DW_OP_GNU_const_index)
- lldb::RegisterKind m_reg_kind; ///< One of the defines that starts with LLDB_REGKIND_
- lldb::addr_t m_loclist_slide; ///< A value used to slide the location list offsets so that
- ///< they are relative to the object that owns the location list
- ///< (the function for frame base and variable location lists)
+ //------------------------------------------------------------------
+ /// Pretty-prints the location expression to a stream
+ ///
+ /// @param[in] stream
+ /// The stream to use for pretty-printing.
+ ///
+ /// @param[in] offset
+ /// The offset into the data buffer of the opcodes to be printed.
+ ///
+ /// @param[in] length
+ /// The length in bytes of the opcodes to be printed.
+ ///
+ /// @param[in] level
+ /// The level of detail to use in pretty-printing.
+ ///
+ /// @param[in] abi
+ /// An optional ABI plug-in that can be used to resolve register
+ /// names.
+ //------------------------------------------------------------------
+ void DumpLocation(Stream *s, lldb::offset_t offset, lldb::offset_t length,
+ lldb::DescriptionLevel level, ABI *abi) const;
+
+ bool GetLocation(lldb::addr_t base_addr, lldb::addr_t pc,
+ lldb::offset_t &offset, lldb::offset_t &len);
+
+ static bool AddressRangeForLocationListEntry(
+ const DWARFCompileUnit *dwarf_cu, const DataExtractor &debug_loc_data,
+ lldb::offset_t *offset_ptr, lldb::addr_t &low_pc, lldb::addr_t &high_pc);
+
+ bool GetOpAndEndOffsets(StackFrame &frame, lldb::offset_t &op_offset,
+ lldb::offset_t &end_offset);
+
+ //------------------------------------------------------------------
+ /// Classes that inherit from DWARFExpression can see and modify these
+ //------------------------------------------------------------------
+
+ lldb::ModuleWP m_module_wp; ///< Module which defined this expression.
+ DataExtractor m_data; ///< A data extractor capable of reading opcode bytes
+ DWARFCompileUnit *m_dwarf_cu; ///< The DWARF compile unit this expression
+ ///belongs to. It is used
+ ///< to evaluate values indexing into the .debug_addr section (e.g.
+ ///< DW_OP_GNU_addr_index, DW_OP_GNU_const_index)
+ lldb::RegisterKind
+ m_reg_kind; ///< One of the defines that starts with LLDB_REGKIND_
+ lldb::addr_t m_loclist_slide; ///< A value used to slide the location list
+ ///offsets so that
+ ///< they are relative to the object that owns the location list
+ ///< (the function for frame base and variable location lists)
};
} // namespace lldb_private
-#endif // liblldb_DWARFExpression_h_
+#endif // liblldb_DWARFExpression_h_
diff --git a/include/lldb/Expression/DiagnosticManager.h b/include/lldb/Expression/DiagnosticManager.h
index c294bdecf2b2..d9024e649b80 100644
--- a/include/lldb/Expression/DiagnosticManager.h
+++ b/include/lldb/Expression/DiagnosticManager.h
@@ -13,199 +13,151 @@
#include "lldb/lldb-defines.h"
#include "lldb/lldb-types.h"
+#include "llvm/ADT/StringRef.h"
+
#include <string>
#include <vector>
-namespace lldb_private
-{
-
-enum DiagnosticOrigin
-{
- eDiagnosticOriginUnknown = 0,
- eDiagnosticOriginLLDB,
- eDiagnosticOriginClang,
- eDiagnosticOriginGo,
- eDiagnosticOriginSwift,
- eDiagnosticOriginLLVM
+namespace lldb_private {
+
+enum DiagnosticOrigin {
+ eDiagnosticOriginUnknown = 0,
+ eDiagnosticOriginLLDB,
+ eDiagnosticOriginClang,
+ eDiagnosticOriginGo,
+ eDiagnosticOriginSwift,
+ eDiagnosticOriginLLVM
};
-enum DiagnosticSeverity
-{
- eDiagnosticSeverityError,
- eDiagnosticSeverityWarning,
- eDiagnosticSeverityRemark
+enum DiagnosticSeverity {
+ eDiagnosticSeverityError,
+ eDiagnosticSeverityWarning,
+ eDiagnosticSeverityRemark
};
const uint32_t LLDB_INVALID_COMPILER_ID = UINT32_MAX;
-class Diagnostic
-{
-friend class DiagnosticManager;
+class Diagnostic {
+ friend class DiagnosticManager;
public:
- DiagnosticOrigin getKind() const { return m_origin; }
-
- static bool classof(const Diagnostic *diag)
- {
- DiagnosticOrigin kind = diag->getKind();
- switch (kind)
- {
- case eDiagnosticOriginUnknown:
- case eDiagnosticOriginLLDB:
- case eDiagnosticOriginGo:
- case eDiagnosticOriginLLVM:
- return true;
- case eDiagnosticOriginClang:
- case eDiagnosticOriginSwift:
- return false;
- }
- }
-
- Diagnostic(const char *message, DiagnosticSeverity severity, DiagnosticOrigin origin, uint32_t compiler_id) :
- m_message(message),
- m_severity(severity),
- m_origin(origin),
- m_compiler_id(compiler_id)
- {
- }
-
- Diagnostic(const Diagnostic &rhs) :
- m_message(rhs.m_message),
- m_severity(rhs.m_severity),
- m_origin(rhs.m_origin),
- m_compiler_id(rhs.m_compiler_id)
- {
- }
-
- virtual ~Diagnostic() = default;
-
- virtual bool HasFixIts () const { return false; }
-
- DiagnosticSeverity
- GetSeverity() const
- {
- return m_severity;
- }
-
- uint32_t
- GetCompilerID() const
- {
- return m_compiler_id;
- }
-
- const char *
- GetMessage() const
- {
- return m_message.c_str();
- }
-
- void AppendMessage(const char *message, bool precede_with_newline = true)
- {
- if (precede_with_newline)
- m_message.push_back('\n');
- m_message.append(message);
+ DiagnosticOrigin getKind() const { return m_origin; }
+
+ static bool classof(const Diagnostic *diag) {
+ DiagnosticOrigin kind = diag->getKind();
+ switch (kind) {
+ case eDiagnosticOriginUnknown:
+ case eDiagnosticOriginLLDB:
+ case eDiagnosticOriginGo:
+ case eDiagnosticOriginLLVM:
+ return true;
+ case eDiagnosticOriginClang:
+ case eDiagnosticOriginSwift:
+ return false;
}
+ }
+
+ Diagnostic(llvm::StringRef message, DiagnosticSeverity severity,
+ DiagnosticOrigin origin, uint32_t compiler_id)
+ : m_message(message), m_severity(severity), m_origin(origin),
+ m_compiler_id(compiler_id) {}
+
+ Diagnostic(const Diagnostic &rhs)
+ : m_message(rhs.m_message), m_severity(rhs.m_severity),
+ m_origin(rhs.m_origin), m_compiler_id(rhs.m_compiler_id) {}
+
+ virtual ~Diagnostic() = default;
+
+ virtual bool HasFixIts() const { return false; }
+
+ DiagnosticSeverity GetSeverity() const { return m_severity; }
+
+ uint32_t GetCompilerID() const { return m_compiler_id; }
+
+ llvm::StringRef GetMessage() const { return m_message; }
+
+ void AppendMessage(llvm::StringRef message,
+ bool precede_with_newline = true) {
+ if (precede_with_newline)
+ m_message.push_back('\n');
+ m_message.append(message);
+ }
protected:
- std::string m_message;
- DiagnosticSeverity m_severity;
- DiagnosticOrigin m_origin;
- uint32_t m_compiler_id; // Compiler-specific diagnostic ID
+ std::string m_message;
+ DiagnosticSeverity m_severity;
+ DiagnosticOrigin m_origin;
+ uint32_t m_compiler_id; // Compiler-specific diagnostic ID
};
typedef std::vector<Diagnostic *> DiagnosticList;
-class DiagnosticManager
-{
+class DiagnosticManager {
public:
- void
- Clear()
- {
- m_diagnostics.clear();
- m_fixed_expression.clear();
- }
+ void Clear() {
+ m_diagnostics.clear();
+ m_fixed_expression.clear();
+ }
- // The diagnostic manager holds a list of diagnostics, which are owned by the manager.
- const DiagnosticList &
- Diagnostics()
- {
- return m_diagnostics;
- }
-
- ~DiagnosticManager()
- {
- for (Diagnostic *diag : m_diagnostics)
- {
- delete diag;
- }
- }
-
- bool
- HasFixIts()
- {
- for (Diagnostic *diag : m_diagnostics)
- {
- if (diag->HasFixIts())
- return true;
- }
- return false;
- }
-
- void
- AddDiagnostic(const char *message, DiagnosticSeverity severity, DiagnosticOrigin origin,
- uint32_t compiler_id = LLDB_INVALID_COMPILER_ID)
- {
- m_diagnostics.push_back(new Diagnostic(message, severity, origin, compiler_id));
- }
-
- void
- AddDiagnostic(Diagnostic *diagnostic)
- {
- m_diagnostics.push_back(diagnostic);
- }
+ // The diagnostic manager holds a list of diagnostics, which are owned by the
+ // manager.
+ const DiagnosticList &Diagnostics() { return m_diagnostics; }
- size_t
- Printf(DiagnosticSeverity severity, const char *format, ...) __attribute__((format(printf, 3, 4)));
- size_t
- PutCString(DiagnosticSeverity severity, const char *cstr);
-
- void
- AppendMessageToDiagnostic(const char *cstr)
- {
- if (m_diagnostics.size())
- {
- m_diagnostics.back()->AppendMessage(cstr);
- }
+ ~DiagnosticManager() {
+ for (Diagnostic *diag : m_diagnostics) {
+ delete diag;
}
-
- // Returns a string containing errors in this format:
- //
- // "error: error text\n
- // warning: warning text\n
- // remark text\n"
- std::string
- GetString(char separator = '\n');
-
- void
- Dump(Log *log);
-
- const std::string &
- GetFixedExpression()
- {
- return m_fixed_expression;
+ }
+
+ bool HasFixIts() {
+ for (Diagnostic *diag : m_diagnostics) {
+ if (diag->HasFixIts())
+ return true;
}
-
- // Moves fixed_expression to the internal storage.
- void
- SetFixedExpression(std::string fixed_expression)
- {
- m_fixed_expression = std::move(fixed_expression);
- fixed_expression.clear();
+ return false;
+ }
+
+ void AddDiagnostic(llvm::StringRef message, DiagnosticSeverity severity,
+ DiagnosticOrigin origin,
+ uint32_t compiler_id = LLDB_INVALID_COMPILER_ID) {
+ m_diagnostics.push_back(
+ new Diagnostic(message, severity, origin, compiler_id));
+ }
+
+ void AddDiagnostic(Diagnostic *diagnostic) {
+ m_diagnostics.push_back(diagnostic);
+ }
+
+ size_t Printf(DiagnosticSeverity severity, const char *format, ...)
+ __attribute__((format(printf, 3, 4)));
+ size_t PutString(DiagnosticSeverity severity, llvm::StringRef str);
+
+ void AppendMessageToDiagnostic(llvm::StringRef str) {
+ if (!m_diagnostics.empty()) {
+ m_diagnostics.back()->AppendMessage(str);
}
-
+ }
+
+ // Returns a string containing errors in this format:
+ //
+ // "error: error text\n
+ // warning: warning text\n
+ // remark text\n"
+ std::string GetString(char separator = '\n');
+
+ void Dump(Log *log);
+
+ const std::string &GetFixedExpression() { return m_fixed_expression; }
+
+ // Moves fixed_expression to the internal storage.
+ void SetFixedExpression(std::string fixed_expression) {
+ m_fixed_expression = std::move(fixed_expression);
+ fixed_expression.clear();
+ }
+
protected:
- DiagnosticList m_diagnostics;
- std::string m_fixed_expression;
+ DiagnosticList m_diagnostics;
+ std::string m_fixed_expression;
};
}
diff --git a/include/lldb/Expression/Expression.h b/include/lldb/Expression/Expression.h
index b5c2d575ae04..f48a7992227d 100644
--- a/include/lldb/Expression/Expression.h
+++ b/include/lldb/Expression/Expression.h
@@ -12,16 +12,16 @@
// C Includes
// C++ Includes
-#include <string>
#include <map>
+#include <string>
#include <vector>
// Other libraries and framework includes
// Project includes
+#include "lldb/Expression/ExpressionTypeSystemHelper.h"
#include "lldb/lldb-forward.h"
#include "lldb/lldb-private.h"
-#include "lldb/Expression/ExpressionTypeSystemHelper.h"
namespace lldb_private {
@@ -37,105 +37,83 @@ class RecordingMemoryManager;
/// uses the expression parser appropriate to the language of the expression
/// to produce LLVM IR from the expression.
//----------------------------------------------------------------------
-class Expression
-{
+class Expression {
public:
- enum ResultType {
- eResultTypeAny,
- eResultTypeId
- };
-
- Expression (Target &target);
-
- Expression (ExecutionContextScope &exe_scope);
-
- //------------------------------------------------------------------
- /// Destructor
- //------------------------------------------------------------------
- virtual ~Expression ()
- {
- }
-
- //------------------------------------------------------------------
- /// Return the string that the parser should parse. Must be a full
- /// translation unit.
- //------------------------------------------------------------------
- virtual const char *
- Text () = 0;
-
- //------------------------------------------------------------------
- /// Return the function name that should be used for executing the
- /// expression. Text() should contain the definition of this
- /// function.
- //------------------------------------------------------------------
- virtual const char *
- FunctionName () = 0;
-
- //------------------------------------------------------------------
- /// Return the language that should be used when parsing. To use
- /// the default, return eLanguageTypeUnknown.
- //------------------------------------------------------------------
- virtual lldb::LanguageType
- Language ()
- {
- return lldb::eLanguageTypeUnknown;
- }
-
- //------------------------------------------------------------------
- /// Return the desired result type of the function, or
- /// eResultTypeAny if indifferent.
- //------------------------------------------------------------------
- virtual ResultType
- DesiredResultType ()
- {
- return eResultTypeAny;
- }
-
- //------------------------------------------------------------------
- /// Flags
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Return true if validation code should be inserted into the
- /// expression.
- //------------------------------------------------------------------
- virtual bool
- NeedsValidation () = 0;
-
- //------------------------------------------------------------------
- /// Return true if external variables in the expression should be
- /// resolved.
- //------------------------------------------------------------------
- virtual bool
- NeedsVariableResolution () = 0;
-
- virtual EvaluateExpressionOptions *GetOptions() { return nullptr; };
-
- //------------------------------------------------------------------
- /// Return the address of the function's JIT-compiled code, or
- /// LLDB_INVALID_ADDRESS if the function is not JIT compiled
- //------------------------------------------------------------------
- lldb::addr_t
- StartAddress ()
- {
- return m_jit_start_addr;
- }
-
- virtual ExpressionTypeSystemHelper *
- GetTypeSystemHelper ()
- {
- return nullptr;
- }
+ enum ResultType { eResultTypeAny, eResultTypeId };
-protected:
+ Expression(Target &target);
+
+ Expression(ExecutionContextScope &exe_scope);
+
+ //------------------------------------------------------------------
+ /// Destructor
+ //------------------------------------------------------------------
+ virtual ~Expression() {}
+
+ //------------------------------------------------------------------
+ /// Return the string that the parser should parse. Must be a full
+ /// translation unit.
+ //------------------------------------------------------------------
+ virtual const char *Text() = 0;
+
+ //------------------------------------------------------------------
+ /// Return the function name that should be used for executing the
+ /// expression. Text() should contain the definition of this
+ /// function.
+ //------------------------------------------------------------------
+ virtual const char *FunctionName() = 0;
- lldb::TargetWP m_target_wp; /// Expression's always have to have a target...
- lldb::ProcessWP m_jit_process_wp; /// An expression might have a process, but it doesn't need to (e.g. calculator mode.)
- lldb::addr_t m_jit_start_addr; ///< The address of the JITted function within the JIT allocation. LLDB_INVALID_ADDRESS if invalid.
- lldb::addr_t m_jit_end_addr; ///< The address of the JITted function within the JIT allocation. LLDB_INVALID_ADDRESS if invalid.
+ //------------------------------------------------------------------
+ /// Return the language that should be used when parsing. To use
+ /// the default, return eLanguageTypeUnknown.
+ //------------------------------------------------------------------
+ virtual lldb::LanguageType Language() { return lldb::eLanguageTypeUnknown; }
+ //------------------------------------------------------------------
+ /// Return the desired result type of the function, or
+ /// eResultTypeAny if indifferent.
+ //------------------------------------------------------------------
+ virtual ResultType DesiredResultType() { return eResultTypeAny; }
+
+ //------------------------------------------------------------------
+ /// Flags
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Return true if validation code should be inserted into the
+ /// expression.
+ //------------------------------------------------------------------
+ virtual bool NeedsValidation() = 0;
+
+ //------------------------------------------------------------------
+ /// Return true if external variables in the expression should be
+ /// resolved.
+ //------------------------------------------------------------------
+ virtual bool NeedsVariableResolution() = 0;
+
+ virtual EvaluateExpressionOptions *GetOptions() { return nullptr; };
+
+ //------------------------------------------------------------------
+ /// Return the address of the function's JIT-compiled code, or
+ /// LLDB_INVALID_ADDRESS if the function is not JIT compiled
+ //------------------------------------------------------------------
+ lldb::addr_t StartAddress() { return m_jit_start_addr; }
+
+ virtual ExpressionTypeSystemHelper *GetTypeSystemHelper() { return nullptr; }
+
+protected:
+ lldb::TargetWP m_target_wp; /// Expression's always have to have a target...
+ lldb::ProcessWP m_jit_process_wp; /// An expression might have a process, but
+ /// it doesn't need to (e.g. calculator
+ /// mode.)
+ lldb::addr_t m_jit_start_addr; ///< The address of the JITted function within
+ ///the JIT allocation. LLDB_INVALID_ADDRESS if
+ ///invalid.
+ lldb::addr_t m_jit_end_addr; ///< The address of the JITted function within
+ ///the JIT allocation. LLDB_INVALID_ADDRESS if
+ ///invalid.
};
} // namespace lldb_private
-#endif // liblldb_Expression_h_
+#endif // liblldb_Expression_h_
diff --git a/include/lldb/Expression/ExpressionParser.h b/include/lldb/Expression/ExpressionParser.h
index 323e515e3bba..99f583d7ca92 100644
--- a/include/lldb/Expression/ExpressionParser.h
+++ b/include/lldb/Expression/ExpressionParser.h
@@ -10,131 +10,116 @@
#ifndef liblldb_ExpressionParser_h_
#define liblldb_ExpressionParser_h_
-#include "lldb/lldb-public.h"
#include "lldb/Core/Error.h"
+#include "lldb/lldb-public.h"
-namespace lldb_private
-{
+namespace lldb_private {
class IRExecutionUnit;
-
+
//----------------------------------------------------------------------
-/// @class ExpressionParser ExpressionParser.h "lldb/Expression/ExpressionParser.h"
+/// @class ExpressionParser ExpressionParser.h
+/// "lldb/Expression/ExpressionParser.h"
/// @brief Encapsulates an instance of a compiler that can parse expressions.
///
/// ExpressionParser is the base class for llvm based Expression parsers.
//----------------------------------------------------------------------
-class ExpressionParser
-{
+class ExpressionParser {
public:
- //------------------------------------------------------------------
- /// Constructor
- ///
- /// Initializes class variables.
- ///
- /// @param[in] exe_scope,
- /// If non-NULL, an execution context scope that can help to
- /// correctly create an expression with a valid process for
- /// optional tuning Objective-C runtime support. Can be NULL.
- ///
- /// @param[in] expr
- /// The expression to be parsed.
- //------------------------------------------------------------------
- ExpressionParser (ExecutionContextScope *exe_scope,
- Expression &expr,
- bool generate_debug_info) :
- m_expr(expr),
- m_generate_debug_info(generate_debug_info)
- {
- }
-
- //------------------------------------------------------------------
- /// Destructor
- //------------------------------------------------------------------
- virtual ~ExpressionParser () {};
-
- //------------------------------------------------------------------
- /// Parse a single expression and convert it to IR using Clang. Don't
- /// wrap the expression in anything at all.
- ///
- /// @param[in] diagnostic_manager
- /// The diagnostic manager in which to store the errors and warnings.
- ///
- /// @return
- /// The number of errors encountered during parsing. 0 means
- /// success.
- //------------------------------------------------------------------
- virtual unsigned
- Parse(DiagnosticManager &diagnostic_manager) = 0;
-
- //------------------------------------------------------------------
- /// Try to use the FixIts in the diagnostic_manager to rewrite the
- /// expression. If successful, the rewritten expression is stored
- /// in the diagnostic_manager, get it out with GetFixedExpression.
- ///
- /// @param[in] diagnostic_manager
- /// The diagnostic manager containing fixit's to apply.
- ///
- /// @return
- /// \b true if the rewrite was successful, \b false otherwise.
- //------------------------------------------------------------------
- virtual bool
- RewriteExpression(DiagnosticManager &diagnostic_manager)
- {
- return false;
- }
+ //------------------------------------------------------------------
+ /// Constructor
+ ///
+ /// Initializes class variables.
+ ///
+ /// @param[in] exe_scope,
+ /// If non-NULL, an execution context scope that can help to
+ /// correctly create an expression with a valid process for
+ /// optional tuning Objective-C runtime support. Can be NULL.
+ ///
+ /// @param[in] expr
+ /// The expression to be parsed.
+ //------------------------------------------------------------------
+ ExpressionParser(ExecutionContextScope *exe_scope, Expression &expr,
+ bool generate_debug_info)
+ : m_expr(expr), m_generate_debug_info(generate_debug_info) {}
+
+ //------------------------------------------------------------------
+ /// Destructor
+ //------------------------------------------------------------------
+ virtual ~ExpressionParser(){};
+
+ //------------------------------------------------------------------
+ /// Parse a single expression and convert it to IR using Clang. Don't
+ /// wrap the expression in anything at all.
+ ///
+ /// @param[in] diagnostic_manager
+ /// The diagnostic manager in which to store the errors and warnings.
+ ///
+ /// @return
+ /// The number of errors encountered during parsing. 0 means
+ /// success.
+ //------------------------------------------------------------------
+ virtual unsigned Parse(DiagnosticManager &diagnostic_manager) = 0;
+
+ //------------------------------------------------------------------
+ /// Try to use the FixIts in the diagnostic_manager to rewrite the
+ /// expression. If successful, the rewritten expression is stored
+ /// in the diagnostic_manager, get it out with GetFixedExpression.
+ ///
+ /// @param[in] diagnostic_manager
+ /// The diagnostic manager containing fixit's to apply.
+ ///
+ /// @return
+ /// \b true if the rewrite was successful, \b false otherwise.
+ //------------------------------------------------------------------
+ virtual bool RewriteExpression(DiagnosticManager &diagnostic_manager) {
+ return false;
+ }
+
+ //------------------------------------------------------------------
+ /// Ready an already-parsed expression for execution, possibly
+ /// evaluating it statically.
+ ///
+ /// @param[out] func_addr
+ /// The address to which the function has been written.
+ ///
+ /// @param[out] func_end
+ /// The end of the function's allocated memory region. (func_addr
+ /// and func_end do not delimit an allocated region; the allocated
+ /// region may begin before func_addr.)
+ ///
+ /// @param[in] execution_unit_sp
+ /// After parsing, ownership of the execution unit for
+ /// for the expression is handed to this shared pointer.
+ ///
+ /// @param[in] exe_ctx
+ /// The execution context to write the function into.
+ ///
+ /// @param[out] can_interpret
+ /// Set to true if the expression could be interpreted statically;
+ /// untouched otherwise.
+ ///
+ /// @param[in] execution_policy
+ /// Determines whether the expression must be JIT-compiled, must be
+ /// evaluated statically, or whether this decision may be made
+ /// opportunistically.
+ ///
+ /// @return
+ /// An error code indicating the success or failure of the operation.
+ /// Test with Success().
+ //------------------------------------------------------------------
+ virtual Error
+ PrepareForExecution(lldb::addr_t &func_addr, lldb::addr_t &func_end,
+ std::shared_ptr<IRExecutionUnit> &execution_unit_sp,
+ ExecutionContext &exe_ctx, bool &can_interpret,
+ lldb_private::ExecutionPolicy execution_policy) = 0;
+
+ bool GetGenerateDebugInfo() const { return m_generate_debug_info; }
- //------------------------------------------------------------------
- /// Ready an already-parsed expression for execution, possibly
- /// evaluating it statically.
- ///
- /// @param[out] func_addr
- /// The address to which the function has been written.
- ///
- /// @param[out] func_end
- /// The end of the function's allocated memory region. (func_addr
- /// and func_end do not delimit an allocated region; the allocated
- /// region may begin before func_addr.)
- ///
- /// @param[in] execution_unit_sp
- /// After parsing, ownership of the execution unit for
- /// for the expression is handed to this shared pointer.
- ///
- /// @param[in] exe_ctx
- /// The execution context to write the function into.
- ///
- /// @param[out] can_interpret
- /// Set to true if the expression could be interpreted statically;
- /// untouched otherwise.
- ///
- /// @param[in] execution_policy
- /// Determines whether the expression must be JIT-compiled, must be
- /// evaluated statically, or whether this decision may be made
- /// opportunistically.
- ///
- /// @return
- /// An error code indicating the success or failure of the operation.
- /// Test with Success().
- //------------------------------------------------------------------
- virtual Error
- PrepareForExecution (lldb::addr_t &func_addr,
- lldb::addr_t &func_end,
- std::shared_ptr<IRExecutionUnit> &execution_unit_sp,
- ExecutionContext &exe_ctx,
- bool &can_interpret,
- lldb_private::ExecutionPolicy execution_policy) = 0;
-
- bool
- GetGenerateDebugInfo () const
- {
- return m_generate_debug_info;
- }
-
protected:
- Expression & m_expr; ///< The expression to be parsed
- bool m_generate_debug_info;
+ Expression &m_expr; ///< The expression to be parsed
+ bool m_generate_debug_info;
};
-
}
-#endif // liblldb_ExpressionParser_h_
+#endif // liblldb_ExpressionParser_h_
diff --git a/include/lldb/Expression/ExpressionSourceCode.h b/include/lldb/Expression/ExpressionSourceCode.h
index 33ceade45558..02fc72aaf251 100644
--- a/include/lldb/Expression/ExpressionSourceCode.h
+++ b/include/lldb/Expression/ExpressionSourceCode.h
@@ -14,73 +14,48 @@
#include <string>
-namespace lldb_private
-{
+namespace lldb_private {
class ExecutionContext;
-class ExpressionSourceCode
-{
+class ExpressionSourceCode {
public:
- static const char * g_expression_prefix;
-
- static ExpressionSourceCode *CreateWrapped (const char *prefix,
- const char *body)
- {
- return new ExpressionSourceCode ("$__lldb_expr",
- prefix,
- body,
- true);
- }
-
- static ExpressionSourceCode *CreateUnwrapped (const char *name,
- const char *body)
- {
- return new ExpressionSourceCode (name,
- "",
- body,
- false);
- }
-
- bool NeedsWrapping () const
- {
- return m_wrap;
- }
-
- const char *GetName () const
- {
- return m_name.c_str();
- }
-
- bool GetText (std::string &text,
- lldb::LanguageType wrapping_language,
- bool static_method,
- ExecutionContext &exe_ctx) const;
-
- // Given a string returned by GetText, find the beginning and end of the body passed to CreateWrapped.
- // Return true if the bounds could be found. This will also work on text with FixItHints applied.
- static bool
- GetOriginalBodyBounds(std::string transformed_text,
- lldb::LanguageType wrapping_language,
- size_t &start_loc,
- size_t &end_loc);
-
+ static const char *g_expression_prefix;
+
+ static ExpressionSourceCode *CreateWrapped(const char *prefix,
+ const char *body) {
+ return new ExpressionSourceCode("$__lldb_expr", prefix, body, true);
+ }
+
+ static ExpressionSourceCode *CreateUnwrapped(const char *name,
+ const char *body) {
+ return new ExpressionSourceCode(name, "", body, false);
+ }
+
+ bool NeedsWrapping() const { return m_wrap; }
+
+ const char *GetName() const { return m_name.c_str(); }
+
+ bool GetText(std::string &text, lldb::LanguageType wrapping_language,
+ bool static_method, ExecutionContext &exe_ctx) const;
+
+ // Given a string returned by GetText, find the beginning and end of the body
+ // passed to CreateWrapped.
+ // Return true if the bounds could be found. This will also work on text with
+ // FixItHints applied.
+ static bool GetOriginalBodyBounds(std::string transformed_text,
+ lldb::LanguageType wrapping_language,
+ size_t &start_loc, size_t &end_loc);
+
private:
- ExpressionSourceCode (const char *name,
- const char *prefix,
- const char *body,
- bool wrap) :
- m_name(name),
- m_prefix(prefix),
- m_body(body),
- m_wrap(wrap)
- {
- }
-
- std::string m_name;
- std::string m_prefix;
- std::string m_body;
- bool m_wrap;
+ ExpressionSourceCode(const char *name, const char *prefix, const char *body,
+ bool wrap)
+ : m_name(name), m_prefix(prefix), m_body(body), m_wrap(wrap) {}
+
+ std::string m_name;
+ std::string m_prefix;
+ std::string m_body;
+ bool m_wrap;
};
} // namespace lldb_private
diff --git a/include/lldb/Expression/ExpressionTypeSystemHelper.h b/include/lldb/Expression/ExpressionTypeSystemHelper.h
index cb560c9b5a42..20a5e67cf9b7 100644
--- a/include/lldb/Expression/ExpressionTypeSystemHelper.h
+++ b/include/lldb/Expression/ExpressionTypeSystemHelper.h
@@ -1,4 +1,5 @@
-//===-- ExpressionTypeSystemHelper.h ---------------------------------*- C++ -*-===//
+//===-- ExpressionTypeSystemHelper.h ---------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -12,42 +13,37 @@
#include "llvm/Support/Casting.h"
-namespace lldb_private
-{
+namespace lldb_private {
//----------------------------------------------------------------------
-/// @class ExpressionTypeSystemHelper ExpressionTypeSystemHelper.h "lldb/Expression/ExpressionTypeSystemHelper.h"
-/// @brief A helper object that the Expression can pass to its ExpressionParser to provide generic information that
-/// any type of expression will need to supply. It's only job is to support dyn_cast so that the expression parser
+/// @class ExpressionTypeSystemHelper ExpressionTypeSystemHelper.h
+/// "lldb/Expression/ExpressionTypeSystemHelper.h"
+/// @brief A helper object that the Expression can pass to its ExpressionParser
+/// to provide generic information that
+/// any type of expression will need to supply. It's only job is to support
+/// dyn_cast so that the expression parser
/// can cast it back to the requisite specific type.
///
//----------------------------------------------------------------------
-class ExpressionTypeSystemHelper
-{
+class ExpressionTypeSystemHelper {
public:
- enum LLVMCastKind {
- eKindClangHelper,
- eKindSwiftHelper,
- eKindGoHelper,
- kNumKinds
- };
-
- LLVMCastKind getKind() const { return m_kind; }
-
- ExpressionTypeSystemHelper (LLVMCastKind kind) :
- m_kind(kind)
- {
- }
-
- ~ExpressionTypeSystemHelper () {}
+ enum LLVMCastKind {
+ eKindClangHelper,
+ eKindSwiftHelper,
+ eKindGoHelper,
+ kNumKinds
+ };
-protected:
- LLVMCastKind m_kind;
-};
+ LLVMCastKind getKind() const { return m_kind; }
+ ExpressionTypeSystemHelper(LLVMCastKind kind) : m_kind(kind) {}
+ ~ExpressionTypeSystemHelper() {}
+protected:
+ LLVMCastKind m_kind;
+};
} // namespace lldb_private
diff --git a/include/lldb/Expression/ExpressionVariable.h b/include/lldb/Expression/ExpressionVariable.h
index 451acb685bb7..3f6b020139de 100644
--- a/include/lldb/Expression/ExpressionVariable.h
+++ b/include/lldb/Expression/ExpressionVariable.h
@@ -19,313 +19,250 @@
#include "llvm/ADT/DenseMap.h"
// Project includes
-#include "lldb/lldb-public.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/ValueObject.h"
+#include "lldb/lldb-public.h"
+
+namespace lldb_private {
-namespace lldb_private
-{
-
class ClangExpressionVariable;
-class ExpressionVariable :
- public std::enable_shared_from_this<ExpressionVariable>
-{
+class ExpressionVariable
+ : public std::enable_shared_from_this<ExpressionVariable> {
public:
- //----------------------------------------------------------------------
- // See TypeSystem.h for how to add subclasses to this.
- //----------------------------------------------------------------------
- enum LLVMCastKind {
- eKindClang,
- eKindSwift,
- eKindGo,
- kNumKinds
- };
-
- LLVMCastKind getKind() const { return m_kind; }
-
- ExpressionVariable(LLVMCastKind kind) :
- m_flags(0),
- m_kind(kind)
- {
- }
+ //----------------------------------------------------------------------
+ // See TypeSystem.h for how to add subclasses to this.
+ //----------------------------------------------------------------------
+ enum LLVMCastKind { eKindClang, eKindSwift, eKindGo, kNumKinds };
- virtual ~ExpressionVariable();
+ LLVMCastKind getKind() const { return m_kind; }
- size_t
- GetByteSize ()
- {
- return m_frozen_sp->GetByteSize();
- }
-
- const ConstString &
- GetName ()
- {
- return m_frozen_sp->GetName();
- }
-
- lldb::ValueObjectSP
- GetValueObject()
- {
- return m_frozen_sp;
- }
-
- uint8_t *GetValueBytes();
-
- void
- ValueUpdated ()
- {
- m_frozen_sp->ValueUpdated ();
- }
-
- RegisterInfo *
- GetRegisterInfo()
- {
- return m_frozen_sp->GetValue().GetRegisterInfo();
- }
-
- void
- SetRegisterInfo (const RegisterInfo *reg_info)
- {
- return m_frozen_sp->GetValue().SetContext (Value::eContextTypeRegisterInfo, const_cast<RegisterInfo *>(reg_info));
- }
-
- CompilerType
- GetCompilerType()
- {
- return m_frozen_sp->GetCompilerType();
- }
-
- void
- SetCompilerType(const CompilerType &compiler_type)
- {
- m_frozen_sp->GetValue().SetCompilerType(compiler_type);
- }
-
- void
- SetName (const ConstString &name)
- {
- m_frozen_sp->SetName (name);
- }
-
- // this function is used to copy the address-of m_live_sp into m_frozen_sp
- // this is necessary because the results of certain cast and pointer-arithmetic
- // operations (such as those described in bugzilla issues 11588 and 11618) generate
- // frozen objects that do not have a valid address-of, which can be troublesome when
- // using synthetic children providers. Transferring the address-of the live object
- // solves these issues and provides the expected user-level behavior
- void
- TransferAddress (bool force = false)
- {
- if (m_live_sp.get() == nullptr)
- return;
-
- if (m_frozen_sp.get() == nullptr)
- return;
-
- if (force || (m_frozen_sp->GetLiveAddress() == LLDB_INVALID_ADDRESS))
- m_frozen_sp->SetLiveAddress(m_live_sp->GetLiveAddress());
- }
-
- enum Flags
- {
- EVNone = 0,
- EVIsLLDBAllocated = 1 << 0, ///< This variable is resident in a location specifically allocated for it by LLDB in the target process
- EVIsProgramReference = 1 << 1, ///< This variable is a reference to a (possibly invalid) area managed by the target program
- EVNeedsAllocation = 1 << 2, ///< Space for this variable has yet to be allocated in the target process
- EVIsFreezeDried = 1 << 3, ///< This variable's authoritative version is in m_frozen_sp (for example, for statically-computed results)
- EVNeedsFreezeDry = 1 << 4, ///< Copy from m_live_sp to m_frozen_sp during dematerialization
- EVKeepInTarget = 1 << 5, ///< Keep the allocation after the expression is complete rather than freeze drying its contents and freeing it
- EVTypeIsReference = 1 << 6, ///< The original type of this variable is a reference, so materialize the value rather than the location
- EVUnknownType = 1 << 7, ///< This is a symbol of unknown type, and the type must be resolved after parsing is complete
- EVBareRegister = 1 << 8 ///< This variable is a direct reference to $pc or some other entity.
- };
-
- typedef uint16_t FlagType;
-
- FlagType m_flags; // takes elements of Flags
-
- // these should be private
- lldb::ValueObjectSP m_frozen_sp;
- lldb::ValueObjectSP m_live_sp;
- LLVMCastKind m_kind;
+ ExpressionVariable(LLVMCastKind kind) : m_flags(0), m_kind(kind) {}
+
+ virtual ~ExpressionVariable();
+
+ size_t GetByteSize() { return m_frozen_sp->GetByteSize(); }
+
+ const ConstString &GetName() { return m_frozen_sp->GetName(); }
+
+ lldb::ValueObjectSP GetValueObject() { return m_frozen_sp; }
+
+ uint8_t *GetValueBytes();
+
+ void ValueUpdated() { m_frozen_sp->ValueUpdated(); }
+
+ RegisterInfo *GetRegisterInfo() {
+ return m_frozen_sp->GetValue().GetRegisterInfo();
+ }
+
+ void SetRegisterInfo(const RegisterInfo *reg_info) {
+ return m_frozen_sp->GetValue().SetContext(
+ Value::eContextTypeRegisterInfo, const_cast<RegisterInfo *>(reg_info));
+ }
+
+ CompilerType GetCompilerType() { return m_frozen_sp->GetCompilerType(); }
+
+ void SetCompilerType(const CompilerType &compiler_type) {
+ m_frozen_sp->GetValue().SetCompilerType(compiler_type);
+ }
+
+ void SetName(const ConstString &name) { m_frozen_sp->SetName(name); }
+
+ // this function is used to copy the address-of m_live_sp into m_frozen_sp
+ // this is necessary because the results of certain cast and
+ // pointer-arithmetic
+ // operations (such as those described in bugzilla issues 11588 and 11618)
+ // generate
+ // frozen objects that do not have a valid address-of, which can be
+ // troublesome when
+ // using synthetic children providers. Transferring the address-of the live
+ // object
+ // solves these issues and provides the expected user-level behavior
+ void TransferAddress(bool force = false) {
+ if (m_live_sp.get() == nullptr)
+ return;
+
+ if (m_frozen_sp.get() == nullptr)
+ return;
+
+ if (force || (m_frozen_sp->GetLiveAddress() == LLDB_INVALID_ADDRESS))
+ m_frozen_sp->SetLiveAddress(m_live_sp->GetLiveAddress());
+ }
+
+ enum Flags {
+ EVNone = 0,
+ EVIsLLDBAllocated = 1 << 0, ///< This variable is resident in a location
+ ///specifically allocated for it by LLDB in the
+ ///target process
+ EVIsProgramReference = 1 << 1, ///< This variable is a reference to a
+ ///(possibly invalid) area managed by the
+ ///target program
+ EVNeedsAllocation = 1 << 2, ///< Space for this variable has yet to be
+ ///allocated in the target process
+ EVIsFreezeDried = 1 << 3, ///< This variable's authoritative version is in
+ ///m_frozen_sp (for example, for
+ ///statically-computed results)
+ EVNeedsFreezeDry =
+ 1 << 4, ///< Copy from m_live_sp to m_frozen_sp during dematerialization
+ EVKeepInTarget = 1 << 5, ///< Keep the allocation after the expression is
+ ///complete rather than freeze drying its contents
+ ///and freeing it
+ EVTypeIsReference = 1 << 6, ///< The original type of this variable is a
+ ///reference, so materialize the value rather
+ ///than the location
+ EVUnknownType = 1 << 7, ///< This is a symbol of unknown type, and the type
+ ///must be resolved after parsing is complete
+ EVBareRegister = 1 << 8 ///< This variable is a direct reference to $pc or
+ ///some other entity.
+ };
+
+ typedef uint16_t FlagType;
+
+ FlagType m_flags; // takes elements of Flags
+
+ // these should be private
+ lldb::ValueObjectSP m_frozen_sp;
+ lldb::ValueObjectSP m_live_sp;
+ LLVMCastKind m_kind;
};
-
+
//----------------------------------------------------------------------
-/// @class ExpressionVariableList ExpressionVariable.h "lldb/Expression/ExpressionVariable.h"
+/// @class ExpressionVariableList ExpressionVariable.h
+/// "lldb/Expression/ExpressionVariable.h"
/// @brief A list of variable references.
///
/// This class stores variables internally, acting as the permanent store.
//----------------------------------------------------------------------
-class ExpressionVariableList
-{
+class ExpressionVariableList {
public:
- //----------------------------------------------------------------------
- /// Implementation of methods in ExpressionVariableListBase
- //----------------------------------------------------------------------
- size_t
- GetSize()
- {
- return m_variables.size();
- }
-
- lldb::ExpressionVariableSP
- GetVariableAtIndex(size_t index)
- {
- lldb::ExpressionVariableSP var_sp;
- if (index < m_variables.size())
- var_sp = m_variables[index];
- return var_sp;
- }
-
- size_t
- AddVariable (const lldb::ExpressionVariableSP &var_sp)
- {
- m_variables.push_back(var_sp);
- return m_variables.size() - 1;
- }
-
- lldb::ExpressionVariableSP
- AddNewlyConstructedVariable (ExpressionVariable *var)
- {
- lldb::ExpressionVariableSP var_sp(var);
- m_variables.push_back(var_sp);
- return m_variables.back();
- }
+ //----------------------------------------------------------------------
+ /// Implementation of methods in ExpressionVariableListBase
+ //----------------------------------------------------------------------
+ size_t GetSize() { return m_variables.size(); }
- bool
- ContainsVariable (const lldb::ExpressionVariableSP &var_sp)
- {
- const size_t size = m_variables.size();
- for (size_t index = 0; index < size; ++index)
- {
- if (m_variables[index].get() == var_sp.get())
- return true;
- }
- return false;
+ lldb::ExpressionVariableSP GetVariableAtIndex(size_t index) {
+ lldb::ExpressionVariableSP var_sp;
+ if (index < m_variables.size())
+ var_sp = m_variables[index];
+ return var_sp;
+ }
+
+ size_t AddVariable(const lldb::ExpressionVariableSP &var_sp) {
+ m_variables.push_back(var_sp);
+ return m_variables.size() - 1;
+ }
+
+ lldb::ExpressionVariableSP
+ AddNewlyConstructedVariable(ExpressionVariable *var) {
+ lldb::ExpressionVariableSP var_sp(var);
+ m_variables.push_back(var_sp);
+ return m_variables.back();
+ }
+
+ bool ContainsVariable(const lldb::ExpressionVariableSP &var_sp) {
+ const size_t size = m_variables.size();
+ for (size_t index = 0; index < size; ++index) {
+ if (m_variables[index].get() == var_sp.get())
+ return true;
}
+ return false;
+ }
- //----------------------------------------------------------------------
- /// Finds a variable by name in the list.
- ///
- /// @param[in] name
- /// The name of the requested variable.
- ///
- /// @return
- /// The variable requested, or nullptr if that variable is not in the list.
- //----------------------------------------------------------------------
- lldb::ExpressionVariableSP
- GetVariable (const ConstString &name)
- {
- lldb::ExpressionVariableSP var_sp;
- for (size_t index = 0, size = GetSize(); index < size; ++index)
- {
- var_sp = GetVariableAtIndex(index);
- if (var_sp->GetName() == name)
- return var_sp;
- }
- var_sp.reset();
+ //----------------------------------------------------------------------
+ /// Finds a variable by name in the list.
+ ///
+ /// @param[in] name
+ /// The name of the requested variable.
+ ///
+ /// @return
+ /// The variable requested, or nullptr if that variable is not in the
+ /// list.
+ //----------------------------------------------------------------------
+ lldb::ExpressionVariableSP GetVariable(const ConstString &name) {
+ lldb::ExpressionVariableSP var_sp;
+ for (size_t index = 0, size = GetSize(); index < size; ++index) {
+ var_sp = GetVariableAtIndex(index);
+ if (var_sp->GetName() == name)
return var_sp;
}
+ var_sp.reset();
+ return var_sp;
+ }
+
+ lldb::ExpressionVariableSP GetVariable(llvm::StringRef name) {
+ if (name.empty())
+ return nullptr;
- lldb::ExpressionVariableSP
- GetVariable (const char *name)
- {
- lldb::ExpressionVariableSP var_sp;
- if (name && name[0])
- {
- for (size_t index = 0, size = GetSize(); index < size; ++index)
- {
- var_sp = GetVariableAtIndex(index);
- const char *var_name_cstr = var_sp->GetName().GetCString();
- if (!var_name_cstr || !name)
- continue;
- if (::strcmp (var_name_cstr, name) == 0)
- return var_sp;
- }
- var_sp.reset();
- }
+ for (size_t index = 0, size = GetSize(); index < size; ++index) {
+ auto var_sp = GetVariableAtIndex(index);
+ llvm::StringRef var_name_str = var_sp->GetName().GetStringRef();
+ if (var_name_str == name)
return var_sp;
}
-
- void
- RemoveVariable (lldb::ExpressionVariableSP var_sp)
- {
- for (std::vector<lldb::ExpressionVariableSP>::iterator vi = m_variables.begin(), ve = m_variables.end();
- vi != ve;
- ++vi)
- {
- if (vi->get() == var_sp.get())
- {
- m_variables.erase(vi);
- return;
- }
- }
- }
-
- void
- Clear()
- {
- m_variables.clear();
+ return nullptr;
+ }
+
+ void RemoveVariable(lldb::ExpressionVariableSP var_sp) {
+ for (std::vector<lldb::ExpressionVariableSP>::iterator
+ vi = m_variables.begin(),
+ ve = m_variables.end();
+ vi != ve; ++vi) {
+ if (vi->get() == var_sp.get()) {
+ m_variables.erase(vi);
+ return;
+ }
}
+ }
+
+ void Clear() { m_variables.clear(); }
private:
- std::vector <lldb::ExpressionVariableSP> m_variables;
+ std::vector<lldb::ExpressionVariableSP> m_variables;
};
-
+
class PersistentExpressionState : public ExpressionVariableList {
public:
- //----------------------------------------------------------------------
- // See TypeSystem.h for how to add subclasses to this.
- //----------------------------------------------------------------------
- enum LLVMCastKind {
- eKindClang,
- eKindSwift,
- eKindGo,
- kNumKinds
- };
-
- LLVMCastKind getKind() const { return m_kind; }
-
- PersistentExpressionState(LLVMCastKind kind) :
- m_kind(kind)
- {
- }
+ //----------------------------------------------------------------------
+ // See TypeSystem.h for how to add subclasses to this.
+ //----------------------------------------------------------------------
+ enum LLVMCastKind { eKindClang, eKindSwift, eKindGo, kNumKinds };
+
+ LLVMCastKind getKind() const { return m_kind; }
+
+ PersistentExpressionState(LLVMCastKind kind) : m_kind(kind) {}
+
+ virtual ~PersistentExpressionState();
+
+ virtual lldb::ExpressionVariableSP
+ CreatePersistentVariable(const lldb::ValueObjectSP &valobj_sp) = 0;
+
+ virtual lldb::ExpressionVariableSP
+ CreatePersistentVariable(ExecutionContextScope *exe_scope,
+ const ConstString &name, const CompilerType &type,
+ lldb::ByteOrder byte_order,
+ uint32_t addr_byte_size) = 0;
+
+ virtual ConstString GetNextPersistentVariableName() = 0;
+
+ virtual void
+ RemovePersistentVariable(lldb::ExpressionVariableSP variable) = 0;
+
+ virtual lldb::addr_t LookupSymbol(const ConstString &name);
+
+ void RegisterExecutionUnit(lldb::IRExecutionUnitSP &execution_unit_sp);
- virtual ~PersistentExpressionState();
-
- virtual lldb::ExpressionVariableSP
- CreatePersistentVariable (const lldb::ValueObjectSP &valobj_sp) = 0;
-
- virtual lldb::ExpressionVariableSP
- CreatePersistentVariable (ExecutionContextScope *exe_scope,
- const ConstString &name,
- const CompilerType &type,
- lldb::ByteOrder byte_order,
- uint32_t addr_byte_size) = 0;
-
- virtual ConstString
- GetNextPersistentVariableName () = 0;
-
- virtual void
- RemovePersistentVariable (lldb::ExpressionVariableSP variable) = 0;
-
- virtual lldb::addr_t
- LookupSymbol (const ConstString &name);
-
- void
- RegisterExecutionUnit (lldb::IRExecutionUnitSP &execution_unit_sp);
-
private:
- LLVMCastKind m_kind;
-
- typedef std::set<lldb::IRExecutionUnitSP> ExecutionUnitSet;
- ExecutionUnitSet m_execution_units; ///< The execution units that contain valuable symbols.
-
- typedef llvm::DenseMap<const char *, lldb::addr_t> SymbolMap;
- SymbolMap m_symbol_map; ///< The addresses of the symbols in m_execution_units.
+ LLVMCastKind m_kind;
+
+ typedef std::set<lldb::IRExecutionUnitSP> ExecutionUnitSet;
+ ExecutionUnitSet
+ m_execution_units; ///< The execution units that contain valuable symbols.
+
+ typedef llvm::DenseMap<const char *, lldb::addr_t> SymbolMap;
+ SymbolMap
+ m_symbol_map; ///< The addresses of the symbols in m_execution_units.
};
-
+
} // namespace lldb_private
#endif // liblldb_ExpressionVariable_h_
diff --git a/include/lldb/Expression/FunctionCaller.h b/include/lldb/Expression/FunctionCaller.h
index 3848073c654f..56305d5181bd 100644
--- a/include/lldb/Expression/FunctionCaller.h
+++ b/include/lldb/Expression/FunctionCaller.h
@@ -25,9 +25,8 @@
#include "lldb/Expression/ExpressionParser.h"
#include "lldb/Symbol/CompilerType.h"
-namespace lldb_private
-{
-
+namespace lldb_private {
+
//----------------------------------------------------------------------
/// @class FunctionCaller FunctionCaller.h "lldb/Expression/FunctionCaller.h"
/// @brief Encapsulates a function that can be called.
@@ -39,7 +38,7 @@ namespace lldb_private
/// It performs the call by synthesizing a structure that contains the pointer
/// to the function and the arguments that should be passed to that function,
/// and producing a special-purpose JIT-compiled function that accepts a void*
-/// pointing to this struct as its only argument and calls the function in the
+/// pointing to this struct as its only argument and calls the function in the
/// struct with the written arguments. This method lets Clang handle the
/// vagaries of function calling conventions.
///
@@ -51,341 +50,340 @@ namespace lldb_private
/// InsertFunction() followed by WriteFunctionArguments(), which will return
/// the location of the args struct for the wrapper function in args_addr_ref.
///
-/// If you need to call the function on the thread plan stack, you can also
+/// If you need to call the function on the thread plan stack, you can also
/// call InsertFunction() followed by GetThreadPlanToCallFunction().
///
/// Any of the methods that take arg_addr_ptr or arg_addr_ref can be passed
/// a pointer set to LLDB_INVALID_ADDRESS and new structure will be allocated
/// and its address returned in that variable.
-///
+///
/// Any of the methods that take arg_addr_ptr can be passed nullptr, and the
/// argument space will be managed for you.
-//----------------------------------------------------------------------
-class FunctionCaller : public Expression
-{
+//----------------------------------------------------------------------
+class FunctionCaller : public Expression {
public:
- //------------------------------------------------------------------
- /// Constructor
- ///
- /// @param[in] exe_scope
- /// An execution context scope that gets us at least a target and
- /// process.
- ///
- /// @param[in] ast_context
- /// The AST context to evaluate argument types in.
- ///
- /// @param[in] return_qualtype
- /// An opaque Clang QualType for the function result. Should be
- /// defined in ast_context.
- ///
- /// @param[in] function_address
- /// The address of the function to call.
- ///
- /// @param[in] arg_value_list
- /// The default values to use when calling this function. Can
- /// be overridden using WriteFunctionArguments().
- //------------------------------------------------------------------
- FunctionCaller (ExecutionContextScope &exe_scope,
- const CompilerType &return_type,
- const Address& function_address,
- const ValueList &arg_value_list,
- const char *name);
-
- //------------------------------------------------------------------
- /// Destructor
- //------------------------------------------------------------------
- ~FunctionCaller() override;
-
- //------------------------------------------------------------------
- /// Compile the wrapper function
- ///
- /// @param[in] thread_to_use_sp
- /// Compilation might end up calling functions. Pass in the thread you
- /// want the compilation to use. If you pass in an empty ThreadSP it will
- /// use the currently selected thread.
- ///
- /// @param[in] diagnostic_manager
- /// The diagnostic manager to report parser errors to.
- ///
- /// @return
- /// The number of errors.
- //------------------------------------------------------------------
- virtual unsigned
- CompileFunction (lldb::ThreadSP thread_to_use_sp,
- DiagnosticManager &diagnostic_manager) = 0;
-
- //------------------------------------------------------------------
- /// Insert the default function wrapper and its default argument struct
- ///
- /// @param[in] exe_ctx
- /// The execution context to insert the function and its arguments
- /// into.
- ///
- /// @param[in,out] args_addr_ref
- /// The address of the structure to write the arguments into. May
- /// be LLDB_INVALID_ADDRESS; if it is, a new structure is allocated
- /// and args_addr_ref is pointed to it.
- ///
- /// @param[in] diagnostic_manager
- /// The diagnostic manager to report errors to.
- ///
- /// @return
- /// True on success; false otherwise.
- //------------------------------------------------------------------
- bool
- InsertFunction(ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, DiagnosticManager &diagnostic_manager);
-
- //------------------------------------------------------------------
- /// Insert the default function wrapper (using the JIT)
- ///
- /// @param[in] exe_ctx
- /// The execution context to insert the function and its arguments
- /// into.
- ///
- /// @param[in] diagnostic_manager
- /// The diagnostic manager to report errors to.
- ///
- /// @return
- /// True on success; false otherwise.
- //------------------------------------------------------------------
- bool
- WriteFunctionWrapper(ExecutionContext &exe_ctx, DiagnosticManager &diagnostic_manager);
-
- //------------------------------------------------------------------
- /// Insert the default function argument struct
- ///
- /// @param[in] exe_ctx
- /// The execution context to insert the function and its arguments
- /// into.
- ///
- /// @param[in,out] args_addr_ref
- /// The address of the structure to write the arguments into. May
- /// be LLDB_INVALID_ADDRESS; if it is, a new structure is allocated
- /// and args_addr_ref is pointed to it.
- ///
- /// @param[in] diagnostic_manager
- /// The diagnostic manager to report errors to.
- ///
- /// @return
- /// True on success; false otherwise.
- //------------------------------------------------------------------
- bool
- WriteFunctionArguments(ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref,
- DiagnosticManager &diagnostic_manager);
-
- //------------------------------------------------------------------
- /// Insert an argument struct with a non-default function address and
- /// non-default argument values
- ///
- /// @param[in] exe_ctx
- /// The execution context to insert the function and its arguments
- /// into.
- ///
- /// @param[in,out] args_addr_ref
- /// The address of the structure to write the arguments into. May
- /// be LLDB_INVALID_ADDRESS; if it is, a new structure is allocated
- /// and args_addr_ref is pointed at it.
- ///
- /// @param[in] arg_values
- /// The values of the function's arguments.
- ///
- /// @param[in] diagnostic_manager
- /// The diagnostic manager to report errors to.
- ///
- /// @return
- /// True on success; false otherwise.
- //------------------------------------------------------------------
- bool
- WriteFunctionArguments(ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, ValueList &arg_values,
- DiagnosticManager &diagnostic_manager);
-
- //------------------------------------------------------------------
- /// Run the function this FunctionCaller was created with.
- ///
- /// This is the full version.
- ///
- /// @param[in] exe_ctx
- /// The thread & process in which this function will run.
- ///
- /// @param[in] args_addr_ptr
- /// If nullptr, the function will take care of allocating & deallocating the wrapper
- /// args structure. Otherwise, if set to LLDB_INVALID_ADDRESS, a new structure
- /// will be allocated, filled and the address returned to you. You are responsible
- /// for deallocating it. And if passed in with a value other than LLDB_INVALID_ADDRESS,
- /// this should point to an already allocated structure with the values already written.
- ///
- /// @param[in] diagnostic_manager
- /// The diagnostic manager to report errors to.
- ///
- /// @param[in] options
- /// The options for this expression execution.
- ///
- /// @param[out] results
- /// The result value will be put here after running the function.
- ///
- /// @return
- /// Returns one of the ExpressionResults enum indicating function call status.
- //------------------------------------------------------------------
- lldb::ExpressionResults
- ExecuteFunction(ExecutionContext &exe_ctx, lldb::addr_t *args_addr_ptr, const EvaluateExpressionOptions &options,
- DiagnosticManager &diagnostic_manager, Value &results);
-
- //------------------------------------------------------------------
- /// Get a thread plan to run the function this FunctionCaller was created with.
- ///
- /// @param[in] exe_ctx
- /// The execution context to insert the function and its arguments
- /// into.
- ///
- /// @param[in] func_addr
- /// The address of the function in the target process.
- ///
- /// @param[in] args_addr
- /// The address of the argument struct.
- ///
- /// @param[in] diagnostic_manager
- /// The diagnostic manager to report errors to.
- ///
- /// @param[in] stop_others
- /// True if other threads should pause during execution.
- ///
- /// @param[in] unwind_on_error
- /// True if the thread plan may simply be discarded if an error occurs.
- ///
- /// @return
- /// A ThreadPlan shared pointer for executing the function.
- //------------------------------------------------------------------
- lldb::ThreadPlanSP
- GetThreadPlanToCallFunction(ExecutionContext &exe_ctx, lldb::addr_t args_addr,
- const EvaluateExpressionOptions &options, DiagnosticManager &diagnostic_manager);
-
- //------------------------------------------------------------------
- /// Get the result of the function from its struct
- ///
- /// @param[in] exe_ctx
- /// The execution context to retrieve the result from.
- ///
- /// @param[in] args_addr
- /// The address of the argument struct.
- ///
- /// @param[out] ret_value
- /// The value returned by the function.
- ///
- /// @return
- /// True on success; false otherwise.
- //------------------------------------------------------------------
- bool FetchFunctionResults (ExecutionContext &exe_ctx,
- lldb::addr_t args_addr,
- Value &ret_value);
-
- //------------------------------------------------------------------
- /// Deallocate the arguments structure
- ///
- /// @param[in] exe_ctx
- /// The execution context to insert the function and its arguments
- /// into.
- ///
- /// @param[in] args_addr
- /// The address of the argument struct.
- //------------------------------------------------------------------
- void DeallocateFunctionResults (ExecutionContext &exe_ctx,
- lldb::addr_t args_addr);
-
- //------------------------------------------------------------------
- /// Interface for ClangExpression
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Return the string that the parser should parse. Must be a full
- /// translation unit.
- //------------------------------------------------------------------
- const char *
- Text() override
- {
- return m_wrapper_function_text.c_str();
- }
-
- //------------------------------------------------------------------
- /// Return the function name that should be used for executing the
- /// expression. Text() should contain the definition of this
- /// function.
- //------------------------------------------------------------------
- const char *
- FunctionName() override
- {
- return m_wrapper_function_name.c_str();
- }
-
- //------------------------------------------------------------------
- /// Return the object that the parser should use when registering
- /// local variables. May be nullptr if the Expression doesn't care.
- //------------------------------------------------------------------
- ExpressionVariableList *
- LocalVariables ()
- {
- return nullptr;
- }
-
- //------------------------------------------------------------------
- /// Return true if validation code should be inserted into the
- /// expression.
- //------------------------------------------------------------------
- bool
- NeedsValidation() override
- {
- return false;
- }
-
- //------------------------------------------------------------------
- /// Return true if external variables in the expression should be
- /// resolved.
- //------------------------------------------------------------------
- bool
- NeedsVariableResolution() override
- {
- return false;
- }
-
- ValueList
- GetArgumentValues () const
- {
- return m_arg_values;
- }
+ //------------------------------------------------------------------
+ /// Constructor
+ ///
+ /// @param[in] exe_scope
+ /// An execution context scope that gets us at least a target and
+ /// process.
+ ///
+ /// @param[in] ast_context
+ /// The AST context to evaluate argument types in.
+ ///
+ /// @param[in] return_qualtype
+ /// An opaque Clang QualType for the function result. Should be
+ /// defined in ast_context.
+ ///
+ /// @param[in] function_address
+ /// The address of the function to call.
+ ///
+ /// @param[in] arg_value_list
+ /// The default values to use when calling this function. Can
+ /// be overridden using WriteFunctionArguments().
+ //------------------------------------------------------------------
+ FunctionCaller(ExecutionContextScope &exe_scope,
+ const CompilerType &return_type,
+ const Address &function_address,
+ const ValueList &arg_value_list, const char *name);
+
+ //------------------------------------------------------------------
+ /// Destructor
+ //------------------------------------------------------------------
+ ~FunctionCaller() override;
+
+ //------------------------------------------------------------------
+ /// Compile the wrapper function
+ ///
+ /// @param[in] thread_to_use_sp
+ /// Compilation might end up calling functions. Pass in the thread you
+ /// want the compilation to use. If you pass in an empty ThreadSP it will
+ /// use the currently selected thread.
+ ///
+ /// @param[in] diagnostic_manager
+ /// The diagnostic manager to report parser errors to.
+ ///
+ /// @return
+ /// The number of errors.
+ //------------------------------------------------------------------
+ virtual unsigned CompileFunction(lldb::ThreadSP thread_to_use_sp,
+ DiagnosticManager &diagnostic_manager) = 0;
+
+ //------------------------------------------------------------------
+ /// Insert the default function wrapper and its default argument struct
+ ///
+ /// @param[in] exe_ctx
+ /// The execution context to insert the function and its arguments
+ /// into.
+ ///
+ /// @param[in,out] args_addr_ref
+ /// The address of the structure to write the arguments into. May
+ /// be LLDB_INVALID_ADDRESS; if it is, a new structure is allocated
+ /// and args_addr_ref is pointed to it.
+ ///
+ /// @param[in] diagnostic_manager
+ /// The diagnostic manager to report errors to.
+ ///
+ /// @return
+ /// True on success; false otherwise.
+ //------------------------------------------------------------------
+ bool InsertFunction(ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref,
+ DiagnosticManager &diagnostic_manager);
+
+ //------------------------------------------------------------------
+ /// Insert the default function wrapper (using the JIT)
+ ///
+ /// @param[in] exe_ctx
+ /// The execution context to insert the function and its arguments
+ /// into.
+ ///
+ /// @param[in] diagnostic_manager
+ /// The diagnostic manager to report errors to.
+ ///
+ /// @return
+ /// True on success; false otherwise.
+ //------------------------------------------------------------------
+ bool WriteFunctionWrapper(ExecutionContext &exe_ctx,
+ DiagnosticManager &diagnostic_manager);
+
+ //------------------------------------------------------------------
+ /// Insert the default function argument struct
+ ///
+ /// @param[in] exe_ctx
+ /// The execution context to insert the function and its arguments
+ /// into.
+ ///
+ /// @param[in,out] args_addr_ref
+ /// The address of the structure to write the arguments into. May
+ /// be LLDB_INVALID_ADDRESS; if it is, a new structure is allocated
+ /// and args_addr_ref is pointed to it.
+ ///
+ /// @param[in] diagnostic_manager
+ /// The diagnostic manager to report errors to.
+ ///
+ /// @return
+ /// True on success; false otherwise.
+ //------------------------------------------------------------------
+ bool WriteFunctionArguments(ExecutionContext &exe_ctx,
+ lldb::addr_t &args_addr_ref,
+ DiagnosticManager &diagnostic_manager);
+
+ //------------------------------------------------------------------
+ /// Insert an argument struct with a non-default function address and
+ /// non-default argument values
+ ///
+ /// @param[in] exe_ctx
+ /// The execution context to insert the function and its arguments
+ /// into.
+ ///
+ /// @param[in,out] args_addr_ref
+ /// The address of the structure to write the arguments into. May
+ /// be LLDB_INVALID_ADDRESS; if it is, a new structure is allocated
+ /// and args_addr_ref is pointed at it.
+ ///
+ /// @param[in] arg_values
+ /// The values of the function's arguments.
+ ///
+ /// @param[in] diagnostic_manager
+ /// The diagnostic manager to report errors to.
+ ///
+ /// @return
+ /// True on success; false otherwise.
+ //------------------------------------------------------------------
+ bool WriteFunctionArguments(ExecutionContext &exe_ctx,
+ lldb::addr_t &args_addr_ref,
+ ValueList &arg_values,
+ DiagnosticManager &diagnostic_manager);
+
+ //------------------------------------------------------------------
+ /// Run the function this FunctionCaller was created with.
+ ///
+ /// This is the full version.
+ ///
+ /// @param[in] exe_ctx
+ /// The thread & process in which this function will run.
+ ///
+ /// @param[in] args_addr_ptr
+ /// If nullptr, the function will take care of allocating & deallocating
+ /// the wrapper
+ /// args structure. Otherwise, if set to LLDB_INVALID_ADDRESS, a new
+ /// structure
+ /// will be allocated, filled and the address returned to you. You are
+ /// responsible
+ /// for deallocating it. And if passed in with a value other than
+ /// LLDB_INVALID_ADDRESS,
+ /// this should point to an already allocated structure with the values
+ /// already written.
+ ///
+ /// @param[in] diagnostic_manager
+ /// The diagnostic manager to report errors to.
+ ///
+ /// @param[in] options
+ /// The options for this expression execution.
+ ///
+ /// @param[out] results
+ /// The result value will be put here after running the function.
+ ///
+ /// @return
+ /// Returns one of the ExpressionResults enum indicating function call
+ /// status.
+ //------------------------------------------------------------------
+ lldb::ExpressionResults
+ ExecuteFunction(ExecutionContext &exe_ctx, lldb::addr_t *args_addr_ptr,
+ const EvaluateExpressionOptions &options,
+ DiagnosticManager &diagnostic_manager, Value &results);
+
+ //------------------------------------------------------------------
+ /// Get a thread plan to run the function this FunctionCaller was created
+ /// with.
+ ///
+ /// @param[in] exe_ctx
+ /// The execution context to insert the function and its arguments
+ /// into.
+ ///
+ /// @param[in] func_addr
+ /// The address of the function in the target process.
+ ///
+ /// @param[in] args_addr
+ /// The address of the argument struct.
+ ///
+ /// @param[in] diagnostic_manager
+ /// The diagnostic manager to report errors to.
+ ///
+ /// @param[in] stop_others
+ /// True if other threads should pause during execution.
+ ///
+ /// @param[in] unwind_on_error
+ /// True if the thread plan may simply be discarded if an error occurs.
+ ///
+ /// @return
+ /// A ThreadPlan shared pointer for executing the function.
+ //------------------------------------------------------------------
+ lldb::ThreadPlanSP
+ GetThreadPlanToCallFunction(ExecutionContext &exe_ctx, lldb::addr_t args_addr,
+ const EvaluateExpressionOptions &options,
+ DiagnosticManager &diagnostic_manager);
+
+ //------------------------------------------------------------------
+ /// Get the result of the function from its struct
+ ///
+ /// @param[in] exe_ctx
+ /// The execution context to retrieve the result from.
+ ///
+ /// @param[in] args_addr
+ /// The address of the argument struct.
+ ///
+ /// @param[out] ret_value
+ /// The value returned by the function.
+ ///
+ /// @return
+ /// True on success; false otherwise.
+ //------------------------------------------------------------------
+ bool FetchFunctionResults(ExecutionContext &exe_ctx, lldb::addr_t args_addr,
+ Value &ret_value);
+
+ //------------------------------------------------------------------
+ /// Deallocate the arguments structure
+ ///
+ /// @param[in] exe_ctx
+ /// The execution context to insert the function and its arguments
+ /// into.
+ ///
+ /// @param[in] args_addr
+ /// The address of the argument struct.
+ //------------------------------------------------------------------
+ void DeallocateFunctionResults(ExecutionContext &exe_ctx,
+ lldb::addr_t args_addr);
+
+ //------------------------------------------------------------------
+ /// Interface for ClangExpression
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Return the string that the parser should parse. Must be a full
+ /// translation unit.
+ //------------------------------------------------------------------
+ const char *Text() override { return m_wrapper_function_text.c_str(); }
+
+ //------------------------------------------------------------------
+ /// Return the function name that should be used for executing the
+ /// expression. Text() should contain the definition of this
+ /// function.
+ //------------------------------------------------------------------
+ const char *FunctionName() override {
+ return m_wrapper_function_name.c_str();
+ }
+
+ //------------------------------------------------------------------
+ /// Return the object that the parser should use when registering
+ /// local variables. May be nullptr if the Expression doesn't care.
+ //------------------------------------------------------------------
+ ExpressionVariableList *LocalVariables() { return nullptr; }
+
+ //------------------------------------------------------------------
+ /// Return true if validation code should be inserted into the
+ /// expression.
+ //------------------------------------------------------------------
+ bool NeedsValidation() override { return false; }
+
+ //------------------------------------------------------------------
+ /// Return true if external variables in the expression should be
+ /// resolved.
+ //------------------------------------------------------------------
+ bool NeedsVariableResolution() override { return false; }
+
+ ValueList GetArgumentValues() const { return m_arg_values; }
protected:
- // Note: the parser needs to be destructed before the execution unit, so
- // declare the execution unit first.
- std::shared_ptr<IRExecutionUnit> m_execution_unit_sp;
- std::unique_ptr<ExpressionParser> m_parser; ///< The parser responsible for compiling the function.
- ///< This will get made in CompileFunction, so it is
- ///< safe to access it after that.
-
- lldb::ModuleWP m_jit_module_wp;
- std::string m_name; ///< The name of this clang function - for debugging purposes.
-
- Function *m_function_ptr; ///< The function we're going to call. May be nullptr if we don't have debug info for the function.
- Address m_function_addr; ///< If we don't have the FunctionSP, we at least need the address & return type.
- CompilerType m_function_return_type; ///< The opaque clang qual type for the function return type.
-
- std::string m_wrapper_function_name; ///< The name of the wrapper function.
- std::string m_wrapper_function_text; ///< The contents of the wrapper function.
- std::string m_wrapper_struct_name; ///< The name of the struct that contains the target function address, arguments, and result.
- std::list<lldb::addr_t> m_wrapper_args_addrs; ///< The addresses of the arguments to the wrapper function.
-
- bool m_struct_valid; ///< True if the ASTStructExtractor has populated the variables below.
-
- //------------------------------------------------------------------
- /// These values are populated by the ASTStructExtractor
- size_t m_struct_size; ///< The size of the argument struct, in bytes.
- std::vector<uint64_t> m_member_offsets; ///< The offset of each member in the struct, in bytes.
- uint64_t m_return_size; ///< The size of the result variable, in bytes.
- uint64_t m_return_offset; ///< The offset of the result variable in the struct, in bytes.
- //------------------------------------------------------------------
-
- ValueList m_arg_values; ///< The default values of the arguments.
-
- bool m_compiled; ///< True if the wrapper function has already been parsed.
- bool m_JITted; ///< True if the wrapper function has already been JIT-compiled.
+ // Note: the parser needs to be destructed before the execution unit, so
+ // declare the execution unit first.
+ std::shared_ptr<IRExecutionUnit> m_execution_unit_sp;
+ std::unique_ptr<ExpressionParser>
+ m_parser; ///< The parser responsible for compiling the function.
+ ///< This will get made in CompileFunction, so it is
+ ///< safe to access it after that.
+
+ lldb::ModuleWP m_jit_module_wp;
+ std::string
+ m_name; ///< The name of this clang function - for debugging purposes.
+
+ Function *m_function_ptr; ///< The function we're going to call. May be
+ ///nullptr if we don't have debug info for the
+ ///function.
+ Address m_function_addr; ///< If we don't have the FunctionSP, we at least
+ ///need the address & return type.
+ CompilerType m_function_return_type; ///< The opaque clang qual type for the
+ ///function return type.
+
+ std::string m_wrapper_function_name; ///< The name of the wrapper function.
+ std::string
+ m_wrapper_function_text; ///< The contents of the wrapper function.
+ std::string m_wrapper_struct_name; ///< The name of the struct that contains
+ ///the target function address, arguments,
+ ///and result.
+ std::list<lldb::addr_t> m_wrapper_args_addrs; ///< The addresses of the
+ ///arguments to the wrapper
+ ///function.
+
+ bool m_struct_valid; ///< True if the ASTStructExtractor has populated the
+ ///variables below.
+
+ //------------------------------------------------------------------
+ /// These values are populated by the ASTStructExtractor
+ size_t m_struct_size; ///< The size of the argument struct, in bytes.
+ std::vector<uint64_t>
+ m_member_offsets; ///< The offset of each member in the struct, in bytes.
+ uint64_t m_return_size; ///< The size of the result variable, in bytes.
+ uint64_t m_return_offset; ///< The offset of the result variable in the
+ ///struct, in bytes.
+ //------------------------------------------------------------------
+
+ ValueList m_arg_values; ///< The default values of the arguments.
+
+ bool m_compiled; ///< True if the wrapper function has already been parsed.
+ bool
+ m_JITted; ///< True if the wrapper function has already been JIT-compiled.
};
} // namespace lldb_private
diff --git a/include/lldb/Expression/IRDynamicChecks.h b/include/lldb/Expression/IRDynamicChecks.h
index 9f31a6eb01d6..b793a60585bb 100644
--- a/include/lldb/Expression/IRDynamicChecks.h
+++ b/include/lldb/Expression/IRDynamicChecks.h
@@ -1,4 +1,5 @@
-//===-- IRDynamicChecks.h ---------------------------------------------*- C++ -*-===//
+//===-- IRDynamicChecks.h ---------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,25 +15,25 @@
#include "llvm/Pass.h"
namespace llvm {
- class BasicBlock;
- class CallInst;
- class Constant;
- class Function;
- class Instruction;
- class Module;
- class DataLayout;
- class Value;
+class BasicBlock;
+class CallInst;
+class Constant;
+class Function;
+class Instruction;
+class Module;
+class DataLayout;
+class Value;
}
-namespace lldb_private
-{
+namespace lldb_private {
class ClangExpressionDeclMap;
class ExecutionContext;
class Stream;
//----------------------------------------------------------------------
-/// @class DynamicCheckerFunctions IRDynamicChecks.h "lldb/Expression/IRDynamicChecks.h"
+/// @class DynamicCheckerFunctions IRDynamicChecks.h
+/// "lldb/Expression/IRDynamicChecks.h"
/// @brief Encapsulates dynamic check functions used by expressions.
///
/// Each of the utility functions encapsulated in this class is responsible
@@ -44,46 +45,45 @@ class Stream;
/// The class installs each checker function into the target process and
/// makes it available to IRDynamicChecks to use.
//----------------------------------------------------------------------
-class DynamicCheckerFunctions
-{
+class DynamicCheckerFunctions {
public:
- //------------------------------------------------------------------
- /// Constructor
- //------------------------------------------------------------------
- DynamicCheckerFunctions ();
-
- //------------------------------------------------------------------
- /// Destructor
- //------------------------------------------------------------------
- ~DynamicCheckerFunctions ();
-
- //------------------------------------------------------------------
- /// Install the utility functions into a process. This binds the
- /// instance of DynamicCheckerFunctions to that process.
- ///
- /// @param[in] diagnostic_manager
- /// A diagnostic manager to report errors to.
- ///
- /// @param[in] exe_ctx
- /// The execution context to install the functions into.
- ///
- /// @return
- /// True on success; false on failure, or if the functions have
- /// already been installed.
- //------------------------------------------------------------------
- bool
- Install(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx);
-
- bool
- DoCheckersExplainStop(lldb::addr_t addr, Stream &message);
-
- std::unique_ptr<UtilityFunction> m_valid_pointer_check;
- std::unique_ptr<UtilityFunction> m_objc_object_check;
+ //------------------------------------------------------------------
+ /// Constructor
+ //------------------------------------------------------------------
+ DynamicCheckerFunctions();
+
+ //------------------------------------------------------------------
+ /// Destructor
+ //------------------------------------------------------------------
+ ~DynamicCheckerFunctions();
+
+ //------------------------------------------------------------------
+ /// Install the utility functions into a process. This binds the
+ /// instance of DynamicCheckerFunctions to that process.
+ ///
+ /// @param[in] diagnostic_manager
+ /// A diagnostic manager to report errors to.
+ ///
+ /// @param[in] exe_ctx
+ /// The execution context to install the functions into.
+ ///
+ /// @return
+ /// True on success; false on failure, or if the functions have
+ /// already been installed.
+ //------------------------------------------------------------------
+ bool Install(DiagnosticManager &diagnostic_manager,
+ ExecutionContext &exe_ctx);
+
+ bool DoCheckersExplainStop(lldb::addr_t addr, Stream &message);
+
+ std::unique_ptr<UtilityFunction> m_valid_pointer_check;
+ std::unique_ptr<UtilityFunction> m_objc_object_check;
};
//----------------------------------------------------------------------
/// @class IRDynamicChecks IRDynamicChecks.h "lldb/Expression/IRDynamicChecks.h"
-/// @brief Adds dynamic checks to a user-entered expression to reduce its likelihood of crashing
+/// @brief Adds dynamic checks to a user-entered expression to reduce its
+/// likelihood of crashing
///
/// When an IR function is executed in the target process, it may cause
/// crashes or hangs by dereferencing NULL pointers, trying to call Objective-C
@@ -92,79 +92,79 @@ public:
/// IRDynamicChecks adds calls to the functions in DynamicCheckerFunctions
/// to appropriate locations in an expression's IR.
//----------------------------------------------------------------------
-class IRDynamicChecks : public llvm::ModulePass
-{
+class IRDynamicChecks : public llvm::ModulePass {
public:
- //------------------------------------------------------------------
- /// Constructor
- ///
- /// @param[in] checker_functions
- /// The checker functions for the target process.
- ///
- /// @param[in] func_name
- /// The name of the function to prepare for execution in the target.
- ///
- /// @param[in] decl_map
- /// The mapping used to look up entities in the target process. In
- /// this case, used to find objc_msgSend
- //------------------------------------------------------------------
- IRDynamicChecks (DynamicCheckerFunctions &checker_functions,
- const char* func_name = "$__lldb_expr");
-
- //------------------------------------------------------------------
- /// Destructor
- //------------------------------------------------------------------
- ~IRDynamicChecks() override;
-
- //------------------------------------------------------------------
- /// Run this IR transformer on a single module
- ///
- /// @param[in] M
- /// The module to run on. This module is searched for the function
- /// $__lldb_expr, and that function is passed to the passes one by
- /// one.
- ///
- /// @return
- /// True on success; false otherwise
- //------------------------------------------------------------------
- bool runOnModule(llvm::Module &M) override;
-
- //------------------------------------------------------------------
- /// Interface stub
- //------------------------------------------------------------------
- void assignPassManager(llvm::PMStack &PMS,
- llvm::PassManagerType T = llvm::PMT_ModulePassManager) override;
-
- //------------------------------------------------------------------
- /// Returns PMT_ModulePassManager
- //------------------------------------------------------------------
- llvm::PassManagerType getPotentialPassManagerType() const override;
+ //------------------------------------------------------------------
+ /// Constructor
+ ///
+ /// @param[in] checker_functions
+ /// The checker functions for the target process.
+ ///
+ /// @param[in] func_name
+ /// The name of the function to prepare for execution in the target.
+ ///
+ /// @param[in] decl_map
+ /// The mapping used to look up entities in the target process. In
+ /// this case, used to find objc_msgSend
+ //------------------------------------------------------------------
+ IRDynamicChecks(DynamicCheckerFunctions &checker_functions,
+ const char *func_name = "$__lldb_expr");
+
+ //------------------------------------------------------------------
+ /// Destructor
+ //------------------------------------------------------------------
+ ~IRDynamicChecks() override;
+
+ //------------------------------------------------------------------
+ /// Run this IR transformer on a single module
+ ///
+ /// @param[in] M
+ /// The module to run on. This module is searched for the function
+ /// $__lldb_expr, and that function is passed to the passes one by
+ /// one.
+ ///
+ /// @return
+ /// True on success; false otherwise
+ //------------------------------------------------------------------
+ bool runOnModule(llvm::Module &M) override;
+
+ //------------------------------------------------------------------
+ /// Interface stub
+ //------------------------------------------------------------------
+ void assignPassManager(
+ llvm::PMStack &PMS,
+ llvm::PassManagerType T = llvm::PMT_ModulePassManager) override;
+
+ //------------------------------------------------------------------
+ /// Returns PMT_ModulePassManager
+ //------------------------------------------------------------------
+ llvm::PassManagerType getPotentialPassManagerType() const override;
private:
- //------------------------------------------------------------------
- /// A basic block-level pass to find all pointer dereferences and
- /// validate them before use.
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// The top-level pass implementation
- ///
- /// @param[in] M
- /// The module currently being processed.
- ///
- /// @param[in] BB
- /// The basic block currently being processed.
- ///
- /// @return
- /// True on success; false otherwise
- //------------------------------------------------------------------
- bool FindDataLoads(llvm::Module &M,
- llvm::BasicBlock &BB);
-
- std::string m_func_name; ///< The name of the function to add checks to
- DynamicCheckerFunctions &m_checker_functions; ///< The checker functions for the process
+ //------------------------------------------------------------------
+ /// A basic block-level pass to find all pointer dereferences and
+ /// validate them before use.
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// The top-level pass implementation
+ ///
+ /// @param[in] M
+ /// The module currently being processed.
+ ///
+ /// @param[in] BB
+ /// The basic block currently being processed.
+ ///
+ /// @return
+ /// True on success; false otherwise
+ //------------------------------------------------------------------
+ bool FindDataLoads(llvm::Module &M, llvm::BasicBlock &BB);
+
+ std::string m_func_name; ///< The name of the function to add checks to
+ DynamicCheckerFunctions
+ &m_checker_functions; ///< The checker functions for the process
};
-
+
} // namespace lldb_private
#endif // liblldb_IRDynamicChecks_h_
diff --git a/include/lldb/Expression/IRExecutionUnit.h b/include/lldb/Expression/IRExecutionUnit.h
index d557a35d0b06..72c1775b550d 100644
--- a/include/lldb/Expression/IRExecutionUnit.h
+++ b/include/lldb/Expression/IRExecutionUnit.h
@@ -18,28 +18,29 @@
#include <vector>
// Other libraries and framework includes
-#include "llvm/IR/Module.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
+#include "llvm/IR/Module.h"
// Project includes
-#include "lldb/lldb-forward.h"
-#include "lldb/lldb-private.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Expression/IRMemoryMap.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/lldb-forward.h"
+#include "lldb/lldb-private.h"
namespace llvm {
-
+
class Module;
class ExecutionEngine;
-
+class ObjectCache;
+
} // namespace llvm
namespace lldb_private {
class Error;
-
+
//----------------------------------------------------------------------
/// @class IRExecutionUnit IRExecutionUnit.h "lldb/Expression/IRExecutionUnit.h"
/// @brief Contains the IR and, optionally, JIT-compiled code for a module.
@@ -52,427 +53,383 @@ class Error;
/// and knows how to use the JIT to make it into executable code. It can
/// then be used as input to the IR interpreter, or the address of the
/// executable code can be passed to a thread plan to run in the target.
-///
-/// This class creates a subclass of LLVM's SectionMemoryManager, because that is
+///
+/// This class creates a subclass of LLVM's SectionMemoryManager, because that
+/// is
/// how the JIT emits code. Because LLDB needs to move JIT-compiled code
/// into the target process, the IRExecutionUnit knows how to copy the
/// emitted code into the target process.
//----------------------------------------------------------------------
-class IRExecutionUnit :
- public std::enable_shared_from_this<IRExecutionUnit>,
- public IRMemoryMap,
- public ObjectFileJITDelegate
-{
+class IRExecutionUnit : public std::enable_shared_from_this<IRExecutionUnit>,
+ public IRMemoryMap,
+ public ObjectFileJITDelegate {
public:
- //------------------------------------------------------------------
- /// Constructor
- //------------------------------------------------------------------
- IRExecutionUnit (std::unique_ptr<llvm::LLVMContext> &context_ap,
- std::unique_ptr<llvm::Module> &module_ap,
- ConstString &name,
- const lldb::TargetSP &target_sp,
- const SymbolContext &sym_ctx,
- std::vector<std::string> &cpu_features);
-
- //------------------------------------------------------------------
- /// Destructor
- //------------------------------------------------------------------
- ~IRExecutionUnit() override;
-
- ConstString GetFunctionName()
- {
- return m_name;
- }
-
- llvm::Module *
- GetModule()
- {
- return m_module;
- }
-
- llvm::Function *
- GetFunction()
- {
- return ((m_module != nullptr) ? m_module->getFunction(m_name.AsCString()) : nullptr);
- }
-
- void
- GetRunnableInfo (Error &error,
- lldb::addr_t &func_addr,
- lldb::addr_t &func_end);
-
- //------------------------------------------------------------------
- /// Accessors for IRForTarget and other clients that may want binary
- /// data placed on their behalf. The binary data is owned by the
- /// IRExecutionUnit unless the client explicitly chooses to free it.
- //------------------------------------------------------------------
-
+ //------------------------------------------------------------------
+ /// Constructor
+ //------------------------------------------------------------------
+ IRExecutionUnit(std::unique_ptr<llvm::LLVMContext> &context_ap,
+ std::unique_ptr<llvm::Module> &module_ap, ConstString &name,
+ const lldb::TargetSP &target_sp, const SymbolContext &sym_ctx,
+ std::vector<std::string> &cpu_features);
+
+ //------------------------------------------------------------------
+ /// Destructor
+ //------------------------------------------------------------------
+ ~IRExecutionUnit() override;
+
+ ConstString GetFunctionName() { return m_name; }
+
+ llvm::Module *GetModule() { return m_module; }
+
+ llvm::Function *GetFunction() {
+ return ((m_module != nullptr) ? m_module->getFunction(m_name.AsCString())
+ : nullptr);
+ }
+
+ void GetRunnableInfo(Error &error, lldb::addr_t &func_addr,
+ lldb::addr_t &func_end);
+
+ //------------------------------------------------------------------
+ /// Accessors for IRForTarget and other clients that may want binary
+ /// data placed on their behalf. The binary data is owned by the
+ /// IRExecutionUnit unless the client explicitly chooses to free it.
+ //------------------------------------------------------------------
+
+ lldb::addr_t WriteNow(const uint8_t *bytes, size_t size, Error &error);
+
+ void FreeNow(lldb::addr_t allocation);
+
+ //------------------------------------------------------------------
+ /// ObjectFileJITDelegate overrides
+ //------------------------------------------------------------------
+ lldb::ByteOrder GetByteOrder() const override;
+
+ uint32_t GetAddressByteSize() const override;
+
+ void PopulateSymtab(lldb_private::ObjectFile *obj_file,
+ lldb_private::Symtab &symtab) override;
+
+ void PopulateSectionList(lldb_private::ObjectFile *obj_file,
+ lldb_private::SectionList &section_list) override;
+
+ bool GetArchitecture(lldb_private::ArchSpec &arch) override;
+
+ lldb::ModuleSP GetJITModule();
+
+ lldb::addr_t FindSymbol(const ConstString &name);
+
+ void GetStaticInitializers(std::vector<lldb::addr_t> &static_initializers);
+
+ //----------------------------------------------------------------------
+ /// @class JittedFunction IRExecutionUnit.h
+ /// "lldb/Expression/IRExecutionUnit.h"
+ /// @brief Encapsulates a single function that has been generated by the JIT.
+ ///
+ /// Functions that have been generated by the JIT are first resident in the
+ /// local process, and then placed in the target process. JittedFunction
+ /// represents a function possibly resident in both.
+ //----------------------------------------------------------------------
+ struct JittedEntity {
+ ConstString m_name; ///< The function's name
+ lldb::addr_t m_local_addr; ///< The address of the function in LLDB's memory
lldb::addr_t
- WriteNow (const uint8_t *bytes,
- size_t size,
- Error &error);
-
- void
- FreeNow (lldb::addr_t allocation);
-
- //------------------------------------------------------------------
- /// ObjectFileJITDelegate overrides
+ m_remote_addr; ///< The address of the function in the target's memory
+
//------------------------------------------------------------------
- lldb::ByteOrder
- GetByteOrder() const override;
-
- uint32_t
- GetAddressByteSize() const override;
-
- void
- PopulateSymtab(lldb_private::ObjectFile *obj_file,
- lldb_private::Symtab &symtab) override;
-
- void
- PopulateSectionList(lldb_private::ObjectFile *obj_file,
- lldb_private::SectionList &section_list) override;
-
- bool
- GetArchitecture(lldb_private::ArchSpec &arch) override;
-
- lldb::ModuleSP
- GetJITModule ();
-
- lldb::addr_t
- FindSymbol(const ConstString &name);
-
- void
- GetStaticInitializers(std::vector <lldb::addr_t> &static_initializers);
-
- //----------------------------------------------------------------------
- /// @class JittedFunction IRExecutionUnit.h "lldb/Expression/IRExecutionUnit.h"
- /// @brief Encapsulates a single function that has been generated by the JIT.
+ /// Constructor
///
- /// Functions that have been generated by the JIT are first resident in the
- /// local process, and then placed in the target process. JittedFunction
- /// represents a function possibly resident in both.
- //----------------------------------------------------------------------
- struct JittedEntity {
- ConstString m_name; ///< The function's name
- lldb::addr_t m_local_addr; ///< The address of the function in LLDB's memory
- lldb::addr_t m_remote_addr; ///< The address of the function in the target's memory
-
- //------------------------------------------------------------------
- /// Constructor
- ///
- /// Initializes class variabes.
- ///
- /// @param[in] name
- /// The name of the function.
- ///
- /// @param[in] local_addr
- /// The address of the function in LLDB, or LLDB_INVALID_ADDRESS if
- /// it is not present in LLDB's memory.
- ///
- /// @param[in] remote_addr
- /// The address of the function in the target, or LLDB_INVALID_ADDRESS
- /// if it is not present in the target's memory.
- //------------------------------------------------------------------
- JittedEntity (const char *name,
- lldb::addr_t local_addr = LLDB_INVALID_ADDRESS,
- lldb::addr_t remote_addr = LLDB_INVALID_ADDRESS) :
- m_name (name),
- m_local_addr (local_addr),
- m_remote_addr (remote_addr)
- {
- }
- };
-
- struct JittedFunction : JittedEntity
- {
- bool m_external;
- JittedFunction (const char *name,
- bool external,
- lldb::addr_t local_addr = LLDB_INVALID_ADDRESS,
- lldb::addr_t remote_addr = LLDB_INVALID_ADDRESS) :
- JittedEntity (name, local_addr, remote_addr),
- m_external(external)
- {}
- };
-
- struct JittedGlobalVariable : JittedEntity
- {
- JittedGlobalVariable (const char *name,
- lldb::addr_t local_addr = LLDB_INVALID_ADDRESS,
- lldb::addr_t remote_addr = LLDB_INVALID_ADDRESS) :
- JittedEntity (name, local_addr, remote_addr)
- {}
- };
-
- const std::vector<JittedFunction> &GetJittedFunctions()
- {
- return m_jitted_functions;
- }
-
- const std::vector<JittedGlobalVariable> &GetJittedGlobalVariables()
- {
- return m_jitted_global_variables;
- }
+ /// Initializes class variabes.
+ ///
+ /// @param[in] name
+ /// The name of the function.
+ ///
+ /// @param[in] local_addr
+ /// The address of the function in LLDB, or LLDB_INVALID_ADDRESS if
+ /// it is not present in LLDB's memory.
+ ///
+ /// @param[in] remote_addr
+ /// The address of the function in the target, or LLDB_INVALID_ADDRESS
+ /// if it is not present in the target's memory.
+ //------------------------------------------------------------------
+ JittedEntity(const char *name,
+ lldb::addr_t local_addr = LLDB_INVALID_ADDRESS,
+ lldb::addr_t remote_addr = LLDB_INVALID_ADDRESS)
+ : m_name(name), m_local_addr(local_addr), m_remote_addr(remote_addr) {}
+ };
+
+ struct JittedFunction : JittedEntity {
+ bool m_external;
+ JittedFunction(const char *name, bool external,
+ lldb::addr_t local_addr = LLDB_INVALID_ADDRESS,
+ lldb::addr_t remote_addr = LLDB_INVALID_ADDRESS)
+ : JittedEntity(name, local_addr, remote_addr), m_external(external) {}
+ };
+
+ struct JittedGlobalVariable : JittedEntity {
+ JittedGlobalVariable(const char *name,
+ lldb::addr_t local_addr = LLDB_INVALID_ADDRESS,
+ lldb::addr_t remote_addr = LLDB_INVALID_ADDRESS)
+ : JittedEntity(name, local_addr, remote_addr) {}
+ };
+
+ const std::vector<JittedFunction> &GetJittedFunctions() {
+ return m_jitted_functions;
+ }
+
+ const std::vector<JittedGlobalVariable> &GetJittedGlobalVariables() {
+ return m_jitted_global_variables;
+ }
private:
+ //------------------------------------------------------------------
+ /// Look up the object in m_address_map that contains a given address,
+ /// find where it was copied to, and return the remote address at the
+ /// same offset into the copied entity
+ ///
+ /// @param[in] local_address
+ /// The address in the debugger.
+ ///
+ /// @return
+ /// The address in the target process.
+ //------------------------------------------------------------------
+ lldb::addr_t GetRemoteAddressForLocal(lldb::addr_t local_address);
+
+ //------------------------------------------------------------------
+ /// Look up the object in m_address_map that contains a given address,
+ /// find where it was copied to, and return its address range in the
+ /// target process
+ ///
+ /// @param[in] local_address
+ /// The address in the debugger.
+ ///
+ /// @return
+ /// The range of the containing object in the target process.
+ //------------------------------------------------------------------
+ typedef std::pair<lldb::addr_t, uintptr_t> AddrRange;
+ AddrRange GetRemoteRangeForLocal(lldb::addr_t local_address);
+
+ //------------------------------------------------------------------
+ /// Commit all allocations to the process and record where they were stored.
+ ///
+ /// @param[in] process
+ /// The process to allocate memory in.
+ ///
+ /// @return
+ /// True <=> all allocations were performed successfully.
+ /// This method will attempt to free allocated memory if the
+ /// operation fails.
+ //------------------------------------------------------------------
+ bool CommitAllocations(lldb::ProcessSP &process_sp);
+
+ //------------------------------------------------------------------
+ /// Report all committed allocations to the execution engine.
+ ///
+ /// @param[in] engine
+ /// The execution engine to notify.
+ //------------------------------------------------------------------
+ void ReportAllocations(llvm::ExecutionEngine &engine);
+
+ //------------------------------------------------------------------
+ /// Write the contents of all allocations to the process.
+ ///
+ /// @param[in] local_address
+ /// The process containing the allocations.
+ ///
+ /// @return
+ /// True <=> all allocations were performed successfully.
+ //------------------------------------------------------------------
+ bool WriteData(lldb::ProcessSP &process_sp);
+
+ Error DisassembleFunction(Stream &stream, lldb::ProcessSP &process_sp);
+
+ struct SearchSpec;
+
+ void CollectCandidateCNames(std::vector<SearchSpec> &C_specs,
+ const ConstString &name);
+
+ void CollectCandidateCPlusPlusNames(std::vector<SearchSpec> &CPP_specs,
+ const std::vector<SearchSpec> &C_specs,
+ const SymbolContext &sc);
+
+ void CollectFallbackNames(std::vector<SearchSpec> &fallback_specs,
+ const std::vector<SearchSpec> &C_specs);
+
+ lldb::addr_t FindInSymbols(const std::vector<SearchSpec> &specs,
+ const lldb_private::SymbolContext &sc);
+
+ lldb::addr_t FindInRuntimes(const std::vector<SearchSpec> &specs,
+ const lldb_private::SymbolContext &sc);
+
+ lldb::addr_t FindInUserDefinedSymbols(const std::vector<SearchSpec> &specs,
+ const lldb_private::SymbolContext &sc);
+
+ void ReportSymbolLookupError(const ConstString &name);
+
+ class MemoryManager : public llvm::SectionMemoryManager {
+ public:
+ MemoryManager(IRExecutionUnit &parent);
+
+ ~MemoryManager() override;
+
//------------------------------------------------------------------
- /// Look up the object in m_address_map that contains a given address,
- /// find where it was copied to, and return the remote address at the
- /// same offset into the copied entity
+ /// Allocate space for executable code, and add it to the
+ /// m_spaceBlocks map
///
- /// @param[in] local_address
- /// The address in the debugger.
+ /// @param[in] Size
+ /// The size of the area.
///
- /// @return
- /// The address in the target process.
- //------------------------------------------------------------------
- lldb::addr_t
- GetRemoteAddressForLocal (lldb::addr_t local_address);
-
- //------------------------------------------------------------------
- /// Look up the object in m_address_map that contains a given address,
- /// find where it was copied to, and return its address range in the
- /// target process
+ /// @param[in] Alignment
+ /// The required alignment of the area.
///
- /// @param[in] local_address
- /// The address in the debugger.
+ /// @param[in] SectionID
+ /// A unique identifier for the section.
///
/// @return
- /// The range of the containing object in the target process.
+ /// Allocated space.
//------------------------------------------------------------------
- typedef std::pair <lldb::addr_t, uintptr_t> AddrRange;
- AddrRange
- GetRemoteRangeForLocal (lldb::addr_t local_address);
-
+ uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
+ unsigned SectionID,
+ llvm::StringRef SectionName) override;
+
//------------------------------------------------------------------
- /// Commit all allocations to the process and record where they were stored.
+ /// Allocate space for data, and add it to the m_spaceBlocks map
///
- /// @param[in] process
- /// The process to allocate memory in.
+ /// @param[in] Size
+ /// The size of the area.
///
- /// @return
- /// True <=> all allocations were performed successfully.
- /// This method will attempt to free allocated memory if the
- /// operation fails.
- //------------------------------------------------------------------
- bool
- CommitAllocations (lldb::ProcessSP &process_sp);
-
- //------------------------------------------------------------------
- /// Report all committed allocations to the execution engine.
+ /// @param[in] Alignment
+ /// The required alignment of the area.
+ ///
+ /// @param[in] SectionID
+ /// A unique identifier for the section.
+ ///
+ /// @param[in] IsReadOnly
+ /// Flag indicating the section is read-only.
///
- /// @param[in] engine
- /// The execution engine to notify.
+ /// @return
+ /// Allocated space.
//------------------------------------------------------------------
- void
- ReportAllocations (llvm::ExecutionEngine &engine);
-
+ uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
+ unsigned SectionID,
+ llvm::StringRef SectionName,
+ bool IsReadOnly) override;
+
//------------------------------------------------------------------
- /// Write the contents of all allocations to the process.
+ /// Called when object loading is complete and section page
+ /// permissions can be applied. Currently unimplemented for LLDB.
///
- /// @param[in] local_address
- /// The process containing the allocations.
+ /// @param[out] ErrMsg
+ /// The error that prevented the page protection from succeeding.
///
/// @return
- /// True <=> all allocations were performed successfully.
+ /// True in case of failure, false in case of success.
//------------------------------------------------------------------
- bool
- WriteData (lldb::ProcessSP &process_sp);
-
- Error
- DisassembleFunction (Stream &stream,
- lldb::ProcessSP &process_sp);
-
- struct SearchSpec;
-
- void
- CollectCandidateCNames(std::vector<SearchSpec> &C_specs,
- const ConstString &name);
-
- void
- CollectCandidateCPlusPlusNames(std::vector<SearchSpec> &CPP_specs,
- const std::vector<SearchSpec> &C_specs,
- const SymbolContext &sc);
-
- void
- CollectFallbackNames(std::vector<SearchSpec> &fallback_specs,
- const std::vector<SearchSpec> &C_specs);
-
- lldb::addr_t
- FindInSymbols(const std::vector<SearchSpec> &specs,
- const lldb_private::SymbolContext &sc);
-
- lldb::addr_t
- FindInRuntimes(const std::vector<SearchSpec> &specs,
- const lldb_private::SymbolContext &sc);
-
- lldb::addr_t
- FindInUserDefinedSymbols(const std::vector<SearchSpec> &specs,
- const lldb_private::SymbolContext &sc);
-
- void
- ReportSymbolLookupError(const ConstString &name);
-
- class MemoryManager : public llvm::SectionMemoryManager
- {
- public:
- MemoryManager (IRExecutionUnit &parent);
-
- ~MemoryManager() override;
-
- //------------------------------------------------------------------
- /// Allocate space for executable code, and add it to the
- /// m_spaceBlocks map
- ///
- /// @param[in] Size
- /// The size of the area.
- ///
- /// @param[in] Alignment
- /// The required alignment of the area.
- ///
- /// @param[in] SectionID
- /// A unique identifier for the section.
- ///
- /// @return
- /// Allocated space.
- //------------------------------------------------------------------
- uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
- unsigned SectionID,
- llvm::StringRef SectionName) override;
-
- //------------------------------------------------------------------
- /// Allocate space for data, and add it to the m_spaceBlocks map
- ///
- /// @param[in] Size
- /// The size of the area.
- ///
- /// @param[in] Alignment
- /// The required alignment of the area.
- ///
- /// @param[in] SectionID
- /// A unique identifier for the section.
- ///
- /// @param[in] IsReadOnly
- /// Flag indicating the section is read-only.
- ///
- /// @return
- /// Allocated space.
- //------------------------------------------------------------------
- uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
- unsigned SectionID,
- llvm::StringRef SectionName,
- bool IsReadOnly) override;
-
- //------------------------------------------------------------------
- /// Called when object loading is complete and section page
- /// permissions can be applied. Currently unimplemented for LLDB.
- ///
- /// @param[out] ErrMsg
- /// The error that prevented the page protection from succeeding.
- ///
- /// @return
- /// True in case of failure, false in case of success.
- //------------------------------------------------------------------
- bool finalizeMemory(std::string *ErrMsg) override {
- // TODO: Ensure that the instruction cache is flushed because
- // relocations are updated by dy-load. See:
- // sys::Memory::InvalidateInstructionCache
- // llvm::SectionMemoryManager
- return false;
- }
-
- void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) override {
- }
-
- uint64_t getSymbolAddress(const std::string &Name) override;
-
- void *getPointerToNamedFunction(const std::string &Name,
- bool AbortOnFailure = true) override;
-
- private:
- std::unique_ptr<SectionMemoryManager> m_default_mm_ap; ///< The memory allocator to use in actually creating space. All calls are passed through to it.
- IRExecutionUnit &m_parent; ///< The execution unit this is a proxy for.
- };
-
- static const unsigned eSectionIDInvalid = (unsigned)-1;
-
- //----------------------------------------------------------------------
- /// @class AllocationRecord IRExecutionUnit.h "lldb/Expression/IRExecutionUnit.h"
- /// @brief Encapsulates a single allocation request made by the JIT.
- ///
- /// Allocations made by the JIT are first queued up and then applied in
- /// bulk to the underlying process.
- //----------------------------------------------------------------------
- enum class AllocationKind {
- Stub, Code, Data, Global, Bytes
- };
-
- static lldb::SectionType
- GetSectionTypeFromSectionName (const llvm::StringRef &name,
- AllocationKind alloc_kind);
-
- struct AllocationRecord {
- std::string m_name;
- lldb::addr_t m_process_address;
- uintptr_t m_host_address;
- uint32_t m_permissions;
- lldb::SectionType m_sect_type;
- size_t m_size;
- unsigned m_alignment;
- unsigned m_section_id;
-
- AllocationRecord (uintptr_t host_address,
- uint32_t permissions,
- lldb::SectionType sect_type,
- size_t size,
- unsigned alignment,
- unsigned section_id,
- const char *name) :
- m_name (),
- m_process_address(LLDB_INVALID_ADDRESS),
- m_host_address(host_address),
- m_permissions(permissions),
- m_sect_type (sect_type),
- m_size(size),
- m_alignment(alignment),
- m_section_id(section_id)
- {
- if (name && name[0])
- m_name = name;
- }
-
- void dump (Log *log);
- };
-
- bool
- CommitOneAllocation (lldb::ProcessSP &process_sp, Error &error, AllocationRecord &record);
-
- typedef std::vector<AllocationRecord> RecordVector;
- RecordVector m_records;
-
- std::unique_ptr<llvm::LLVMContext> m_context_ap;
- std::unique_ptr<llvm::ExecutionEngine> m_execution_engine_ap;
- std::unique_ptr<llvm::Module> m_module_ap; ///< Holder for the module until it's been handed off
- llvm::Module *m_module; ///< Owned by the execution engine
- std::vector<std::string> m_cpu_features;
- std::vector<JittedFunction> m_jitted_functions; ///< A vector of all functions that have been JITted into machine code
- std::vector<JittedGlobalVariable> m_jitted_global_variables; ///< A vector of all functions that have been JITted into machine code
- const ConstString m_name;
- SymbolContext m_sym_ctx; ///< Used for symbol lookups
- std::vector<ConstString> m_failed_lookups;
-
- std::atomic<bool> m_did_jit;
-
- lldb::addr_t m_function_load_addr;
- lldb::addr_t m_function_end_load_addr;
-
- bool m_strip_underscore; ///< True for platforms where global symbols have a _ prefix
- bool m_reported_allocations; ///< True after allocations have been reported. It is possible that
- ///< sections will be allocated when this is true, in which case they weren't
- ///< depended on by any function. (Top-level code defining a variable, but
- ///< defining no functions using that variable, would do this.) If this
- ///< is true, any allocations need to be committed immediately -- no
- ///< opportunity for relocation.
+ bool finalizeMemory(std::string *ErrMsg) override {
+ // TODO: Ensure that the instruction cache is flushed because
+ // relocations are updated by dy-load. See:
+ // sys::Memory::InvalidateInstructionCache
+ // llvm::SectionMemoryManager
+ return false;
+ }
+
+ void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr,
+ size_t Size) override {}
+
+ uint64_t getSymbolAddress(const std::string &Name) override;
+
+ void *getPointerToNamedFunction(const std::string &Name,
+ bool AbortOnFailure = true) override;
+
+ private:
+ std::unique_ptr<SectionMemoryManager> m_default_mm_ap; ///< The memory
+ ///allocator to use
+ ///in actually
+ ///creating space.
+ ///All calls are
+ ///passed through to
+ ///it.
+ IRExecutionUnit &m_parent; ///< The execution unit this is a proxy for.
+ };
+
+ static const unsigned eSectionIDInvalid = (unsigned)-1;
+
+ //----------------------------------------------------------------------
+ /// @class AllocationRecord IRExecutionUnit.h
+ /// "lldb/Expression/IRExecutionUnit.h"
+ /// @brief Encapsulates a single allocation request made by the JIT.
+ ///
+ /// Allocations made by the JIT are first queued up and then applied in
+ /// bulk to the underlying process.
+ //----------------------------------------------------------------------
+ enum class AllocationKind { Stub, Code, Data, Global, Bytes };
+
+ static lldb::SectionType
+ GetSectionTypeFromSectionName(const llvm::StringRef &name,
+ AllocationKind alloc_kind);
+
+ struct AllocationRecord {
+ std::string m_name;
+ lldb::addr_t m_process_address;
+ uintptr_t m_host_address;
+ uint32_t m_permissions;
+ lldb::SectionType m_sect_type;
+ size_t m_size;
+ unsigned m_alignment;
+ unsigned m_section_id;
+
+ AllocationRecord(uintptr_t host_address, uint32_t permissions,
+ lldb::SectionType sect_type, size_t size,
+ unsigned alignment, unsigned section_id, const char *name)
+ : m_name(), m_process_address(LLDB_INVALID_ADDRESS),
+ m_host_address(host_address), m_permissions(permissions),
+ m_sect_type(sect_type), m_size(size), m_alignment(alignment),
+ m_section_id(section_id) {
+ if (name && name[0])
+ m_name = name;
+ }
+
+ void dump(Log *log);
+ };
+
+ bool CommitOneAllocation(lldb::ProcessSP &process_sp, Error &error,
+ AllocationRecord &record);
+
+ typedef std::vector<AllocationRecord> RecordVector;
+ RecordVector m_records;
+
+ std::unique_ptr<llvm::LLVMContext> m_context_ap;
+ std::unique_ptr<llvm::ExecutionEngine> m_execution_engine_ap;
+ std::unique_ptr<llvm::ObjectCache> m_object_cache_ap;
+ std::unique_ptr<llvm::Module>
+ m_module_ap; ///< Holder for the module until it's been handed off
+ llvm::Module *m_module; ///< Owned by the execution engine
+ std::vector<std::string> m_cpu_features;
+ std::vector<JittedFunction> m_jitted_functions; ///< A vector of all functions
+ ///that have been JITted into
+ ///machine code
+ std::vector<JittedGlobalVariable> m_jitted_global_variables; ///< A vector of
+ ///all functions
+ ///that have been
+ ///JITted into
+ ///machine code
+ const ConstString m_name;
+ SymbolContext m_sym_ctx; ///< Used for symbol lookups
+ std::vector<ConstString> m_failed_lookups;
+
+ std::atomic<bool> m_did_jit;
+
+ lldb::addr_t m_function_load_addr;
+ lldb::addr_t m_function_end_load_addr;
+
+ bool m_strip_underscore; ///< True for platforms where global symbols have a _
+ ///prefix
+ bool m_reported_allocations; ///< True after allocations have been reported.
+ ///It is possible that
+ ///< sections will be allocated when this is true, in which case they weren't
+ ///< depended on by any function. (Top-level code defining a variable, but
+ ///< defining no functions using that variable, would do this.) If this
+ ///< is true, any allocations need to be committed immediately -- no
+ ///< opportunity for relocation.
};
} // namespace lldb_private
diff --git a/include/lldb/Expression/IRInterpreter.h b/include/lldb/Expression/IRInterpreter.h
index 14c145b91c26..b821e6750b2d 100644
--- a/include/lldb/Expression/IRInterpreter.h
+++ b/include/lldb/Expression/IRInterpreter.h
@@ -10,22 +10,21 @@
#ifndef liblldb_IRInterpreter_h_
#define liblldb_IRInterpreter_h_
-#include "lldb/lldb-public.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Stream.h"
+#include "lldb/lldb-public.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/Pass.h"
namespace llvm {
- class Function;
- class Module;
+class Function;
+class Module;
}
namespace lldb_private {
class ClangExpressionDeclMap;
class IRMemoryMap;
-
}
//----------------------------------------------------------------------
@@ -37,29 +36,23 @@ class IRMemoryMap;
/// in the debugger, manipulating variables but not executing any code
/// in the target. The IRInterpreter attempts to do this.
//----------------------------------------------------------------------
-class IRInterpreter
-{
+class IRInterpreter {
public:
- static bool
- CanInterpret (llvm::Module &module,
- llvm::Function &function,
- lldb_private::Error &error,
- const bool support_function_calls);
-
- static bool
- Interpret (llvm::Module &module,
- llvm::Function &function,
- llvm::ArrayRef<lldb::addr_t> args,
- lldb_private::IRExecutionUnit &execution_unit,
- lldb_private::Error &error,
- lldb::addr_t stack_frame_bottom,
- lldb::addr_t stack_frame_top,
- lldb_private::ExecutionContext &exe_ctx);
-
-private:
- static bool
- supportsFunction (llvm::Function &llvm_function,
- lldb_private::Error &err);
+ static bool CanInterpret(llvm::Module &module, llvm::Function &function,
+ lldb_private::Error &error,
+ const bool support_function_calls);
+
+ static bool Interpret(llvm::Module &module, llvm::Function &function,
+ llvm::ArrayRef<lldb::addr_t> args,
+ lldb_private::IRExecutionUnit &execution_unit,
+ lldb_private::Error &error,
+ lldb::addr_t stack_frame_bottom,
+ lldb::addr_t stack_frame_top,
+ lldb_private::ExecutionContext &exe_ctx);
+
+private:
+ static bool supportsFunction(llvm::Function &llvm_function,
+ lldb_private::Error &err);
};
#endif
diff --git a/include/lldb/Expression/IRMemoryMap.h b/include/lldb/Expression/IRMemoryMap.h
index 36631d25a742..405de51bfc45 100644
--- a/include/lldb/Expression/IRMemoryMap.h
+++ b/include/lldb/Expression/IRMemoryMap.h
@@ -10,14 +10,13 @@
#ifndef lldb_IRMemoryMap_h_
#define lldb_IRMemoryMap_h_
-#include "lldb/lldb-public.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/UserID.h"
+#include "lldb/lldb-public.h"
#include <map>
-namespace lldb_private
-{
+namespace lldb_private {
//----------------------------------------------------------------------
/// @class IRMemoryMap IRMemoryMap.h "lldb/Expression/IRMemoryMap.h"
@@ -35,111 +34,106 @@ namespace lldb_private
/// exist, allocations still get made-up addresses. If an inferior appears
/// at some point, then those addresses need to be re-mapped.
//----------------------------------------------------------------------
-class IRMemoryMap
-{
+class IRMemoryMap {
public:
- IRMemoryMap (lldb::TargetSP target_sp);
- ~IRMemoryMap ();
-
- enum AllocationPolicy {
- eAllocationPolicyInvalid = 0, ///< It is an error for an allocation to have this policy.
- eAllocationPolicyHostOnly, ///< This allocation was created in the host and will never make it into the process.
- ///< It is an error to create other types of allocations while such allocations exist.
- eAllocationPolicyMirror, ///< The intent is that this allocation exist both in the host and the process and have
- ///< the same content in both.
- eAllocationPolicyProcessOnly ///< The intent is that this allocation exist only in the process.
- };
-
- lldb::addr_t Malloc (size_t size,
- uint8_t alignment,
- uint32_t permissions,
- AllocationPolicy policy,
- bool zero_memory,
- Error &error);
- void Leak (lldb::addr_t process_address, Error &error);
- void Free (lldb::addr_t process_address, Error &error);
-
- void WriteMemory (lldb::addr_t process_address, const uint8_t *bytes, size_t size, Error &error);
- void WriteScalarToMemory (lldb::addr_t process_address, Scalar &scalar, size_t size, Error &error);
- void WritePointerToMemory (lldb::addr_t process_address, lldb::addr_t address, Error &error);
- void ReadMemory (uint8_t *bytes, lldb::addr_t process_address, size_t size, Error &error);
- void ReadScalarFromMemory (Scalar &scalar, lldb::addr_t process_address, size_t size, Error &error);
- void ReadPointerFromMemory (lldb::addr_t *address, lldb::addr_t process_address, Error &error);
- bool GetAllocSize(lldb::addr_t address, size_t &size);
- void GetMemoryData (DataExtractor &extractor, lldb::addr_t process_address, size_t size, Error &error);
-
- lldb::ByteOrder GetByteOrder();
- uint32_t GetAddressByteSize();
-
- // This function can return NULL.
- ExecutionContextScope *GetBestExecutionContextScope() const;
-
- lldb::TargetSP
- GetTarget ()
- {
- return m_target_wp.lock();
- }
+ IRMemoryMap(lldb::TargetSP target_sp);
+ ~IRMemoryMap();
+
+ enum AllocationPolicy {
+ eAllocationPolicyInvalid =
+ 0, ///< It is an error for an allocation to have this policy.
+ eAllocationPolicyHostOnly, ///< This allocation was created in the host and
+ ///will never make it into the process.
+ ///< It is an error to create other types of allocations while such
+ ///allocations exist.
+ eAllocationPolicyMirror, ///< The intent is that this allocation exist both
+ ///in the host and the process and have
+ ///< the same content in both.
+ eAllocationPolicyProcessOnly ///< The intent is that this allocation exist
+ ///only in the process.
+ };
+
+ lldb::addr_t Malloc(size_t size, uint8_t alignment, uint32_t permissions,
+ AllocationPolicy policy, bool zero_memory, Error &error);
+ void Leak(lldb::addr_t process_address, Error &error);
+ void Free(lldb::addr_t process_address, Error &error);
+
+ void WriteMemory(lldb::addr_t process_address, const uint8_t *bytes,
+ size_t size, Error &error);
+ void WriteScalarToMemory(lldb::addr_t process_address, Scalar &scalar,
+ size_t size, Error &error);
+ void WritePointerToMemory(lldb::addr_t process_address, lldb::addr_t address,
+ Error &error);
+ void ReadMemory(uint8_t *bytes, lldb::addr_t process_address, size_t size,
+ Error &error);
+ void ReadScalarFromMemory(Scalar &scalar, lldb::addr_t process_address,
+ size_t size, Error &error);
+ void ReadPointerFromMemory(lldb::addr_t *address,
+ lldb::addr_t process_address, Error &error);
+ bool GetAllocSize(lldb::addr_t address, size_t &size);
+ void GetMemoryData(DataExtractor &extractor, lldb::addr_t process_address,
+ size_t size, Error &error);
+
+ lldb::ByteOrder GetByteOrder();
+ uint32_t GetAddressByteSize();
+
+ // This function can return NULL.
+ ExecutionContextScope *GetBestExecutionContextScope() const;
+
+ lldb::TargetSP GetTarget() { return m_target_wp.lock(); }
protected:
- // This function should only be used if you know you are using the JIT.
- // Any other cases should use GetBestExecutionContextScope().
+ // This function should only be used if you know you are using the JIT.
+ // Any other cases should use GetBestExecutionContextScope().
- lldb::ProcessWP &
- GetProcessWP ()
- {
- return m_process_wp;
- }
+ lldb::ProcessWP &GetProcessWP() { return m_process_wp; }
private:
- struct Allocation
- {
- lldb::addr_t m_process_alloc; ///< The (unaligned) base for the remote allocation
- lldb::addr_t m_process_start; ///< The base address of the allocation in the process
- size_t m_size; ///< The size of the requested allocation
- uint32_t m_permissions; ///< The access permissions on the memory in the process. In the host, the memory is always read/write.
- uint8_t m_alignment; ///< The alignment of the requested allocation
- DataBufferHeap m_data;
-
- ///< Flags
- AllocationPolicy m_policy;
- bool m_leak;
- public:
- Allocation (lldb::addr_t process_alloc,
- lldb::addr_t process_start,
- size_t size,
- uint32_t permissions,
- uint8_t alignment,
- AllocationPolicy m_policy);
-
- Allocation () :
- m_process_alloc (LLDB_INVALID_ADDRESS),
- m_process_start (LLDB_INVALID_ADDRESS),
- m_size (0),
- m_permissions (0),
- m_alignment (0),
- m_data (),
- m_policy (eAllocationPolicyInvalid),
- m_leak (false)
- {
- }
- };
-
- lldb::ProcessWP m_process_wp;
- lldb::TargetWP m_target_wp;
- typedef std::map<lldb::addr_t, Allocation> AllocationMap;
- AllocationMap m_allocations;
-
- lldb::addr_t FindSpace (size_t size);
- bool ContainsHostOnlyAllocations ();
- AllocationMap::iterator FindAllocation (lldb::addr_t addr, size_t size);
-
- // Returns true if the given allocation intersects any allocation in the memory map.
- bool IntersectsAllocation (lldb::addr_t addr, size_t size) const;
-
- // Returns true if the two given allocations intersect each other.
- static bool AllocationsIntersect (lldb::addr_t addr1, size_t size1, lldb::addr_t addr2, size_t size2);
+ struct Allocation {
+ lldb::addr_t
+ m_process_alloc; ///< The (unaligned) base for the remote allocation
+ lldb::addr_t
+ m_process_start; ///< The base address of the allocation in the process
+ size_t m_size; ///< The size of the requested allocation
+ uint32_t m_permissions; ///< The access permissions on the memory in the
+ ///process. In the host, the memory is always
+ ///read/write.
+ uint8_t m_alignment; ///< The alignment of the requested allocation
+ DataBufferHeap m_data;
+
+ ///< Flags
+ AllocationPolicy m_policy;
+ bool m_leak;
+
+ public:
+ Allocation(lldb::addr_t process_alloc, lldb::addr_t process_start,
+ size_t size, uint32_t permissions, uint8_t alignment,
+ AllocationPolicy m_policy);
+
+ Allocation()
+ : m_process_alloc(LLDB_INVALID_ADDRESS),
+ m_process_start(LLDB_INVALID_ADDRESS), m_size(0), m_permissions(0),
+ m_alignment(0), m_data(), m_policy(eAllocationPolicyInvalid),
+ m_leak(false) {}
+ };
+
+ lldb::ProcessWP m_process_wp;
+ lldb::TargetWP m_target_wp;
+ typedef std::map<lldb::addr_t, Allocation> AllocationMap;
+ AllocationMap m_allocations;
+
+ lldb::addr_t FindSpace(size_t size);
+ bool ContainsHostOnlyAllocations();
+ AllocationMap::iterator FindAllocation(lldb::addr_t addr, size_t size);
+
+ // Returns true if the given allocation intersects any allocation in the
+ // memory map.
+ bool IntersectsAllocation(lldb::addr_t addr, size_t size) const;
+
+ // Returns true if the two given allocations intersect each other.
+ static bool AllocationsIntersect(lldb::addr_t addr1, size_t size1,
+ lldb::addr_t addr2, size_t size2);
};
-
}
#endif
diff --git a/include/lldb/Expression/LLVMUserExpression.h b/include/lldb/Expression/LLVMUserExpression.h
index 3762fa11ddbd..48d0161991d7 100644
--- a/include/lldb/Expression/LLVMUserExpression.h
+++ b/include/lldb/Expression/LLVMUserExpression.h
@@ -12,8 +12,8 @@
// C Includes
// C++ Includes
-#include <string>
#include <map>
+#include <string>
#include <vector>
// Other libraries and framework includes
@@ -22,106 +22,116 @@
// Project includes
#include "lldb/Expression/UserExpression.h"
-namespace lldb_private
-{
+namespace lldb_private {
//----------------------------------------------------------------------
-/// @class LLVMUserExpression LLVMUserExpression.h "lldb/Expression/LLVMUserExpression.h"
+/// @class LLVMUserExpression LLVMUserExpression.h
+/// "lldb/Expression/LLVMUserExpression.h"
/// @brief Encapsulates a one-time expression for use in lldb.
///
/// LLDB uses expressions for various purposes, notably to call functions
/// and as a backend for the expr command. LLVMUserExpression is a virtual base
/// class that encapsulates the objects needed to parse and JIT an expression.
/// The actual parsing part will be provided by the specific implementations
-/// of LLVMUserExpression - which will be vended through the appropriate TypeSystem.
+/// of LLVMUserExpression - which will be vended through the appropriate
+/// TypeSystem.
//----------------------------------------------------------------------
-class LLVMUserExpression : public UserExpression
-{
+class LLVMUserExpression : public UserExpression {
public:
- // The IRPasses struct is filled in by a runtime after an expression is compiled and can be used to to run
- // fixups/analysis passes as required. EarlyPasses are run on the generated module before lldb runs its own IR
- // fixups and inserts instrumentation code/pointer checks. LatePasses are run after the module has been processed by
- // llvm, before the module is assembled and run in the ThreadPlan.
- struct IRPasses
- {
- IRPasses() : EarlyPasses(nullptr), LatePasses(nullptr){};
- std::shared_ptr<llvm::legacy::PassManager> EarlyPasses;
- std::shared_ptr<llvm::legacy::PassManager> LatePasses;
- };
-
- LLVMUserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
- lldb::LanguageType language, ResultType desired_type,
- const EvaluateExpressionOptions &options);
- ~LLVMUserExpression() override;
-
- bool
- FinalizeJITExecution(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
- lldb::ExpressionVariableSP &result,
- lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS,
- lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS) override;
-
- bool
- CanInterpret() override
- {
- return m_can_interpret;
- }
-
- //------------------------------------------------------------------
- /// Return the string that the parser should parse. Must be a full
- /// translation unit.
- //------------------------------------------------------------------
- const char *
- Text() override
- {
- return m_transformed_text.c_str();
- }
-
- lldb::ModuleSP GetJITModule() override;
+ // The IRPasses struct is filled in by a runtime after an expression is
+ // compiled and can be used to to run
+ // fixups/analysis passes as required. EarlyPasses are run on the generated
+ // module before lldb runs its own IR
+ // fixups and inserts instrumentation code/pointer checks. LatePasses are run
+ // after the module has been processed by
+ // llvm, before the module is assembled and run in the ThreadPlan.
+ struct IRPasses {
+ IRPasses() : EarlyPasses(nullptr), LatePasses(nullptr){};
+ std::shared_ptr<llvm::legacy::PassManager> EarlyPasses;
+ std::shared_ptr<llvm::legacy::PassManager> LatePasses;
+ };
+
+ LLVMUserExpression(ExecutionContextScope &exe_scope, llvm::StringRef expr,
+ llvm::StringRef prefix, lldb::LanguageType language,
+ ResultType desired_type,
+ const EvaluateExpressionOptions &options);
+ ~LLVMUserExpression() override;
+
+ bool FinalizeJITExecution(
+ DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
+ lldb::ExpressionVariableSP &result,
+ lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS,
+ lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS) override;
+
+ bool CanInterpret() override { return m_can_interpret; }
+
+ //------------------------------------------------------------------
+ /// Return the string that the parser should parse. Must be a full
+ /// translation unit.
+ //------------------------------------------------------------------
+ const char *Text() override { return m_transformed_text.c_str(); }
+
+ lldb::ModuleSP GetJITModule() override;
protected:
- lldb::ExpressionResults
- DoExecute(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
- const EvaluateExpressionOptions &options, lldb::UserExpressionSP &shared_ptr_to_me,
- lldb::ExpressionVariableSP &result) override;
-
- virtual void
- ScanContext(ExecutionContext &exe_ctx, lldb_private::Error &err) = 0;
-
- bool
- PrepareToExecuteJITExpression(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
- lldb::addr_t &struct_address);
-
- virtual bool
- AddArguments(ExecutionContext &exe_ctx, std::vector<lldb::addr_t> &args, lldb::addr_t struct_address,
- DiagnosticManager &diagnostic_manager) = 0;
-
- lldb::addr_t m_stack_frame_bottom; ///< The bottom of the allocated stack frame.
- lldb::addr_t m_stack_frame_top; ///< The top of the allocated stack frame.
-
- bool m_allow_cxx; ///< True if the language allows C++.
- bool m_allow_objc; ///< True if the language allows Objective-C.
- std::string m_transformed_text; ///< The text of the expression, as send to the parser
-
- std::shared_ptr<IRExecutionUnit> m_execution_unit_sp; ///< The execution unit the expression is stored in.
- std::unique_ptr<Materializer> m_materializer_ap; ///< The materializer to use when running the expression.
- lldb::ModuleWP m_jit_module_wp;
- bool m_enforce_valid_object; ///< True if the expression parser should enforce the presence of a valid class pointer
- ///in order to generate the expression as a method.
- bool m_in_cplusplus_method; ///< True if the expression is compiled as a C++ member function (true if it was parsed
- ///when exe_ctx was in a C++ method).
- bool m_in_objectivec_method; ///< True if the expression is compiled as an Objective-C method (true if it was parsed
- ///when exe_ctx was in an Objective-C method).
- bool m_in_static_method; ///< True if the expression is compiled as a static (or class) method (currently true if it
- ///was parsed when exe_ctx was in an Objective-C class method).
- bool m_needs_object_ptr; ///< True if "this" or "self" must be looked up and passed in. False if the expression
- ///doesn't really use them and they can be NULL.
- bool m_const_object; ///< True if "this" is const.
- Target *m_target; ///< The target for storing persistent data like types and variables.
-
- bool m_can_interpret; ///< True if the expression could be evaluated statically; false otherwise.
- lldb::addr_t
- m_materialized_address; ///< The address at which the arguments to the expression have been materialized.
- Materializer::DematerializerSP m_dematerializer_sp; ///< The dematerializer.
+ lldb::ExpressionResults
+ DoExecute(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
+ const EvaluateExpressionOptions &options,
+ lldb::UserExpressionSP &shared_ptr_to_me,
+ lldb::ExpressionVariableSP &result) override;
+
+ virtual void ScanContext(ExecutionContext &exe_ctx,
+ lldb_private::Error &err) = 0;
+
+ bool PrepareToExecuteJITExpression(DiagnosticManager &diagnostic_manager,
+ ExecutionContext &exe_ctx,
+ lldb::addr_t &struct_address);
+
+ virtual bool AddArguments(ExecutionContext &exe_ctx,
+ std::vector<lldb::addr_t> &args,
+ lldb::addr_t struct_address,
+ DiagnosticManager &diagnostic_manager) = 0;
+
+ lldb::addr_t
+ m_stack_frame_bottom; ///< The bottom of the allocated stack frame.
+ lldb::addr_t m_stack_frame_top; ///< The top of the allocated stack frame.
+
+ bool m_allow_cxx; ///< True if the language allows C++.
+ bool m_allow_objc; ///< True if the language allows Objective-C.
+ std::string
+ m_transformed_text; ///< The text of the expression, as send to the parser
+
+ std::shared_ptr<IRExecutionUnit>
+ m_execution_unit_sp; ///< The execution unit the expression is stored in.
+ std::unique_ptr<Materializer> m_materializer_ap; ///< The materializer to use
+ ///when running the
+ ///expression.
+ lldb::ModuleWP m_jit_module_wp;
+ bool m_enforce_valid_object; ///< True if the expression parser should enforce
+ ///the presence of a valid class pointer
+ /// in order to generate the expression as a method.
+ bool m_in_cplusplus_method; ///< True if the expression is compiled as a C++
+ ///member function (true if it was parsed
+ /// when exe_ctx was in a C++ method).
+ bool m_in_objectivec_method; ///< True if the expression is compiled as an
+ ///Objective-C method (true if it was parsed
+ /// when exe_ctx was in an Objective-C method).
+ bool m_in_static_method; ///< True if the expression is compiled as a static
+ ///(or class) method (currently true if it
+ /// was parsed when exe_ctx was in an Objective-C class method).
+ bool m_needs_object_ptr; ///< True if "this" or "self" must be looked up and
+ ///passed in. False if the expression
+ /// doesn't really use them and they can be NULL.
+ bool m_const_object; ///< True if "this" is const.
+ Target *m_target; ///< The target for storing persistent data like types and
+ ///variables.
+
+ bool m_can_interpret; ///< True if the expression could be evaluated
+ ///statically; false otherwise.
+ lldb::addr_t m_materialized_address; ///< The address at which the arguments
+ ///to the expression have been
+ ///materialized.
+ Materializer::DematerializerSP m_dematerializer_sp; ///< The dematerializer.
};
} // namespace lldb_private
diff --git a/include/lldb/Expression/Materializer.h b/include/lldb/Expression/Materializer.h
index f293fddc1022..4874929136fd 100644
--- a/include/lldb/Expression/Materializer.h
+++ b/include/lldb/Expression/Materializer.h
@@ -17,168 +17,128 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private-types.h"
#include "lldb/Core/Error.h"
#include "lldb/Expression/IRMemoryMap.h"
#include "lldb/Symbol/TaggedASTType.h"
#include "lldb/Target/StackFrame.h"
+#include "lldb/lldb-private-types.h"
-namespace lldb_private
-{
-
-class Materializer
-{
+namespace lldb_private {
+
+class Materializer {
public:
- Materializer ();
- ~Materializer ();
-
- class Dematerializer
- {
- public:
- Dematerializer () :
- m_materializer(nullptr),
- m_map(nullptr),
- m_process_address(LLDB_INVALID_ADDRESS)
- {
- }
-
- ~Dematerializer ()
- {
- Wipe ();
- }
-
- void Dematerialize (Error &err,
- lldb::addr_t frame_top,
- lldb::addr_t frame_bottom);
-
- void Wipe ();
-
- bool IsValid ()
- {
- return m_materializer && m_map && (m_process_address != LLDB_INVALID_ADDRESS);
- }
-
- private:
- friend class Materializer;
-
- Dematerializer (Materializer &materializer,
- lldb::StackFrameSP &frame_sp,
- IRMemoryMap &map,
- lldb::addr_t process_address) :
- m_materializer(&materializer),
- m_map(&map),
- m_process_address(process_address)
- {
- if (frame_sp)
- {
- m_thread_wp = frame_sp->GetThread();
- m_stack_id = frame_sp->GetStackID();
- }
- }
-
- Materializer *m_materializer;
- lldb::ThreadWP m_thread_wp;
- StackID m_stack_id;
- IRMemoryMap *m_map;
- lldb::addr_t m_process_address;
- };
-
- typedef std::shared_ptr<Dematerializer> DematerializerSP;
- typedef std::weak_ptr<Dematerializer> DematerializerWP;
-
- DematerializerSP Materialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, Error &err);
-
- class PersistentVariableDelegate
- {
- public:
- virtual ~PersistentVariableDelegate();
- virtual ConstString GetName() = 0;
- virtual void DidDematerialize(lldb::ExpressionVariableSP &variable) = 0;
- };
-
- uint32_t AddPersistentVariable (lldb::ExpressionVariableSP &persistent_variable_sp,
- PersistentVariableDelegate *delegate,
- Error &err);
- uint32_t AddVariable (lldb::VariableSP &variable_sp,
- Error &err);
- uint32_t AddResultVariable (const CompilerType &type,
- bool is_lvalue,
- bool keep_in_memory,
- PersistentVariableDelegate *delegate,
- Error &err);
- uint32_t AddSymbol (const Symbol &symbol_sp,
- Error &err);
- uint32_t AddRegister (const RegisterInfo &register_info,
- Error &err);
-
- uint32_t GetStructAlignment ()
- {
- return m_struct_alignment;
+ Materializer();
+ ~Materializer();
+
+ class Dematerializer {
+ public:
+ Dematerializer()
+ : m_materializer(nullptr), m_map(nullptr),
+ m_process_address(LLDB_INVALID_ADDRESS) {}
+
+ ~Dematerializer() { Wipe(); }
+
+ void Dematerialize(Error &err, lldb::addr_t frame_top,
+ lldb::addr_t frame_bottom);
+
+ void Wipe();
+
+ bool IsValid() {
+ return m_materializer && m_map &&
+ (m_process_address != LLDB_INVALID_ADDRESS);
}
-
- uint32_t GetStructByteSize ()
- {
- return m_current_offset;
+
+ private:
+ friend class Materializer;
+
+ Dematerializer(Materializer &materializer, lldb::StackFrameSP &frame_sp,
+ IRMemoryMap &map, lldb::addr_t process_address)
+ : m_materializer(&materializer), m_map(&map),
+ m_process_address(process_address) {
+ if (frame_sp) {
+ m_thread_wp = frame_sp->GetThread();
+ m_stack_id = frame_sp->GetStackID();
+ }
}
-
- class Entity
- {
- public:
- Entity () :
- m_alignment(1),
- m_size(0),
- m_offset(0)
- {
- }
-
- virtual ~Entity() = default;
-
- virtual void Materialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, Error &err) = 0;
- virtual void Dematerialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address,
- lldb::addr_t frame_top, lldb::addr_t frame_bottom, Error &err) = 0;
- virtual void DumpToLog (IRMemoryMap &map, lldb::addr_t process_address, Log *log) = 0;
- virtual void Wipe (IRMemoryMap &map, lldb::addr_t process_address) = 0;
-
- uint32_t GetAlignment ()
- {
- return m_alignment;
- }
-
- uint32_t GetSize ()
- {
- return m_size;
- }
-
- uint32_t GetOffset ()
- {
- return m_offset;
- }
-
- void SetOffset (uint32_t offset)
- {
- m_offset = offset;
- }
-
- protected:
- void SetSizeAndAlignmentFromType (CompilerType &type);
-
- uint32_t m_alignment;
- uint32_t m_size;
- uint32_t m_offset;
- };
+
+ Materializer *m_materializer;
+ lldb::ThreadWP m_thread_wp;
+ StackID m_stack_id;
+ IRMemoryMap *m_map;
+ lldb::addr_t m_process_address;
+ };
+
+ typedef std::shared_ptr<Dematerializer> DematerializerSP;
+ typedef std::weak_ptr<Dematerializer> DematerializerWP;
+
+ DematerializerSP Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,
+ lldb::addr_t process_address, Error &err);
+
+ class PersistentVariableDelegate {
+ public:
+ virtual ~PersistentVariableDelegate();
+ virtual ConstString GetName() = 0;
+ virtual void DidDematerialize(lldb::ExpressionVariableSP &variable) = 0;
+ };
+
+ uint32_t
+ AddPersistentVariable(lldb::ExpressionVariableSP &persistent_variable_sp,
+ PersistentVariableDelegate *delegate, Error &err);
+ uint32_t AddVariable(lldb::VariableSP &variable_sp, Error &err);
+ uint32_t AddResultVariable(const CompilerType &type, bool is_lvalue,
+ bool keep_in_memory,
+ PersistentVariableDelegate *delegate, Error &err);
+ uint32_t AddSymbol(const Symbol &symbol_sp, Error &err);
+ uint32_t AddRegister(const RegisterInfo &register_info, Error &err);
+
+ uint32_t GetStructAlignment() { return m_struct_alignment; }
+
+ uint32_t GetStructByteSize() { return m_current_offset; }
+
+ class Entity {
+ public:
+ Entity() : m_alignment(1), m_size(0), m_offset(0) {}
+
+ virtual ~Entity() = default;
+
+ virtual void Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,
+ lldb::addr_t process_address, Error &err) = 0;
+ virtual void Dematerialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,
+ lldb::addr_t process_address,
+ lldb::addr_t frame_top,
+ lldb::addr_t frame_bottom, Error &err) = 0;
+ virtual void DumpToLog(IRMemoryMap &map, lldb::addr_t process_address,
+ Log *log) = 0;
+ virtual void Wipe(IRMemoryMap &map, lldb::addr_t process_address) = 0;
+
+ uint32_t GetAlignment() { return m_alignment; }
+
+ uint32_t GetSize() { return m_size; }
+
+ uint32_t GetOffset() { return m_offset; }
+
+ void SetOffset(uint32_t offset) { m_offset = offset; }
+
+ protected:
+ void SetSizeAndAlignmentFromType(CompilerType &type);
+
+ uint32_t m_alignment;
+ uint32_t m_size;
+ uint32_t m_offset;
+ };
private:
- uint32_t AddStructMember (Entity &entity);
-
- typedef std::unique_ptr<Entity> EntityUP;
- typedef std::vector<EntityUP> EntityVector;
-
- DematerializerWP m_dematerializer_wp;
- EntityVector m_entities;
- uint32_t m_current_offset;
- uint32_t m_struct_alignment;
+ uint32_t AddStructMember(Entity &entity);
+
+ typedef std::unique_ptr<Entity> EntityUP;
+ typedef std::vector<EntityUP> EntityVector;
+
+ DematerializerWP m_dematerializer_wp;
+ EntityVector m_entities;
+ uint32_t m_current_offset;
+ uint32_t m_struct_alignment;
};
-
+
} // namespace lldb_private
#endif // liblldb_Materializer_h
diff --git a/include/lldb/Expression/REPL.h b/include/lldb/Expression/REPL.h
index 21d22de8e0d7..56d31cfd3b15 100644
--- a/include/lldb/Expression/REPL.h
+++ b/include/lldb/Expression/REPL.h
@@ -16,194 +16,159 @@
// Other libraries and framework includes
// Project includes
+#include "lldb/../../source/Commands/CommandObjectExpression.h"
#include "lldb/Interpreter/OptionGroupFormat.h"
#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
-#include "lldb/../../source/Commands/CommandObjectExpression.h"
-namespace lldb_private
-{
-
-class REPL : public IOHandlerDelegate
-{
+namespace lldb_private {
+
+class REPL : public IOHandlerDelegate {
public:
- //----------------------------------------------------------------------
- // See TypeSystem.h for how to add subclasses to this.
- //----------------------------------------------------------------------
- enum LLVMCastKind {
- eKindClang,
- eKindSwift,
- eKindGo,
- kNumKinds
- };
-
- LLVMCastKind getKind() const { return m_kind; }
-
- REPL(LLVMCastKind kind, Target &target);
-
- ~REPL() override;
-
- //------------------------------------------------------------------
- /// Get a REPL with an existing target (or, failing that, a debugger to use), and (optional) extra arguments for the compiler.
- ///
- /// @param[out] error
- /// If this language is supported but the REPL couldn't be created, this error is populated with the reason.
- ///
- /// @param[in] language
- /// The language to create a REPL for.
- ///
- /// @param[in] debugger
- /// If provided, and target is nullptr, the debugger to use when setting up a top-level REPL.
- ///
- /// @param[in] target
- /// If provided, the target to put the REPL inside.
- ///
- /// @param[in] repl_options
- /// If provided, additional options for the compiler when parsing REPL expressions.
- ///
- /// @return
- /// The range of the containing object in the target process.
- //------------------------------------------------------------------
- static lldb::REPLSP
- Create (Error &Error, lldb::LanguageType language, Debugger *debugger, Target *target, const char *repl_options);
-
- void
- SetFormatOptions (const OptionGroupFormat &options)
- {
- m_format_options = options;
- }
-
- void
- SetValueObjectDisplayOptions (const OptionGroupValueObjectDisplay &options)
- {
- m_varobj_options = options;
- }
-
- void
- SetCommandOptions (const CommandObjectExpression::CommandOptions &options)
- {
- m_command_options = options;
- }
-
- void
- SetCompilerOptions (const char *options)
- {
- if (options)
- m_compiler_options = options;
- }
-
- lldb::IOHandlerSP
- GetIOHandler ();
-
- Error
- RunLoop ();
-
- //------------------------------------------------------------------
- // IOHandler::Delegate functions
- //------------------------------------------------------------------
- void
- IOHandlerActivated (IOHandler &io_handler) override;
-
- bool
- IOHandlerInterrupt (IOHandler &io_handler) override;
-
- void
- IOHandlerInputInterrupted (IOHandler &io_handler,
- std::string &line) override;
-
- const char *
- IOHandlerGetFixIndentationCharacters () override;
-
- ConstString
- IOHandlerGetControlSequence (char ch) override;
-
- const char *
- IOHandlerGetCommandPrefix () override;
-
- const char *
- IOHandlerGetHelpPrologue () override;
-
- bool
- IOHandlerIsInputComplete (IOHandler &io_handler,
- StringList &lines) override;
-
- int
- IOHandlerFixIndentation (IOHandler &io_handler,
- const StringList &lines,
- int cursor_position) override;
-
- void
- IOHandlerInputComplete (IOHandler &io_handler,
- std::string &line) override;
-
- int
- IOHandlerComplete (IOHandler &io_handler,
- const char *current_line,
- const char *cursor,
- const char *last_char,
- int skip_first_n_matches,
- int max_matches,
- StringList &matches) override;
+ //----------------------------------------------------------------------
+ // See TypeSystem.h for how to add subclasses to this.
+ //----------------------------------------------------------------------
+ enum LLVMCastKind { eKindClang, eKindSwift, eKindGo, kNumKinds };
+
+ LLVMCastKind getKind() const { return m_kind; }
+
+ REPL(LLVMCastKind kind, Target &target);
+
+ ~REPL() override;
+
+ //------------------------------------------------------------------
+ /// Get a REPL with an existing target (or, failing that, a debugger to use),
+ /// and (optional) extra arguments for the compiler.
+ ///
+ /// @param[out] error
+ /// If this language is supported but the REPL couldn't be created, this
+ /// error is populated with the reason.
+ ///
+ /// @param[in] language
+ /// The language to create a REPL for.
+ ///
+ /// @param[in] debugger
+ /// If provided, and target is nullptr, the debugger to use when setting
+ /// up a top-level REPL.
+ ///
+ /// @param[in] target
+ /// If provided, the target to put the REPL inside.
+ ///
+ /// @param[in] repl_options
+ /// If provided, additional options for the compiler when parsing REPL
+ /// expressions.
+ ///
+ /// @return
+ /// The range of the containing object in the target process.
+ //------------------------------------------------------------------
+ static lldb::REPLSP Create(Error &Error, lldb::LanguageType language,
+ Debugger *debugger, Target *target,
+ const char *repl_options);
+
+ void SetFormatOptions(const OptionGroupFormat &options) {
+ m_format_options = options;
+ }
+
+ void
+ SetValueObjectDisplayOptions(const OptionGroupValueObjectDisplay &options) {
+ m_varobj_options = options;
+ }
+
+ void
+ SetCommandOptions(const CommandObjectExpression::CommandOptions &options) {
+ m_command_options = options;
+ }
+
+ void SetCompilerOptions(const char *options) {
+ if (options)
+ m_compiler_options = options;
+ }
+
+ lldb::IOHandlerSP GetIOHandler();
+
+ Error RunLoop();
+
+ //------------------------------------------------------------------
+ // IOHandler::Delegate functions
+ //------------------------------------------------------------------
+ void IOHandlerActivated(IOHandler &io_handler) override;
+
+ bool IOHandlerInterrupt(IOHandler &io_handler) override;
+
+ void IOHandlerInputInterrupted(IOHandler &io_handler,
+ std::string &line) override;
+
+ const char *IOHandlerGetFixIndentationCharacters() override;
+
+ ConstString IOHandlerGetControlSequence(char ch) override;
+
+ const char *IOHandlerGetCommandPrefix() override;
+
+ const char *IOHandlerGetHelpPrologue() override;
+
+ bool IOHandlerIsInputComplete(IOHandler &io_handler,
+ StringList &lines) override;
+
+ int IOHandlerFixIndentation(IOHandler &io_handler, const StringList &lines,
+ int cursor_position) override;
+
+ void IOHandlerInputComplete(IOHandler &io_handler,
+ std::string &line) override;
+
+ int IOHandlerComplete(IOHandler &io_handler, const char *current_line,
+ const char *cursor, const char *last_char,
+ int skip_first_n_matches, int max_matches,
+ StringList &matches) override;
protected:
- static int
- CalculateActualIndentation (const StringList &lines);
-
- //----------------------------------------------------------------------
- // Subclasses should override these functions to implement a functional REPL.
- //----------------------------------------------------------------------
-
- virtual Error
- DoInitialization () = 0;
-
- virtual ConstString
- GetSourceFileBasename () = 0;
-
- virtual const char *
- GetAutoIndentCharacters () = 0;
-
- virtual bool
- SourceIsComplete (const std::string &source) = 0;
-
- virtual lldb::offset_t
- GetDesiredIndentation (const StringList &lines,
- int cursor_position,
- int tab_size) = 0; // LLDB_INVALID_OFFSET means no change
-
- virtual lldb::LanguageType
- GetLanguage () = 0;
-
- virtual bool
- PrintOneVariable (Debugger &debugger,
- lldb::StreamFileSP &output_sp,
- lldb::ValueObjectSP &valobj_sp,
- ExpressionVariable *var = nullptr) = 0;
-
- virtual int
- CompleteCode(const std::string &current_code,
- StringList &matches) = 0;
-
- OptionGroupFormat m_format_options = OptionGroupFormat(lldb::eFormatDefault);
- OptionGroupValueObjectDisplay m_varobj_options;
- CommandObjectExpression::CommandOptions m_command_options;
- std::string m_compiler_options;
-
- bool m_enable_auto_indent = true;
- std::string m_indent_str; // Use this string for each level of indentation
- std::string m_current_indent_str;
- uint32_t m_current_indent_level = 0;
-
- std::string m_repl_source_path;
- bool m_dedicated_repl_mode = false;
-
- StringList m_code; // All accumulated REPL statements are saved here
-
- Target &m_target;
- lldb::IOHandlerSP m_io_handler_sp;
- LLVMCastKind m_kind;
+ static int CalculateActualIndentation(const StringList &lines);
+
+ //----------------------------------------------------------------------
+ // Subclasses should override these functions to implement a functional REPL.
+ //----------------------------------------------------------------------
+
+ virtual Error DoInitialization() = 0;
+
+ virtual ConstString GetSourceFileBasename() = 0;
+
+ virtual const char *GetAutoIndentCharacters() = 0;
+
+ virtual bool SourceIsComplete(const std::string &source) = 0;
+
+ virtual lldb::offset_t GetDesiredIndentation(
+ const StringList &lines, int cursor_position,
+ int tab_size) = 0; // LLDB_INVALID_OFFSET means no change
+
+ virtual lldb::LanguageType GetLanguage() = 0;
+
+ virtual bool PrintOneVariable(Debugger &debugger,
+ lldb::StreamFileSP &output_sp,
+ lldb::ValueObjectSP &valobj_sp,
+ ExpressionVariable *var = nullptr) = 0;
+
+ virtual int CompleteCode(const std::string &current_code,
+ StringList &matches) = 0;
+
+ OptionGroupFormat m_format_options = OptionGroupFormat(lldb::eFormatDefault);
+ OptionGroupValueObjectDisplay m_varobj_options;
+ CommandObjectExpression::CommandOptions m_command_options;
+ std::string m_compiler_options;
+
+ bool m_enable_auto_indent = true;
+ std::string m_indent_str; // Use this string for each level of indentation
+ std::string m_current_indent_str;
+ uint32_t m_current_indent_level = 0;
+
+ std::string m_repl_source_path;
+ bool m_dedicated_repl_mode = false;
+
+ StringList m_code; // All accumulated REPL statements are saved here
+
+ Target &m_target;
+ lldb::IOHandlerSP m_io_handler_sp;
+ LLVMCastKind m_kind;
private:
- std::string
- GetSourcePath();
+ std::string GetSourcePath();
};
} // namespace lldb_private
diff --git a/include/lldb/Expression/UserExpression.h b/include/lldb/Expression/UserExpression.h
index 2b685dc046c7..fca667e8ee96 100644
--- a/include/lldb/Expression/UserExpression.h
+++ b/include/lldb/Expression/UserExpression.h
@@ -18,16 +18,15 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-forward.h"
-#include "lldb/lldb-private.h"
#include "lldb/Core/Address.h"
#include "lldb/Expression/Expression.h"
#include "lldb/Expression/Materializer.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Target.h"
+#include "lldb/lldb-forward.h"
+#include "lldb/lldb-private.h"
-namespace lldb_private
-{
+namespace lldb_private {
//----------------------------------------------------------------------
/// @class UserExpression UserExpression.h "lldb/Expression/UserExpression.h"
@@ -40,308 +39,274 @@ namespace lldb_private
/// implementations of UserExpression - which will be vended through the
/// appropriate TypeSystem.
//----------------------------------------------------------------------
-class UserExpression : public Expression
-{
+class UserExpression : public Expression {
public:
- enum { kDefaultTimeout = 500000u };
-
- //------------------------------------------------------------------
- /// Constructor
- ///
- /// @param[in] expr
- /// The expression to parse.
- ///
- /// @param[in] expr_prefix
- /// If non-nullptr, a C string containing translation-unit level
- /// definitions to be included when the expression is parsed.
- ///
- /// @param[in] language
- /// If not eLanguageTypeUnknown, a language to use when parsing
- /// the expression. Currently restricted to those languages
- /// supported by Clang.
- ///
- /// @param[in] desired_type
- /// If not eResultTypeAny, the type to use for the expression
- /// result.
- //------------------------------------------------------------------
- UserExpression (ExecutionContextScope &exe_scope,
- const char *expr,
- const char *expr_prefix,
- lldb::LanguageType language,
- ResultType desired_type,
- const EvaluateExpressionOptions &options);
-
- //------------------------------------------------------------------
- /// Destructor
- //------------------------------------------------------------------
- ~UserExpression() override;
-
- //------------------------------------------------------------------
- /// Parse the expression
- ///
- /// @param[in] diagnostic_manager
- /// A diagnostic manager to report parse errors and warnings to.
- ///
- /// @param[in] exe_ctx
- /// The execution context to use when looking up entities that
- /// are needed for parsing (locations of functions, types of
- /// variables, persistent variables, etc.)
- ///
- /// @param[in] execution_policy
- /// Determines whether interpretation is possible or mandatory.
- ///
- /// @param[in] keep_result_in_memory
- /// True if the resulting persistent variable should reside in
- /// target memory, if applicable.
- ///
- /// @return
- /// True on success (no errors); false otherwise.
- //------------------------------------------------------------------
- virtual bool
- Parse(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
- lldb_private::ExecutionPolicy execution_policy, bool keep_result_in_memory, bool generate_debug_info) = 0;
-
- virtual bool CanInterpret() = 0;
-
- bool
- MatchesContext (ExecutionContext &exe_ctx);
-
- //------------------------------------------------------------------
- /// Execute the parsed expression by callinng the derived class's
- /// DoExecute method.
- ///
- /// @param[in] diagnostic_manager
- /// A diagnostic manager to report errors to.
- ///
- /// @param[in] exe_ctx
- /// The execution context to use when looking up entities that
- /// are needed for parsing (locations of variables, etc.)
- ///
- /// @param[in] options
- /// Expression evaluation options.
- ///
- /// @param[in] shared_ptr_to_me
- /// This is a shared pointer to this UserExpression. This is
- /// needed because Execute can push a thread plan that will hold onto
- /// the UserExpression for an unbounded period of time. So you
- /// need to give the thread plan a reference to this object that can
- /// keep it alive.
- ///
- /// @param[in] result
- /// A pointer to direct at the persistent variable in which the
- /// expression's result is stored.
- ///
- /// @return
- /// A Process::Execution results value.
- //------------------------------------------------------------------
- lldb::ExpressionResults
- Execute(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options,
- lldb::UserExpressionSP &shared_ptr_to_me, lldb::ExpressionVariableSP &result);
-
- //------------------------------------------------------------------
- /// Apply the side effects of the function to program state.
- ///
- /// @param[in] diagnostic_manager
- /// A diagnostic manager to report errors to.
- ///
- /// @param[in] exe_ctx
- /// The execution context to use when looking up entities that
- /// are needed for parsing (locations of variables, etc.)
- ///
- /// @param[in] result
- /// A pointer to direct at the persistent variable in which the
- /// expression's result is stored.
- ///
- /// @param[in] function_stack_pointer
- /// A pointer to the base of the function's stack frame. This
- /// is used to determine whether the expression result resides in
- /// memory that will still be valid, or whether it needs to be
- /// treated as homeless for the purpose of future expressions.
- ///
- /// @return
- /// A Process::Execution results value.
- //------------------------------------------------------------------
- virtual bool
- FinalizeJITExecution(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
- lldb::ExpressionVariableSP &result, lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS,
- lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS) = 0;
-
- //------------------------------------------------------------------
- /// Return the string that the parser should parse.
- //------------------------------------------------------------------
- const char *
- Text() override
- {
- return m_expr_text.c_str();
- }
-
- //------------------------------------------------------------------
- /// Return the string that the user typed.
- //------------------------------------------------------------------
- const char *
- GetUserText ()
- {
- return m_expr_text.c_str();
- }
-
- //------------------------------------------------------------------
- /// Return the function name that should be used for executing the
- /// expression. Text() should contain the definition of this
- /// function.
- //------------------------------------------------------------------
- const char *
- FunctionName() override
- {
- return "$__lldb_expr";
- }
-
- //------------------------------------------------------------------
- /// Return the language that should be used when parsing. To use
- /// the default, return eLanguageTypeUnknown.
- //------------------------------------------------------------------
- lldb::LanguageType
- Language() override
- {
- return m_language;
- }
-
- //------------------------------------------------------------------
- /// Return the desired result type of the function, or
- /// eResultTypeAny if indifferent.
- //------------------------------------------------------------------
- ResultType
- DesiredResultType() override
- {
- return m_desired_type;
- }
-
- //------------------------------------------------------------------
- /// Return true if validation code should be inserted into the
- /// expression.
- //------------------------------------------------------------------
- bool
- NeedsValidation() override
- {
- return true;
- }
-
- //------------------------------------------------------------------
- /// Return true if external variables in the expression should be
- /// resolved.
- //------------------------------------------------------------------
- bool
- NeedsVariableResolution() override
- {
- return true;
- }
-
- EvaluateExpressionOptions *
- GetOptions() override
- {
- return &m_options;
- }
-
- virtual lldb::ExpressionVariableSP
- GetResultAfterDematerialization(ExecutionContextScope *exe_scope)
- {
- return lldb::ExpressionVariableSP();
- }
-
- virtual lldb::ModuleSP
- GetJITModule()
- {
- return lldb::ModuleSP();
- }
-
- //------------------------------------------------------------------
- /// Evaluate one expression in the scratch context of the
- /// target passed in the exe_ctx and return its result.
- ///
- /// @param[in] exe_ctx
- /// The execution context to use when evaluating the expression.
- ///
- /// @param[in] options
- /// Expression evaluation options. N.B. The language in the
- /// evaluation options will be used to determine the language used for
- /// expression evaluation.
- ///
- /// @param[in] expr_cstr
- /// A C string containing the expression to be evaluated.
- ///
- /// @param[in] expr_prefix
- /// If non-nullptr, a C string containing translation-unit level
- /// definitions to be included when the expression is parsed.
- ///
- /// @param[in,out] result_valobj_sp
- /// If execution is successful, the result valobj is placed here.
- ///
- /// @param[out] error
- /// Filled in with an error in case the expression evaluation
- /// fails to parse, run, or evaluated.
- ///
- /// @param[in] line_offset
- /// The offset of the first line of the expression from the "beginning" of a virtual source file used for error reporting and debug info.
- ///
- /// @param[out] fixed_expression
- /// If non-nullptr, the fixed expression is copied into the provided string.
- ///
- /// @param[out] jit_module_sp_ptr
- /// If non-nullptr, used to persist the generated IR module.
- ///
- /// @result
- /// A Process::ExpressionResults value. eExpressionCompleted for success.
- //------------------------------------------------------------------
- static lldb::ExpressionResults
- Evaluate(ExecutionContext &exe_ctx,
- const EvaluateExpressionOptions& options,
- const char *expr_cstr,
- const char *expr_prefix,
- lldb::ValueObjectSP &result_valobj_sp,
- Error &error,
- uint32_t line_offset = 0,
- std::string *fixed_expression = nullptr,
- lldb::ModuleSP *jit_module_sp_ptr = nullptr);
-
- static const Error::ValueType kNoResult = 0x1001; ///< ValueObject::GetError() returns this if there is no result from the expression.
-
- const char *
- GetFixedText()
- {
- if (m_fixed_text.empty())
- return nullptr;
- return m_fixed_text.c_str();
- }
+ enum { kDefaultTimeout = 500000u };
+
+ //------------------------------------------------------------------
+ /// Constructor
+ ///
+ /// @param[in] expr
+ /// The expression to parse.
+ ///
+ /// @param[in] expr_prefix
+ /// If non-nullptr, a C string containing translation-unit level
+ /// definitions to be included when the expression is parsed.
+ ///
+ /// @param[in] language
+ /// If not eLanguageTypeUnknown, a language to use when parsing
+ /// the expression. Currently restricted to those languages
+ /// supported by Clang.
+ ///
+ /// @param[in] desired_type
+ /// If not eResultTypeAny, the type to use for the expression
+ /// result.
+ //------------------------------------------------------------------
+ UserExpression(ExecutionContextScope &exe_scope, llvm::StringRef expr,
+ llvm::StringRef prefix, lldb::LanguageType language,
+ ResultType desired_type,
+ const EvaluateExpressionOptions &options);
+
+ //------------------------------------------------------------------
+ /// Destructor
+ //------------------------------------------------------------------
+ ~UserExpression() override;
+
+ //------------------------------------------------------------------
+ /// Parse the expression
+ ///
+ /// @param[in] diagnostic_manager
+ /// A diagnostic manager to report parse errors and warnings to.
+ ///
+ /// @param[in] exe_ctx
+ /// The execution context to use when looking up entities that
+ /// are needed for parsing (locations of functions, types of
+ /// variables, persistent variables, etc.)
+ ///
+ /// @param[in] execution_policy
+ /// Determines whether interpretation is possible or mandatory.
+ ///
+ /// @param[in] keep_result_in_memory
+ /// True if the resulting persistent variable should reside in
+ /// target memory, if applicable.
+ ///
+ /// @return
+ /// True on success (no errors); false otherwise.
+ //------------------------------------------------------------------
+ virtual bool Parse(DiagnosticManager &diagnostic_manager,
+ ExecutionContext &exe_ctx,
+ lldb_private::ExecutionPolicy execution_policy,
+ bool keep_result_in_memory, bool generate_debug_info) = 0;
+
+ virtual bool CanInterpret() = 0;
+
+ bool MatchesContext(ExecutionContext &exe_ctx);
+
+ //------------------------------------------------------------------
+ /// Execute the parsed expression by callinng the derived class's
+ /// DoExecute method.
+ ///
+ /// @param[in] diagnostic_manager
+ /// A diagnostic manager to report errors to.
+ ///
+ /// @param[in] exe_ctx
+ /// The execution context to use when looking up entities that
+ /// are needed for parsing (locations of variables, etc.)
+ ///
+ /// @param[in] options
+ /// Expression evaluation options.
+ ///
+ /// @param[in] shared_ptr_to_me
+ /// This is a shared pointer to this UserExpression. This is
+ /// needed because Execute can push a thread plan that will hold onto
+ /// the UserExpression for an unbounded period of time. So you
+ /// need to give the thread plan a reference to this object that can
+ /// keep it alive.
+ ///
+ /// @param[in] result
+ /// A pointer to direct at the persistent variable in which the
+ /// expression's result is stored.
+ ///
+ /// @return
+ /// A Process::Execution results value.
+ //------------------------------------------------------------------
+ lldb::ExpressionResults Execute(DiagnosticManager &diagnostic_manager,
+ ExecutionContext &exe_ctx,
+ const EvaluateExpressionOptions &options,
+ lldb::UserExpressionSP &shared_ptr_to_me,
+ lldb::ExpressionVariableSP &result);
+
+ //------------------------------------------------------------------
+ /// Apply the side effects of the function to program state.
+ ///
+ /// @param[in] diagnostic_manager
+ /// A diagnostic manager to report errors to.
+ ///
+ /// @param[in] exe_ctx
+ /// The execution context to use when looking up entities that
+ /// are needed for parsing (locations of variables, etc.)
+ ///
+ /// @param[in] result
+ /// A pointer to direct at the persistent variable in which the
+ /// expression's result is stored.
+ ///
+ /// @param[in] function_stack_pointer
+ /// A pointer to the base of the function's stack frame. This
+ /// is used to determine whether the expression result resides in
+ /// memory that will still be valid, or whether it needs to be
+ /// treated as homeless for the purpose of future expressions.
+ ///
+ /// @return
+ /// A Process::Execution results value.
+ //------------------------------------------------------------------
+ virtual bool FinalizeJITExecution(
+ DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
+ lldb::ExpressionVariableSP &result,
+ lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS,
+ lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS) = 0;
+
+ //------------------------------------------------------------------
+ /// Return the string that the parser should parse.
+ //------------------------------------------------------------------
+ const char *Text() override { return m_expr_text.c_str(); }
+
+ //------------------------------------------------------------------
+ /// Return the string that the user typed.
+ //------------------------------------------------------------------
+ const char *GetUserText() { return m_expr_text.c_str(); }
+
+ //------------------------------------------------------------------
+ /// Return the function name that should be used for executing the
+ /// expression. Text() should contain the definition of this
+ /// function.
+ //------------------------------------------------------------------
+ const char *FunctionName() override { return "$__lldb_expr"; }
+
+ //------------------------------------------------------------------
+ /// Return the language that should be used when parsing. To use
+ /// the default, return eLanguageTypeUnknown.
+ //------------------------------------------------------------------
+ lldb::LanguageType Language() override { return m_language; }
+
+ //------------------------------------------------------------------
+ /// Return the desired result type of the function, or
+ /// eResultTypeAny if indifferent.
+ //------------------------------------------------------------------
+ ResultType DesiredResultType() override { return m_desired_type; }
+
+ //------------------------------------------------------------------
+ /// Return true if validation code should be inserted into the
+ /// expression.
+ //------------------------------------------------------------------
+ bool NeedsValidation() override { return true; }
+
+ //------------------------------------------------------------------
+ /// Return true if external variables in the expression should be
+ /// resolved.
+ //------------------------------------------------------------------
+ bool NeedsVariableResolution() override { return true; }
+
+ EvaluateExpressionOptions *GetOptions() override { return &m_options; }
+
+ virtual lldb::ExpressionVariableSP
+ GetResultAfterDematerialization(ExecutionContextScope *exe_scope) {
+ return lldb::ExpressionVariableSP();
+ }
+
+ virtual lldb::ModuleSP GetJITModule() { return lldb::ModuleSP(); }
+
+ //------------------------------------------------------------------
+ /// Evaluate one expression in the scratch context of the
+ /// target passed in the exe_ctx and return its result.
+ ///
+ /// @param[in] exe_ctx
+ /// The execution context to use when evaluating the expression.
+ ///
+ /// @param[in] options
+ /// Expression evaluation options. N.B. The language in the
+ /// evaluation options will be used to determine the language used for
+ /// expression evaluation.
+ ///
+ /// @param[in] expr_cstr
+ /// A C string containing the expression to be evaluated.
+ ///
+ /// @param[in] expr_prefix
+ /// If non-nullptr, a C string containing translation-unit level
+ /// definitions to be included when the expression is parsed.
+ ///
+ /// @param[in,out] result_valobj_sp
+ /// If execution is successful, the result valobj is placed here.
+ ///
+ /// @param[out] error
+ /// Filled in with an error in case the expression evaluation
+ /// fails to parse, run, or evaluated.
+ ///
+ /// @param[in] line_offset
+ /// The offset of the first line of the expression from the "beginning" of
+ /// a virtual source file used for error reporting and debug info.
+ ///
+ /// @param[out] fixed_expression
+ /// If non-nullptr, the fixed expression is copied into the provided
+ /// string.
+ ///
+ /// @param[out] jit_module_sp_ptr
+ /// If non-nullptr, used to persist the generated IR module.
+ ///
+ /// @result
+ /// A Process::ExpressionResults value. eExpressionCompleted for
+ /// success.
+ //------------------------------------------------------------------
+ static lldb::ExpressionResults
+ Evaluate(ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options,
+ llvm::StringRef expr_cstr, llvm::StringRef expr_prefix,
+ lldb::ValueObjectSP &result_valobj_sp, Error &error,
+ uint32_t line_offset = 0, std::string *fixed_expression = nullptr,
+ lldb::ModuleSP *jit_module_sp_ptr = nullptr);
+
+ static const Error::ValueType kNoResult =
+ 0x1001; ///< ValueObject::GetError() returns this if there is no result
+ ///from the expression.
+
+ const char *GetFixedText() {
+ if (m_fixed_text.empty())
+ return nullptr;
+ return m_fixed_text.c_str();
+ }
protected:
- virtual lldb::ExpressionResults
- DoExecute(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options,
- lldb::UserExpressionSP &shared_ptr_to_me, lldb::ExpressionVariableSP &result) = 0;
-
- static lldb::addr_t
- GetObjectPointer (lldb::StackFrameSP frame_sp,
- ConstString &object_name,
- Error &err);
-
- //------------------------------------------------------------------
- /// Populate m_in_cplusplus_method and m_in_objectivec_method based on the environment.
- //------------------------------------------------------------------
-
- void
- InstallContext (ExecutionContext &exe_ctx);
-
- bool
- LockAndCheckContext (ExecutionContext &exe_ctx,
- lldb::TargetSP &target_sp,
- lldb::ProcessSP &process_sp,
- lldb::StackFrameSP &frame_sp);
-
- Address m_address; ///< The address the process is stopped in.
- std::string m_expr_text; ///< The text of the expression, as typed by the user
- std::string m_expr_prefix; ///< The text of the translation-level definitions, as provided by the user
- std::string m_fixed_text; ///< The text of the expression with fix-its applied - this won't be set if the fixed text doesn't parse.
- lldb::LanguageType m_language; ///< The language to use when parsing (eLanguageTypeUnknown means use defaults)
- ResultType m_desired_type; ///< The type to coerce the expression's result to. If eResultTypeAny, inferred from the expression.
- EvaluateExpressionOptions m_options; ///< Additional options provided by the user.
+ virtual lldb::ExpressionResults
+ DoExecute(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
+ const EvaluateExpressionOptions &options,
+ lldb::UserExpressionSP &shared_ptr_to_me,
+ lldb::ExpressionVariableSP &result) = 0;
+
+ static lldb::addr_t GetObjectPointer(lldb::StackFrameSP frame_sp,
+ ConstString &object_name, Error &err);
+
+ //------------------------------------------------------------------
+ /// Populate m_in_cplusplus_method and m_in_objectivec_method based on the
+ /// environment.
+ //------------------------------------------------------------------
+
+ void InstallContext(ExecutionContext &exe_ctx);
+
+ bool LockAndCheckContext(ExecutionContext &exe_ctx, lldb::TargetSP &target_sp,
+ lldb::ProcessSP &process_sp,
+ lldb::StackFrameSP &frame_sp);
+
+ Address m_address; ///< The address the process is stopped in.
+ std::string m_expr_text; ///< The text of the expression, as typed by the user
+ std::string m_expr_prefix; ///< The text of the translation-level definitions,
+ ///as provided by the user
+ std::string m_fixed_text; ///< The text of the expression with fix-its applied
+ ///- this won't be set if the fixed text doesn't
+ ///parse.
+ lldb::LanguageType m_language; ///< The language to use when parsing
+ ///(eLanguageTypeUnknown means use defaults)
+ ResultType m_desired_type; ///< The type to coerce the expression's result to.
+ ///If eResultTypeAny, inferred from the expression.
+ EvaluateExpressionOptions
+ m_options; ///< Additional options provided by the user.
};
} // namespace lldb_private
diff --git a/include/lldb/Expression/UtilityFunction.h b/include/lldb/Expression/UtilityFunction.h
index a78972082c52..0e2b87da20ad 100644
--- a/include/lldb/Expression/UtilityFunction.h
+++ b/include/lldb/Expression/UtilityFunction.h
@@ -1,4 +1,5 @@
-//===-- UtilityFunction.h ----------------------------------------*- C++ -*-===//
+//===-- UtilityFunction.h ----------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -17,146 +18,124 @@
// Other libraries and framework includes
// Project includes
+#include "lldb/Expression/Expression.h"
#include "lldb/lldb-forward.h"
#include "lldb/lldb-private.h"
-#include "lldb/Expression/Expression.h"
-namespace lldb_private
-{
+namespace lldb_private {
//----------------------------------------------------------------------
/// @class UtilityFunction UtilityFunction.h "lldb/Expression/UtilityFunction.h"
-/// @brief Encapsulates a bit of source code that provides a function that is callable
+/// @brief Encapsulates a bit of source code that provides a function that is
+/// callable
///
/// LLDB uses expressions for various purposes, notably to call functions
/// and as a backend for the expr command. UtilityFunction encapsulates
/// a self-contained function meant to be used from other code. Utility
-/// functions can perform error-checking for ClangUserExpressions,
+/// functions can perform error-checking for ClangUserExpressions,
//----------------------------------------------------------------------
-class UtilityFunction : public Expression
-{
+class UtilityFunction : public Expression {
public:
- //------------------------------------------------------------------
- /// Constructor
- ///
- /// @param[in] text
- /// The text of the function. Must be a full translation unit.
- ///
- /// @param[in] name
- /// The name of the function, as used in the text.
- //------------------------------------------------------------------
- UtilityFunction (ExecutionContextScope &exe_scope,
- const char *text,
- const char *name);
-
- ~UtilityFunction() override;
-
- //------------------------------------------------------------------
- /// Install the utility function into a process
- ///
- /// @param[in] diagnostic_manager
- /// A diagnostic manager to print parse errors and warnings to.
- ///
- /// @param[in] exe_ctx
- /// The execution context to install the utility function to.
- ///
- /// @return
- /// True on success (no errors); false otherwise.
- //------------------------------------------------------------------
- virtual bool
- Install(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx) = 0;
-
- //------------------------------------------------------------------
- /// Check whether the given PC is inside the function
- ///
- /// Especially useful if the function dereferences nullptr to indicate a failed
- /// assert.
- ///
- /// @param[in] pc
- /// The program counter to check.
- ///
- /// @return
- /// True if the program counter falls within the function's bounds;
- /// false if not (or the function is not JIT compiled)
- //------------------------------------------------------------------
- bool
- ContainsAddress (lldb::addr_t address)
- {
- // nothing is both >= LLDB_INVALID_ADDRESS and < LLDB_INVALID_ADDRESS,
- // so this always returns false if the function is not JIT compiled yet
- return (address >= m_jit_start_addr && address < m_jit_end_addr);
- }
-
- //------------------------------------------------------------------
- /// Return the string that the parser should parse. Must be a full
- /// translation unit.
- //------------------------------------------------------------------
- const char *
- Text() override
- {
- return m_function_text.c_str();
- }
-
- //------------------------------------------------------------------
- /// Return the function name that should be used for executing the
- /// expression. Text() should contain the definition of this
- /// function.
- //------------------------------------------------------------------
- const char *
- FunctionName() override
- {
- return m_function_name.c_str();
- }
-
- //------------------------------------------------------------------
- /// Return the object that the parser should use when registering
- /// local variables. May be nullptr if the Expression doesn't care.
- //------------------------------------------------------------------
- ExpressionVariableList *
- LocalVariables ()
- {
- return nullptr;
- }
-
- //------------------------------------------------------------------
- /// Return true if validation code should be inserted into the
- /// expression.
- //------------------------------------------------------------------
- bool
- NeedsValidation() override
- {
- return false;
- }
-
- //------------------------------------------------------------------
- /// Return true if external variables in the expression should be
- /// resolved.
- //------------------------------------------------------------------
- bool
- NeedsVariableResolution() override
- {
- return false;
- }
-
- // This makes the function caller function.
- // Pass in the ThreadSP if you have one available, compilation can end up calling code (e.g. to look up indirect
- // functions) and we don't want this to wander onto another thread.
- FunctionCaller *
- MakeFunctionCaller(const CompilerType &return_type, const ValueList &arg_value_list, lldb::ThreadSP compilation_thread, Error &error);
-
- // This one retrieves the function caller that is already made. If you haven't made it yet, this returns nullptr
- FunctionCaller *
- GetFunctionCaller()
- {
- return m_caller_up.get();
- }
-
+ //------------------------------------------------------------------
+ /// Constructor
+ ///
+ /// @param[in] text
+ /// The text of the function. Must be a full translation unit.
+ ///
+ /// @param[in] name
+ /// The name of the function, as used in the text.
+ //------------------------------------------------------------------
+ UtilityFunction(ExecutionContextScope &exe_scope, const char *text,
+ const char *name);
+
+ ~UtilityFunction() override;
+
+ //------------------------------------------------------------------
+ /// Install the utility function into a process
+ ///
+ /// @param[in] diagnostic_manager
+ /// A diagnostic manager to print parse errors and warnings to.
+ ///
+ /// @param[in] exe_ctx
+ /// The execution context to install the utility function to.
+ ///
+ /// @return
+ /// True on success (no errors); false otherwise.
+ //------------------------------------------------------------------
+ virtual bool Install(DiagnosticManager &diagnostic_manager,
+ ExecutionContext &exe_ctx) = 0;
+
+ //------------------------------------------------------------------
+ /// Check whether the given PC is inside the function
+ ///
+ /// Especially useful if the function dereferences nullptr to indicate a
+ /// failed
+ /// assert.
+ ///
+ /// @param[in] pc
+ /// The program counter to check.
+ ///
+ /// @return
+ /// True if the program counter falls within the function's bounds;
+ /// false if not (or the function is not JIT compiled)
+ //------------------------------------------------------------------
+ bool ContainsAddress(lldb::addr_t address) {
+ // nothing is both >= LLDB_INVALID_ADDRESS and < LLDB_INVALID_ADDRESS,
+ // so this always returns false if the function is not JIT compiled yet
+ return (address >= m_jit_start_addr && address < m_jit_end_addr);
+ }
+
+ //------------------------------------------------------------------
+ /// Return the string that the parser should parse. Must be a full
+ /// translation unit.
+ //------------------------------------------------------------------
+ const char *Text() override { return m_function_text.c_str(); }
+
+ //------------------------------------------------------------------
+ /// Return the function name that should be used for executing the
+ /// expression. Text() should contain the definition of this
+ /// function.
+ //------------------------------------------------------------------
+ const char *FunctionName() override { return m_function_name.c_str(); }
+
+ //------------------------------------------------------------------
+ /// Return the object that the parser should use when registering
+ /// local variables. May be nullptr if the Expression doesn't care.
+ //------------------------------------------------------------------
+ ExpressionVariableList *LocalVariables() { return nullptr; }
+
+ //------------------------------------------------------------------
+ /// Return true if validation code should be inserted into the
+ /// expression.
+ //------------------------------------------------------------------
+ bool NeedsValidation() override { return false; }
+
+ //------------------------------------------------------------------
+ /// Return true if external variables in the expression should be
+ /// resolved.
+ //------------------------------------------------------------------
+ bool NeedsVariableResolution() override { return false; }
+
+ // This makes the function caller function.
+ // Pass in the ThreadSP if you have one available, compilation can end up
+ // calling code (e.g. to look up indirect
+ // functions) and we don't want this to wander onto another thread.
+ FunctionCaller *MakeFunctionCaller(const CompilerType &return_type,
+ const ValueList &arg_value_list,
+ lldb::ThreadSP compilation_thread,
+ Error &error);
+
+ // This one retrieves the function caller that is already made. If you
+ // haven't made it yet, this returns nullptr
+ FunctionCaller *GetFunctionCaller() { return m_caller_up.get(); }
+
protected:
- std::shared_ptr<IRExecutionUnit> m_execution_unit_sp;
- lldb::ModuleWP m_jit_module_wp;
- std::string m_function_text; ///< The text of the function. Must be a well-formed translation unit.
- std::string m_function_name; ///< The name of the function.
- std::unique_ptr<FunctionCaller> m_caller_up;
+ std::shared_ptr<IRExecutionUnit> m_execution_unit_sp;
+ lldb::ModuleWP m_jit_module_wp;
+ std::string m_function_text; ///< The text of the function. Must be a
+ ///well-formed translation unit.
+ std::string m_function_name; ///< The name of the function.
+ std::unique_ptr<FunctionCaller> m_caller_up;
};
} // namespace lldb_private
diff --git a/include/lldb/Host/Condition.h b/include/lldb/Host/Condition.h
deleted file mode 100644
index bd793c65e0f4..000000000000
--- a/include/lldb/Host/Condition.h
+++ /dev/null
@@ -1,123 +0,0 @@
-//===-- Condition.h ---------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_Condition_h_
-#define liblldb_Condition_h_
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/lldb-types.h"
-#include "lldb/Host/Mutex.h"
-
-namespace lldb_private {
-
-class TimeValue;
-
-//----------------------------------------------------------------------
-/// @class Condition Condition.h "lldb/Host/Condition.h"
-/// @brief A C++ wrapper class for pthread condition variables.
-///
-/// A class that wraps up a pthread condition (pthread_cond_t). The
-/// class will create a pthread condition when an instance is
-/// constructed, and destroy it when it is destructed. It also provides
-/// access to the standard pthread condition calls.
-//----------------------------------------------------------------------
-class Condition
-{
-public:
- //------------------------------------------------------------------
- /// Default constructor
- ///
- /// The default constructor will initialize a new pthread condition
- /// and maintain the condition in the object state.
- //------------------------------------------------------------------
- Condition ();
-
- //------------------------------------------------------------------
- /// Destructor
- ///
- /// Destroys the pthread condition that the object owns.
- //------------------------------------------------------------------
- ~Condition ();
-
- //------------------------------------------------------------------
- /// Unblock all threads waiting for a condition variable
- ///
- /// @return
- /// The return value from \c pthread_cond_broadcast()
- //------------------------------------------------------------------
- int
- Broadcast ();
-
- //------------------------------------------------------------------
- /// Unblocks one thread waiting for the condition variable
- ///
- /// @return
- /// The return value from \c pthread_cond_signal()
- //------------------------------------------------------------------
- int
- Signal ();
-
- //------------------------------------------------------------------
- /// Wait for the condition variable to be signaled.
- ///
- /// The Wait() function atomically blocks the current thread
- /// waiting on this object's condition variable, and unblocks
- /// \a mutex. The waiting thread unblocks only after another thread
- /// signals or broadcasts this object's condition variable.
- ///
- /// If \a abstime is non-nullptr, this function will return when the
- /// system time reaches the time specified in \a abstime if the
- /// condition variable doesn't get unblocked. If \a abstime is nullptr
- /// this function will wait for an infinite amount of time for the
- /// condition variable to be unblocked.
- ///
- /// The current thread re-acquires the lock on \a mutex following
- /// the wait.
- ///
- /// @param[in] mutex
- /// The mutex to use in the \c pthread_cond_timedwait() or
- /// \c pthread_cond_wait() calls.
- ///
- /// @param[in] abstime
- /// An absolute time at which to stop waiting if non-nullptr, else
- /// wait an infinite amount of time for the condition variable
- /// toget signaled.
- ///
- /// @param[out] timed_out
- /// If not nullptr, will be set to true if the wait timed out, and
- // false otherwise.
- ///
- /// @see Condition::Broadcast()
- /// @see Condition::Signal()
- //------------------------------------------------------------------
- int
- Wait(Mutex &mutex, const TimeValue *abstime = nullptr, bool *timed_out = nullptr);
-
-protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- lldb::condition_t m_condition; ///< The condition variable.
-
- //------------------------------------------------------------------
- /// Get accessor to the pthread condition object.
- ///
- /// @return
- /// A pointer to the condition variable owned by this object.
- //------------------------------------------------------------------
- lldb::condition_t *
- GetCondition ();
-};
-
-} // namespace lldb_private
-
-#endif // liblldb_Condition_h_
diff --git a/include/lldb/Host/Config.h b/include/lldb/Host/Config.h
index f70f4de0819d..16845ae9327b 100644
--- a/include/lldb/Host/Config.h
+++ b/include/lldb/Host/Config.h
@@ -14,7 +14,7 @@
#include "lldb/Host/macosx/Config.h"
-#elif defined(__ANDROID_NDK__)
+#elif defined(__ANDROID__)
#include "lldb/Host/android/Config.h"
@@ -22,7 +22,8 @@
#include "lldb/Host/linux/Config.h"
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
+ defined(__OpenBSD__)
#include "lldb/Host/freebsd/Config.h"
@@ -30,7 +31,7 @@
#include "lldb/Host/netbsd/Config.h"
-#elif defined(__MINGW__) || defined (__MINGW32__)
+#elif defined(__MINGW__) || defined(__MINGW32__)
#include "lldb/Host/mingw/Config.h"
diff --git a/include/lldb/Host/Debug.h b/include/lldb/Host/Debug.h
index 7954ee0b6b3f..fc190a4eca8f 100644
--- a/include/lldb/Host/Debug.h
+++ b/include/lldb/Host/Debug.h
@@ -20,191 +20,141 @@
namespace lldb_private {
- //------------------------------------------------------------------
- // Tells a thread what it needs to do when the process is resumed.
- //------------------------------------------------------------------
- struct ResumeAction
- {
- lldb::tid_t tid; // The thread ID that this action applies to, LLDB_INVALID_THREAD_ID for the default thread action
- lldb::StateType state; // Valid values are eStateStopped/eStateSuspended, eStateRunning, and eStateStepping.
- int signal; // When resuming this thread, resume it with this signal if this value is > 0
- };
-
- //------------------------------------------------------------------
- // A class that contains instructions for all threads for
- // NativeProcessProtocol::Resume(). Each thread can either run, stay
- // suspended, or step when the process is resumed. We optionally
- // have the ability to also send a signal to the thread when the
- // action is run or step.
- //------------------------------------------------------------------
- class ResumeActionList
- {
- public:
- ResumeActionList () :
- m_actions (),
- m_signal_handled ()
- {
- }
-
- ResumeActionList (lldb::StateType default_action, int signal) :
- m_actions(),
- m_signal_handled ()
- {
- SetDefaultThreadActionIfNeeded (default_action, signal);
- }
-
- ResumeActionList (const ResumeAction *actions, size_t num_actions) :
- m_actions (),
- m_signal_handled ()
- {
- if (actions && num_actions)
- {
- m_actions.assign (actions, actions + num_actions);
- m_signal_handled.assign (num_actions, false);
- }
- }
-
- ~ResumeActionList() = default;
-
- bool
- IsEmpty() const
- {
- return m_actions.empty();
- }
-
- void
- Append (const ResumeAction &action)
- {
- m_actions.push_back (action);
- m_signal_handled.push_back (false);
- }
-
- void
- AppendAction (lldb::tid_t tid,
- lldb::StateType state,
- int signal = 0)
- {
- ResumeAction action = { tid, state, signal };
- Append (action);
- }
-
- void
- AppendResumeAll ()
- {
- AppendAction (LLDB_INVALID_THREAD_ID, lldb::eStateRunning);
- }
-
- void
- AppendSuspendAll ()
- {
- AppendAction (LLDB_INVALID_THREAD_ID, lldb::eStateStopped);
- }
-
- void
- AppendStepAll ()
- {
- AppendAction (LLDB_INVALID_THREAD_ID, lldb::eStateStepping);
- }
-
- const ResumeAction *
- GetActionForThread (lldb::tid_t tid, bool default_ok) const
- {
- const size_t num_actions = m_actions.size();
- for (size_t i=0; i<num_actions; ++i)
- {
- if (m_actions[i].tid == tid)
- return &m_actions[i];
- }
- if (default_ok && tid != LLDB_INVALID_THREAD_ID)
- return GetActionForThread (LLDB_INVALID_THREAD_ID, false);
- return nullptr;
- }
-
- size_t
- NumActionsWithState (lldb::StateType state) const
- {
- size_t count = 0;
- const size_t num_actions = m_actions.size();
- for (size_t i=0; i<num_actions; ++i)
- {
- if (m_actions[i].state == state)
- ++count;
- }
- return count;
- }
-
- bool
- SetDefaultThreadActionIfNeeded (lldb::StateType action, int signal)
- {
- if (GetActionForThread (LLDB_INVALID_THREAD_ID, true) == nullptr)
- {
- // There isn't a default action so we do need to set it.
- ResumeAction default_action = {LLDB_INVALID_THREAD_ID, action, signal };
- m_actions.push_back (default_action);
- m_signal_handled.push_back (false);
- return true; // Return true as we did add the default action
- }
- return false;
- }
-
- void
- SetSignalHandledForThread (lldb::tid_t tid) const
- {
- if (tid != LLDB_INVALID_THREAD_ID)
- {
- const size_t num_actions = m_actions.size();
- for (size_t i=0; i<num_actions; ++i)
- {
- if (m_actions[i].tid == tid)
- m_signal_handled[i] = true;
- }
- }
- }
-
- const ResumeAction *
- GetFirst() const
- {
- return m_actions.data();
- }
-
- size_t
- GetSize () const
- {
- return m_actions.size();
- }
-
- void
- Clear()
- {
- m_actions.clear();
- m_signal_handled.clear();
- }
-
- protected:
- std::vector<ResumeAction> m_actions;
- mutable std::vector<bool> m_signal_handled;
- };
-
- struct ThreadStopInfo
- {
- lldb::StopReason reason;
- union
- {
- // eStopReasonSignal
- struct
- {
- uint32_t signo;
- } signal;
-
- // eStopReasonException
- struct
- {
- uint64_t type;
- uint32_t data_count;
- lldb::addr_t data[2];
- } exception;
- } details;
- };
+//------------------------------------------------------------------
+// Tells a thread what it needs to do when the process is resumed.
+//------------------------------------------------------------------
+struct ResumeAction {
+ lldb::tid_t tid; // The thread ID that this action applies to,
+ // LLDB_INVALID_THREAD_ID for the default thread action
+ lldb::StateType state; // Valid values are eStateStopped/eStateSuspended,
+ // eStateRunning, and eStateStepping.
+ int signal; // When resuming this thread, resume it with this signal if this
+ // value is > 0
+};
+
+//------------------------------------------------------------------
+// A class that contains instructions for all threads for
+// NativeProcessProtocol::Resume(). Each thread can either run, stay
+// suspended, or step when the process is resumed. We optionally
+// have the ability to also send a signal to the thread when the
+// action is run or step.
+//------------------------------------------------------------------
+class ResumeActionList {
+public:
+ ResumeActionList() : m_actions(), m_signal_handled() {}
+
+ ResumeActionList(lldb::StateType default_action, int signal)
+ : m_actions(), m_signal_handled() {
+ SetDefaultThreadActionIfNeeded(default_action, signal);
+ }
+
+ ResumeActionList(const ResumeAction *actions, size_t num_actions)
+ : m_actions(), m_signal_handled() {
+ if (actions && num_actions) {
+ m_actions.assign(actions, actions + num_actions);
+ m_signal_handled.assign(num_actions, false);
+ }
+ }
+
+ ~ResumeActionList() = default;
+
+ bool IsEmpty() const { return m_actions.empty(); }
+
+ void Append(const ResumeAction &action) {
+ m_actions.push_back(action);
+ m_signal_handled.push_back(false);
+ }
+
+ void AppendAction(lldb::tid_t tid, lldb::StateType state, int signal = 0) {
+ ResumeAction action = {tid, state, signal};
+ Append(action);
+ }
+
+ void AppendResumeAll() {
+ AppendAction(LLDB_INVALID_THREAD_ID, lldb::eStateRunning);
+ }
+
+ void AppendSuspendAll() {
+ AppendAction(LLDB_INVALID_THREAD_ID, lldb::eStateStopped);
+ }
+
+ void AppendStepAll() {
+ AppendAction(LLDB_INVALID_THREAD_ID, lldb::eStateStepping);
+ }
+
+ const ResumeAction *GetActionForThread(lldb::tid_t tid,
+ bool default_ok) const {
+ const size_t num_actions = m_actions.size();
+ for (size_t i = 0; i < num_actions; ++i) {
+ if (m_actions[i].tid == tid)
+ return &m_actions[i];
+ }
+ if (default_ok && tid != LLDB_INVALID_THREAD_ID)
+ return GetActionForThread(LLDB_INVALID_THREAD_ID, false);
+ return nullptr;
+ }
+
+ size_t NumActionsWithState(lldb::StateType state) const {
+ size_t count = 0;
+ const size_t num_actions = m_actions.size();
+ for (size_t i = 0; i < num_actions; ++i) {
+ if (m_actions[i].state == state)
+ ++count;
+ }
+ return count;
+ }
+
+ bool SetDefaultThreadActionIfNeeded(lldb::StateType action, int signal) {
+ if (GetActionForThread(LLDB_INVALID_THREAD_ID, true) == nullptr) {
+ // There isn't a default action so we do need to set it.
+ ResumeAction default_action = {LLDB_INVALID_THREAD_ID, action, signal};
+ m_actions.push_back(default_action);
+ m_signal_handled.push_back(false);
+ return true; // Return true as we did add the default action
+ }
+ return false;
+ }
+
+ void SetSignalHandledForThread(lldb::tid_t tid) const {
+ if (tid != LLDB_INVALID_THREAD_ID) {
+ const size_t num_actions = m_actions.size();
+ for (size_t i = 0; i < num_actions; ++i) {
+ if (m_actions[i].tid == tid)
+ m_signal_handled[i] = true;
+ }
+ }
+ }
+
+ const ResumeAction *GetFirst() const { return m_actions.data(); }
+
+ size_t GetSize() const { return m_actions.size(); }
+
+ void Clear() {
+ m_actions.clear();
+ m_signal_handled.clear();
+ }
+
+protected:
+ std::vector<ResumeAction> m_actions;
+ mutable std::vector<bool> m_signal_handled;
+};
+
+struct ThreadStopInfo {
+ lldb::StopReason reason;
+ union {
+ // eStopReasonSignal
+ struct {
+ uint32_t signo;
+ } signal;
+
+ // eStopReasonException
+ struct {
+ uint64_t type;
+ uint32_t data_count;
+ lldb::addr_t data[8];
+ } exception;
+ } details;
+};
}
#endif // liblldb_Debug_h_
diff --git a/include/lldb/Host/Editline.h b/include/lldb/Host/Editline.h
index 43c0eccf37dd..f92cbba7f2a0 100644
--- a/include/lldb/Host/Editline.h
+++ b/include/lldb/Host/Editline.h
@@ -7,373 +7,359 @@
//
//===----------------------------------------------------------------------===//
-//TODO: wire up window size changes
+// TODO: wire up window size changes
-// If we ever get a private copy of libedit, there are a number of defects that would be nice to fix;
-// a) Sometimes text just disappears while editing. In an 80-column editor paste the following text, without
+// If we ever get a private copy of libedit, there are a number of defects that
+// would be nice to fix;
+// a) Sometimes text just disappears while editing. In an 80-column editor
+// paste the following text, without
// the quotes:
-// "This is a test of the input system missing Hello, World! Do you disappear when it gets to a particular length?"
-// Now press ^A to move to the start and type 3 characters, and you'll see a good amount of the text will
+// "This is a test of the input system missing Hello, World! Do you
+// disappear when it gets to a particular length?"
+// Now press ^A to move to the start and type 3 characters, and you'll see a
+// good amount of the text will
// disappear. It's still in the buffer, just invisible.
-// b) The prompt printing logic for dealing with ANSI formatting characters is broken, which is why we're
+// b) The prompt printing logic for dealing with ANSI formatting characters is
+// broken, which is why we're
// working around it here.
-// c) When resizing the terminal window, if the cursor moves between rows libedit will get confused.
-// d) The incremental search uses escape to cancel input, so it's confused by ANSI sequences starting with escape.
-// e) Emoji support is fairly terrible, presumably it doesn't understand composed characters?
+// c) When resizing the terminal window, if the cursor moves between rows
+// libedit will get confused.
+// d) The incremental search uses escape to cancel input, so it's confused by
+// ANSI sequences starting with escape.
+// e) Emoji support is fairly terrible, presumably it doesn't understand
+// composed characters?
#ifndef liblldb_Editline_h_
#define liblldb_Editline_h_
#if defined(__cplusplus)
+#include <locale>
#include <sstream>
#include <vector>
-#include <locale>
-// components needed to handle wide characters ( <codecvt>, codecvt_utf8, libedit built with '--enable-widec' )
-// are available on some platforms. The wchar_t versions of libedit functions will only be
-// used in cases where this is true. This is a compile time dependecy, for now selected per target Platform
-#if defined (__APPLE__) || defined(__NetBSD__)
+// components needed to handle wide characters ( <codecvt>, codecvt_utf8,
+// libedit built with '--enable-widec' )
+// are available on some platforms. The wchar_t versions of libedit functions
+// will only be
+// used in cases where this is true. This is a compile time dependecy, for now
+// selected per target Platform
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
#define LLDB_EDITLINE_USE_WCHAR 1
#include <codecvt>
#else
#define LLDB_EDITLINE_USE_WCHAR 0
#endif
-#include "lldb/lldb-private.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
+#include "lldb/lldb-private.h"
#if defined(_WIN32)
#include "lldb/Host/windows/editlinewin.h"
-#else
-#if !defined(__ANDROID_NDK__)
+#elif !defined(__ANDROID__)
#include <histedit.h>
#endif
-#endif
#include <mutex>
#include <string>
#include <vector>
-#include "lldb/Host/Condition.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Predicate.h"
namespace lldb_private {
- namespace line_editor {
+namespace line_editor {
- // type alias's to help manage 8 bit and wide character versions of libedit
+// type alias's to help manage 8 bit and wide character versions of libedit
#if LLDB_EDITLINE_USE_WCHAR
- using EditLineStringType = std::wstring;
- using EditLineStringStreamType = std::wstringstream;
- using EditLineCharType = wchar_t;
+using EditLineStringType = std::wstring;
+using EditLineStringStreamType = std::wstringstream;
+using EditLineCharType = wchar_t;
#else
- using EditLineStringType=std::string;
- using EditLineStringStreamType = std::stringstream;
- using EditLineCharType = char;
+using EditLineStringType = std::string;
+using EditLineStringStreamType = std::stringstream;
+using EditLineCharType = char;
#endif
- typedef int (* EditlineGetCharCallbackType)(::EditLine * editline, EditLineCharType * c);
- typedef unsigned char (* EditlineCommandCallbackType)(::EditLine * editline, int ch);
- typedef const char * (* EditlinePromptCallbackType)(::EditLine * editline);
-
- class EditlineHistory;
-
- typedef std::shared_ptr<EditlineHistory> EditlineHistorySP;
-
- typedef bool (* IsInputCompleteCallbackType) (
- Editline * editline,
- StringList & lines,
- void * baton);
-
- typedef int (* FixIndentationCallbackType) (
- Editline * editline,
- const StringList & lines,
- int cursor_position,
- void * baton);
-
- typedef int (* CompleteCallbackType) (
- const char * current_line,
- const char * cursor,
- const char * last_char,
- int skip_first_n_matches,
- int max_matches,
- StringList & matches,
- void * baton);
-
- /// Status used to decide when and how to start editing another line in multi-line sessions
- enum class EditorStatus
- {
-
- /// The default state proceeds to edit the current line
- Editing,
-
- /// Editing complete, returns the complete set of edited lines
- Complete,
-
- /// End of input reported
- EndOfInput,
-
- /// Editing interrupted
- Interrupted
- };
-
- /// Established locations that can be easily moved among with MoveCursor
- enum class CursorLocation
- {
- /// The start of the first line in a multi-line edit session
- BlockStart,
-
- /// The start of the current line in a multi-line edit session
- EditingPrompt,
-
- /// The location of the cursor on the current line in a multi-line edit session
- EditingCursor,
-
- /// The location immediately after the last character in a multi-line edit session
- BlockEnd
- };
- }
-
- using namespace line_editor;
-
- /// Instances of Editline provide an abstraction over libedit's EditLine facility. Both
- /// single- and multi-line editing are supported.
- class Editline
- {
- public:
- Editline (const char * editor_name, FILE * input_file, FILE * output_file, FILE * error_file, bool color_prompts);
-
- ~Editline();
-
- /// Uses the user data storage of EditLine to retrieve an associated instance of Editline.
- static Editline *
- InstanceFor (::EditLine * editline);
-
- /// Sets a string to be used as a prompt, or combined with a line number to form a prompt.
- void
- SetPrompt (const char * prompt);
-
- /// Sets an alternate string to be used as a prompt for the second line and beyond in multi-line
- /// editing scenarios.
- void
- SetContinuationPrompt (const char * continuation_prompt);
-
- /// Required to update the width of the terminal registered for I/O. It is critical that this
- /// be correct at all times.
- void
- TerminalSizeChanged();
-
- /// Returns the prompt established by SetPrompt()
- const char *
- GetPrompt();
-
- /// Returns the index of the line currently being edited
- uint32_t
- GetCurrentLine();
-
- /// Interrupt the current edit as if ^C was pressed
- bool
- Interrupt();
-
- /// Cancel this edit and oblitarate all trace of it
- bool
- Cancel();
-
- /// Register a callback for the tab key
- void
- SetAutoCompleteCallback (CompleteCallbackType callback, void * baton);
-
- /// Register a callback for testing whether multi-line input is complete
- void
- SetIsInputCompleteCallback (IsInputCompleteCallbackType callback, void * baton);
-
- /// Register a callback for determining the appropriate indentation for a line
- /// when creating a newline. An optional set of insertable characters can also
- /// trigger the callback.
- bool
- SetFixIndentationCallback (FixIndentationCallbackType callback,
- void * baton,
- const char * indent_chars);
-
- /// Prompts for and reads a single line of user input.
- bool
- GetLine (std::string &line, bool &interrupted);
-
- /// Prompts for and reads a multi-line batch of user input.
- bool
- GetLines (int first_line_number, StringList &lines, bool &interrupted);
-
- void
- PrintAsync (Stream *stream, const char *s, size_t len);
-
- private:
-
- /// Sets the lowest line number for multi-line editing sessions. A value of zero suppresses
- /// line number printing in the prompt.
- void
- SetBaseLineNumber (int line_number);
-
- /// Returns the complete prompt by combining the prompt or continuation prompt with line numbers
- /// as appropriate. The line index is a zero-based index into the current multi-line session.
- std::string
- PromptForIndex (int line_index);
-
- /// Sets the current line index between line edits to allow free movement between lines. Updates
- /// the prompt to match.
- void
- SetCurrentLine (int line_index);
-
- /// Determines the width of the prompt in characters. The width is guaranteed to be the same for
- /// all lines of the current multi-line session.
- int
- GetPromptWidth();
-
- /// Returns true if the underlying EditLine session's keybindings are Emacs-based, or false if
- /// they are VI-based.
- bool
- IsEmacs();
-
- /// Returns true if the current EditLine buffer contains nothing but spaces, or is empty.
- bool
- IsOnlySpaces();
-
- /// Helper method used by MoveCursor to determine relative line position.
- int
- GetLineIndexForLocation (CursorLocation location, int cursor_row);
-
- /// Move the cursor from one well-established location to another using relative line positioning
- /// and absolute column positioning.
- void
- MoveCursor (CursorLocation from, CursorLocation to);
-
- /// Clear from cursor position to bottom of screen and print input lines including prompts, optionally
- /// starting from a specific line. Lines are drawn with an extra space at the end to reserve room for
- /// the rightmost cursor position.
- void
- DisplayInput (int firstIndex = 0);
-
- /// Counts the number of rows a given line of content will end up occupying, taking into account both
- /// the preceding prompt and a single trailing space occupied by a cursor when at the end of the line.
- int
- CountRowsForLine (const EditLineStringType & content);
-
- /// Save the line currently being edited
- void
- SaveEditedLine();
-
- /// Convert the current input lines into a UTF8 StringList
- StringList
- GetInputAsStringList(int line_count = UINT32_MAX);
-
- /// Replaces the current multi-line session with the next entry from history. When the parameter is
- /// true it will take the next earlier entry from history, when it is false it takes the next most
- /// recent.
- unsigned char
- RecallHistory (bool earlier);
-
- /// Character reading implementation for EditLine that supports our multi-line editing trickery.
- int
- GetCharacter (EditLineCharType * c);
-
- /// Prompt implementation for EditLine.
- const char *
- Prompt();
-
- /// Line break command used when meta+return is pressed in multi-line mode.
- unsigned char
- BreakLineCommand (int ch);
-
- /// Command used when return is pressed in multi-line mode.
- unsigned char
- EndOrAddLineCommand(int ch);
-
- /// Delete command used when delete is pressed in multi-line mode.
- unsigned char
- DeleteNextCharCommand (int ch);
-
- /// Delete command used when backspace is pressed in multi-line mode.
- unsigned char
- DeletePreviousCharCommand (int ch);
-
- /// Line navigation command used when ^P or up arrow are pressed in multi-line mode.
- unsigned char
- PreviousLineCommand (int ch);
-
- /// Line navigation command used when ^N or down arrow are pressed in multi-line mode.
- unsigned char
- NextLineCommand (int ch);
-
- /// History navigation command used when Alt + up arrow is pressed in multi-line mode.
- unsigned char
- PreviousHistoryCommand(int ch);
-
- /// History navigation command used when Alt + down arrow is pressed in multi-line mode.
- unsigned char
- NextHistoryCommand(int ch);
-
- /// Buffer start command used when Esc < is typed in multi-line emacs mode.
- unsigned char
- BufferStartCommand (int ch);
-
- /// Buffer end command used when Esc > is typed in multi-line emacs mode.
- unsigned char
- BufferEndCommand (int ch);
-
- /// Context-sensitive tab insertion or code completion command used when the tab key is typed.
- unsigned char
- TabCommand (int ch);
-
- /// Respond to normal character insertion by fixing line indentation
- unsigned char
- FixIndentationCommand (int ch);
-
- /// Revert line command used when moving between lines.
- unsigned char
- RevertLineCommand (int ch);
-
- /// Ensures that the current EditLine instance is properly configured for single or multi-line editing.
- void
- ConfigureEditor (bool multiline);
-
- private:
+typedef int (*EditlineGetCharCallbackType)(::EditLine *editline,
+ EditLineCharType *c);
+typedef unsigned char (*EditlineCommandCallbackType)(::EditLine *editline,
+ int ch);
+typedef const char *(*EditlinePromptCallbackType)(::EditLine *editline);
+
+class EditlineHistory;
+
+typedef std::shared_ptr<EditlineHistory> EditlineHistorySP;
+
+typedef bool (*IsInputCompleteCallbackType)(Editline *editline,
+ StringList &lines, void *baton);
+
+typedef int (*FixIndentationCallbackType)(Editline *editline,
+ const StringList &lines,
+ int cursor_position, void *baton);
+
+typedef int (*CompleteCallbackType)(const char *current_line,
+ const char *cursor, const char *last_char,
+ int skip_first_n_matches, int max_matches,
+ StringList &matches, void *baton);
+
+/// Status used to decide when and how to start editing another line in
+/// multi-line sessions
+enum class EditorStatus {
+
+ /// The default state proceeds to edit the current line
+ Editing,
+
+ /// Editing complete, returns the complete set of edited lines
+ Complete,
+
+ /// End of input reported
+ EndOfInput,
+
+ /// Editing interrupted
+ Interrupted
+};
+
+/// Established locations that can be easily moved among with MoveCursor
+enum class CursorLocation {
+ /// The start of the first line in a multi-line edit session
+ BlockStart,
+
+ /// The start of the current line in a multi-line edit session
+ EditingPrompt,
+
+ /// The location of the cursor on the current line in a multi-line edit
+ /// session
+ EditingCursor,
+
+ /// The location immediately after the last character in a multi-line edit
+ /// session
+ BlockEnd
+};
+}
+
+using namespace line_editor;
+
+/// Instances of Editline provide an abstraction over libedit's EditLine
+/// facility. Both
+/// single- and multi-line editing are supported.
+class Editline {
+public:
+ Editline(const char *editor_name, FILE *input_file, FILE *output_file,
+ FILE *error_file, bool color_prompts);
+
+ ~Editline();
+
+ /// Uses the user data storage of EditLine to retrieve an associated instance
+ /// of Editline.
+ static Editline *InstanceFor(::EditLine *editline);
+
+ /// Sets a string to be used as a prompt, or combined with a line number to
+ /// form a prompt.
+ void SetPrompt(const char *prompt);
+
+ /// Sets an alternate string to be used as a prompt for the second line and
+ /// beyond in multi-line
+ /// editing scenarios.
+ void SetContinuationPrompt(const char *continuation_prompt);
+
+ /// Required to update the width of the terminal registered for I/O. It is
+ /// critical that this
+ /// be correct at all times.
+ void TerminalSizeChanged();
+
+ /// Returns the prompt established by SetPrompt()
+ const char *GetPrompt();
+
+ /// Returns the index of the line currently being edited
+ uint32_t GetCurrentLine();
+
+ /// Interrupt the current edit as if ^C was pressed
+ bool Interrupt();
+
+ /// Cancel this edit and oblitarate all trace of it
+ bool Cancel();
+
+ /// Register a callback for the tab key
+ void SetAutoCompleteCallback(CompleteCallbackType callback, void *baton);
+
+ /// Register a callback for testing whether multi-line input is complete
+ void SetIsInputCompleteCallback(IsInputCompleteCallbackType callback,
+ void *baton);
+
+ /// Register a callback for determining the appropriate indentation for a line
+ /// when creating a newline. An optional set of insertable characters can
+ /// also
+ /// trigger the callback.
+ bool SetFixIndentationCallback(FixIndentationCallbackType callback,
+ void *baton, const char *indent_chars);
+
+ /// Prompts for and reads a single line of user input.
+ bool GetLine(std::string &line, bool &interrupted);
+
+ /// Prompts for and reads a multi-line batch of user input.
+ bool GetLines(int first_line_number, StringList &lines, bool &interrupted);
+
+ void PrintAsync(Stream *stream, const char *s, size_t len);
+
+private:
+ /// Sets the lowest line number for multi-line editing sessions. A value of
+ /// zero suppresses
+ /// line number printing in the prompt.
+ void SetBaseLineNumber(int line_number);
+
+ /// Returns the complete prompt by combining the prompt or continuation prompt
+ /// with line numbers
+ /// as appropriate. The line index is a zero-based index into the current
+ /// multi-line session.
+ std::string PromptForIndex(int line_index);
+
+ /// Sets the current line index between line edits to allow free movement
+ /// between lines. Updates
+ /// the prompt to match.
+ void SetCurrentLine(int line_index);
+
+ /// Determines the width of the prompt in characters. The width is guaranteed
+ /// to be the same for
+ /// all lines of the current multi-line session.
+ int GetPromptWidth();
+
+ /// Returns true if the underlying EditLine session's keybindings are
+ /// Emacs-based, or false if
+ /// they are VI-based.
+ bool IsEmacs();
+
+ /// Returns true if the current EditLine buffer contains nothing but spaces,
+ /// or is empty.
+ bool IsOnlySpaces();
+
+ /// Helper method used by MoveCursor to determine relative line position.
+ int GetLineIndexForLocation(CursorLocation location, int cursor_row);
+
+ /// Move the cursor from one well-established location to another using
+ /// relative line positioning
+ /// and absolute column positioning.
+ void MoveCursor(CursorLocation from, CursorLocation to);
+
+ /// Clear from cursor position to bottom of screen and print input lines
+ /// including prompts, optionally
+ /// starting from a specific line. Lines are drawn with an extra space at the
+ /// end to reserve room for
+ /// the rightmost cursor position.
+ void DisplayInput(int firstIndex = 0);
+
+ /// Counts the number of rows a given line of content will end up occupying,
+ /// taking into account both
+ /// the preceding prompt and a single trailing space occupied by a cursor when
+ /// at the end of the line.
+ int CountRowsForLine(const EditLineStringType &content);
+
+ /// Save the line currently being edited
+ void SaveEditedLine();
+
+ /// Convert the current input lines into a UTF8 StringList
+ StringList GetInputAsStringList(int line_count = UINT32_MAX);
+
+ /// Replaces the current multi-line session with the next entry from history.
+ /// When the parameter is
+ /// true it will take the next earlier entry from history, when it is false it
+ /// takes the next most
+ /// recent.
+ unsigned char RecallHistory(bool earlier);
+
+ /// Character reading implementation for EditLine that supports our multi-line
+ /// editing trickery.
+ int GetCharacter(EditLineCharType *c);
+
+ /// Prompt implementation for EditLine.
+ const char *Prompt();
+
+ /// Line break command used when meta+return is pressed in multi-line mode.
+ unsigned char BreakLineCommand(int ch);
+
+ /// Command used when return is pressed in multi-line mode.
+ unsigned char EndOrAddLineCommand(int ch);
+
+ /// Delete command used when delete is pressed in multi-line mode.
+ unsigned char DeleteNextCharCommand(int ch);
+
+ /// Delete command used when backspace is pressed in multi-line mode.
+ unsigned char DeletePreviousCharCommand(int ch);
+
+ /// Line navigation command used when ^P or up arrow are pressed in multi-line
+ /// mode.
+ unsigned char PreviousLineCommand(int ch);
+
+ /// Line navigation command used when ^N or down arrow are pressed in
+ /// multi-line mode.
+ unsigned char NextLineCommand(int ch);
+
+ /// History navigation command used when Alt + up arrow is pressed in
+ /// multi-line mode.
+ unsigned char PreviousHistoryCommand(int ch);
+
+ /// History navigation command used when Alt + down arrow is pressed in
+ /// multi-line mode.
+ unsigned char NextHistoryCommand(int ch);
+
+ /// Buffer start command used when Esc < is typed in multi-line emacs mode.
+ unsigned char BufferStartCommand(int ch);
+
+ /// Buffer end command used when Esc > is typed in multi-line emacs mode.
+ unsigned char BufferEndCommand(int ch);
+
+ /// Context-sensitive tab insertion or code completion command used when the
+ /// tab key is typed.
+ unsigned char TabCommand(int ch);
+
+ /// Respond to normal character insertion by fixing line indentation
+ unsigned char FixIndentationCommand(int ch);
+
+ /// Revert line command used when moving between lines.
+ unsigned char RevertLineCommand(int ch);
+
+ /// Ensures that the current EditLine instance is properly configured for
+ /// single or multi-line editing.
+ void ConfigureEditor(bool multiline);
+
+private:
#if LLDB_EDITLINE_USE_WCHAR
- std::wstring_convert<std::codecvt_utf8<wchar_t>> m_utf8conv;
+ std::wstring_convert<std::codecvt_utf8<wchar_t>> m_utf8conv;
#endif
- ::EditLine * m_editline = nullptr;
- EditlineHistorySP m_history_sp;
- bool m_in_history = false;
- std::vector<EditLineStringType> m_live_history_lines;
- bool m_multiline_enabled = false;
- std::vector<EditLineStringType> m_input_lines;
- EditorStatus m_editor_status;
- bool m_color_prompts = true;
- int m_terminal_width = 0;
- int m_base_line_number = 0;
- unsigned m_current_line_index = 0;
- int m_current_line_rows = -1;
- int m_revert_cursor_index = 0;
- int m_line_number_digits = 3;
- std::string m_set_prompt;
- std::string m_set_continuation_prompt;
- std::string m_current_prompt;
- bool m_needs_prompt_repaint = false;
- std::string m_editor_name;
- FILE * m_input_file;
- FILE * m_output_file;
- FILE * m_error_file;
- ConnectionFileDescriptor m_input_connection;
- IsInputCompleteCallbackType m_is_input_complete_callback = nullptr;
- void * m_is_input_complete_callback_baton = nullptr;
- FixIndentationCallbackType m_fix_indentation_callback = nullptr;
- void * m_fix_indentation_callback_baton = nullptr;
- const char * m_fix_indentation_callback_chars = nullptr;
- CompleteCallbackType m_completion_callback = nullptr;
- void * m_completion_callback_baton = nullptr;
-
- std::mutex m_output_mutex;
- };
+ ::EditLine *m_editline = nullptr;
+ EditlineHistorySP m_history_sp;
+ bool m_in_history = false;
+ std::vector<EditLineStringType> m_live_history_lines;
+ bool m_multiline_enabled = false;
+ std::vector<EditLineStringType> m_input_lines;
+ EditorStatus m_editor_status;
+ bool m_color_prompts = true;
+ int m_terminal_width = 0;
+ int m_base_line_number = 0;
+ unsigned m_current_line_index = 0;
+ int m_current_line_rows = -1;
+ int m_revert_cursor_index = 0;
+ int m_line_number_digits = 3;
+ std::string m_set_prompt;
+ std::string m_set_continuation_prompt;
+ std::string m_current_prompt;
+ bool m_needs_prompt_repaint = false;
+ std::string m_editor_name;
+ FILE *m_input_file;
+ FILE *m_output_file;
+ FILE *m_error_file;
+ ConnectionFileDescriptor m_input_connection;
+ IsInputCompleteCallbackType m_is_input_complete_callback = nullptr;
+ void *m_is_input_complete_callback_baton = nullptr;
+ FixIndentationCallbackType m_fix_indentation_callback = nullptr;
+ void *m_fix_indentation_callback_baton = nullptr;
+ const char *m_fix_indentation_callback_chars = nullptr;
+ CompleteCallbackType m_completion_callback = nullptr;
+ void *m_completion_callback_baton = nullptr;
+
+ std::mutex m_output_mutex;
+};
}
-#endif // #if defined(__cplusplus)
-#endif // liblldb_Editline_h_
+#endif // #if defined(__cplusplus)
+#endif // liblldb_Editline_h_
diff --git a/include/lldb/Host/Endian.h b/include/lldb/Host/Endian.h
index df0796b7baf1..82bc0b7749b1 100644
--- a/include/lldb/Host/Endian.h
+++ b/include/lldb/Host/Endian.h
@@ -16,18 +16,17 @@ namespace lldb_private {
namespace endian {
- static union EndianTest
- {
- uint32_t num;
- uint8_t bytes[sizeof(uint32_t)];
- } const endianTest = { 0x01020304 };
-
- inline lldb::ByteOrder InlHostByteOrder() { return (lldb::ByteOrder)endianTest.bytes[0]; }
+static union EndianTest {
+ uint32_t num;
+ uint8_t bytes[sizeof(uint32_t)];
+} const endianTest = {0x01020304};
-// ByteOrder const InlHostByteOrder = (ByteOrder)endianTest.bytes[0];
+inline lldb::ByteOrder InlHostByteOrder() {
+ return (lldb::ByteOrder)endianTest.bytes[0];
}
+// ByteOrder const InlHostByteOrder = (ByteOrder)endianTest.bytes[0];
+}
}
-#endif // liblldb_host_endian_h_
-
+#endif // liblldb_host_endian_h_
diff --git a/include/lldb/Host/File.h b/include/lldb/Host/File.h
index e2c44fa5c0d2..6fa4e568218f 100644
--- a/include/lldb/Host/File.h
+++ b/include/lldb/Host/File.h
@@ -18,8 +18,9 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Host/IOObject.h"
+#include "lldb/Host/PosixApi.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -30,528 +31,460 @@ namespace lldb_private {
/// A file class that divides abstracts the LLDB core from host file
/// functionality.
//----------------------------------------------------------------------
-class File : public IOObject
-{
+class File : public IOObject {
public:
- static int kInvalidDescriptor;
- static FILE * kInvalidStream;
-
- enum OpenOptions
- {
- eOpenOptionRead = (1u << 0), // Open file for reading
- eOpenOptionWrite = (1u << 1), // Open file for writing
- eOpenOptionAppend = (1u << 2), // Don't truncate file when opening, append to end of file
- eOpenOptionTruncate = (1u << 3), // Truncate file when opening
- eOpenOptionNonBlocking = (1u << 4), // File reads
- eOpenOptionCanCreate = (1u << 5), // Create file if doesn't already exist
- eOpenOptionCanCreateNewOnly = (1u << 6), // Can create file only if it doesn't already exist
- eOpenOptionDontFollowSymlinks = (1u << 7),
- eOpenOptionCloseOnExec = (1u << 8) // Close the file when executing a new process
- };
-
- static mode_t
- ConvertOpenOptionsForPOSIXOpen (uint32_t open_options);
-
- File() :
- IOObject(eFDTypeFile, false),
- m_descriptor (kInvalidDescriptor),
- m_stream (kInvalidStream),
- m_options (0),
- m_own_stream (false),
- m_is_interactive (eLazyBoolCalculate),
- m_is_real_terminal (eLazyBoolCalculate)
- {
- }
-
- File (FILE *fh, bool transfer_ownership) :
- IOObject(eFDTypeFile, false),
- m_descriptor (kInvalidDescriptor),
- m_stream (fh),
- m_options (0),
- m_own_stream (transfer_ownership),
- m_is_interactive (eLazyBoolCalculate),
- m_is_real_terminal (eLazyBoolCalculate)
- {
- }
-
- //------------------------------------------------------------------
- /// Constructor with path.
- ///
- /// Takes a path to a file which can be just a filename, or a full
- /// path. If \a path is not nullptr or empty, this function will call
- /// File::Open (const char *path, uint32_t options, uint32_t permissions).
- ///
- /// @param[in] path
- /// The full or partial path to a file.
- ///
- /// @param[in] options
- /// Options to use when opening (see File::OpenOptions)
- ///
- /// @param[in] permissions
- /// Options to use when opening (see File::Permissions)
- ///
- /// @see File::Open (const char *path, uint32_t options, uint32_t permissions)
- //------------------------------------------------------------------
- File (const char *path,
- uint32_t options,
- uint32_t permissions = lldb::eFilePermissionsFileDefault);
-
- //------------------------------------------------------------------
- /// Constructor with FileSpec.
- ///
- /// Takes a FileSpec pointing to a file which can be just a filename, or a full
- /// path. If \a path is not nullptr or empty, this function will call
- /// File::Open (const char *path, uint32_t options, uint32_t permissions).
- ///
- /// @param[in] filespec
- /// The FileSpec for this file.
- ///
- /// @param[in] options
- /// Options to use when opening (see File::OpenOptions)
- ///
- /// @param[in] permissions
- /// Options to use when opening (see File::Permissions)
- ///
- /// @see File::Open (const char *path, uint32_t options, uint32_t permissions)
- //------------------------------------------------------------------
- File (const FileSpec& filespec,
- uint32_t options,
- uint32_t permissions = lldb::eFilePermissionsFileDefault);
-
- File (int fd, bool transfer_ownership) :
- IOObject(eFDTypeFile, transfer_ownership),
- m_descriptor (fd),
- m_stream (kInvalidStream),
- m_options (0),
- m_own_stream (false),
- m_is_interactive (eLazyBoolCalculate),
- m_is_real_terminal (eLazyBoolCalculate)
- {
- }
-
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// The destructor is virtual in case this class is subclassed.
- //------------------------------------------------------------------
- ~File() override;
-
- bool
- IsValid() const override
- {
- return DescriptorIsValid() || StreamIsValid();
- }
-
- //------------------------------------------------------------------
- /// Convert to pointer operator.
- ///
- /// This allows code to check a File object to see if it
- /// contains anything valid using code such as:
- ///
- /// @code
- /// File file(...);
- /// if (file)
- /// { ...
- /// @endcode
- ///
- /// @return
- /// A pointer to this object if either the directory or filename
- /// is valid, nullptr otherwise.
- //------------------------------------------------------------------
- operator
- bool () const
- {
- return DescriptorIsValid() || StreamIsValid();
- }
-
- //------------------------------------------------------------------
- /// Logical NOT operator.
- ///
- /// This allows code to check a File object to see if it is
- /// invalid using code such as:
- ///
- /// @code
- /// File file(...);
- /// if (!file)
- /// { ...
- /// @endcode
- ///
- /// @return
- /// Returns \b true if the object has an empty directory and
- /// filename, \b false otherwise.
- //------------------------------------------------------------------
- bool
- operator! () const
- {
- return !DescriptorIsValid() && !StreamIsValid();
- }
-
- //------------------------------------------------------------------
- /// Get the file spec for this file.
- ///
- /// @return
- /// A reference to the file specification object.
- //------------------------------------------------------------------
- Error
- GetFileSpec (FileSpec &file_spec) const;
-
- //------------------------------------------------------------------
- /// Open a file for read/writing with the specified options.
- ///
- /// Takes a path to a file which can be just a filename, or a full
- /// path.
- ///
- /// @param[in] path
- /// The full or partial path to a file.
- ///
- /// @param[in] options
- /// Options to use when opening (see File::OpenOptions)
- ///
- /// @param[in] permissions
- /// Options to use when opening (see File::Permissions)
- //------------------------------------------------------------------
- Error
- Open (const char *path,
- uint32_t options,
- uint32_t permissions = lldb::eFilePermissionsFileDefault);
-
- Error
- Close() override;
-
- void
- Clear ();
-
- int
- GetDescriptor() const;
-
- WaitableHandle
- GetWaitableHandle() override;
-
- void
- SetDescriptor(int fd, bool transfer_ownership);
-
- FILE *
- GetStream ();
-
- void
- SetStream (FILE *fh, bool transfer_ownership);
-
- //------------------------------------------------------------------
- /// Read bytes from a file from the current file position.
- ///
- /// NOTE: This function is NOT thread safe. Use the read function
- /// that takes an "off_t &offset" to ensure correct operation in
- /// multi-threaded environments.
- ///
- /// @param[in] buf
- /// A buffer where to put the bytes that are read.
- ///
- /// @param[in,out] num_bytes
- /// The number of bytes to read form the current file position
- /// which gets modified with the number of bytes that were read.
- ///
- /// @return
- /// An error object that indicates success or the reason for
- /// failure.
- //------------------------------------------------------------------
- Error
- Read(void *buf, size_t &num_bytes) override;
-
- //------------------------------------------------------------------
- /// Write bytes to a file at the current file position.
- ///
- /// NOTE: This function is NOT thread safe. Use the write function
- /// that takes an "off_t &offset" to ensure correct operation in
- /// multi-threaded environments.
- ///
- /// @param[in] buf
- /// A buffer where to put the bytes that are read.
- ///
- /// @param[in,out] num_bytes
- /// The number of bytes to write to the current file position
- /// which gets modified with the number of bytes that were
- /// written.
- ///
- /// @return
- /// An error object that indicates success or the reason for
- /// failure.
- //------------------------------------------------------------------
- Error
- Write(const void *buf, size_t &num_bytes) override;
-
- //------------------------------------------------------------------
- /// Seek to an offset relative to the beginning of the file.
- ///
- /// NOTE: This function is NOT thread safe, other threads that
- /// access this object might also change the current file position.
- /// For thread safe reads and writes see the following functions:
- /// @see File::Read (void *, size_t, off_t &)
- /// @see File::Write (const void *, size_t, off_t &)
- ///
- /// @param[in] offset
- /// The offset to seek to within the file relative to the
- /// beginning of the file.
- ///
- /// @param[in] error_ptr
- /// A pointer to a lldb_private::Error object that will be
- /// filled in if non-nullptr.
- ///
- /// @return
- /// The resulting seek offset, or -1 on error.
- //------------------------------------------------------------------
- off_t
- SeekFromStart(off_t offset, Error *error_ptr = nullptr);
-
- //------------------------------------------------------------------
- /// Seek to an offset relative to the current file position.
- ///
- /// NOTE: This function is NOT thread safe, other threads that
- /// access this object might also change the current file position.
- /// For thread safe reads and writes see the following functions:
- /// @see File::Read (void *, size_t, off_t &)
- /// @see File::Write (const void *, size_t, off_t &)
- ///
- /// @param[in] offset
- /// The offset to seek to within the file relative to the
- /// current file position.
- ///
- /// @param[in] error_ptr
- /// A pointer to a lldb_private::Error object that will be
- /// filled in if non-nullptr.
- ///
- /// @return
- /// The resulting seek offset, or -1 on error.
- //------------------------------------------------------------------
- off_t
- SeekFromCurrent(off_t offset, Error *error_ptr = nullptr);
-
- //------------------------------------------------------------------
- /// Seek to an offset relative to the end of the file.
- ///
- /// NOTE: This function is NOT thread safe, other threads that
- /// access this object might also change the current file position.
- /// For thread safe reads and writes see the following functions:
- /// @see File::Read (void *, size_t, off_t &)
- /// @see File::Write (const void *, size_t, off_t &)
- ///
- /// @param[in,out] offset
- /// The offset to seek to within the file relative to the
- /// end of the file which gets filled in with the resulting
- /// absolute file offset.
- ///
- /// @param[in] error_ptr
- /// A pointer to a lldb_private::Error object that will be
- /// filled in if non-nullptr.
- ///
- /// @return
- /// The resulting seek offset, or -1 on error.
- //------------------------------------------------------------------
- off_t
- SeekFromEnd(off_t offset, Error *error_ptr = nullptr);
-
- //------------------------------------------------------------------
- /// Read bytes from a file from the specified file offset.
- ///
- /// NOTE: This function is thread safe in that clients manager their
- /// own file position markers and reads on other threads won't mess
- /// up the current read.
- ///
- /// @param[in] dst
- /// A buffer where to put the bytes that are read.
- ///
- /// @param[in,out] num_bytes
- /// The number of bytes to read form the current file position
- /// which gets modified with the number of bytes that were read.
- ///
- /// @param[in,out] offset
- /// The offset within the file from which to read \a num_bytes
- /// bytes. This offset gets incremented by the number of bytes
- /// that were read.
- ///
- /// @return
- /// An error object that indicates success or the reason for
- /// failure.
- //------------------------------------------------------------------
- Error
- Read (void *dst, size_t &num_bytes, off_t &offset);
-
- //------------------------------------------------------------------
- /// Read bytes from a file from the specified file offset.
- ///
- /// NOTE: This function is thread safe in that clients manager their
- /// own file position markers and reads on other threads won't mess
- /// up the current read.
- ///
- /// @param[in,out] num_bytes
- /// The number of bytes to read form the current file position
- /// which gets modified with the number of bytes that were read.
- ///
- /// @param[in,out] offset
- /// The offset within the file from which to read \a num_bytes
- /// bytes. This offset gets incremented by the number of bytes
- /// that were read.
- ///
- /// @param[in] null_terminate
- /// Ensure that the data that is read is terminated with a NULL
- /// character so that the data can be used as a C string.
- ///
- /// @param[out] data_buffer_sp
- /// A data buffer to create and fill in that will contain any
- /// data that is read from the file. This buffer will be reset
- /// if an error occurs.
- ///
- /// @return
- /// An error object that indicates success or the reason for
- /// failure.
- //------------------------------------------------------------------
- Error
- Read (size_t &num_bytes,
- off_t &offset,
- bool null_terminate,
- lldb::DataBufferSP &data_buffer_sp);
-
- //------------------------------------------------------------------
- /// Write bytes to a file at the specified file offset.
- ///
- /// NOTE: This function is thread safe in that clients manager their
- /// own file position markers, though clients will need to implement
- /// their own locking externally to avoid multiple people writing
- /// to the file at the same time.
- ///
- /// @param[in] src
- /// A buffer containing the bytes to write.
- ///
- /// @param[in,out] num_bytes
- /// The number of bytes to write to the file at offset \a offset.
- /// \a num_bytes gets modified with the number of bytes that
- /// were read.
- ///
- /// @param[in,out] offset
- /// The offset within the file at which to write \a num_bytes
- /// bytes. This offset gets incremented by the number of bytes
- /// that were written.
- ///
- /// @return
- /// An error object that indicates success or the reason for
- /// failure.
- //------------------------------------------------------------------
- Error
- Write (const void *src, size_t &num_bytes, off_t &offset);
-
- //------------------------------------------------------------------
- /// Flush the current stream
- ///
- /// @return
- /// An error object that indicates success or the reason for
- /// failure.
- //------------------------------------------------------------------
- Error
- Flush ();
-
- //------------------------------------------------------------------
- /// Sync to disk.
- ///
- /// @return
- /// An error object that indicates success or the reason for
- /// failure.
- //------------------------------------------------------------------
- Error
- Sync ();
-
- //------------------------------------------------------------------
- /// Get the permissions for a this file.
- ///
- /// @return
- /// Bits logical OR'ed together from the permission bits defined
- /// in lldb_private::File::Permissions.
- //------------------------------------------------------------------
- uint32_t
- GetPermissions(Error &error) const;
-
- static uint32_t
- GetPermissions(const FileSpec &file_spec, Error &error);
-
- //------------------------------------------------------------------
- /// Return true if this file is interactive.
- ///
- /// @return
- /// True if this file is a terminal (tty or pty), false
- /// otherwise.
- //------------------------------------------------------------------
- bool
- GetIsInteractive ();
-
- //------------------------------------------------------------------
- /// Return true if this file from a real terminal.
- ///
- /// Just knowing a file is a interactive isn't enough, we also need
- /// to know if the terminal has a width and height so we can do
- /// cursor movement and other terminal manipulations by sending
- /// escape sequences.
- ///
- /// @return
- /// True if this file is a terminal (tty, not a pty) that has
- /// a non-zero width and height, false otherwise.
- //------------------------------------------------------------------
- bool
- GetIsRealTerminal ();
-
- bool
- GetIsTerminalWithColors ();
-
- //------------------------------------------------------------------
- /// Output printf formatted output to the stream.
- ///
- /// Print some formatted output to the stream.
- ///
- /// @param[in] format
- /// A printf style format string.
- ///
- /// @param[in] ...
- /// Variable arguments that are needed for the printf style
- /// format string \a format.
- //------------------------------------------------------------------
- size_t
- Printf (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
-
- size_t
- PrintfVarArg(const char *format, va_list args);
-
- void
- SetOptions (uint32_t options)
- {
- m_options = options;
- }
+ static int kInvalidDescriptor;
+ static FILE *kInvalidStream;
+
+ enum OpenOptions {
+ eOpenOptionRead = (1u << 0), // Open file for reading
+ eOpenOptionWrite = (1u << 1), // Open file for writing
+ eOpenOptionAppend =
+ (1u << 2), // Don't truncate file when opening, append to end of file
+ eOpenOptionTruncate = (1u << 3), // Truncate file when opening
+ eOpenOptionNonBlocking = (1u << 4), // File reads
+ eOpenOptionCanCreate = (1u << 5), // Create file if doesn't already exist
+ eOpenOptionCanCreateNewOnly =
+ (1u << 6), // Can create file only if it doesn't already exist
+ eOpenOptionDontFollowSymlinks = (1u << 7),
+ eOpenOptionCloseOnExec =
+ (1u << 8) // Close the file when executing a new process
+ };
+
+ static mode_t ConvertOpenOptionsForPOSIXOpen(uint32_t open_options);
+
+ File()
+ : IOObject(eFDTypeFile, false), m_descriptor(kInvalidDescriptor),
+ m_stream(kInvalidStream), m_options(0), m_own_stream(false),
+ m_is_interactive(eLazyBoolCalculate),
+ m_is_real_terminal(eLazyBoolCalculate) {}
+
+ File(FILE *fh, bool transfer_ownership)
+ : IOObject(eFDTypeFile, false), m_descriptor(kInvalidDescriptor),
+ m_stream(fh), m_options(0), m_own_stream(transfer_ownership),
+ m_is_interactive(eLazyBoolCalculate),
+ m_is_real_terminal(eLazyBoolCalculate) {}
+
+ //------------------------------------------------------------------
+ /// Constructor with path.
+ ///
+ /// Takes a path to a file which can be just a filename, or a full
+ /// path. If \a path is not nullptr or empty, this function will call
+ /// File::Open (const char *path, uint32_t options, uint32_t permissions).
+ ///
+ /// @param[in] path
+ /// The full or partial path to a file.
+ ///
+ /// @param[in] options
+ /// Options to use when opening (see File::OpenOptions)
+ ///
+ /// @param[in] permissions
+ /// Options to use when opening (see File::Permissions)
+ ///
+ /// @see File::Open (const char *path, uint32_t options, uint32_t permissions)
+ //------------------------------------------------------------------
+ File(const char *path, uint32_t options,
+ uint32_t permissions = lldb::eFilePermissionsFileDefault);
+
+ //------------------------------------------------------------------
+ /// Constructor with FileSpec.
+ ///
+ /// Takes a FileSpec pointing to a file which can be just a filename, or a
+ /// full
+ /// path. If \a path is not nullptr or empty, this function will call
+ /// File::Open (const char *path, uint32_t options, uint32_t permissions).
+ ///
+ /// @param[in] filespec
+ /// The FileSpec for this file.
+ ///
+ /// @param[in] options
+ /// Options to use when opening (see File::OpenOptions)
+ ///
+ /// @param[in] permissions
+ /// Options to use when opening (see File::Permissions)
+ ///
+ /// @see File::Open (const char *path, uint32_t options, uint32_t permissions)
+ //------------------------------------------------------------------
+ File(const FileSpec &filespec, uint32_t options,
+ uint32_t permissions = lldb::eFilePermissionsFileDefault);
+
+ File(int fd, bool transfer_ownership)
+ : IOObject(eFDTypeFile, transfer_ownership), m_descriptor(fd),
+ m_stream(kInvalidStream), m_options(0), m_own_stream(false),
+ m_is_interactive(eLazyBoolCalculate),
+ m_is_real_terminal(eLazyBoolCalculate) {}
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ ///
+ /// The destructor is virtual in case this class is subclassed.
+ //------------------------------------------------------------------
+ ~File() override;
+
+ bool IsValid() const override {
+ return DescriptorIsValid() || StreamIsValid();
+ }
+
+ //------------------------------------------------------------------
+ /// Convert to pointer operator.
+ ///
+ /// This allows code to check a File object to see if it
+ /// contains anything valid using code such as:
+ ///
+ /// @code
+ /// File file(...);
+ /// if (file)
+ /// { ...
+ /// @endcode
+ ///
+ /// @return
+ /// A pointer to this object if either the directory or filename
+ /// is valid, nullptr otherwise.
+ //------------------------------------------------------------------
+ operator bool() const { return DescriptorIsValid() || StreamIsValid(); }
+
+ //------------------------------------------------------------------
+ /// Logical NOT operator.
+ ///
+ /// This allows code to check a File object to see if it is
+ /// invalid using code such as:
+ ///
+ /// @code
+ /// File file(...);
+ /// if (!file)
+ /// { ...
+ /// @endcode
+ ///
+ /// @return
+ /// Returns \b true if the object has an empty directory and
+ /// filename, \b false otherwise.
+ //------------------------------------------------------------------
+ bool operator!() const { return !DescriptorIsValid() && !StreamIsValid(); }
+
+ //------------------------------------------------------------------
+ /// Get the file spec for this file.
+ ///
+ /// @return
+ /// A reference to the file specification object.
+ //------------------------------------------------------------------
+ Error GetFileSpec(FileSpec &file_spec) const;
+
+ //------------------------------------------------------------------
+ /// Open a file for read/writing with the specified options.
+ ///
+ /// Takes a path to a file which can be just a filename, or a full
+ /// path.
+ ///
+ /// @param[in] path
+ /// The full or partial path to a file.
+ ///
+ /// @param[in] options
+ /// Options to use when opening (see File::OpenOptions)
+ ///
+ /// @param[in] permissions
+ /// Options to use when opening (see File::Permissions)
+ //------------------------------------------------------------------
+ Error Open(const char *path, uint32_t options,
+ uint32_t permissions = lldb::eFilePermissionsFileDefault);
+
+ Error Close() override;
+
+ void Clear();
+
+ int GetDescriptor() const;
+
+ WaitableHandle GetWaitableHandle() override;
+
+ void SetDescriptor(int fd, bool transfer_ownership);
+
+ FILE *GetStream();
+
+ void SetStream(FILE *fh, bool transfer_ownership);
+
+ //------------------------------------------------------------------
+ /// Read bytes from a file from the current file position.
+ ///
+ /// NOTE: This function is NOT thread safe. Use the read function
+ /// that takes an "off_t &offset" to ensure correct operation in
+ /// multi-threaded environments.
+ ///
+ /// @param[in] buf
+ /// A buffer where to put the bytes that are read.
+ ///
+ /// @param[in,out] num_bytes
+ /// The number of bytes to read form the current file position
+ /// which gets modified with the number of bytes that were read.
+ ///
+ /// @return
+ /// An error object that indicates success or the reason for
+ /// failure.
+ //------------------------------------------------------------------
+ Error Read(void *buf, size_t &num_bytes) override;
+
+ //------------------------------------------------------------------
+ /// Write bytes to a file at the current file position.
+ ///
+ /// NOTE: This function is NOT thread safe. Use the write function
+ /// that takes an "off_t &offset" to ensure correct operation in
+ /// multi-threaded environments.
+ ///
+ /// @param[in] buf
+ /// A buffer where to put the bytes that are read.
+ ///
+ /// @param[in,out] num_bytes
+ /// The number of bytes to write to the current file position
+ /// which gets modified with the number of bytes that were
+ /// written.
+ ///
+ /// @return
+ /// An error object that indicates success or the reason for
+ /// failure.
+ //------------------------------------------------------------------
+ Error Write(const void *buf, size_t &num_bytes) override;
+
+ //------------------------------------------------------------------
+ /// Seek to an offset relative to the beginning of the file.
+ ///
+ /// NOTE: This function is NOT thread safe, other threads that
+ /// access this object might also change the current file position.
+ /// For thread safe reads and writes see the following functions:
+ /// @see File::Read (void *, size_t, off_t &)
+ /// @see File::Write (const void *, size_t, off_t &)
+ ///
+ /// @param[in] offset
+ /// The offset to seek to within the file relative to the
+ /// beginning of the file.
+ ///
+ /// @param[in] error_ptr
+ /// A pointer to a lldb_private::Error object that will be
+ /// filled in if non-nullptr.
+ ///
+ /// @return
+ /// The resulting seek offset, or -1 on error.
+ //------------------------------------------------------------------
+ off_t SeekFromStart(off_t offset, Error *error_ptr = nullptr);
+
+ //------------------------------------------------------------------
+ /// Seek to an offset relative to the current file position.
+ ///
+ /// NOTE: This function is NOT thread safe, other threads that
+ /// access this object might also change the current file position.
+ /// For thread safe reads and writes see the following functions:
+ /// @see File::Read (void *, size_t, off_t &)
+ /// @see File::Write (const void *, size_t, off_t &)
+ ///
+ /// @param[in] offset
+ /// The offset to seek to within the file relative to the
+ /// current file position.
+ ///
+ /// @param[in] error_ptr
+ /// A pointer to a lldb_private::Error object that will be
+ /// filled in if non-nullptr.
+ ///
+ /// @return
+ /// The resulting seek offset, or -1 on error.
+ //------------------------------------------------------------------
+ off_t SeekFromCurrent(off_t offset, Error *error_ptr = nullptr);
+
+ //------------------------------------------------------------------
+ /// Seek to an offset relative to the end of the file.
+ ///
+ /// NOTE: This function is NOT thread safe, other threads that
+ /// access this object might also change the current file position.
+ /// For thread safe reads and writes see the following functions:
+ /// @see File::Read (void *, size_t, off_t &)
+ /// @see File::Write (const void *, size_t, off_t &)
+ ///
+ /// @param[in,out] offset
+ /// The offset to seek to within the file relative to the
+ /// end of the file which gets filled in with the resulting
+ /// absolute file offset.
+ ///
+ /// @param[in] error_ptr
+ /// A pointer to a lldb_private::Error object that will be
+ /// filled in if non-nullptr.
+ ///
+ /// @return
+ /// The resulting seek offset, or -1 on error.
+ //------------------------------------------------------------------
+ off_t SeekFromEnd(off_t offset, Error *error_ptr = nullptr);
+
+ //------------------------------------------------------------------
+ /// Read bytes from a file from the specified file offset.
+ ///
+ /// NOTE: This function is thread safe in that clients manager their
+ /// own file position markers and reads on other threads won't mess
+ /// up the current read.
+ ///
+ /// @param[in] dst
+ /// A buffer where to put the bytes that are read.
+ ///
+ /// @param[in,out] num_bytes
+ /// The number of bytes to read form the current file position
+ /// which gets modified with the number of bytes that were read.
+ ///
+ /// @param[in,out] offset
+ /// The offset within the file from which to read \a num_bytes
+ /// bytes. This offset gets incremented by the number of bytes
+ /// that were read.
+ ///
+ /// @return
+ /// An error object that indicates success or the reason for
+ /// failure.
+ //------------------------------------------------------------------
+ Error Read(void *dst, size_t &num_bytes, off_t &offset);
+
+ //------------------------------------------------------------------
+ /// Read bytes from a file from the specified file offset.
+ ///
+ /// NOTE: This function is thread safe in that clients manager their
+ /// own file position markers and reads on other threads won't mess
+ /// up the current read.
+ ///
+ /// @param[in,out] num_bytes
+ /// The number of bytes to read form the current file position
+ /// which gets modified with the number of bytes that were read.
+ ///
+ /// @param[in,out] offset
+ /// The offset within the file from which to read \a num_bytes
+ /// bytes. This offset gets incremented by the number of bytes
+ /// that were read.
+ ///
+ /// @param[in] null_terminate
+ /// Ensure that the data that is read is terminated with a NULL
+ /// character so that the data can be used as a C string.
+ ///
+ /// @param[out] data_buffer_sp
+ /// A data buffer to create and fill in that will contain any
+ /// data that is read from the file. This buffer will be reset
+ /// if an error occurs.
+ ///
+ /// @return
+ /// An error object that indicates success or the reason for
+ /// failure.
+ //------------------------------------------------------------------
+ Error Read(size_t &num_bytes, off_t &offset, bool null_terminate,
+ lldb::DataBufferSP &data_buffer_sp);
+
+ //------------------------------------------------------------------
+ /// Write bytes to a file at the specified file offset.
+ ///
+ /// NOTE: This function is thread safe in that clients manager their
+ /// own file position markers, though clients will need to implement
+ /// their own locking externally to avoid multiple people writing
+ /// to the file at the same time.
+ ///
+ /// @param[in] src
+ /// A buffer containing the bytes to write.
+ ///
+ /// @param[in,out] num_bytes
+ /// The number of bytes to write to the file at offset \a offset.
+ /// \a num_bytes gets modified with the number of bytes that
+ /// were read.
+ ///
+ /// @param[in,out] offset
+ /// The offset within the file at which to write \a num_bytes
+ /// bytes. This offset gets incremented by the number of bytes
+ /// that were written.
+ ///
+ /// @return
+ /// An error object that indicates success or the reason for
+ /// failure.
+ //------------------------------------------------------------------
+ Error Write(const void *src, size_t &num_bytes, off_t &offset);
+
+ //------------------------------------------------------------------
+ /// Flush the current stream
+ ///
+ /// @return
+ /// An error object that indicates success or the reason for
+ /// failure.
+ //------------------------------------------------------------------
+ Error Flush();
+
+ //------------------------------------------------------------------
+ /// Sync to disk.
+ ///
+ /// @return
+ /// An error object that indicates success or the reason for
+ /// failure.
+ //------------------------------------------------------------------
+ Error Sync();
+
+ //------------------------------------------------------------------
+ /// Get the permissions for a this file.
+ ///
+ /// @return
+ /// Bits logical OR'ed together from the permission bits defined
+ /// in lldb_private::File::Permissions.
+ //------------------------------------------------------------------
+ uint32_t GetPermissions(Error &error) const;
+
+ static uint32_t GetPermissions(const FileSpec &file_spec, Error &error);
+
+ //------------------------------------------------------------------
+ /// Return true if this file is interactive.
+ ///
+ /// @return
+ /// True if this file is a terminal (tty or pty), false
+ /// otherwise.
+ //------------------------------------------------------------------
+ bool GetIsInteractive();
+
+ //------------------------------------------------------------------
+ /// Return true if this file from a real terminal.
+ ///
+ /// Just knowing a file is a interactive isn't enough, we also need
+ /// to know if the terminal has a width and height so we can do
+ /// cursor movement and other terminal manipulations by sending
+ /// escape sequences.
+ ///
+ /// @return
+ /// True if this file is a terminal (tty, not a pty) that has
+ /// a non-zero width and height, false otherwise.
+ //------------------------------------------------------------------
+ bool GetIsRealTerminal();
+
+ bool GetIsTerminalWithColors();
+
+ //------------------------------------------------------------------
+ /// Output printf formatted output to the stream.
+ ///
+ /// Print some formatted output to the stream.
+ ///
+ /// @param[in] format
+ /// A printf style format string.
+ ///
+ /// @param[in] ...
+ /// Variable arguments that are needed for the printf style
+ /// format string \a format.
+ //------------------------------------------------------------------
+ size_t Printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
+
+ size_t PrintfVarArg(const char *format, va_list args);
+
+ void SetOptions(uint32_t options) { m_options = options; }
protected:
- bool
- DescriptorIsValid () const
- {
- return m_descriptor >= 0;
- }
-
- bool
- StreamIsValid () const
- {
- return m_stream != kInvalidStream;
- }
-
- void
- CalculateInteractiveAndTerminal ();
-
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- int m_descriptor;
- FILE *m_stream;
- uint32_t m_options;
- bool m_own_stream;
- LazyBool m_is_interactive;
- LazyBool m_is_real_terminal;
- LazyBool m_supports_colors;
+ bool DescriptorIsValid() const { return m_descriptor >= 0; }
+
+ bool StreamIsValid() const { return m_stream != kInvalidStream; }
+
+ void CalculateInteractiveAndTerminal();
+
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ int m_descriptor;
+ FILE *m_stream;
+ uint32_t m_options;
+ bool m_own_stream;
+ LazyBool m_is_interactive;
+ LazyBool m_is_real_terminal;
+ LazyBool m_supports_colors;
private:
- DISALLOW_COPY_AND_ASSIGN(File);
+ DISALLOW_COPY_AND_ASSIGN(File);
};
} // namespace lldb_private
diff --git a/include/lldb/Host/FileCache.h b/include/lldb/Host/FileCache.h
index 779ff983de98..1667d05e2a52 100644
--- a/include/lldb/Host/FileCache.h
+++ b/include/lldb/Host/FileCache.h
@@ -17,28 +17,29 @@
#include "lldb/Core/Error.h"
#include "lldb/Host/FileSpec.h"
-namespace lldb_private
-{
-class FileCache
-{
- private:
- FileCache() {}
+namespace lldb_private {
+class FileCache {
+private:
+ FileCache() {}
- typedef std::map<lldb::user_id_t, lldb::FileSP> FDToFileMap;
+ typedef std::map<lldb::user_id_t, lldb::FileSP> FDToFileMap;
- public:
- static FileCache &GetInstance();
+public:
+ static FileCache &GetInstance();
- lldb::user_id_t OpenFile(const FileSpec &file_spec, uint32_t flags, uint32_t mode, Error &error);
- bool CloseFile(lldb::user_id_t fd, Error &error);
+ lldb::user_id_t OpenFile(const FileSpec &file_spec, uint32_t flags,
+ uint32_t mode, Error &error);
+ bool CloseFile(lldb::user_id_t fd, Error &error);
- uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, uint64_t src_len, Error &error);
- uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, uint64_t dst_len, Error &error);
+ uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src,
+ uint64_t src_len, Error &error);
+ uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
+ uint64_t dst_len, Error &error);
- private:
- static FileCache *m_instance;
+private:
+ static FileCache *m_instance;
- FDToFileMap m_cache;
+ FDToFileMap m_cache;
};
}
diff --git a/include/lldb/Host/FileSpec.h b/include/lldb/Host/FileSpec.h
index 219af662dfcb..b8df7453886c 100644
--- a/include/lldb/Host/FileSpec.h
+++ b/include/lldb/Host/FileSpec.h
@@ -17,10 +17,12 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/STLUtils.h"
-#include "lldb/Host/TimeValue.h"
+#include "lldb/Host/PosixApi.h"
+#include "lldb/lldb-private.h"
+
+#include "llvm/Support/FormatVariadic.h"
namespace lldb_private {
@@ -32,826 +34,757 @@ namespace lldb_private {
/// and basename. These string values of the paths are put into uniqued
/// string pools for fast comparisons and efficient memory usage.
///
-/// Another reason the paths are split into the directory and basename
-/// is to allow efficient debugger searching. Often in a debugger the
-/// user types in the basename of the file, for example setting a
+/// Another reason the paths are split into the directory and basename
+/// is to allow efficient debugger searching. Often in a debugger the
+/// user types in the basename of the file, for example setting a
/// breakpoint by file and line, or specifying a module (shared library)
/// to limit the scope in which to execute a command. The user rarely
/// types in a full path. When the paths are already split up, it makes
-/// it easy for us to compare only the basenames of a lot of file
+/// it easy for us to compare only the basenames of a lot of file
/// specifications without having to split up the file path each time
/// to get to the basename.
//----------------------------------------------------------------------
-class FileSpec
-{
+class FileSpec {
public:
- typedef enum FileType
- {
- eFileTypeInvalid = -1,
- eFileTypeUnknown = 0,
- eFileTypeDirectory,
- eFileTypePipe,
- eFileTypeRegular,
- eFileTypeSocket,
- eFileTypeSymbolicLink,
- eFileTypeOther
- } FileType;
-
- enum PathSyntax
- {
- ePathSyntaxPosix,
- ePathSyntaxWindows,
- ePathSyntaxHostNative
- };
-
- FileSpec();
-
- //------------------------------------------------------------------
- /// Constructor with path.
- ///
- /// Takes a path to a file which can be just a filename, or a full
- /// path. If \a path is not nullptr or empty, this function will call
- /// FileSpec::SetFile (const char *path, bool resolve).
- ///
- /// @param[in] path
- /// The full or partial path to a file.
- ///
- /// @param[in] resolve_path
- /// If \b true, then we resolve the path, removing stray ../.. and so forth,
- /// if \b false we trust the path is in canonical form already.
- ///
- /// @see FileSpec::SetFile (const char *path, bool resolve)
- //------------------------------------------------------------------
- explicit FileSpec (const char *path, bool resolve_path, PathSyntax syntax = ePathSyntaxHostNative);
-
- explicit FileSpec (const char *path, bool resolve_path, ArchSpec arch);
-
- explicit FileSpec(const std::string &path, bool resolve_path, PathSyntax syntax = ePathSyntaxHostNative);
-
- explicit FileSpec(const std::string &path, bool resolve_path, ArchSpec arch);
-
- //------------------------------------------------------------------
- /// Copy constructor
- ///
- /// Makes a copy of the uniqued directory and filename strings from
- /// \a rhs.
- ///
- /// @param[in] rhs
- /// A const FileSpec object reference to copy.
- //------------------------------------------------------------------
- FileSpec (const FileSpec& rhs);
-
- //------------------------------------------------------------------
- /// Copy constructor
- ///
- /// Makes a copy of the uniqued directory and filename strings from
- /// \a rhs if it is not nullptr.
- ///
- /// @param[in] rhs
- /// A const FileSpec object pointer to copy if non-nullptr.
- //------------------------------------------------------------------
- FileSpec (const FileSpec* rhs);
-
- //------------------------------------------------------------------
- /// Destructor.
- //------------------------------------------------------------------
- ~FileSpec ();
-
- bool
- DirectoryEquals(const FileSpec &other) const;
-
- bool
- FileEquals(const FileSpec &other) const;
-
- //------------------------------------------------------------------
- /// Assignment operator.
- ///
- /// Makes a copy of the uniqued directory and filename strings from
- /// \a rhs.
- ///
- /// @param[in] rhs
- /// A const FileSpec object reference to assign to this object.
- ///
- /// @return
- /// A const reference to this object.
- //------------------------------------------------------------------
- const FileSpec&
- operator= (const FileSpec& rhs);
-
- //------------------------------------------------------------------
- /// Equal to operator
- ///
- /// Tests if this object is equal to \a rhs.
- ///
- /// @param[in] rhs
- /// A const FileSpec object reference to compare this object
- /// to.
- ///
- /// @return
- /// \b true if this object is equal to \a rhs, \b false
- /// otherwise.
- //------------------------------------------------------------------
- bool
- operator== (const FileSpec& rhs) const;
-
- //------------------------------------------------------------------
- /// Not equal to operator
- ///
- /// Tests if this object is not equal to \a rhs.
- ///
- /// @param[in] rhs
- /// A const FileSpec object reference to compare this object
- /// to.
- ///
- /// @return
- /// \b true if this object is equal to \a rhs, \b false
- /// otherwise.
- //------------------------------------------------------------------
- bool
- operator!= (const FileSpec& rhs) const;
-
- //------------------------------------------------------------------
- /// Less than to operator
- ///
- /// Tests if this object is less than \a rhs.
- ///
- /// @param[in] rhs
- /// A const FileSpec object reference to compare this object
- /// to.
- ///
- /// @return
- /// \b true if this object is less than \a rhs, \b false
- /// otherwise.
- //------------------------------------------------------------------
- bool
- operator< (const FileSpec& rhs) const;
-
- //------------------------------------------------------------------
- /// Convert to pointer operator.
- ///
- /// This allows code to check a FileSpec object to see if it
- /// contains anything valid using code such as:
- ///
- /// @code
- /// FileSpec file_spec(...);
- /// if (file_spec)
- /// { ...
- /// @endcode
- ///
- /// @return
- /// A pointer to this object if either the directory or filename
- /// is valid, nullptr otherwise.
- //------------------------------------------------------------------
- explicit operator bool() const;
-
- //------------------------------------------------------------------
- /// Logical NOT operator.
- ///
- /// This allows code to check a FileSpec object to see if it is
- /// invalid using code such as:
- ///
- /// @code
- /// FileSpec file_spec(...);
- /// if (!file_spec)
- /// { ...
- /// @endcode
- ///
- /// @return
- /// Returns \b true if the object has an empty directory and
- /// filename, \b false otherwise.
- //------------------------------------------------------------------
- bool
- operator! () const;
-
- //------------------------------------------------------------------
- /// Clears the object state.
- ///
- /// Clear this object by releasing both the directory and filename
- /// string values and reverting them to empty strings.
- //------------------------------------------------------------------
- void
- Clear ();
-
- //------------------------------------------------------------------
- /// Compare two FileSpec objects.
- ///
- /// If \a full is true, then both the directory and the filename
- /// must match. If \a full is false, then the directory names for
- /// \a lhs and \a rhs are only compared if they are both not empty.
- /// This allows a FileSpec object to only contain a filename
- /// and it can match FileSpec objects that have matching
- /// filenames with different paths.
- ///
- /// @param[in] lhs
- /// A const reference to the Left Hand Side object to compare.
- ///
- /// @param[in] rhs
- /// A const reference to the Right Hand Side object to compare.
- ///
- /// @param[in] full
- /// If true, then both the directory and filenames will have to
- /// match for a compare to return zero (equal to). If false
- /// and either directory from \a lhs or \a rhs is empty, then
- /// only the filename will be compared, else a full comparison
- /// is done.
- ///
- /// @return
- /// @li -1 if \a lhs is less than \a rhs
- /// @li 0 if \a lhs is equal to \a rhs
- /// @li 1 if \a lhs is greater than \a rhs
- //------------------------------------------------------------------
- static int
- Compare (const FileSpec& lhs, const FileSpec& rhs, bool full);
-
- static bool
- Equal (const FileSpec& a, const FileSpec& b, bool full, bool remove_backups = false);
-
- //------------------------------------------------------------------
- /// Case sensitivity of path.
- ///
- /// @return
- /// \b true if the file path is case sensitive (POSIX), false
- /// if case insensitive (Windows).
- //------------------------------------------------------------------
- bool
- IsCaseSensitive() const
- {
- return m_syntax != ePathSyntaxWindows;
- }
-
- //------------------------------------------------------------------
- /// Dump this object to a Stream.
- ///
- /// Dump the object to the supplied stream \a s. If the object
- /// contains a valid directory name, it will be displayed followed
- /// by a directory delimiter, and the filename.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- //------------------------------------------------------------------
- void
- Dump(Stream *s) const;
-
- //------------------------------------------------------------------
- /// Existence test.
- ///
- /// @return
- /// \b true if the file exists on disk, \b false otherwise.
- //------------------------------------------------------------------
- bool
- Exists () const;
-
- //------------------------------------------------------------------
- /// Check if a file is readable by the current user
- ///
- /// @return
- /// \b true if the file exists on disk and is readable, \b false
- /// otherwise.
- //------------------------------------------------------------------
- bool
- Readable () const;
-
- //------------------------------------------------------------------
- /// Expanded existence test.
- ///
- /// Call into the Host to see if it can help find the file (e.g. by
- /// searching paths set in the environment, etc.).
- ///
- /// If found, sets the value of m_directory to the directory where
- /// the file was found.
- ///
- /// @return
- /// \b true if was able to find the file using expanded search
- /// methods, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ResolveExecutableLocation ();
-
- //------------------------------------------------------------------
- /// Canonicalize this file path (basically running the static
- /// FileSpec::Resolve method on it). Useful if you asked us not to
- /// resolve the file path when you set the file.
- //------------------------------------------------------------------
- bool
- ResolvePath ();
-
- uint64_t
- GetByteSize() const;
-
- PathSyntax
- GetPathSyntax() const;
-
- //------------------------------------------------------------------
- /// Directory string get accessor.
- ///
- /// @return
- /// A reference to the directory string object.
- //------------------------------------------------------------------
- ConstString &
- GetDirectory ();
-
- //------------------------------------------------------------------
- /// Directory string const get accessor.
- ///
- /// @return
- /// A const reference to the directory string object.
- //------------------------------------------------------------------
- const ConstString &
- GetDirectory () const;
-
- //------------------------------------------------------------------
- /// Filename string get accessor.
- ///
- /// @return
- /// A reference to the filename string object.
- //------------------------------------------------------------------
- ConstString &
- GetFilename ();
-
- //------------------------------------------------------------------
- /// Filename string const get accessor.
- ///
- /// @return
- /// A const reference to the filename string object.
- //------------------------------------------------------------------
- const ConstString &
- GetFilename () const;
-
- //------------------------------------------------------------------
- /// Returns true if the filespec represents an implementation source
- /// file (files with a ".c", ".cpp", ".m", ".mm" (many more)
- /// extension).
- ///
- /// @return
- /// \b true if the filespec represents an implementation source
- /// file, \b false otherwise.
- //------------------------------------------------------------------
- bool
- IsSourceImplementationFile () const;
-
- //------------------------------------------------------------------
- /// Returns true if the filespec represents a relative path.
- ///
- /// @return
- /// \b true if the filespec represents a relative path,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool
- IsRelative() const;
-
- //------------------------------------------------------------------
- /// Returns true if the filespec represents an absolute path.
- ///
- /// @return
- /// \b true if the filespec represents an absolute path,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool
- IsAbsolute() const;
-
- TimeValue
- GetModificationTime () const;
-
- //------------------------------------------------------------------
- /// Extract the full path to the file.
- ///
- /// Extract the directory and path into a fixed buffer. This is
- /// needed as the directory and path are stored in separate string
- /// values.
- ///
- /// @param[out] path
- /// The buffer in which to place the extracted full path.
- ///
- /// @param[in] max_path_length
- /// The maximum length of \a path.
- ///
- /// @return
- /// Returns the number of characters that would be needed to
- /// properly copy the full path into \a path. If the returned
- /// number is less than \a max_path_length, then the path is
- /// properly copied and terminated. If the return value is
- /// >= \a max_path_length, then the path was truncated (but is
- /// still NULL terminated).
- //------------------------------------------------------------------
- size_t
- GetPath (char *path, size_t max_path_length, bool denormalize = true) const;
-
- //------------------------------------------------------------------
- /// Extract the full path to the file.
- ///
- /// Extract the directory and path into a std::string, which is returned.
- ///
- /// @return
- /// Returns a std::string with the directory and filename
- /// concatenated.
- //------------------------------------------------------------------
- std::string
- GetPath (bool denormalize = true) const;
-
- const char *
- GetCString(bool denormalize = true) const;
-
- //------------------------------------------------------------------
- /// Extract the full path to the file.
- ///
- /// Extract the directory and path into an llvm::SmallVectorImpl<>
- ///
- /// @return
- /// Returns a std::string with the directory and filename
- /// concatenated.
- //------------------------------------------------------------------
- void GetPath(llvm::SmallVectorImpl<char> &path, bool denormalize = true) const;
-
- //------------------------------------------------------------------
- /// Extract the extension of the file.
- ///
- /// Returns a ConstString that represents the extension of the filename
- /// for this FileSpec object. If this object does not represent a file,
- /// or the filename has no extension, ConstString(nullptr) is returned.
- /// The dot ('.') character is not returned as part of the extension
- ///
- /// @return
- /// Returns the extension of the file as a ConstString object.
- //------------------------------------------------------------------
- ConstString
- GetFileNameExtension () const;
-
- //------------------------------------------------------------------
- /// Return the filename without the extension part
- ///
- /// Returns a ConstString that represents the filename of this object
- /// without the extension part (e.g. for a file named "foo.bar", "foo"
- /// is returned)
- ///
- /// @return
- /// Returns the filename without extension
- /// as a ConstString object.
- //------------------------------------------------------------------
- ConstString
- GetFileNameStrippingExtension () const;
-
- FileType
- GetFileType () const;
-
- //------------------------------------------------------------------
- /// Return the current permissions of the path.
- ///
- /// Returns a bitmask for the current permissions of the file
- /// ( zero or more of the permission bits defined in
- /// File::Permissions).
- ///
- /// @return
- /// Zero if the file doesn't exist or we are unable to get
- /// information for the file, otherwise one or more permission
- /// bits from the File::Permissions enumeration.
- //------------------------------------------------------------------
- uint32_t
- GetPermissions () const;
-
- bool
- IsDirectory () const
- {
- return GetFileType() == FileSpec::eFileTypeDirectory;
- }
-
- bool
- IsPipe () const
- {
- return GetFileType() == FileSpec::eFileTypePipe;
- }
-
- bool
- IsRegularFile () const
- {
- return GetFileType() == FileSpec::eFileTypeRegular;
- }
-
- bool
- IsSocket () const
- {
- return GetFileType() == FileSpec::eFileTypeSocket;
- }
-
- bool
- IsSymbolicLink () const;
-
- //------------------------------------------------------------------
- /// Get the memory cost of this object.
- ///
- /// Return the size in bytes that this object takes in memory. This
- /// returns the size in bytes of this object, not any shared string
- /// values it may refer to.
- ///
- /// @return
- /// The number of bytes that this object occupies in memory.
- ///
- /// @see ConstString::StaticMemorySize ()
- //------------------------------------------------------------------
- size_t
- MemorySize () const;
-
- //------------------------------------------------------------------
- /// Memory map part of, or the entire contents of, a file.
- ///
- /// Returns a shared pointer to a data buffer that contains all or
- /// part of the contents of a file. The data is memory mapped and
- /// will lazily page in data from the file as memory is accessed.
- /// The data that is mapped will start \a offset bytes into the
- /// file, and \a length bytes will be mapped. If \a length is
- /// greater than the number of bytes available in the file starting
- /// at \a offset, the number of bytes will be appropriately
- /// truncated. The final number of bytes that get mapped can be
- /// verified using the DataBuffer::GetByteSize() function on the return
- /// shared data pointer object contents.
- ///
- /// @param[in] offset
- /// The offset in bytes from the beginning of the file where
- /// memory mapping should begin.
- ///
- /// @param[in] length
- /// The size in bytes that should be mapped starting \a offset
- /// bytes into the file. If \a length is \c SIZE_MAX, map
- /// as many bytes as possible.
- ///
- /// @return
- /// A shared pointer to the memory mapped data. This shared
- /// pointer can contain a nullptr DataBuffer pointer, so the contained
- /// pointer must be checked prior to using it.
- //------------------------------------------------------------------
- lldb::DataBufferSP
- MemoryMapFileContents (off_t offset = 0, size_t length = SIZE_MAX) const;
-
- //------------------------------------------------------------------
- /// Memory map part of, or the entire contents of, a file only if
- /// the file is local (not on a network mount).
- ///
- /// Returns a shared pointer to a data buffer that contains all or
- /// part of the contents of a file. The data will be memory mapped
- /// if the file is local and will lazily page in data from the file
- /// as memory is accessed. If the data is memory mapped, the data
- /// that is mapped will start \a offset bytes into the file, and
- /// \a length bytes will be mapped. If \a length is
- /// greater than the number of bytes available in the file starting
- /// at \a offset, the number of bytes will be appropriately
- /// truncated. The final number of bytes that get mapped can be
- /// verified using the DataBuffer::GetByteSize() function on the return
- /// shared data pointer object contents.
- ///
- /// If the file is on a network mount the data will be read into a
- /// heap buffer immediately so that accesses to the data won't later
- /// cause a crash if we touch a page that isn't paged in and the
- /// network mount has been disconnected or gone away.
- ///
- /// @param[in] offset
- /// The offset in bytes from the beginning of the file where
- /// memory mapping should begin.
- ///
- /// @param[in] length
- /// The size in bytes that should be mapped starting \a offset
- /// bytes into the file. If \a length is \c SIZE_MAX, map
- /// as many bytes as possible.
- ///
- /// @return
- /// A shared pointer to the memory mapped data. This shared
- /// pointer can contain a nullptr DataBuffer pointer, so the contained
- /// pointer must be checked prior to using it.
- //------------------------------------------------------------------
- lldb::DataBufferSP
- MemoryMapFileContentsIfLocal(off_t file_offset, size_t file_size) const;
-
- //------------------------------------------------------------------
- /// Read part of, or the entire contents of, a file into a heap based data buffer.
- ///
- /// Returns a shared pointer to a data buffer that contains all or
- /// part of the contents of a file. The data copies into a heap based
- /// buffer that lives in the DataBuffer shared pointer object returned.
- /// The data that is cached will start \a offset bytes into the
- /// file, and \a length bytes will be mapped. If \a length is
- /// greater than the number of bytes available in the file starting
- /// at \a offset, the number of bytes will be appropriately
- /// truncated. The final number of bytes that get mapped can be
- /// verified using the DataBuffer::GetByteSize() function.
- ///
- /// @param[in] offset
- /// The offset in bytes from the beginning of the file where
- /// memory mapping should begin.
- ///
- /// @param[in] length
- /// The size in bytes that should be mapped starting \a offset
- /// bytes into the file. If \a length is \c SIZE_MAX, map
- /// as many bytes as possible.
- ///
- /// @return
- /// A shared pointer to the memory mapped data. This shared
- /// pointer can contain a nullptr DataBuffer pointer, so the contained
- /// pointer must be checked prior to using it.
- //------------------------------------------------------------------
- lldb::DataBufferSP
- ReadFileContents(off_t offset = 0, size_t length = SIZE_MAX, Error *error_ptr = nullptr) const;
-
- size_t
- ReadFileContents (off_t file_offset, void *dst, size_t dst_len, Error *error_ptr) const;
-
- //------------------------------------------------------------------
- /// Read the entire contents of a file as data that can be used
- /// as a C string.
- ///
- /// Read the entire contents of a file and ensure that the data
- /// is NULL terminated so it can be used as a C string.
- ///
- /// @return
- /// A shared pointer to the data. This shared pointer can
- /// contain a nullptr DataBuffer pointer, so the contained pointer
- /// must be checked prior to using it.
- //------------------------------------------------------------------
- lldb::DataBufferSP
- ReadFileContentsAsCString(Error *error_ptr = nullptr);
-
- //------------------------------------------------------------------
- /// Normalize a pathname by collapsing redundant separators and
- /// up-level references.
- //------------------------------------------------------------------
- void
- NormalizePath ();
-
- //------------------------------------------------------------------
- /// Run through the input string, replaying the effect of any ".." and produce
- /// the resultant path. The input path is not required to be in the host file system
- /// format, but it is required to be normalized to that system.
- ///
- /// @param[in] input
- /// The input path to analyze.
- ///
- /// @param[out] result
- /// The backup-resolved path will be written here.
- //------------------------------------------------------------------
- static void RemoveBackupDots (const ConstString &input_const_str, ConstString &result_const_str);
-
- //------------------------------------------------------------------
- /// Change the file specified with a new path.
- ///
- /// Update the contents of this object with a new path. The path will
- /// be split up into a directory and filename and stored as uniqued
- /// string values for quick comparison and efficient memory usage.
- ///
- /// @param[in] path
- /// A full, partial, or relative path to a file.
- ///
- /// @param[in] resolve_path
- /// If \b true, then we will try to resolve links the path using
- /// the static FileSpec::Resolve.
- //------------------------------------------------------------------
- void
- SetFile (const char *path, bool resolve_path, PathSyntax syntax = ePathSyntaxHostNative);
-
- void
- SetFile(const char *path, bool resolve_path, ArchSpec arch);
-
- void
- SetFile(const std::string &path, bool resolve_path, PathSyntax syntax = ePathSyntaxHostNative);
-
- void
- SetFile(const std::string &path, bool resolve_path, ArchSpec arch);
-
- bool
- IsResolved () const
- {
- return m_is_resolved;
- }
-
- //------------------------------------------------------------------
- /// Set if the file path has been resolved or not.
- ///
- /// If you know a file path is already resolved and avoided passing
- /// a \b true parameter for any functions that take a "bool
- /// resolve_path" parameter, you can set the value manually using
- /// this call to make sure we don't try and resolve it later, or try
- /// and resolve a path that has already been resolved.
- ///
- /// @param[in] is_resolved
- /// A boolean value that will replace the current value that
- /// indicates if the paths in this object have been resolved.
- //------------------------------------------------------------------
- void
- SetIsResolved (bool is_resolved)
- {
- m_is_resolved = is_resolved;
- }
-
- //------------------------------------------------------------------
- /// Read the file into an array of strings, one per line.
- ///
- /// Opens and reads the file in this object into an array of strings,
- /// one string per line of the file. Returns a boolean indicating
- /// success or failure.
- ///
- /// @param[out] lines
- /// The string array into which to read the file.
- ///
- /// @result
- /// Returns the number of lines that were read from the file.
- //------------------------------------------------------------------
- size_t
- ReadFileLines (STLStringArray &lines);
-
- //------------------------------------------------------------------
- /// Resolves user name and links in \a path, and overwrites the input
- /// argument with the resolved path.
- ///
- /// @param[in] path
- /// Input path to be resolved, in the form of a llvm::SmallString or similar.
- //------------------------------------------------------------------
- static void
- Resolve (llvm::SmallVectorImpl<char> &path);
-
- FileSpec
- CopyByAppendingPathComponent (const char *new_path) const;
-
- FileSpec
- CopyByRemovingLastPathComponent () const;
-
- void
- PrependPathComponent(const char *new_path);
-
- void
- PrependPathComponent(const std::string &new_path);
-
- void
- PrependPathComponent(const FileSpec &new_path);
-
- void
- AppendPathComponent(const char *new_path);
-
- void
- AppendPathComponent(const std::string &new_path);
-
- void
- AppendPathComponent(const FileSpec &new_path);
-
- void
- RemoveLastPathComponent ();
-
- ConstString
- GetLastPathComponent () const;
-
- //------------------------------------------------------------------
- /// Resolves the user name at the beginning of \a src_path, and writes the output
- /// to \a dst_path. Note, \a src_path can contain other path components after the
- /// user name, they will be copied over, and if the path doesn't start with "~" it
- /// will also be copied over to \a dst_path.
- ///
- /// @param[in] src_path
- /// Input path to be resolved.
- ///
- /// @param[in] dst_path
- /// Buffer to store the resolved path.
- //------------------------------------------------------------------
- static void
- ResolveUsername (llvm::SmallVectorImpl<char> &path);
-
- static size_t
- ResolvePartialUsername (const char *partial_name, StringList &matches);
-
- enum EnumerateDirectoryResult
- {
- eEnumerateDirectoryResultNext, // Enumerate next entry in the current directory
- eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
- eEnumerateDirectoryResultExit, // Exit from the current directory at the current level.
- eEnumerateDirectoryResultQuit // Stop directory enumerations at any level
- };
-
- typedef EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
- FileType file_type,
- const FileSpec &spec);
-
- static EnumerateDirectoryResult
- EnumerateDirectory (const char *dir_path,
- bool find_directories,
- bool find_files,
- bool find_other,
- EnumerateDirectoryCallbackType callback,
- void *callback_baton);
-
- typedef std::function <EnumerateDirectoryResult(FileType file_type, const FileSpec &spec)> DirectoryCallback;
-
- static EnumerateDirectoryResult
- ForEachItemInDirectory (const char *dir_path, DirectoryCallback const &callback);
+ typedef enum FileType {
+ eFileTypeInvalid = -1,
+ eFileTypeUnknown = 0,
+ eFileTypeDirectory,
+ eFileTypePipe,
+ eFileTypeRegular,
+ eFileTypeSocket,
+ eFileTypeSymbolicLink,
+ eFileTypeOther
+ } FileType;
+
+ enum PathSyntax {
+ ePathSyntaxPosix,
+ ePathSyntaxWindows,
+ ePathSyntaxHostNative
+ };
+
+ FileSpec();
+
+ //------------------------------------------------------------------
+ /// Constructor with path.
+ ///
+ /// Takes a path to a file which can be just a filename, or a full
+ /// path. If \a path is not nullptr or empty, this function will call
+ /// FileSpec::SetFile (const char *path, bool resolve).
+ ///
+ /// @param[in] path
+ /// The full or partial path to a file.
+ ///
+ /// @param[in] resolve_path
+ /// If \b true, then we resolve the path, removing stray ../.. and so
+ /// forth,
+ /// if \b false we trust the path is in canonical form already.
+ ///
+ /// @see FileSpec::SetFile (const char *path, bool resolve)
+ //------------------------------------------------------------------
+ explicit FileSpec(llvm::StringRef path, bool resolve_path,
+ PathSyntax syntax = ePathSyntaxHostNative);
+
+ explicit FileSpec(llvm::StringRef path, bool resolve_path, ArchSpec arch);
+
+ //------------------------------------------------------------------
+ /// Copy constructor
+ ///
+ /// Makes a copy of the uniqued directory and filename strings from
+ /// \a rhs.
+ ///
+ /// @param[in] rhs
+ /// A const FileSpec object reference to copy.
+ //------------------------------------------------------------------
+ FileSpec(const FileSpec &rhs);
+
+ //------------------------------------------------------------------
+ /// Copy constructor
+ ///
+ /// Makes a copy of the uniqued directory and filename strings from
+ /// \a rhs if it is not nullptr.
+ ///
+ /// @param[in] rhs
+ /// A const FileSpec object pointer to copy if non-nullptr.
+ //------------------------------------------------------------------
+ FileSpec(const FileSpec *rhs);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ //------------------------------------------------------------------
+ ~FileSpec();
+
+ bool DirectoryEquals(const FileSpec &other) const;
+
+ bool FileEquals(const FileSpec &other) const;
+
+ //------------------------------------------------------------------
+ /// Assignment operator.
+ ///
+ /// Makes a copy of the uniqued directory and filename strings from
+ /// \a rhs.
+ ///
+ /// @param[in] rhs
+ /// A const FileSpec object reference to assign to this object.
+ ///
+ /// @return
+ /// A const reference to this object.
+ //------------------------------------------------------------------
+ const FileSpec &operator=(const FileSpec &rhs);
+
+ //------------------------------------------------------------------
+ /// Equal to operator
+ ///
+ /// Tests if this object is equal to \a rhs.
+ ///
+ /// @param[in] rhs
+ /// A const FileSpec object reference to compare this object
+ /// to.
+ ///
+ /// @return
+ /// \b true if this object is equal to \a rhs, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ bool operator==(const FileSpec &rhs) const;
+
+ //------------------------------------------------------------------
+ /// Not equal to operator
+ ///
+ /// Tests if this object is not equal to \a rhs.
+ ///
+ /// @param[in] rhs
+ /// A const FileSpec object reference to compare this object
+ /// to.
+ ///
+ /// @return
+ /// \b true if this object is equal to \a rhs, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ bool operator!=(const FileSpec &rhs) const;
+
+ //------------------------------------------------------------------
+ /// Less than to operator
+ ///
+ /// Tests if this object is less than \a rhs.
+ ///
+ /// @param[in] rhs
+ /// A const FileSpec object reference to compare this object
+ /// to.
+ ///
+ /// @return
+ /// \b true if this object is less than \a rhs, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ bool operator<(const FileSpec &rhs) const;
+
+ //------------------------------------------------------------------
+ /// Convert to pointer operator.
+ ///
+ /// This allows code to check a FileSpec object to see if it
+ /// contains anything valid using code such as:
+ ///
+ /// @code
+ /// FileSpec file_spec(...);
+ /// if (file_spec)
+ /// { ...
+ /// @endcode
+ ///
+ /// @return
+ /// A pointer to this object if either the directory or filename
+ /// is valid, nullptr otherwise.
+ //------------------------------------------------------------------
+ explicit operator bool() const;
+
+ //------------------------------------------------------------------
+ /// Logical NOT operator.
+ ///
+ /// This allows code to check a FileSpec object to see if it is
+ /// invalid using code such as:
+ ///
+ /// @code
+ /// FileSpec file_spec(...);
+ /// if (!file_spec)
+ /// { ...
+ /// @endcode
+ ///
+ /// @return
+ /// Returns \b true if the object has an empty directory and
+ /// filename, \b false otherwise.
+ //------------------------------------------------------------------
+ bool operator!() const;
+
+ //------------------------------------------------------------------
+ /// Clears the object state.
+ ///
+ /// Clear this object by releasing both the directory and filename
+ /// string values and reverting them to empty strings.
+ //------------------------------------------------------------------
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Compare two FileSpec objects.
+ ///
+ /// If \a full is true, then both the directory and the filename
+ /// must match. If \a full is false, then the directory names for
+ /// \a lhs and \a rhs are only compared if they are both not empty.
+ /// This allows a FileSpec object to only contain a filename
+ /// and it can match FileSpec objects that have matching
+ /// filenames with different paths.
+ ///
+ /// @param[in] lhs
+ /// A const reference to the Left Hand Side object to compare.
+ ///
+ /// @param[in] rhs
+ /// A const reference to the Right Hand Side object to compare.
+ ///
+ /// @param[in] full
+ /// If true, then both the directory and filenames will have to
+ /// match for a compare to return zero (equal to). If false
+ /// and either directory from \a lhs or \a rhs is empty, then
+ /// only the filename will be compared, else a full comparison
+ /// is done.
+ ///
+ /// @return
+ /// @li -1 if \a lhs is less than \a rhs
+ /// @li 0 if \a lhs is equal to \a rhs
+ /// @li 1 if \a lhs is greater than \a rhs
+ //------------------------------------------------------------------
+ static int Compare(const FileSpec &lhs, const FileSpec &rhs, bool full);
+
+ static bool Equal(const FileSpec &a, const FileSpec &b, bool full,
+ bool remove_backups = false);
+
+ //------------------------------------------------------------------
+ /// Case sensitivity of path.
+ ///
+ /// @return
+ /// \b true if the file path is case sensitive (POSIX), false
+ /// if case insensitive (Windows).
+ //------------------------------------------------------------------
+ bool IsCaseSensitive() const { return m_syntax != ePathSyntaxWindows; }
+
+ //------------------------------------------------------------------
+ /// Dump this object to a Stream.
+ ///
+ /// Dump the object to the supplied stream \a s. If the object
+ /// contains a valid directory name, it will be displayed followed
+ /// by a directory delimiter, and the filename.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ //------------------------------------------------------------------
+ void Dump(Stream *s) const;
+
+ //------------------------------------------------------------------
+ /// Existence test.
+ ///
+ /// @return
+ /// \b true if the file exists on disk, \b false otherwise.
+ //------------------------------------------------------------------
+ bool Exists() const;
+
+ //------------------------------------------------------------------
+ /// Check if a file is readable by the current user
+ ///
+ /// @return
+ /// \b true if the file exists on disk and is readable, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ bool Readable() const;
+
+ //------------------------------------------------------------------
+ /// Expanded existence test.
+ ///
+ /// Call into the Host to see if it can help find the file (e.g. by
+ /// searching paths set in the environment, etc.).
+ ///
+ /// If found, sets the value of m_directory to the directory where
+ /// the file was found.
+ ///
+ /// @return
+ /// \b true if was able to find the file using expanded search
+ /// methods, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ResolveExecutableLocation();
+
+ //------------------------------------------------------------------
+ /// Canonicalize this file path (basically running the static
+ /// FileSpec::Resolve method on it). Useful if you asked us not to
+ /// resolve the file path when you set the file.
+ //------------------------------------------------------------------
+ bool ResolvePath();
+
+ uint64_t GetByteSize() const;
+
+ PathSyntax GetPathSyntax() const;
+
+ //------------------------------------------------------------------
+ /// Directory string get accessor.
+ ///
+ /// @return
+ /// A reference to the directory string object.
+ //------------------------------------------------------------------
+ ConstString &GetDirectory();
+
+ //------------------------------------------------------------------
+ /// Directory string const get accessor.
+ ///
+ /// @return
+ /// A const reference to the directory string object.
+ //------------------------------------------------------------------
+ const ConstString &GetDirectory() const;
+
+ //------------------------------------------------------------------
+ /// Filename string get accessor.
+ ///
+ /// @return
+ /// A reference to the filename string object.
+ //------------------------------------------------------------------
+ ConstString &GetFilename();
+
+ //------------------------------------------------------------------
+ /// Filename string const get accessor.
+ ///
+ /// @return
+ /// A const reference to the filename string object.
+ //------------------------------------------------------------------
+ const ConstString &GetFilename() const;
+
+ //------------------------------------------------------------------
+ /// Returns true if the filespec represents an implementation source
+ /// file (files with a ".c", ".cpp", ".m", ".mm" (many more)
+ /// extension).
+ ///
+ /// @return
+ /// \b true if the filespec represents an implementation source
+ /// file, \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsSourceImplementationFile() const;
+
+ //------------------------------------------------------------------
+ /// Returns true if the filespec represents a relative path.
+ ///
+ /// @return
+ /// \b true if the filespec represents a relative path,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsRelative() const;
+
+ //------------------------------------------------------------------
+ /// Returns true if the filespec represents an absolute path.
+ ///
+ /// @return
+ /// \b true if the filespec represents an absolute path,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsAbsolute() const;
+
+ //------------------------------------------------------------------
+ /// Extract the full path to the file.
+ ///
+ /// Extract the directory and path into a fixed buffer. This is
+ /// needed as the directory and path are stored in separate string
+ /// values.
+ ///
+ /// @param[out] path
+ /// The buffer in which to place the extracted full path.
+ ///
+ /// @param[in] max_path_length
+ /// The maximum length of \a path.
+ ///
+ /// @return
+ /// Returns the number of characters that would be needed to
+ /// properly copy the full path into \a path. If the returned
+ /// number is less than \a max_path_length, then the path is
+ /// properly copied and terminated. If the return value is
+ /// >= \a max_path_length, then the path was truncated (but is
+ /// still NULL terminated).
+ //------------------------------------------------------------------
+ size_t GetPath(char *path, size_t max_path_length,
+ bool denormalize = true) const;
+
+ //------------------------------------------------------------------
+ /// Extract the full path to the file.
+ ///
+ /// Extract the directory and path into a std::string, which is returned.
+ ///
+ /// @return
+ /// Returns a std::string with the directory and filename
+ /// concatenated.
+ //------------------------------------------------------------------
+ std::string GetPath(bool denormalize = true) const;
+
+ const char *GetCString(bool denormalize = true) const;
+
+ //------------------------------------------------------------------
+ /// Extract the full path to the file.
+ ///
+ /// Extract the directory and path into an llvm::SmallVectorImpl<>
+ ///
+ /// @return
+ /// Returns a std::string with the directory and filename
+ /// concatenated.
+ //------------------------------------------------------------------
+ void GetPath(llvm::SmallVectorImpl<char> &path,
+ bool denormalize = true) const;
+
+ //------------------------------------------------------------------
+ /// Extract the extension of the file.
+ ///
+ /// Returns a ConstString that represents the extension of the filename
+ /// for this FileSpec object. If this object does not represent a file,
+ /// or the filename has no extension, ConstString(nullptr) is returned.
+ /// The dot ('.') character is not returned as part of the extension
+ ///
+ /// @return
+ /// Returns the extension of the file as a ConstString object.
+ //------------------------------------------------------------------
+ ConstString GetFileNameExtension() const;
+
+ //------------------------------------------------------------------
+ /// Return the filename without the extension part
+ ///
+ /// Returns a ConstString that represents the filename of this object
+ /// without the extension part (e.g. for a file named "foo.bar", "foo"
+ /// is returned)
+ ///
+ /// @return
+ /// Returns the filename without extension
+ /// as a ConstString object.
+ //------------------------------------------------------------------
+ ConstString GetFileNameStrippingExtension() const;
+
+ FileType GetFileType() const;
+
+ //------------------------------------------------------------------
+ /// Return the current permissions of the path.
+ ///
+ /// Returns a bitmask for the current permissions of the file
+ /// ( zero or more of the permission bits defined in
+ /// File::Permissions).
+ ///
+ /// @return
+ /// Zero if the file doesn't exist or we are unable to get
+ /// information for the file, otherwise one or more permission
+ /// bits from the File::Permissions enumeration.
+ //------------------------------------------------------------------
+ uint32_t GetPermissions() const;
+
+ bool IsDirectory() const {
+ return GetFileType() == FileSpec::eFileTypeDirectory;
+ }
+
+ bool IsPipe() const { return GetFileType() == FileSpec::eFileTypePipe; }
+
+ bool IsRegularFile() const {
+ return GetFileType() == FileSpec::eFileTypeRegular;
+ }
+
+ bool IsSocket() const { return GetFileType() == FileSpec::eFileTypeSocket; }
+
+ bool IsSymbolicLink() const;
+
+ //------------------------------------------------------------------
+ /// Get the memory cost of this object.
+ ///
+ /// Return the size in bytes that this object takes in memory. This
+ /// returns the size in bytes of this object, not any shared string
+ /// values it may refer to.
+ ///
+ /// @return
+ /// The number of bytes that this object occupies in memory.
+ ///
+ /// @see ConstString::StaticMemorySize ()
+ //------------------------------------------------------------------
+ size_t MemorySize() const;
+
+ //------------------------------------------------------------------
+ /// Memory map part of, or the entire contents of, a file.
+ ///
+ /// Returns a shared pointer to a data buffer that contains all or
+ /// part of the contents of a file. The data is memory mapped and
+ /// will lazily page in data from the file as memory is accessed.
+ /// The data that is mapped will start \a offset bytes into the
+ /// file, and \a length bytes will be mapped. If \a length is
+ /// greater than the number of bytes available in the file starting
+ /// at \a offset, the number of bytes will be appropriately
+ /// truncated. The final number of bytes that get mapped can be
+ /// verified using the DataBuffer::GetByteSize() function on the return
+ /// shared data pointer object contents.
+ ///
+ /// @param[in] offset
+ /// The offset in bytes from the beginning of the file where
+ /// memory mapping should begin.
+ ///
+ /// @param[in] length
+ /// The size in bytes that should be mapped starting \a offset
+ /// bytes into the file. If \a length is \c SIZE_MAX, map
+ /// as many bytes as possible.
+ ///
+ /// @return
+ /// A shared pointer to the memory mapped data. This shared
+ /// pointer can contain a nullptr DataBuffer pointer, so the contained
+ /// pointer must be checked prior to using it.
+ //------------------------------------------------------------------
+ lldb::DataBufferSP MemoryMapFileContents(off_t offset = 0,
+ size_t length = SIZE_MAX) const;
+
+ //------------------------------------------------------------------
+ /// Memory map part of, or the entire contents of, a file only if
+ /// the file is local (not on a network mount).
+ ///
+ /// Returns a shared pointer to a data buffer that contains all or
+ /// part of the contents of a file. The data will be memory mapped
+ /// if the file is local and will lazily page in data from the file
+ /// as memory is accessed. If the data is memory mapped, the data
+ /// that is mapped will start \a offset bytes into the file, and
+ /// \a length bytes will be mapped. If \a length is
+ /// greater than the number of bytes available in the file starting
+ /// at \a offset, the number of bytes will be appropriately
+ /// truncated. The final number of bytes that get mapped can be
+ /// verified using the DataBuffer::GetByteSize() function on the return
+ /// shared data pointer object contents.
+ ///
+ /// If the file is on a network mount the data will be read into a
+ /// heap buffer immediately so that accesses to the data won't later
+ /// cause a crash if we touch a page that isn't paged in and the
+ /// network mount has been disconnected or gone away.
+ ///
+ /// @param[in] offset
+ /// The offset in bytes from the beginning of the file where
+ /// memory mapping should begin.
+ ///
+ /// @param[in] length
+ /// The size in bytes that should be mapped starting \a offset
+ /// bytes into the file. If \a length is \c SIZE_MAX, map
+ /// as many bytes as possible.
+ ///
+ /// @return
+ /// A shared pointer to the memory mapped data. This shared
+ /// pointer can contain a nullptr DataBuffer pointer, so the contained
+ /// pointer must be checked prior to using it.
+ //------------------------------------------------------------------
+ lldb::DataBufferSP MemoryMapFileContentsIfLocal(off_t file_offset,
+ size_t file_size) const;
+
+ //------------------------------------------------------------------
+ /// Read part of, or the entire contents of, a file into a heap based data
+ /// buffer.
+ ///
+ /// Returns a shared pointer to a data buffer that contains all or
+ /// part of the contents of a file. The data copies into a heap based
+ /// buffer that lives in the DataBuffer shared pointer object returned.
+ /// The data that is cached will start \a offset bytes into the
+ /// file, and \a length bytes will be mapped. If \a length is
+ /// greater than the number of bytes available in the file starting
+ /// at \a offset, the number of bytes will be appropriately
+ /// truncated. The final number of bytes that get mapped can be
+ /// verified using the DataBuffer::GetByteSize() function.
+ ///
+ /// @param[in] offset
+ /// The offset in bytes from the beginning of the file where
+ /// memory mapping should begin.
+ ///
+ /// @param[in] length
+ /// The size in bytes that should be mapped starting \a offset
+ /// bytes into the file. If \a length is \c SIZE_MAX, map
+ /// as many bytes as possible.
+ ///
+ /// @return
+ /// A shared pointer to the memory mapped data. This shared
+ /// pointer can contain a nullptr DataBuffer pointer, so the contained
+ /// pointer must be checked prior to using it.
+ //------------------------------------------------------------------
+ lldb::DataBufferSP ReadFileContents(off_t offset = 0,
+ size_t length = SIZE_MAX,
+ Error *error_ptr = nullptr) const;
+
+ size_t ReadFileContents(off_t file_offset, void *dst, size_t dst_len,
+ Error *error_ptr) const;
+
+ //------------------------------------------------------------------
+ /// Read the entire contents of a file as data that can be used
+ /// as a C string.
+ ///
+ /// Read the entire contents of a file and ensure that the data
+ /// is NULL terminated so it can be used as a C string.
+ ///
+ /// @return
+ /// A shared pointer to the data. This shared pointer can
+ /// contain a nullptr DataBuffer pointer, so the contained pointer
+ /// must be checked prior to using it.
+ //------------------------------------------------------------------
+ lldb::DataBufferSP ReadFileContentsAsCString(Error *error_ptr = nullptr);
+
+ //------------------------------------------------------------------
+ /// Normalize a pathname by collapsing redundant separators and
+ /// up-level references.
+ //------------------------------------------------------------------
+ FileSpec GetNormalizedPath() const;
+
+ //------------------------------------------------------------------
+ /// Change the file specified with a new path.
+ ///
+ /// Update the contents of this object with a new path. The path will
+ /// be split up into a directory and filename and stored as uniqued
+ /// string values for quick comparison and efficient memory usage.
+ ///
+ /// @param[in] path
+ /// A full, partial, or relative path to a file.
+ ///
+ /// @param[in] resolve_path
+ /// If \b true, then we will try to resolve links the path using
+ /// the static FileSpec::Resolve.
+ //------------------------------------------------------------------
+ void SetFile(llvm::StringRef path, bool resolve_path,
+ PathSyntax syntax = ePathSyntaxHostNative);
+
+ void SetFile(llvm::StringRef path, bool resolve_path, ArchSpec arch);
+
+ bool IsResolved() const { return m_is_resolved; }
+
+ //------------------------------------------------------------------
+ /// Set if the file path has been resolved or not.
+ ///
+ /// If you know a file path is already resolved and avoided passing
+ /// a \b true parameter for any functions that take a "bool
+ /// resolve_path" parameter, you can set the value manually using
+ /// this call to make sure we don't try and resolve it later, or try
+ /// and resolve a path that has already been resolved.
+ ///
+ /// @param[in] is_resolved
+ /// A boolean value that will replace the current value that
+ /// indicates if the paths in this object have been resolved.
+ //------------------------------------------------------------------
+ void SetIsResolved(bool is_resolved) { m_is_resolved = is_resolved; }
+
+ //------------------------------------------------------------------
+ /// Read the file into an array of strings, one per line.
+ ///
+ /// Opens and reads the file in this object into an array of strings,
+ /// one string per line of the file. Returns a boolean indicating
+ /// success or failure.
+ ///
+ /// @param[out] lines
+ /// The string array into which to read the file.
+ ///
+ /// @result
+ /// Returns the number of lines that were read from the file.
+ //------------------------------------------------------------------
+ size_t ReadFileLines(STLStringArray &lines);
+
+ //------------------------------------------------------------------
+ /// Resolves user name and links in \a path, and overwrites the input
+ /// argument with the resolved path.
+ ///
+ /// @param[in] path
+ /// Input path to be resolved, in the form of a llvm::SmallString or
+ /// similar.
+ //------------------------------------------------------------------
+ static void Resolve(llvm::SmallVectorImpl<char> &path);
+
+ FileSpec CopyByAppendingPathComponent(llvm::StringRef component) const;
+ FileSpec CopyByRemovingLastPathComponent() const;
+
+ void PrependPathComponent(llvm::StringRef component);
+ void PrependPathComponent(const FileSpec &new_path);
+
+ void AppendPathComponent(llvm::StringRef component);
+ void AppendPathComponent(const FileSpec &new_path);
+
+ void RemoveLastPathComponent();
+
+ ConstString GetLastPathComponent() const;
+
+ //------------------------------------------------------------------
+ /// Resolves the user name at the beginning of \a src_path, and writes the
+ /// output
+ /// to \a dst_path. Note, \a src_path can contain other path components after
+ /// the
+ /// user name, they will be copied over, and if the path doesn't start with
+ /// "~" it
+ /// will also be copied over to \a dst_path.
+ ///
+ /// @param[in] src_path
+ /// Input path to be resolved.
+ ///
+ /// @param[in] dst_path
+ /// Buffer to store the resolved path.
+ //------------------------------------------------------------------
+ static void ResolveUsername(llvm::SmallVectorImpl<char> &path);
+
+ static size_t ResolvePartialUsername(llvm::StringRef partial_name,
+ StringList &matches);
+
+ enum EnumerateDirectoryResult {
+ eEnumerateDirectoryResultNext, // Enumerate next entry in the current
+ // directory
+ eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a
+ // directory or symlink, or next if not
+ eEnumerateDirectoryResultExit, // Exit from the current directory at the
+ // current level.
+ eEnumerateDirectoryResultQuit // Stop directory enumerations at any level
+ };
+
+ typedef EnumerateDirectoryResult (*EnumerateDirectoryCallbackType)(
+ void *baton, FileType file_type, const FileSpec &spec);
+
+ static EnumerateDirectoryResult
+ EnumerateDirectory(llvm::StringRef dir_path, bool find_directories,
+ bool find_files, bool find_other,
+ EnumerateDirectoryCallbackType callback,
+ void *callback_baton);
+
+ typedef std::function<EnumerateDirectoryResult(FileType file_type,
+ const FileSpec &spec)>
+ DirectoryCallback;
+
+ static EnumerateDirectoryResult
+ ForEachItemInDirectory(llvm::StringRef dir_path,
+ DirectoryCallback const &callback);
protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- ConstString m_directory; ///< The uniqued directory path
- ConstString m_filename; ///< The uniqued filename path
- mutable bool m_is_resolved; ///< True if this path has been resolved.
- PathSyntax m_syntax; ///< The syntax that this path uses (e.g. Windows / Posix)
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ ConstString m_directory; ///< The uniqued directory path
+ ConstString m_filename; ///< The uniqued filename path
+ mutable bool m_is_resolved = false; ///< True if this path has been resolved.
+ PathSyntax
+ m_syntax; ///< The syntax that this path uses (e.g. Windows / Posix)
};
//----------------------------------------------------------------------
/// Dump a FileSpec object to a stream
//----------------------------------------------------------------------
-Stream& operator << (Stream& s, const FileSpec& f);
+Stream &operator<<(Stream &s, const FileSpec &f);
} // namespace lldb_private
+namespace llvm {
+
+/// Implementation of format_provider<T> for FileSpec.
+///
+/// The options string of a FileSpec has the grammar:
+///
+/// file_spec_options :: (empty) | F | D
+///
+/// =======================================================
+/// | style | Meaning | Example |
+/// -------------------------------------------------------
+/// | | | Input | Output |
+/// =======================================================
+/// | F | Only print filename | /foo/bar | bar |
+/// | D | Only print directory | /foo/bar | /foo/ |
+/// | (empty) | Print file and dir | | |
+/// =======================================================
+///
+/// Any other value is considered an invalid format string.
+///
+template <> struct format_provider<lldb_private::FileSpec> {
+ static void format(const lldb_private::FileSpec &F, llvm::raw_ostream &Stream,
+ StringRef Style);
+};
+}
+
#endif // liblldb_FileSpec_h_
diff --git a/include/lldb/Host/FileSystem.h b/include/lldb/Host/FileSystem.h
index d656d2264f66..6dbea6d2cce3 100644
--- a/include/lldb/Host/FileSystem.h
+++ b/include/lldb/Host/FileSystem.h
@@ -10,67 +10,64 @@
#ifndef liblldb_Host_FileSystem_h
#define liblldb_Host_FileSystem_h
+#include "lldb/Core/Error.h"
+#include "lldb/Host/FileSpec.h"
+#include "llvm/Support/Chrono.h"
+
+#include "lldb/lldb-types.h"
+
#include <stdint.h>
#include <stdio.h>
#include <sys/stat.h>
-#include "lldb/lldb-types.h"
+namespace lldb_private {
+class FileSystem {
+public:
+ static const char *DEV_NULL;
+ static const char *PATH_CONVERSION_ERROR;
-#include "lldb/Core/Error.h"
-#include "lldb/Host/FileSpec.h"
+ static FileSpec::PathSyntax GetNativePathSyntax();
+
+ static Error MakeDirectory(const FileSpec &file_spec, uint32_t mode);
+ static Error DeleteDirectory(const FileSpec &file_spec, bool recurse);
+
+ static Error GetFilePermissions(const FileSpec &file_spec,
+ uint32_t &file_permissions);
+ static Error SetFilePermissions(const FileSpec &file_spec,
+ uint32_t file_permissions);
+ static lldb::user_id_t GetFileSize(const FileSpec &file_spec);
+ static bool GetFileExists(const FileSpec &file_spec);
+
+ static Error Hardlink(const FileSpec &src, const FileSpec &dst);
+ static int GetHardlinkCount(const FileSpec &file_spec);
+ static Error Symlink(const FileSpec &src, const FileSpec &dst);
+ static Error Readlink(const FileSpec &src, FileSpec &dst);
+ static Error Unlink(const FileSpec &file_spec);
+
+ static Error ResolveSymbolicLink(const FileSpec &src, FileSpec &dst);
+
+ static bool CalculateMD5(const FileSpec &file_spec, uint64_t &low,
+ uint64_t &high);
+ static bool CalculateMD5(const FileSpec &file_spec, uint64_t offset,
+ uint64_t length, uint64_t &low, uint64_t &high);
+
+ static bool CalculateMD5AsString(const FileSpec &file_spec,
+ std::string &digest_str);
+ static bool CalculateMD5AsString(const FileSpec &file_spec, uint64_t offset,
+ uint64_t length, std::string &digest_str);
+
+ /// Return \b true if \a spec is on a locally mounted file system, \b false
+ /// otherwise.
+ static bool IsLocal(const FileSpec &spec);
+
+ /// Wraps ::fopen in a platform-independent way. Once opened, FILEs can be
+ /// manipulated and closed with the normal ::fread, ::fclose, etc. functions.
+ static FILE *Fopen(const char *path, const char *mode);
+
+ /// Wraps ::stat in a platform-independent way.
+ static int Stat(const char *path, struct stat *stats);
-namespace lldb_private
-{
-class FileSystem
-{
- public:
- static const char *DEV_NULL;
- static const char *PATH_CONVERSION_ERROR;
-
- static FileSpec::PathSyntax GetNativePathSyntax();
-
- static Error MakeDirectory(const FileSpec &file_spec, uint32_t mode);
- static Error DeleteDirectory(const FileSpec &file_spec, bool recurse);
-
- static Error GetFilePermissions(const FileSpec &file_spec,
- uint32_t &file_permissions);
- static Error SetFilePermissions(const FileSpec &file_spec,
- uint32_t file_permissions);
- static lldb::user_id_t GetFileSize(const FileSpec &file_spec);
- static bool GetFileExists(const FileSpec &file_spec);
-
- static Error Hardlink(const FileSpec &src, const FileSpec &dst);
- static int GetHardlinkCount(const FileSpec &file_spec);
- static Error Symlink(const FileSpec &src, const FileSpec &dst);
- static Error Readlink(const FileSpec &src, FileSpec &dst);
- static Error Unlink(const FileSpec &file_spec);
-
- static Error ResolveSymbolicLink(const FileSpec &src, FileSpec &dst);
-
- static bool CalculateMD5(const FileSpec &file_spec, uint64_t &low, uint64_t &high);
- static bool CalculateMD5(const FileSpec &file_spec,
- uint64_t offset,
- uint64_t length,
- uint64_t &low,
- uint64_t &high);
-
- static bool CalculateMD5AsString(const FileSpec &file_spec, std::string& digest_str);
- static bool CalculateMD5AsString(const FileSpec &file_spec,
- uint64_t offset,
- uint64_t length,
- std::string& digest_str);
-
- /// Return \b true if \a spec is on a locally mounted file system, \b false otherwise.
- static bool IsLocal(const FileSpec &spec);
-
- /// Wraps ::fopen in a platform-independent way. Once opened, FILEs can be
- /// manipulated and closed with the normal ::fread, ::fclose, etc. functions.
- static FILE *
- Fopen(const char *path, const char *mode);
-
- /// Wraps ::stat in a platform-independent way.
- static int
- Stat(const char *path, struct stat *stats);
+ static llvm::sys::TimePoint<> GetModificationTime(const FileSpec &file_spec);
};
}
diff --git a/include/lldb/Host/Host.h b/include/lldb/Host/Host.h
index 6a6b2265257a..64c0dd6cef6b 100644
--- a/include/lldb/Host/Host.h
+++ b/include/lldb/Host/Host.h
@@ -16,12 +16,12 @@
#include <map>
#include <string>
-#include "lldb/lldb-private.h"
-#include "lldb/lldb-private-forward.h"
#include "lldb/Core/StringList.h"
#include "lldb/Host/File.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/HostThread.h"
+#include "lldb/lldb-private-forward.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -35,258 +35,228 @@ class ProcessLaunchInfo;
/// Host is a class that answers information about the host operating
/// system.
//----------------------------------------------------------------------
-class Host
-{
+class Host {
public:
- typedef std::function<bool(lldb::pid_t pid, bool exited,
- int signal, // Zero for no signal
- int status)> // Exit value of process if signal is zero
- MonitorChildProcessCallback;
-
- //------------------------------------------------------------------
- /// Start monitoring a child process.
- ///
- /// Allows easy monitoring of child processes. \a callback will be
- /// called when the child process exits or if it gets a signal. The
- /// callback will only be called with signals if \a monitor_signals
- /// is \b true. \a callback will usually be called from another
- /// thread so the callback function must be thread safe.
- ///
- /// When the callback gets called, the return value indicates if
- /// monitoring should stop. If \b true is returned from \a callback
- /// the information will be removed. If \b false is returned then
- /// monitoring will continue. If the child process exits, the
- /// monitoring will automatically stop after the callback returned
- /// regardless of the callback return value.
- ///
- /// @param[in] callback
- /// A function callback to call when a child receives a signal
- /// (if \a monitor_signals is true) or a child exits.
- ///
- /// @param[in] pid
- /// The process ID of a child process to monitor, -1 for all
- /// processes.
- ///
- /// @param[in] monitor_signals
- /// If \b true the callback will get called when the child
- /// process gets a signal. If \b false, the callback will only
- /// get called if the child process exits.
- ///
- /// @return
- /// A thread handle that can be used to cancel the thread that
- /// was spawned to monitor \a pid.
- ///
- /// @see static void Host::StopMonitoringChildProcess (uint32_t)
- //------------------------------------------------------------------
- static HostThread
- StartMonitoringChildProcess(const MonitorChildProcessCallback &callback, lldb::pid_t pid, bool monitor_signals);
-
- enum SystemLogType
- {
- eSystemLogWarning,
- eSystemLogError
- };
-
- static void
- SystemLog (SystemLogType type, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
-
- static void
- SystemLog (SystemLogType type, const char *format, va_list args);
-
- //------------------------------------------------------------------
- /// Get the process ID for the calling process.
- ///
- /// @return
- /// The process ID for the current process.
- //------------------------------------------------------------------
- static lldb::pid_t
- GetCurrentProcessID ();
-
- static void
- Kill(lldb::pid_t pid, int signo);
-
- //------------------------------------------------------------------
- /// Get the thread ID for the calling thread in the current process.
- ///
- /// @return
- /// The thread ID for the calling thread in the current process.
- //------------------------------------------------------------------
- static lldb::tid_t
- GetCurrentThreadID ();
-
- //------------------------------------------------------------------
- /// Get the thread token (the one returned by ThreadCreate when the thread was created) for the
- /// calling thread in the current process.
- ///
- /// @return
- /// The thread token for the calling thread in the current process.
- //------------------------------------------------------------------
- static lldb::thread_t
- GetCurrentThread ();
-
- static const char *
- GetSignalAsCString (int signo);
-
- typedef void (*ThreadLocalStorageCleanupCallback) (void *p);
-
- static lldb::thread_key_t
- ThreadLocalStorageCreate(ThreadLocalStorageCleanupCallback callback);
-
- static void*
- ThreadLocalStorageGet(lldb::thread_key_t key);
-
- static void
- ThreadLocalStorageSet(lldb::thread_key_t key, void *value);
-
-
- //------------------------------------------------------------------
- /// Given an address in the current process (the process that
- /// is running the LLDB code), return the name of the module that
- /// it comes from. This can be useful when you need to know the
- /// path to the shared library that your code is running in for
- /// loading resources that are relative to your binary.
- ///
- /// @param[in] host_addr
- /// The pointer to some code in the current process.
- ///
- /// @return
- /// \b A file spec with the module that contains \a host_addr,
- /// which may be invalid if \a host_addr doesn't fall into
- /// any valid module address range.
- //------------------------------------------------------------------
- static FileSpec
- GetModuleFileSpecForHostAddress (const void *host_addr);
-
- //------------------------------------------------------------------
- /// If you have an executable that is in a bundle and want to get
- /// back to the bundle directory from the path itself, this
- /// function will change a path to a file within a bundle to the
- /// bundle directory itself.
- ///
- /// @param[in] file
- /// A file spec that might point to a file in a bundle.
- ///
- /// @param[out] bundle_directory
- /// An object will be filled in with the bundle directory for
- /// the bundle when \b true is returned. Otherwise \a file is
- /// left untouched and \b false is returned.
- ///
- /// @return
- /// \b true if \a file was resolved in \a bundle_directory,
- /// \b false otherwise.
- //------------------------------------------------------------------
- static bool
- GetBundleDirectory (const FileSpec &file, FileSpec &bundle_directory);
-
- //------------------------------------------------------------------
- /// When executable files may live within a directory, where the
- /// directory represents an executable bundle (like the MacOSX
- /// app bundles), then locate the executable within the containing
- /// bundle.
- ///
- /// @param[in,out] file
- /// A file spec that currently points to the bundle that will
- /// be filled in with the executable path within the bundle
- /// if \b true is returned. Otherwise \a file is left untouched.
- ///
- /// @return
- /// \b true if \a file was resolved, \b false if this function
- /// was not able to resolve the path.
- //------------------------------------------------------------------
- static bool
- ResolveExecutableInBundle (FileSpec &file);
-
- //------------------------------------------------------------------
- /// Set a string that can be displayed if host application crashes.
- ///
- /// Some operating systems have the ability to print a description
- /// for shared libraries when a program crashes. If the host OS
- /// supports such a mechanism, it should be implemented to help
- /// with crash triage.
- ///
- /// @param[in] format
- /// A printf format that will be used to form a new crash
- /// description string.
- //------------------------------------------------------------------
- static void
- SetCrashDescriptionWithFormat (const char *format, ...) __attribute__ ((format (printf, 1, 2)));
-
- static void
- SetCrashDescription (const char *description);
-
- static uint32_t
- FindProcesses (const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &proc_infos);
-
- typedef std::map<lldb::pid_t, bool> TidMap;
- typedef std::pair<lldb::pid_t, bool> TidPair;
- static bool
- FindProcessThreads (const lldb::pid_t pid, TidMap &tids_to_attach);
-
- static bool
- GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &proc_info);
-
-#if defined (__APPLE__) || defined (__linux__) || defined (__FreeBSD__) || defined (__GLIBC__) || defined (__NetBSD__)
-#if !defined(__ANDROID__) && !defined(__ANDROID_NDK__)
-
- static short GetPosixspawnFlags(const ProcessLaunchInfo &launch_info);
-
- static Error LaunchProcessPosixSpawn(const char *exe_path, const ProcessLaunchInfo &launch_info, lldb::pid_t &pid);
-
- static bool AddPosixSpawnFileAction(void *file_actions, const FileAction *info, Log *log, Error &error);
-
-#endif // !defined(__ANDROID__) && !defined(__ANDROID_NDK__)
-#endif // defined (__APPLE__) || defined (__linux__) || defined (__FreeBSD__) || defined (__GLIBC__) || defined(__NetBSD__)
-
- static const lldb::UnixSignalsSP &
- GetUnixSignals();
-
- static Error
- LaunchProcess (ProcessLaunchInfo &launch_info);
-
- //------------------------------------------------------------------
- /// Perform expansion of the command-line for this launch info
- /// This can potentially involve wildcard expansion
- // environment variable replacement, and whatever other
- // argument magic the platform defines as part of its typical
- // user experience
- //------------------------------------------------------------------
- static Error
- ShellExpandArguments (ProcessLaunchInfo &launch_info);
-
- static Error
- RunShellCommand(const char *command, // Shouldn't be NULL
- const FileSpec &working_dir, // Pass empty FileSpec to use the current working directory
- int *status_ptr, // Pass NULL if you don't want the process exit status
- int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit
- std::string *command_output, // Pass NULL if you don't want the command output
- uint32_t timeout_sec,
- bool run_in_default_shell = true);
-
- static Error
- RunShellCommand(const Args& args,
- const FileSpec &working_dir, // Pass empty FileSpec to use the current working directory
- int *status_ptr, // Pass NULL if you don't want the process exit status
- int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit
- std::string *command_output, // Pass NULL if you don't want the command output
- uint32_t timeout_sec,
- bool run_in_default_shell = true);
-
- static lldb::DataBufferSP
- GetAuxvData (lldb_private::Process *process);
-
- static lldb::DataBufferSP
- GetAuxvData (lldb::pid_t pid);
-
- static bool
- OpenFileInExternalEditor (const FileSpec &file_spec,
- uint32_t line_no);
-
- static size_t
- GetEnvironment (StringList &env);
+ typedef std::function<bool(
+ lldb::pid_t pid, bool exited,
+ int signal, // Zero for no signal
+ int status)> // Exit value of process if signal is zero
+ MonitorChildProcessCallback;
+
+ //------------------------------------------------------------------
+ /// Start monitoring a child process.
+ ///
+ /// Allows easy monitoring of child processes. \a callback will be
+ /// called when the child process exits or if it gets a signal. The
+ /// callback will only be called with signals if \a monitor_signals
+ /// is \b true. \a callback will usually be called from another
+ /// thread so the callback function must be thread safe.
+ ///
+ /// When the callback gets called, the return value indicates if
+ /// monitoring should stop. If \b true is returned from \a callback
+ /// the information will be removed. If \b false is returned then
+ /// monitoring will continue. If the child process exits, the
+ /// monitoring will automatically stop after the callback returned
+ /// regardless of the callback return value.
+ ///
+ /// @param[in] callback
+ /// A function callback to call when a child receives a signal
+ /// (if \a monitor_signals is true) or a child exits.
+ ///
+ /// @param[in] pid
+ /// The process ID of a child process to monitor, -1 for all
+ /// processes.
+ ///
+ /// @param[in] monitor_signals
+ /// If \b true the callback will get called when the child
+ /// process gets a signal. If \b false, the callback will only
+ /// get called if the child process exits.
+ ///
+ /// @return
+ /// A thread handle that can be used to cancel the thread that
+ /// was spawned to monitor \a pid.
+ ///
+ /// @see static void Host::StopMonitoringChildProcess (uint32_t)
+ //------------------------------------------------------------------
+ static HostThread
+ StartMonitoringChildProcess(const MonitorChildProcessCallback &callback,
+ lldb::pid_t pid, bool monitor_signals);
+
+ enum SystemLogType { eSystemLogWarning, eSystemLogError };
+
+ static void SystemLog(SystemLogType type, const char *format, ...)
+ __attribute__((format(printf, 2, 3)));
+
+ static void SystemLog(SystemLogType type, const char *format, va_list args);
+
+ //------------------------------------------------------------------
+ /// Get the process ID for the calling process.
+ ///
+ /// @return
+ /// The process ID for the current process.
+ //------------------------------------------------------------------
+ static lldb::pid_t GetCurrentProcessID();
+
+ static void Kill(lldb::pid_t pid, int signo);
+
+ //------------------------------------------------------------------
+ /// Get the thread ID for the calling thread in the current process.
+ ///
+ /// @return
+ /// The thread ID for the calling thread in the current process.
+ //------------------------------------------------------------------
+ static lldb::tid_t GetCurrentThreadID();
+
+ //------------------------------------------------------------------
+ /// Get the thread token (the one returned by ThreadCreate when the thread was
+ /// created) for the
+ /// calling thread in the current process.
+ ///
+ /// @return
+ /// The thread token for the calling thread in the current process.
+ //------------------------------------------------------------------
+ static lldb::thread_t GetCurrentThread();
+
+ static const char *GetSignalAsCString(int signo);
+
+ typedef void (*ThreadLocalStorageCleanupCallback)(void *p);
+
+ static lldb::thread_key_t
+ ThreadLocalStorageCreate(ThreadLocalStorageCleanupCallback callback);
+
+ static void *ThreadLocalStorageGet(lldb::thread_key_t key);
+
+ static void ThreadLocalStorageSet(lldb::thread_key_t key, void *value);
+
+ //------------------------------------------------------------------
+ /// Given an address in the current process (the process that
+ /// is running the LLDB code), return the name of the module that
+ /// it comes from. This can be useful when you need to know the
+ /// path to the shared library that your code is running in for
+ /// loading resources that are relative to your binary.
+ ///
+ /// @param[in] host_addr
+ /// The pointer to some code in the current process.
+ ///
+ /// @return
+ /// \b A file spec with the module that contains \a host_addr,
+ /// which may be invalid if \a host_addr doesn't fall into
+ /// any valid module address range.
+ //------------------------------------------------------------------
+ static FileSpec GetModuleFileSpecForHostAddress(const void *host_addr);
+
+ //------------------------------------------------------------------
+ /// If you have an executable that is in a bundle and want to get
+ /// back to the bundle directory from the path itself, this
+ /// function will change a path to a file within a bundle to the
+ /// bundle directory itself.
+ ///
+ /// @param[in] file
+ /// A file spec that might point to a file in a bundle.
+ ///
+ /// @param[out] bundle_directory
+ /// An object will be filled in with the bundle directory for
+ /// the bundle when \b true is returned. Otherwise \a file is
+ /// left untouched and \b false is returned.
+ ///
+ /// @return
+ /// \b true if \a file was resolved in \a bundle_directory,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ static bool GetBundleDirectory(const FileSpec &file,
+ FileSpec &bundle_directory);
+
+ //------------------------------------------------------------------
+ /// When executable files may live within a directory, where the
+ /// directory represents an executable bundle (like the MacOSX
+ /// app bundles), then locate the executable within the containing
+ /// bundle.
+ ///
+ /// @param[in,out] file
+ /// A file spec that currently points to the bundle that will
+ /// be filled in with the executable path within the bundle
+ /// if \b true is returned. Otherwise \a file is left untouched.
+ ///
+ /// @return
+ /// \b true if \a file was resolved, \b false if this function
+ /// was not able to resolve the path.
+ //------------------------------------------------------------------
+ static bool ResolveExecutableInBundle(FileSpec &file);
+
+ static uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &proc_infos);
+
+ typedef std::map<lldb::pid_t, bool> TidMap;
+ typedef std::pair<lldb::pid_t, bool> TidPair;
+ static bool FindProcessThreads(const lldb::pid_t pid, TidMap &tids_to_attach);
+
+ static bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info);
+
+#if (defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) || \
+ defined(__GLIBC__) || defined(__NetBSD__)) && \
+ !defined(__ANDROID__)
+
+ static short GetPosixspawnFlags(const ProcessLaunchInfo &launch_info);
+
+ static Error LaunchProcessPosixSpawn(const char *exe_path,
+ const ProcessLaunchInfo &launch_info,
+ lldb::pid_t &pid);
+
+ static bool AddPosixSpawnFileAction(void *file_actions,
+ const FileAction *info, Log *log,
+ Error &error);
+
+#endif
+
+ static const lldb::UnixSignalsSP &GetUnixSignals();
+
+ static Error LaunchProcess(ProcessLaunchInfo &launch_info);
+
+ //------------------------------------------------------------------
+ /// Perform expansion of the command-line for this launch info
+ /// This can potentially involve wildcard expansion
+ // environment variable replacement, and whatever other
+ // argument magic the platform defines as part of its typical
+ // user experience
+ //------------------------------------------------------------------
+ static Error ShellExpandArguments(ProcessLaunchInfo &launch_info);
+
+ // TODO: Convert this function to take a StringRef.
+ static Error RunShellCommand(
+ const char *command, // Shouldn't be NULL
+ const FileSpec &working_dir, // Pass empty FileSpec to use the current
+ // working directory
+ int *status_ptr, // Pass NULL if you don't want the process exit status
+ int *signo_ptr, // Pass NULL if you don't want the signal that caused the
+ // process to exit
+ std::string
+ *command_output, // Pass NULL if you don't want the command output
+ uint32_t timeout_sec,
+ bool run_in_default_shell = true);
+
+ static Error RunShellCommand(
+ const Args &args,
+ const FileSpec &working_dir, // Pass empty FileSpec to use the current
+ // working directory
+ int *status_ptr, // Pass NULL if you don't want the process exit status
+ int *signo_ptr, // Pass NULL if you don't want the signal that caused the
+ // process to exit
+ std::string
+ *command_output, // Pass NULL if you don't want the command output
+ uint32_t timeout_sec,
+ bool run_in_default_shell = true);
+
+ static lldb::DataBufferSP GetAuxvData(lldb_private::Process *process);
+
+ static lldb::DataBufferSP GetAuxvData(lldb::pid_t pid);
+
+ static bool OpenFileInExternalEditor(const FileSpec &file_spec,
+ uint32_t line_no);
+
+ static size_t GetEnvironment(StringList &env);
};
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif // liblldb_Host_h_
+#endif // #if defined(__cplusplus)
+#endif // liblldb_Host_h_
diff --git a/include/lldb/Host/HostGetOpt.h b/include/lldb/Host/HostGetOpt.h
index 6f512915d33c..d37a2526ff04 100644
--- a/include/lldb/Host/HostGetOpt.h
+++ b/include/lldb/Host/HostGetOpt.h
@@ -14,8 +14,8 @@
#define _BSD_SOURCE // Required so that getopt.h defines optreset
#endif
-#include <unistd.h>
#include <getopt.h>
+#include <unistd.h>
#else
diff --git a/include/lldb/Host/HostInfo.h b/include/lldb/Host/HostInfo.h
index 96094389c703..4646be2b9234 100644
--- a/include/lldb/Host/HostInfo.h
+++ b/include/lldb/Host/HostInfo.h
@@ -38,7 +38,7 @@
#include "lldb/Host/windows/HostInfoWindows.h"
#define HOST_INFO_TYPE HostInfoWindows
#elif defined(__linux__)
-#if defined(__ANDROID_NDK__)
+#if defined(__ANDROID__)
#include "lldb/Host/android/HostInfoAndroid.h"
#define HOST_INFO_TYPE HostInfoAndroid
#else
@@ -59,8 +59,7 @@
#define HOST_INFO_TYPE HostInfoPosix
#endif
-namespace lldb_private
-{
+namespace lldb_private {
typedef HOST_INFO_TYPE HostInfo;
}
diff --git a/include/lldb/Host/HostInfoBase.h b/include/lldb/Host/HostInfoBase.h
index 654c9683286b..74ac79b690b9 100644
--- a/include/lldb/Host/HostInfoBase.h
+++ b/include/lldb/Host/HostInfoBase.h
@@ -20,112 +20,113 @@
#include <string>
-namespace lldb_private
-{
+namespace lldb_private {
class FileSpec;
-class HostInfoBase
-{
- private:
- // Static class, unconstructable.
- HostInfoBase() {}
- ~HostInfoBase() {}
-
- public:
- static void Initialize();
- static void
- Terminate();
-
- //------------------------------------------------------------------
- /// Returns the number of CPUs on this current host.
- ///
- /// @return
- /// Number of CPUs on this current host, or zero if the number
- /// of CPUs can't be determined on this host.
- //------------------------------------------------------------------
- static uint32_t GetNumberCPUS();
-
- //------------------------------------------------------------------
- /// Returns the maximum length of a thread name on this platform.
- ///
- /// @return
- /// Maximum length of a thread name on this platform.
- //------------------------------------------------------------------
- static uint32_t GetMaxThreadNameLength();
-
- //------------------------------------------------------------------
- /// Gets the host vendor string.
- ///
- /// @return
- /// A const string object containing the host vendor name.
- //------------------------------------------------------------------
- static llvm::StringRef GetVendorString();
-
- //------------------------------------------------------------------
- /// Gets the host Operating System (OS) string.
- ///
- /// @return
- /// A const string object containing the host OS name.
- //------------------------------------------------------------------
- static llvm::StringRef GetOSString();
-
- //------------------------------------------------------------------
- /// Gets the host target triple as a const string.
- ///
- /// @return
- /// A const string object containing the host target triple.
- //------------------------------------------------------------------
- static llvm::StringRef GetTargetTriple();
-
- //------------------------------------------------------------------
- /// Gets the host architecture.
- ///
- /// @return
- /// A const architecture object that represents the host
- /// architecture.
- //------------------------------------------------------------------
- enum ArchitectureKind
- {
- eArchKindDefault, // The overall default architecture that applications will run on this host
- eArchKind32, // If this host supports 32 bit programs, return the default 32 bit arch
- eArchKind64 // If this host supports 64 bit programs, return the default 64 bit arch
- };
-
- static const ArchSpec &GetArchitecture(ArchitectureKind arch_kind = eArchKindDefault);
-
- //------------------------------------------------------------------
- /// Find a resource files that are related to LLDB.
- ///
- /// Operating systems have different ways of storing shared
- /// libraries and related resources. This function abstracts the
- /// access to these paths.
- ///
- /// @param[in] path_type
- /// The type of LLDB resource path you are looking for. If the
- /// enumeration ends with "Dir", then only the \a file_spec's
- /// directory member gets filled in.
- ///
- /// @param[in] file_spec
- /// A file spec that gets filled in with the appropriate path.
- ///
- /// @return
- /// \b true if \a resource_path was resolved, \a false otherwise.
- //------------------------------------------------------------------
- static bool GetLLDBPath(lldb::PathType type, FileSpec &file_spec);
-
- protected:
- static bool ComputeSharedLibraryDirectory(FileSpec &file_spec);
- static bool ComputeSupportExeDirectory(FileSpec &file_spec);
- static bool ComputeProcessTempFileDirectory(FileSpec &file_spec);
- static bool ComputeGlobalTempFileDirectory(FileSpec &file_spec);
- static bool ComputeTempFileBaseDirectory(FileSpec &file_spec);
- static bool ComputeHeaderDirectory(FileSpec &file_spec);
- static bool ComputeSystemPluginsDirectory(FileSpec &file_spec);
- static bool ComputeClangDirectory(FileSpec &file_spec);
- static bool ComputeUserPluginsDirectory(FileSpec &file_spec);
-
- static void ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64);
+class HostInfoBase {
+private:
+ // Static class, unconstructable.
+ HostInfoBase() {}
+ ~HostInfoBase() {}
+
+public:
+ static void Initialize();
+ static void Terminate();
+
+ //------------------------------------------------------------------
+ /// Returns the number of CPUs on this current host.
+ ///
+ /// @return
+ /// Number of CPUs on this current host, or zero if the number
+ /// of CPUs can't be determined on this host.
+ //------------------------------------------------------------------
+ static uint32_t GetNumberCPUS();
+
+ //------------------------------------------------------------------
+ /// Returns the maximum length of a thread name on this platform.
+ ///
+ /// @return
+ /// Maximum length of a thread name on this platform.
+ //------------------------------------------------------------------
+ static uint32_t GetMaxThreadNameLength();
+
+ //------------------------------------------------------------------
+ /// Gets the host vendor string.
+ ///
+ /// @return
+ /// A const string object containing the host vendor name.
+ //------------------------------------------------------------------
+ static llvm::StringRef GetVendorString();
+
+ //------------------------------------------------------------------
+ /// Gets the host Operating System (OS) string.
+ ///
+ /// @return
+ /// A const string object containing the host OS name.
+ //------------------------------------------------------------------
+ static llvm::StringRef GetOSString();
+
+ //------------------------------------------------------------------
+ /// Gets the host target triple as a const string.
+ ///
+ /// @return
+ /// A const string object containing the host target triple.
+ //------------------------------------------------------------------
+ static llvm::StringRef GetTargetTriple();
+
+ //------------------------------------------------------------------
+ /// Gets the host architecture.
+ ///
+ /// @return
+ /// A const architecture object that represents the host
+ /// architecture.
+ //------------------------------------------------------------------
+ enum ArchitectureKind {
+ eArchKindDefault, // The overall default architecture that applications will
+ // run on this host
+ eArchKind32, // If this host supports 32 bit programs, return the default 32
+ // bit arch
+ eArchKind64 // If this host supports 64 bit programs, return the default 64
+ // bit arch
+ };
+
+ static const ArchSpec &
+ GetArchitecture(ArchitectureKind arch_kind = eArchKindDefault);
+
+ //------------------------------------------------------------------
+ /// Find a resource files that are related to LLDB.
+ ///
+ /// Operating systems have different ways of storing shared
+ /// libraries and related resources. This function abstracts the
+ /// access to these paths.
+ ///
+ /// @param[in] path_type
+ /// The type of LLDB resource path you are looking for. If the
+ /// enumeration ends with "Dir", then only the \a file_spec's
+ /// directory member gets filled in.
+ ///
+ /// @param[in] file_spec
+ /// A file spec that gets filled in with the appropriate path.
+ ///
+ /// @return
+ /// \b true if \a resource_path was resolved, \a false otherwise.
+ //------------------------------------------------------------------
+ static bool GetLLDBPath(lldb::PathType type, FileSpec &file_spec);
+
+protected:
+ static bool ComputeSharedLibraryDirectory(FileSpec &file_spec);
+ static bool ComputeSupportExeDirectory(FileSpec &file_spec);
+ static bool ComputeProcessTempFileDirectory(FileSpec &file_spec);
+ static bool ComputeGlobalTempFileDirectory(FileSpec &file_spec);
+ static bool ComputeTempFileBaseDirectory(FileSpec &file_spec);
+ static bool ComputeHeaderDirectory(FileSpec &file_spec);
+ static bool ComputeSystemPluginsDirectory(FileSpec &file_spec);
+ static bool ComputeClangDirectory(FileSpec &file_spec);
+ static bool ComputeUserPluginsDirectory(FileSpec &file_spec);
+
+ static void ComputeHostArchitectureSupport(ArchSpec &arch_32,
+ ArchSpec &arch_64);
};
}
diff --git a/include/lldb/Host/HostNativeProcess.h b/include/lldb/Host/HostNativeProcess.h
index b48956436116..0aabfe197385 100644
--- a/include/lldb/Host/HostNativeProcess.h
+++ b/include/lldb/Host/HostNativeProcess.h
@@ -12,14 +12,12 @@
#if defined(_WIN32)
#include "lldb/Host/windows/HostProcessWindows.h"
-namespace lldb_private
-{
+namespace lldb_private {
typedef HostProcessWindows HostNativeProcess;
}
#else
#include "lldb/Host/posix/HostProcessPosix.h"
-namespace lldb_private
-{
+namespace lldb_private {
typedef HostProcessPosix HostNativeProcess;
}
#endif
diff --git a/include/lldb/Host/HostNativeProcessBase.h b/include/lldb/Host/HostNativeProcessBase.h
index d51161f1ef1b..204f78eab583 100644
--- a/include/lldb/Host/HostNativeProcessBase.h
+++ b/include/lldb/Host/HostNativeProcessBase.h
@@ -15,44 +15,34 @@
#include "lldb/lldb-defines.h"
#include "lldb/lldb-types.h"
-namespace lldb_private
-{
+namespace lldb_private {
class HostThread;
-class HostNativeProcessBase
-{
- DISALLOW_COPY_AND_ASSIGN(HostNativeProcessBase);
+class HostNativeProcessBase {
+ DISALLOW_COPY_AND_ASSIGN(HostNativeProcessBase);
- public:
- HostNativeProcessBase()
- : m_process(LLDB_INVALID_PROCESS)
- {
- }
- explicit HostNativeProcessBase(lldb::process_t process)
- : m_process(process)
- {}
- virtual ~HostNativeProcessBase() {}
+public:
+ HostNativeProcessBase() : m_process(LLDB_INVALID_PROCESS) {}
+ explicit HostNativeProcessBase(lldb::process_t process)
+ : m_process(process) {}
+ virtual ~HostNativeProcessBase() {}
- virtual Error Terminate() = 0;
- virtual Error GetMainModule(FileSpec &file_spec) const = 0;
+ virtual Error Terminate() = 0;
+ virtual Error GetMainModule(FileSpec &file_spec) const = 0;
- virtual lldb::pid_t GetProcessId() const = 0;
- virtual bool IsRunning() const = 0;
+ virtual lldb::pid_t GetProcessId() const = 0;
+ virtual bool IsRunning() const = 0;
- lldb::process_t
- GetSystemHandle() const
- {
- return m_process;
- }
+ lldb::process_t GetSystemHandle() const { return m_process; }
- virtual HostThread
- StartMonitoring(const Host::MonitorChildProcessCallback &callback, bool monitor_signals) = 0;
+ virtual HostThread
+ StartMonitoring(const Host::MonitorChildProcessCallback &callback,
+ bool monitor_signals) = 0;
protected:
- lldb::process_t m_process;
+ lldb::process_t m_process;
};
-
}
#endif
diff --git a/include/lldb/Host/HostNativeThreadBase.h b/include/lldb/Host/HostNativeThreadBase.h
index c89c6e16533e..284b754266fb 100644
--- a/include/lldb/Host/HostNativeThreadBase.h
+++ b/include/lldb/Host/HostNativeThreadBase.h
@@ -14,8 +14,7 @@
#include "lldb/lldb-defines.h"
#include "lldb/lldb-types.h"
-namespace lldb_private
-{
+namespace lldb_private {
#if defined(_WIN32)
#define THREAD_ROUTINE __stdcall
@@ -23,30 +22,30 @@ namespace lldb_private
#define THREAD_ROUTINE
#endif
-class HostNativeThreadBase
-{
- friend class ThreadLauncher;
- DISALLOW_COPY_AND_ASSIGN(HostNativeThreadBase);
+class HostNativeThreadBase {
+ friend class ThreadLauncher;
+ DISALLOW_COPY_AND_ASSIGN(HostNativeThreadBase);
- public:
- HostNativeThreadBase();
- explicit HostNativeThreadBase(lldb::thread_t thread);
- virtual ~HostNativeThreadBase() {}
+public:
+ HostNativeThreadBase();
+ explicit HostNativeThreadBase(lldb::thread_t thread);
+ virtual ~HostNativeThreadBase() {}
- virtual Error Join(lldb::thread_result_t *result) = 0;
- virtual Error Cancel() = 0;
- virtual bool IsJoinable() const;
- virtual void Reset();
- lldb::thread_t Release();
+ virtual Error Join(lldb::thread_result_t *result) = 0;
+ virtual Error Cancel() = 0;
+ virtual bool IsJoinable() const;
+ virtual void Reset();
+ lldb::thread_t Release();
- lldb::thread_t GetSystemHandle() const;
- lldb::thread_result_t GetResult() const;
+ lldb::thread_t GetSystemHandle() const;
+ lldb::thread_result_t GetResult() const;
- protected:
- static lldb::thread_result_t THREAD_ROUTINE ThreadCreateTrampoline(lldb::thread_arg_t arg);
+protected:
+ static lldb::thread_result_t THREAD_ROUTINE
+ ThreadCreateTrampoline(lldb::thread_arg_t arg);
- lldb::thread_t m_thread;
- lldb::thread_result_t m_result;
+ lldb::thread_t m_thread;
+ lldb::thread_result_t m_result;
};
}
diff --git a/include/lldb/Host/HostNativeThreadForward.h b/include/lldb/Host/HostNativeThreadForward.h
index 520031af6488..5b832136acf5 100644
--- a/include/lldb/Host/HostNativeThreadForward.h
+++ b/include/lldb/Host/HostNativeThreadForward.h
@@ -10,8 +10,7 @@
#ifndef lldb_Host_HostNativeThreadForward_h_
#define lldb_Host_HostNativeThreadForward_h_
-namespace lldb_private
-{
+namespace lldb_private {
#if defined(_WIN32)
class HostThreadWindows;
typedef HostThreadWindows HostNativeThread;
diff --git a/include/lldb/Host/HostProcess.h b/include/lldb/Host/HostProcess.h
index 59585fc31130..56c3ddd9a1c2 100644
--- a/include/lldb/Host/HostProcess.h
+++ b/include/lldb/Host/HostProcess.h
@@ -29,35 +29,32 @@
///
//----------------------------------------------------------------------
-namespace lldb_private
-{
+namespace lldb_private {
class HostNativeProcessBase;
class HostThread;
-class HostProcess
-{
+class HostProcess {
public:
- HostProcess();
- HostProcess(lldb::process_t process);
- ~HostProcess();
+ HostProcess();
+ HostProcess(lldb::process_t process);
+ ~HostProcess();
- Error Terminate();
- Error GetMainModule(FileSpec &file_spec) const;
+ Error Terminate();
+ Error GetMainModule(FileSpec &file_spec) const;
- lldb::pid_t GetProcessId() const;
- bool IsRunning() const;
+ lldb::pid_t GetProcessId() const;
+ bool IsRunning() const;
- HostThread
- StartMonitoring(const Host::MonitorChildProcessCallback &callback, bool monitor_signals);
+ HostThread StartMonitoring(const Host::MonitorChildProcessCallback &callback,
+ bool monitor_signals);
- HostNativeProcessBase &GetNativeProcess();
- const HostNativeProcessBase &GetNativeProcess() const;
+ HostNativeProcessBase &GetNativeProcess();
+ const HostNativeProcessBase &GetNativeProcess() const;
- private:
- std::shared_ptr<HostNativeProcessBase> m_native_process;
+private:
+ std::shared_ptr<HostNativeProcessBase> m_native_process;
};
-
}
#endif
diff --git a/include/lldb/Host/HostThread.h b/include/lldb/Host/HostThread.h
index 9fdf9f9618b5..d14f0f6c638c 100644
--- a/include/lldb/Host/HostThread.h
+++ b/include/lldb/Host/HostThread.h
@@ -16,8 +16,7 @@
#include <memory>
-namespace lldb_private
-{
+namespace lldb_private {
class HostNativeThreadBase;
@@ -30,26 +29,25 @@ class HostNativeThreadBase;
/// machine.
///
//----------------------------------------------------------------------
-class HostThread
-{
- public:
- HostThread();
- HostThread(lldb::thread_t thread);
-
- Error Join(lldb::thread_result_t *result);
- Error Cancel();
- void Reset();
- lldb::thread_t Release();
-
- bool IsJoinable() const;
- HostNativeThread &GetNativeThread();
- const HostNativeThread &GetNativeThread() const;
- lldb::thread_result_t GetResult() const;
-
- bool EqualsThread(lldb::thread_t thread) const;
-
- private:
- std::shared_ptr<HostNativeThreadBase> m_native_thread;
+class HostThread {
+public:
+ HostThread();
+ HostThread(lldb::thread_t thread);
+
+ Error Join(lldb::thread_result_t *result);
+ Error Cancel();
+ void Reset();
+ lldb::thread_t Release();
+
+ bool IsJoinable() const;
+ HostNativeThread &GetNativeThread();
+ const HostNativeThread &GetNativeThread() const;
+ lldb::thread_result_t GetResult() const;
+
+ bool EqualsThread(lldb::thread_t thread) const;
+
+private:
+ std::shared_ptr<HostNativeThreadBase> m_native_thread;
};
}
diff --git a/include/lldb/Host/IOObject.h b/include/lldb/Host/IOObject.h
index 532b1fd1bfce..90e0bcdcd9df 100644
--- a/include/lldb/Host/IOObject.h
+++ b/include/lldb/Host/IOObject.h
@@ -18,44 +18,39 @@
namespace lldb_private {
-class IOObject
-{
+class IOObject {
public:
- typedef enum
- {
- eFDTypeFile, // Other FD requiring read/write
- eFDTypeSocket, // Socket requiring send/recv
- } FDType;
+ typedef enum {
+ eFDTypeFile, // Other FD requiring read/write
+ eFDTypeSocket, // Socket requiring send/recv
+ } FDType;
- // TODO: On Windows this should be a HANDLE, and wait should use
- // WaitForMultipleObjects
- typedef int WaitableHandle;
- static const WaitableHandle kInvalidHandleValue;
+ // TODO: On Windows this should be a HANDLE, and wait should use
+ // WaitForMultipleObjects
+ typedef int WaitableHandle;
+ static const WaitableHandle kInvalidHandleValue;
- IOObject(FDType type, bool should_close)
- : m_fd_type(type)
- , m_should_close_fd(should_close)
- {
- }
- virtual ~IOObject() {}
+ IOObject(FDType type, bool should_close)
+ : m_fd_type(type), m_should_close_fd(should_close) {}
+ virtual ~IOObject() {}
- virtual Error Read (void *buf, size_t &num_bytes) = 0;
- virtual Error Write (const void *buf, size_t &num_bytes) = 0;
- virtual bool IsValid() const = 0;
- virtual Error Close() = 0;
+ virtual Error Read(void *buf, size_t &num_bytes) = 0;
+ virtual Error Write(const void *buf, size_t &num_bytes) = 0;
+ virtual bool IsValid() const = 0;
+ virtual Error Close() = 0;
- FDType GetFdType() const { return m_fd_type; }
+ FDType GetFdType() const { return m_fd_type; }
- virtual WaitableHandle GetWaitableHandle() = 0;
+ virtual WaitableHandle GetWaitableHandle() = 0;
protected:
- FDType m_fd_type;
- bool m_should_close_fd; // True if this class should close the file descriptor when it goes away.
+ FDType m_fd_type;
+ bool m_should_close_fd; // True if this class should close the file descriptor
+ // when it goes away.
private:
- DISALLOW_COPY_AND_ASSIGN (IOObject);
+ DISALLOW_COPY_AND_ASSIGN(IOObject);
};
-
}
#endif
diff --git a/include/lldb/Host/LockFile.h b/include/lldb/Host/LockFile.h
index a89560481874..81cb10c7fbcb 100644
--- a/include/lldb/Host/LockFile.h
+++ b/include/lldb/Host/LockFile.h
@@ -12,14 +12,12 @@
#if defined(_WIN32)
#include "lldb/Host/windows/LockFileWindows.h"
-namespace lldb_private
-{
+namespace lldb_private {
typedef LockFileWindows LockFile;
}
#else
#include "lldb/Host/posix/LockFilePosix.h"
-namespace lldb_private
-{
+namespace lldb_private {
typedef LockFilePosix LockFile;
}
#endif
diff --git a/include/lldb/Host/LockFileBase.h b/include/lldb/Host/LockFileBase.h
index 35dd7d817c59..3b2f72357bd4 100644
--- a/include/lldb/Host/LockFileBase.h
+++ b/include/lldb/Host/LockFileBase.h
@@ -14,60 +14,44 @@
#include <functional>
-namespace lldb_private
-{
+namespace lldb_private {
-class LockFileBase
-{
+class LockFileBase {
public:
- virtual ~LockFileBase () = default;
+ virtual ~LockFileBase() = default;
- bool
- IsLocked () const;
+ bool IsLocked() const;
- Error
- WriteLock (const uint64_t start, const uint64_t len);
- Error
- TryWriteLock (const uint64_t start, const uint64_t len);
+ Error WriteLock(const uint64_t start, const uint64_t len);
+ Error TryWriteLock(const uint64_t start, const uint64_t len);
- Error
- ReadLock (const uint64_t start, const uint64_t len);
- Error
- TryReadLock (const uint64_t start, const uint64_t len);
+ Error ReadLock(const uint64_t start, const uint64_t len);
+ Error TryReadLock(const uint64_t start, const uint64_t len);
- Error
- Unlock ();
+ Error Unlock();
protected:
- using Locker = std::function<Error (const uint64_t, const uint64_t)>;
+ using Locker = std::function<Error(const uint64_t, const uint64_t)>;
- LockFileBase (int fd);
+ LockFileBase(int fd);
- virtual bool
- IsValidFile () const;
+ virtual bool IsValidFile() const;
- virtual Error
- DoWriteLock (const uint64_t start, const uint64_t len) = 0;
- virtual Error
- DoTryWriteLock (const uint64_t start, const uint64_t len) = 0;
+ virtual Error DoWriteLock(const uint64_t start, const uint64_t len) = 0;
+ virtual Error DoTryWriteLock(const uint64_t start, const uint64_t len) = 0;
- virtual Error
- DoReadLock (const uint64_t start, const uint64_t len) = 0;
- virtual Error
- DoTryReadLock (const uint64_t start, const uint64_t len) = 0;
+ virtual Error DoReadLock(const uint64_t start, const uint64_t len) = 0;
+ virtual Error DoTryReadLock(const uint64_t start, const uint64_t len) = 0;
- virtual Error
- DoUnlock () = 0;
+ virtual Error DoUnlock() = 0;
- Error
- DoLock (const Locker &locker, const uint64_t start, const uint64_t len);
+ Error DoLock(const Locker &locker, const uint64_t start, const uint64_t len);
- int m_fd; // not owned.
- bool m_locked;
- uint64_t m_start;
- uint64_t m_len;
+ int m_fd; // not owned.
+ bool m_locked;
+ uint64_t m_start;
+ uint64_t m_len;
};
-
}
#endif
diff --git a/include/lldb/Host/MainLoop.h b/include/lldb/Host/MainLoop.h
index 276538a336b6..8aa26b63183a 100644
--- a/include/lldb/Host/MainLoop.h
+++ b/include/lldb/Host/MainLoop.h
@@ -12,14 +12,12 @@
#ifdef _WIN32
#include "lldb/Host/MainLoopBase.h"
-namespace lldb_private
-{
+namespace lldb_private {
typedef MainLoopBase MainLoop;
}
#else
#include "lldb/Host/posix/MainLoopPosix.h"
-namespace lldb_private
-{
+namespace lldb_private {
typedef MainLoopPosix MainLoop;
}
#endif
diff --git a/include/lldb/Host/MainLoopBase.h b/include/lldb/Host/MainLoopBase.h
index da14349cf82e..cd29796bc9d6 100644
--- a/include/lldb/Host/MainLoopBase.h
+++ b/include/lldb/Host/MainLoopBase.h
@@ -19,76 +19,77 @@
namespace lldb_private {
-// The purpose of this class is to enable multiplexed processing of data from different sources
-// without resorting to multi-threading. Clients can register IOObjects, which will be monitored
-// for readability, and when they become ready, the specified callback will be invoked.
-// Monitoring for writability is not supported, but can be easily added if needed.
+// The purpose of this class is to enable multiplexed processing of data from
+// different sources
+// without resorting to multi-threading. Clients can register IOObjects, which
+// will be monitored
+// for readability, and when they become ready, the specified callback will be
+// invoked.
+// Monitoring for writability is not supported, but can be easily added if
+// needed.
//
-// The RegisterReadObject function return a handle, which controls the duration of the monitoring. When
+// The RegisterReadObject function return a handle, which controls the duration
+// of the monitoring. When
// this handle is destroyed, the callback is deregistered.
//
-// This class simply defines the interface common for all platforms, actual implementations are
+// This class simply defines the interface common for all platforms, actual
+// implementations are
// platform-specific.
-class MainLoopBase
-{
+class MainLoopBase {
private:
- class ReadHandle;
+ class ReadHandle;
public:
- MainLoopBase() { }
- virtual ~MainLoopBase() { }
+ MainLoopBase() {}
+ virtual ~MainLoopBase() {}
- typedef std::unique_ptr<ReadHandle> ReadHandleUP;
+ typedef std::unique_ptr<ReadHandle> ReadHandleUP;
- typedef std::function<void(MainLoopBase &)> Callback;
+ typedef std::function<void(MainLoopBase &)> Callback;
- virtual ReadHandleUP
- RegisterReadObject(const lldb::IOObjectSP &object_sp, const Callback &callback, Error &error)
- { llvm_unreachable("Not implemented"); }
+ virtual ReadHandleUP RegisterReadObject(const lldb::IOObjectSP &object_sp,
+ const Callback &callback,
+ Error &error) {
+ llvm_unreachable("Not implemented");
+ }
- // Waits for registered events and invoke the proper callbacks. Returns when all callbacks
- // deregister themselves or when someone requests termination.
- virtual Error
- Run()
- { llvm_unreachable("Not implemented"); }
+ // Waits for registered events and invoke the proper callbacks. Returns when
+ // all callbacks
+ // deregister themselves or when someone requests termination.
+ virtual Error Run() { llvm_unreachable("Not implemented"); }
- // Requests the exit of the Run() function.
- virtual void
- RequestTermination()
- { llvm_unreachable("Not implemented"); }
+ // Requests the exit of the Run() function.
+ virtual void RequestTermination() { llvm_unreachable("Not implemented"); }
protected:
- ReadHandleUP
- CreateReadHandle(const lldb::IOObjectSP &object_sp)
- { return ReadHandleUP(new ReadHandle(*this, object_sp->GetWaitableHandle())); }
+ ReadHandleUP CreateReadHandle(const lldb::IOObjectSP &object_sp) {
+ return ReadHandleUP(new ReadHandle(*this, object_sp->GetWaitableHandle()));
+ }
- virtual void
- UnregisterReadObject(IOObject::WaitableHandle handle)
- { llvm_unreachable("Not implemented"); }
+ virtual void UnregisterReadObject(IOObject::WaitableHandle handle) {
+ llvm_unreachable("Not implemented");
+ }
private:
- class ReadHandle
- {
- public:
- ~ReadHandle() { m_mainloop.UnregisterReadObject(m_handle); }
+ class ReadHandle {
+ public:
+ ~ReadHandle() { m_mainloop.UnregisterReadObject(m_handle); }
- private:
- ReadHandle(MainLoopBase &mainloop, IOObject::WaitableHandle handle)
- : m_mainloop(mainloop), m_handle(handle)
- { }
+ private:
+ ReadHandle(MainLoopBase &mainloop, IOObject::WaitableHandle handle)
+ : m_mainloop(mainloop), m_handle(handle) {}
- MainLoopBase &m_mainloop;
- IOObject::WaitableHandle m_handle;
+ MainLoopBase &m_mainloop;
+ IOObject::WaitableHandle m_handle;
- friend class MainLoopBase;
- DISALLOW_COPY_AND_ASSIGN(ReadHandle);
- };
+ friend class MainLoopBase;
+ DISALLOW_COPY_AND_ASSIGN(ReadHandle);
+ };
private:
- DISALLOW_COPY_AND_ASSIGN(MainLoopBase);
+ DISALLOW_COPY_AND_ASSIGN(MainLoopBase);
};
} // namespace lldb_private
-
#endif // lldb_Host_posix_MainLoopBase_h_
diff --git a/include/lldb/Host/MonitoringProcessLauncher.h b/include/lldb/Host/MonitoringProcessLauncher.h
index f5d0a92aa8de..7aa819a16c7c 100644
--- a/include/lldb/Host/MonitoringProcessLauncher.h
+++ b/include/lldb/Host/MonitoringProcessLauncher.h
@@ -12,22 +12,23 @@
// C Includes
// C++ Includes
+#include <memory>
// Other libraries and framework includes
// Project includes
#include "lldb/Host/ProcessLauncher.h"
-namespace lldb_private
-{
+namespace lldb_private {
-class MonitoringProcessLauncher : public ProcessLauncher
-{
- public:
- explicit MonitoringProcessLauncher(std::unique_ptr<ProcessLauncher> delegate_launcher);
+class MonitoringProcessLauncher : public ProcessLauncher {
+public:
+ explicit MonitoringProcessLauncher(
+ std::unique_ptr<ProcessLauncher> delegate_launcher);
- HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info, Error &error) override;
+ HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info,
+ Error &error) override;
- private:
- std::unique_ptr<ProcessLauncher> m_delegate_launcher;
+private:
+ std::unique_ptr<ProcessLauncher> m_delegate_launcher;
};
} // namespace lldb_private
diff --git a/include/lldb/Host/Mutex.h b/include/lldb/Host/Mutex.h
deleted file mode 100644
index 5a529fb4554d..000000000000
--- a/include/lldb/Host/Mutex.h
+++ /dev/null
@@ -1,313 +0,0 @@
-//===-- Mutex.h -------------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_Mutex_h_
-#define liblldb_Mutex_h_
-
-// C Includes
-// C++ Includes
-#ifdef LLDB_CONFIGURATION_DEBUG
-#include <string>
-#endif
-
-// Other libraries and framework includes
-// Project includes
-#include "lldb/lldb-types.h"
-
-namespace lldb_private {
-
-//----------------------------------------------------------------------
-/// @class Mutex Mutex.h "lldb/Host/Mutex.h"
-/// @brief A C++ wrapper class for pthread mutexes.
-//----------------------------------------------------------------------
-class Mutex
-{
-public:
- friend class Locker;
- friend class Condition;
-
- enum Type
- {
- eMutexTypeNormal, ///< Mutex that can't recursively entered by the same thread
- eMutexTypeRecursive ///< Mutex can be recursively entered by the same thread
- };
-
- //------------------------------------------------------------------
- /// @class Mutex::Locker
- ///
- /// A scoped locking class that allows a variety of pthread mutex
- /// objects to have a mutex locked when an Mutex::Locker
- /// object is created, and unlocked when it goes out of scope or
- /// when the Mutex::Locker::Reset(pthread_mutex_t *)
- /// is called. This provides an exception safe way to lock a mutex
- /// in a scope.
- //------------------------------------------------------------------
- class Locker
- {
- public:
- //--------------------------------------------------------------
- /// Default constructor.
- ///
- /// This will create a scoped mutex locking object that doesn't
- /// have a mutex to lock. One will need to be provided using the
- /// Mutex::Locker::Reset(pthread_mutex_t *) method.
- ///
- /// @see Mutex::Locker::Reset(pthread_mutex_t *)
- //--------------------------------------------------------------
- Locker();
-
- //--------------------------------------------------------------
- /// Constructor with a Mutex object.
- ///
- /// This will create a scoped mutex locking object that extracts
- /// the mutex owned by \a m and locks it.
- ///
- /// @param[in] m
- /// An instance of a Mutex object that contains a
- /// valid mutex object.
- //--------------------------------------------------------------
- Locker(Mutex& m);
-
- //--------------------------------------------------------------
- /// Constructor with a Mutex object pointer.
- ///
- /// This will create a scoped mutex locking object that extracts
- /// the mutex owned by a m and locks it.
- ///
- /// @param[in] m
- /// A pointer to instance of a Mutex object that
- /// contains a valid mutex object.
- //--------------------------------------------------------------
- Locker(Mutex* m);
-
- //--------------------------------------------------------------
- /// Destructor
- ///
- /// Unlocks any valid pthread_mutex_t that this object may
- /// contain.
- //--------------------------------------------------------------
- ~Locker();
-
- //--------------------------------------------------------------
- /// Change the contained mutex.
- ///
- /// Unlock the current mutex in this object (if it contains a
- /// valid mutex) and lock the new \a mutex object if it is
- /// non-nullptr.
- //--------------------------------------------------------------
- void
- Lock (Mutex &mutex);
-
- void
- Lock (Mutex *mutex)
- {
- if (mutex)
- Lock(*mutex);
- }
-
- //--------------------------------------------------------------
- /// Change the contained mutex only if the mutex can be locked.
- ///
- /// Unlock the current mutex in this object (if it contains a
- /// valid mutex) and try to lock \a mutex. If \a mutex can be
- /// locked this object will take ownership of the lock and will
- /// unlock it when it goes out of scope or Reset or TryLock are
- /// called again. If the mutex is already locked, this object
- /// will not take ownership of the mutex.
- ///
- /// @return
- /// Returns \b true if the lock was acquired and the this
- /// object will unlock the mutex when it goes out of scope,
- /// returns \b false otherwise.
- //--------------------------------------------------------------
- bool
- TryLock(Mutex &mutex, const char *failure_message = nullptr);
-
- bool
- TryLock(Mutex *mutex, const char *failure_message = nullptr)
- {
- if (mutex)
- return TryLock(*mutex, failure_message);
- else
- return false;
- }
-
- void
- Unlock ();
-
- protected:
- //--------------------------------------------------------------
- /// Member variables
- //--------------------------------------------------------------
- Mutex *m_mutex_ptr;
-
- private:
- Locker(const Locker&);
- const Locker& operator=(const Locker&);
- };
-
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Creates a pthread mutex with no attributes.
- //------------------------------------------------------------------
- Mutex();
-
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Creates a pthread mutex with \a type as the mutex type.
- /// Valid values for \a type include:
- /// @li Mutex::Type::eMutexTypeNormal
- /// @li Mutex::Type::eMutexTypeRecursive
- ///
- /// @param[in] type
- /// The type of the mutex.
- ///
- /// @see ::pthread_mutexattr_settype()
- //------------------------------------------------------------------
- Mutex(Mutex::Type type);
-
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// Destroys the mutex owned by this object.
- //------------------------------------------------------------------
-#ifdef LLDB_CONFIGURATION_DEBUG
- virtual
-#endif
- ~Mutex();
-
- //------------------------------------------------------------------
- /// Lock the mutex.
- ///
- /// Locks the mutex owned by this object. If the mutex is already
- /// locked, the calling thread will block until the mutex becomes
- /// available.
- ///
- /// @return
- /// The error code from \c pthread_mutex_lock().
- //------------------------------------------------------------------
-#ifdef LLDB_CONFIGURATION_DEBUG
- virtual
-#endif
- int
- Lock();
-
- //------------------------------------------------------------------
- /// Try to lock the mutex.
- ///
- /// Attempts to lock the mutex owned by this object without blocking.
- /// If the mutex is already locked, TryLock() will not block waiting
- /// for the mutex, but will return an error condition.
- ///
- /// @return
- /// The error code from \c pthread_mutex_trylock().
- //------------------------------------------------------------------
-#ifdef LLDB_CONFIGURATION_DEBUG
- virtual
-#endif
- int
- TryLock(const char *failure_message = nullptr);
-
- //------------------------------------------------------------------
- /// Unlock the mutex.
- ///
- /// If the current thread holds the lock on the owned mutex, then
- /// Unlock() will unlock the mutex. Calling Unlock() on this object
- /// when the calling thread does not hold the lock will result in
- /// undefined behavior.
- ///
- /// @return
- /// The error code from \c pthread_mutex_unlock().
- //------------------------------------------------------------------
-#ifdef LLDB_CONFIGURATION_DEBUG
- virtual
-#endif
- int
- Unlock();
-
-protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- // TODO: Hide the mutex in the implementation file in case we ever need to port to an
- // architecture that doesn't have pthread mutexes.
- lldb::mutex_t m_mutex; ///< The OS mutex object.
-
-private:
- //------------------------------------------------------------------
- /// Mutex get accessor.
- ///
- /// @return
- /// A pointer to the pthread mutex object owned by this object.
- //------------------------------------------------------------------
- lldb::mutex_t *
- GetMutex();
-
- Mutex(const Mutex&);
- const Mutex& operator=(const Mutex&);
-};
-
-#ifdef LLDB_CONFIGURATION_DEBUG
-class TrackingMutex : public Mutex
-{
-public:
- TrackingMutex() : Mutex() {}
- TrackingMutex(Mutex::Type type) : Mutex (type) {}
-
- virtual
- ~TrackingMutex() = default;
-
- virtual int
- Unlock ();
-
- virtual int
- TryLock(const char *failure_message = nullptr)
- {
- int return_value = Mutex::TryLock();
- if (return_value != 0 && failure_message != nullptr)
- {
- m_failure_message.assign(failure_message);
- m_thread_that_tried = pthread_self();
- }
- return return_value;
- }
-
-protected:
- pthread_t m_thread_that_tried;
- std::string m_failure_message;
-};
-
-class LoggingMutex : public Mutex
-{
-public:
- LoggingMutex() : Mutex(),m_locked(false) {}
- LoggingMutex(Mutex::Type type) : Mutex (type),m_locked(false) {}
-
- virtual
- ~LoggingMutex() = default;
-
- virtual int
- Lock ();
-
- virtual int
- Unlock ();
-
- virtual int
- TryLock(const char *failure_message = nullptr);
-
-protected:
- bool m_locked;
-};
-#endif // LLDB_CONFIGURATION_DEBUG
-
-} // namespace lldb_private
-
-#endif // liblldb_Mutex_h_
diff --git a/include/lldb/Host/OptionParser.h b/include/lldb/Host/OptionParser.h
index c2aeaf0430ea..1b0dc4ae19e0 100644
--- a/include/lldb/Host/OptionParser.h
+++ b/include/lldb/Host/OptionParser.h
@@ -13,47 +13,39 @@
#include <mutex>
#include <string>
+#include "llvm/ADT/StringRef.h"
+
struct option;
namespace lldb_private {
struct OptionDefinition;
-struct Option
-{
- // The definition of the option that this refers to.
- const OptionDefinition *definition;
- // if not NULL, set *flag to val when option found
- int *flag;
- // if flag not NULL, value to set *flag to; else return value
- int val;
+struct Option {
+ // The definition of the option that this refers to.
+ const OptionDefinition *definition;
+ // if not NULL, set *flag to val when option found
+ int *flag;
+ // if flag not NULL, value to set *flag to; else return value
+ int val;
};
-class OptionParser
-{
+class OptionParser {
public:
- enum OptionArgument
- {
- eNoArgument = 0,
- eRequiredArgument,
- eOptionalArgument
- };
-
- static void
- Prepare(std::unique_lock<std::mutex> &lock);
-
- static void EnableError(bool error);
-
- static int Parse(int argc, char * const argv [],
- const char *optstring,
- const Option *longopts, int *longindex);
-
- static char* GetOptionArgument();
- static int GetOptionIndex();
- static int GetOptionErrorCause();
- static std::string GetShortOptionString(struct option *long_options);
-};
+ enum OptionArgument { eNoArgument = 0, eRequiredArgument, eOptionalArgument };
+
+ static void Prepare(std::unique_lock<std::mutex> &lock);
+ static void EnableError(bool error);
+
+ static int Parse(int argc, char *const argv[], llvm::StringRef optstring,
+ const Option *longopts, int *longindex);
+
+ static char *GetOptionArgument();
+ static int GetOptionIndex();
+ static int GetOptionErrorCause();
+ static std::string GetShortOptionString(struct option *long_options);
+};
}
-#endif // liblldb_OptionParser_h_
+#endif // liblldb_OptionParser_h_
diff --git a/include/lldb/Host/Pipe.h b/include/lldb/Host/Pipe.h
index a5502efa78ed..283fb1b83c25 100644
--- a/include/lldb/Host/Pipe.h
+++ b/include/lldb/Host/Pipe.h
@@ -12,14 +12,12 @@
#if defined(_WIN32)
#include "lldb/Host/windows/PipeWindows.h"
-namespace lldb_private
-{
+namespace lldb_private {
typedef PipeWindows Pipe;
}
#else
#include "lldb/Host/posix/PipePosix.h"
-namespace lldb_private
-{
+namespace lldb_private {
typedef PipePosix Pipe;
}
#endif
diff --git a/include/lldb/Host/PipeBase.h b/include/lldb/Host/PipeBase.h
index 8680a252d8b6..e3d7c25a9ae2 100644
--- a/include/lldb/Host/PipeBase.h
+++ b/include/lldb/Host/PipeBase.h
@@ -1,4 +1,5 @@
-//===-- PipeBase.h -----------------------------------------------*- C++ -*-===//
+//===-- PipeBase.h -----------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -17,41 +18,46 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
-namespace lldb_private
-{
-class PipeBase
-{
- public:
- virtual ~PipeBase();
+namespace lldb_private {
+class PipeBase {
+public:
+ virtual ~PipeBase();
- virtual Error CreateNew(bool child_process_inherit) = 0;
- virtual Error CreateNew(llvm::StringRef name, bool child_process_inherit) = 0;
- virtual Error CreateWithUniqueName(llvm::StringRef prefix, bool child_process_inherit, llvm::SmallVectorImpl<char>& name) = 0;
+ virtual Error CreateNew(bool child_process_inherit) = 0;
+ virtual Error CreateNew(llvm::StringRef name, bool child_process_inherit) = 0;
+ virtual Error CreateWithUniqueName(llvm::StringRef prefix,
+ bool child_process_inherit,
+ llvm::SmallVectorImpl<char> &name) = 0;
- virtual Error OpenAsReader(llvm::StringRef name, bool child_process_inherit) = 0;
+ virtual Error OpenAsReader(llvm::StringRef name,
+ bool child_process_inherit) = 0;
- Error OpenAsWriter(llvm::StringRef name, bool child_process_inherit);
- virtual Error OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit, const std::chrono::microseconds &timeout) = 0;
+ Error OpenAsWriter(llvm::StringRef name, bool child_process_inherit);
+ virtual Error
+ OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit,
+ const std::chrono::microseconds &timeout) = 0;
- virtual bool CanRead() const = 0;
- virtual bool CanWrite() const = 0;
+ virtual bool CanRead() const = 0;
+ virtual bool CanWrite() const = 0;
- virtual int GetReadFileDescriptor() const = 0;
- virtual int GetWriteFileDescriptor() const = 0;
- virtual int ReleaseReadFileDescriptor() = 0;
- virtual int ReleaseWriteFileDescriptor() = 0;
- virtual void CloseReadFileDescriptor() = 0;
- virtual void CloseWriteFileDescriptor() = 0;
+ virtual int GetReadFileDescriptor() const = 0;
+ virtual int GetWriteFileDescriptor() const = 0;
+ virtual int ReleaseReadFileDescriptor() = 0;
+ virtual int ReleaseWriteFileDescriptor() = 0;
+ virtual void CloseReadFileDescriptor() = 0;
+ virtual void CloseWriteFileDescriptor() = 0;
- // Close both descriptors
- virtual void Close() = 0;
+ // Close both descriptors
+ virtual void Close() = 0;
- // Delete named pipe.
- virtual Error Delete(llvm::StringRef name) = 0;
+ // Delete named pipe.
+ virtual Error Delete(llvm::StringRef name) = 0;
- virtual Error Write(const void *buf, size_t size, size_t &bytes_written) = 0;
- virtual Error ReadWithTimeout(void *buf, size_t size, const std::chrono::microseconds &timeout, size_t &bytes_read) = 0;
- Error Read(void *buf, size_t size, size_t &bytes_read);
+ virtual Error Write(const void *buf, size_t size, size_t &bytes_written) = 0;
+ virtual Error ReadWithTimeout(void *buf, size_t size,
+ const std::chrono::microseconds &timeout,
+ size_t &bytes_read) = 0;
+ Error Read(void *buf, size_t size, size_t &bytes_read);
};
}
diff --git a/include/lldb/Host/PosixApi.h b/include/lldb/Host/PosixApi.h
new file mode 100644
index 000000000000..23a291c401de
--- /dev/null
+++ b/include/lldb/Host/PosixApi.h
@@ -0,0 +1,23 @@
+//===-- PosixApi.h ----------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_Host_PosixApi_h
+#define liblldb_Host_PosixApi_h
+
+// This file defines platform specific functions, macros, and types necessary
+// to provide a minimum level of compatibility across all platforms to rely
+// on various posix api functionality.
+
+#include "llvm/Support/Compiler.h"
+
+#if defined(LLVM_ON_WIN32)
+#include "lldb/Host/windows/PosixApi.h"
+#endif
+
+#endif
diff --git a/include/lldb/Host/Predicate.h b/include/lldb/Host/Predicate.h
index 4f386dc1dd0b..3ee27e74b4ba 100644
--- a/include/lldb/Host/Predicate.h
+++ b/include/lldb/Host/Predicate.h
@@ -15,11 +15,12 @@
#include <time.h>
// C++ Includes
+#include <condition_variable>
+#include <mutex>
+
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-defines.h"
-#include "lldb/Host/Mutex.h"
-#include "lldb/Host/Condition.h"
//#define DB_PTHREAD_LOG_EVENTS
@@ -28,11 +29,11 @@
//----------------------------------------------------------------------
namespace lldb_private {
-typedef enum
-{
- eBroadcastNever, ///< No broadcast will be sent when the value is modified.
- eBroadcastAlways, ///< Always send a broadcast when the value is modified.
- eBroadcastOnChange ///< Only broadcast if the value changes when the value is modified.
+typedef enum {
+ eBroadcastNever, ///< No broadcast will be sent when the value is modified.
+ eBroadcastAlways, ///< Always send a broadcast when the value is modified.
+ eBroadcastOnChange ///< Only broadcast if the value changes when the value is
+ ///modified.
} PredicateBroadcastType;
//----------------------------------------------------------------------
@@ -45,461 +46,477 @@ typedef enum
/// or reset, or wait for T to be set to be equal/not equal to a
/// specified values.
//----------------------------------------------------------------------
-template <class T>
-class Predicate
-{
+template <class T> class Predicate {
public:
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Initializes the mutex, condition and value with their default
- /// constructors.
- //------------------------------------------------------------------
- Predicate () :
- m_value(),
- m_mutex(),
- m_condition()
- {
- }
-
- //------------------------------------------------------------------
- /// Construct with initial T value \a initial_value.
- ///
- /// Initializes the mutex and condition with their default
- /// constructors, and initializes the value with \a initial_value.
- ///
- /// @param[in] initial_value
- /// The initial value for our T object.
- //------------------------------------------------------------------
- Predicate (T initial_value) :
- m_value(initial_value),
- m_mutex(),
- m_condition()
- {
- }
-
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// Destroy the condition, mutex, and T objects.
- //------------------------------------------------------------------
- ~Predicate() = default;
-
- //------------------------------------------------------------------
- /// Value get accessor.
- ///
- /// Copies the current \a m_value in a thread safe manor and returns
- /// the copied value.
- ///
- /// @return
- /// A copy of the current value.
- //------------------------------------------------------------------
- T
- GetValue () const
- {
- Mutex::Locker locker(m_mutex);
- T value = m_value;
- return value;
- }
-
- //------------------------------------------------------------------
- /// Value set accessor.
- ///
- /// Set the contained \a m_value to \a new_value in a thread safe
- /// way and broadcast if needed.
- ///
- /// @param[in] value
- /// The new value to set.
- ///
- /// @param[in] broadcast_type
- /// A value indicating when and if to broadcast. See the
- /// PredicateBroadcastType enumeration for details.
- ///
- /// @see Predicate::Broadcast()
- //------------------------------------------------------------------
- void
- SetValue (T value, PredicateBroadcastType broadcast_type)
- {
- Mutex::Locker locker(m_mutex);
+ //------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// Initializes the mutex, condition and value with their default
+ /// constructors.
+ //------------------------------------------------------------------
+ Predicate() : m_value(), m_mutex(), m_condition() {}
+
+ //------------------------------------------------------------------
+ /// Construct with initial T value \a initial_value.
+ ///
+ /// Initializes the mutex and condition with their default
+ /// constructors, and initializes the value with \a initial_value.
+ ///
+ /// @param[in] initial_value
+ /// The initial value for our T object.
+ //------------------------------------------------------------------
+ Predicate(T initial_value)
+ : m_value(initial_value), m_mutex(), m_condition() {}
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ ///
+ /// Destroy the condition, mutex, and T objects.
+ //------------------------------------------------------------------
+ ~Predicate() = default;
+
+ //------------------------------------------------------------------
+ /// Value get accessor.
+ ///
+ /// Copies the current \a m_value in a thread safe manor and returns
+ /// the copied value.
+ ///
+ /// @return
+ /// A copy of the current value.
+ //------------------------------------------------------------------
+ T GetValue() const {
+ std::lock_guard<std::mutex> guard(m_mutex);
+ T value = m_value;
+ return value;
+ }
+
+ //------------------------------------------------------------------
+ /// Value set accessor.
+ ///
+ /// Set the contained \a m_value to \a new_value in a thread safe
+ /// way and broadcast if needed.
+ ///
+ /// @param[in] value
+ /// The new value to set.
+ ///
+ /// @param[in] broadcast_type
+ /// A value indicating when and if to broadcast. See the
+ /// PredicateBroadcastType enumeration for details.
+ ///
+ /// @see Predicate::Broadcast()
+ //------------------------------------------------------------------
+ void SetValue(T value, PredicateBroadcastType broadcast_type) {
+ std::lock_guard<std::mutex> guard(m_mutex);
#ifdef DB_PTHREAD_LOG_EVENTS
- printf("%s (value = 0x%8.8x, broadcast_type = %i)\n", __FUNCTION__, value, broadcast_type);
+ printf("%s (value = 0x%8.8x, broadcast_type = %i)\n", __FUNCTION__, value,
+ broadcast_type);
#endif
- const T old_value = m_value;
- m_value = value;
-
- Broadcast(old_value, broadcast_type);
- }
-
- //------------------------------------------------------------------
- /// Set some bits in \a m_value.
- ///
- /// Logically set the bits \a bits in the contained \a m_value in a
- /// thread safe way and broadcast if needed.
- ///
- /// @param[in] bits
- /// The bits to set in \a m_value.
- ///
- /// @param[in] broadcast_type
- /// A value indicating when and if to broadcast. See the
- /// PredicateBroadcastType enumeration for details.
- ///
- /// @see Predicate::Broadcast()
- //------------------------------------------------------------------
- void
- SetValueBits (T bits, PredicateBroadcastType broadcast_type)
- {
- Mutex::Locker locker(m_mutex);
+ const T old_value = m_value;
+ m_value = value;
+
+ Broadcast(old_value, broadcast_type);
+ }
+
+ //------------------------------------------------------------------
+ /// Set some bits in \a m_value.
+ ///
+ /// Logically set the bits \a bits in the contained \a m_value in a
+ /// thread safe way and broadcast if needed.
+ ///
+ /// @param[in] bits
+ /// The bits to set in \a m_value.
+ ///
+ /// @param[in] broadcast_type
+ /// A value indicating when and if to broadcast. See the
+ /// PredicateBroadcastType enumeration for details.
+ ///
+ /// @see Predicate::Broadcast()
+ //------------------------------------------------------------------
+ void SetValueBits(T bits, PredicateBroadcastType broadcast_type) {
+ std::lock_guard<std::mutex> guard(m_mutex);
#ifdef DB_PTHREAD_LOG_EVENTS
- printf("%s (bits = 0x%8.8x, broadcast_type = %i)\n", __FUNCTION__, bits, broadcast_type);
+ printf("%s (bits = 0x%8.8x, broadcast_type = %i)\n", __FUNCTION__, bits,
+ broadcast_type);
#endif
- const T old_value = m_value;
- m_value |= bits;
-
- Broadcast(old_value, broadcast_type);
- }
-
- //------------------------------------------------------------------
- /// Reset some bits in \a m_value.
- ///
- /// Logically reset (clear) the bits \a bits in the contained
- /// \a m_value in a thread safe way and broadcast if needed.
- ///
- /// @param[in] bits
- /// The bits to clear in \a m_value.
- ///
- /// @param[in] broadcast_type
- /// A value indicating when and if to broadcast. See the
- /// PredicateBroadcastType enumeration for details.
- ///
- /// @see Predicate::Broadcast()
- //------------------------------------------------------------------
- void
- ResetValueBits (T bits, PredicateBroadcastType broadcast_type)
- {
- Mutex::Locker locker(m_mutex);
+ const T old_value = m_value;
+ m_value |= bits;
+
+ Broadcast(old_value, broadcast_type);
+ }
+
+ //------------------------------------------------------------------
+ /// Reset some bits in \a m_value.
+ ///
+ /// Logically reset (clear) the bits \a bits in the contained
+ /// \a m_value in a thread safe way and broadcast if needed.
+ ///
+ /// @param[in] bits
+ /// The bits to clear in \a m_value.
+ ///
+ /// @param[in] broadcast_type
+ /// A value indicating when and if to broadcast. See the
+ /// PredicateBroadcastType enumeration for details.
+ ///
+ /// @see Predicate::Broadcast()
+ //------------------------------------------------------------------
+ void ResetValueBits(T bits, PredicateBroadcastType broadcast_type) {
+ std::lock_guard<std::mutex> guard(m_mutex);
#ifdef DB_PTHREAD_LOG_EVENTS
- printf("%s (bits = 0x%8.8x, broadcast_type = %i)\n", __FUNCTION__, bits, broadcast_type);
+ printf("%s (bits = 0x%8.8x, broadcast_type = %i)\n", __FUNCTION__, bits,
+ broadcast_type);
#endif
- const T old_value = m_value;
- m_value &= ~bits;
-
- Broadcast(old_value, broadcast_type);
- }
-
- //------------------------------------------------------------------
- /// Wait for bits to be set in \a m_value.
- ///
- /// Waits in a thread safe way for any bits in \a bits to get
- /// logically set in \a m_value. If any bits are already set in
- /// \a m_value, this function will return without waiting.
- ///
- /// It is possible for the value to be changed between the time
- /// the bits are set and the time the waiting thread wakes up.
- /// If the bits are no longer set when the waiting thread wakes
- /// up, it will go back into a wait state. It may be necessary
- /// for the calling code to use additional thread synchronization
- /// methods to detect transitory states.
- ///
- /// @param[in] bits
- /// The bits we are waiting to be set in \a m_value.
- ///
- /// @param[in] abstime
- /// If non-nullptr, the absolute time at which we should stop
- /// waiting, else wait an infinite amount of time.
- ///
- /// @return
- /// Any bits of the requested bits that actually were set within
- /// the time specified. Zero if a timeout or unrecoverable error
- /// occurred.
- //------------------------------------------------------------------
- T
- WaitForSetValueBits(T bits, const TimeValue *abstime = nullptr)
- {
- int err = 0;
- // pthread_cond_timedwait() or pthread_cond_wait() will atomically
- // unlock the mutex and wait for the condition to be set. When either
- // function returns, they will re-lock the mutex. We use an auto lock/unlock
- // class (Mutex::Locker) to allow us to return at any point in this
- // function and not have to worry about unlocking the mutex.
- Mutex::Locker locker(m_mutex);
+ const T old_value = m_value;
+ m_value &= ~bits;
+
+ Broadcast(old_value, broadcast_type);
+ }
+
+ //------------------------------------------------------------------
+ /// Wait for bits to be set in \a m_value.
+ ///
+ /// Waits in a thread safe way for any bits in \a bits to get
+ /// logically set in \a m_value. If any bits are already set in
+ /// \a m_value, this function will return without waiting.
+ ///
+ /// It is possible for the value to be changed between the time
+ /// the bits are set and the time the waiting thread wakes up.
+ /// If the bits are no longer set when the waiting thread wakes
+ /// up, it will go back into a wait state. It may be necessary
+ /// for the calling code to use additional thread synchronization
+ /// methods to detect transitory states.
+ ///
+ /// @param[in] bits
+ /// The bits we are waiting to be set in \a m_value.
+ ///
+ /// @param[in] abstime
+ /// If non-nullptr, the absolute time at which we should stop
+ /// waiting, else wait an infinite amount of time.
+ ///
+ /// @return
+ /// Any bits of the requested bits that actually were set within
+ /// the time specified. Zero if a timeout or unrecoverable error
+ /// occurred.
+ //------------------------------------------------------------------
+ T WaitForSetValueBits(T bits, const std::chrono::microseconds &timeout =
+ std::chrono::microseconds(0)) {
+ // pthread_cond_timedwait() or pthread_cond_wait() will atomically
+ // unlock the mutex and wait for the condition to be set. When either
+ // function returns, they will re-lock the mutex. We use an auto lock/unlock
+ // class (std::lock_guard) to allow us to return at any point in this
+ // function and not have to worry about unlocking the mutex.
+ std::unique_lock<std::mutex> lock(m_mutex);
#ifdef DB_PTHREAD_LOG_EVENTS
- printf("%s (bits = 0x%8.8x, abstime = %p), m_value = 0x%8.8x\n", __FUNCTION__, bits, abstime, m_value);
+ printf("%s (bits = 0x%8.8x, timeout = %llu), m_value = 0x%8.8x\n",
+ __FUNCTION__, bits, timeout.count(), m_value);
#endif
- while (err == 0 && ((m_value & bits) == 0))
- {
- err = m_condition.Wait (m_mutex, abstime);
- }
+ while ((m_value & bits) == 0) {
+ if (timeout == std::chrono::microseconds(0)) {
+ m_condition.wait(lock);
+ } else {
+ std::cv_status result = m_condition.wait_for(lock, timeout);
+ if (result == std::cv_status::timeout)
+ break;
+ }
+ }
#ifdef DB_PTHREAD_LOG_EVENTS
- printf("%s (bits = 0x%8.8x), m_value = 0x%8.8x, returning 0x%8.8x\n", __FUNCTION__, bits, m_value, m_value & bits);
+ printf("%s (bits = 0x%8.8x), m_value = 0x%8.8x, returning 0x%8.8x\n",
+ __FUNCTION__, bits, m_value, m_value & bits);
#endif
- return m_value & bits;
- }
-
- //------------------------------------------------------------------
- /// Wait for bits to be reset in \a m_value.
- ///
- /// Waits in a thread safe way for any bits in \a bits to get
- /// logically reset in \a m_value. If all bits are already reset in
- /// \a m_value, this function will return without waiting.
- ///
- /// It is possible for the value to be changed between the time
- /// the bits are reset and the time the waiting thread wakes up.
- /// If the bits are no set when the waiting thread wakes up, it will
- /// go back into a wait state. It may be necessary for the calling
- /// code to use additional thread synchronization methods to detect
- /// transitory states.
- ///
- /// @param[in] bits
- /// The bits we are waiting to be reset in \a m_value.
- ///
- /// @param[in] abstime
- /// If non-nullptr, the absolute time at which we should stop
- /// waiting, else wait an infinite amount of time.
- ///
- /// @return
- /// Zero on successful waits, or non-zero if a timeout or
- /// unrecoverable error occurs.
- //------------------------------------------------------------------
- T
- WaitForResetValueBits(T bits, const TimeValue *abstime = nullptr)
- {
- int err = 0;
-
- // pthread_cond_timedwait() or pthread_cond_wait() will atomically
- // unlock the mutex and wait for the condition to be set. When either
- // function returns, they will re-lock the mutex. We use an auto lock/unlock
- // class (Mutex::Locker) to allow us to return at any point in this
- // function and not have to worry about unlocking the mutex.
- Mutex::Locker locker(m_mutex);
+ return m_value & bits;
+ }
+
+ //------------------------------------------------------------------
+ /// Wait for bits to be reset in \a m_value.
+ ///
+ /// Waits in a thread safe way for any bits in \a bits to get
+ /// logically reset in \a m_value. If all bits are already reset in
+ /// \a m_value, this function will return without waiting.
+ ///
+ /// It is possible for the value to be changed between the time
+ /// the bits are reset and the time the waiting thread wakes up.
+ /// If the bits are no set when the waiting thread wakes up, it will
+ /// go back into a wait state. It may be necessary for the calling
+ /// code to use additional thread synchronization methods to detect
+ /// transitory states.
+ ///
+ /// @param[in] bits
+ /// The bits we are waiting to be reset in \a m_value.
+ ///
+ /// @param[in] abstime
+ /// If non-nullptr, the absolute time at which we should stop
+ /// waiting, else wait an infinite amount of time.
+ ///
+ /// @return
+ /// Zero on successful waits, or non-zero if a timeout or
+ /// unrecoverable error occurs.
+ //------------------------------------------------------------------
+ T WaitForResetValueBits(T bits, const std::chrono::microseconds &timeout =
+ std::chrono::microseconds(0)) {
+ // pthread_cond_timedwait() or pthread_cond_wait() will atomically
+ // unlock the mutex and wait for the condition to be set. When either
+ // function returns, they will re-lock the mutex. We use an auto lock/unlock
+ // class (std::lock_guard) to allow us to return at any point in this
+ // function and not have to worry about unlocking the mutex.
+ std::unique_lock<std::mutex> lock(m_mutex);
#ifdef DB_PTHREAD_LOG_EVENTS
- printf("%s (bits = 0x%8.8x, abstime = %p), m_value = 0x%8.8x\n", __FUNCTION__, bits, abstime, m_value);
+ printf("%s (bits = 0x%8.8x, timeout = %llu), m_value = 0x%8.8x\n",
+ __FUNCTION__, bits, timeout.count(), m_value);
#endif
- while (err == 0 && ((m_value & bits) != 0))
- {
- err = m_condition.Wait (m_mutex, abstime);
- }
+ while ((m_value & bits) != 0) {
+ if (timeout == std::chrono::microseconds(0)) {
+ m_condition.wait(lock);
+ } else {
+ std::cv_status result = m_condition.wait_for(lock, timeout);
+ if (result == std::cv_status::timeout)
+ break;
+ }
+ }
#ifdef DB_PTHREAD_LOG_EVENTS
- printf("%s (bits = 0x%8.8x), m_value = 0x%8.8x, returning 0x%8.8x\n", __FUNCTION__, bits, m_value, m_value & bits);
+ printf("%s (bits = 0x%8.8x), m_value = 0x%8.8x, returning 0x%8.8x\n",
+ __FUNCTION__, bits, m_value, m_value & bits);
#endif
- return m_value & bits;
- }
-
- //------------------------------------------------------------------
- /// Wait for \a m_value to be equal to \a value.
- ///
- /// Waits in a thread safe way for \a m_value to be equal to \a
- /// value. If \a m_value is already equal to \a value, this
- /// function will return without waiting.
- ///
- /// It is possible for the value to be changed between the time
- /// the value is set and the time the waiting thread wakes up.
- /// If the value no longer matches the requested value when the
- /// waiting thread wakes up, it will go back into a wait state. It
- /// may be necessary for the calling code to use additional thread
- /// synchronization methods to detect transitory states.
- ///
- /// @param[in] value
- /// The value we want \a m_value to be equal to.
- ///
- /// @param[in] abstime
- /// If non-nullptr, the absolute time at which we should stop
- /// waiting, else wait an infinite amount of time.
- ///
- /// @param[out] timed_out
- /// If not null, set to true if we return because of a time out,
- /// and false if the value was set.
- ///
- /// @return
- /// @li \b true if the \a m_value is equal to \a value
- /// @li \b false otherwise
- //------------------------------------------------------------------
- bool
- WaitForValueEqualTo(T value, const TimeValue *abstime = nullptr, bool *timed_out = nullptr)
- {
- int err = 0;
- // pthread_cond_timedwait() or pthread_cond_wait() will atomically
- // unlock the mutex and wait for the condition to be set. When either
- // function returns, they will re-lock the mutex. We use an auto lock/unlock
- // class (Mutex::Locker) to allow us to return at any point in this
- // function and not have to worry about unlocking the mutex.
- Mutex::Locker locker(m_mutex);
+ return m_value & bits;
+ }
+
+ //------------------------------------------------------------------
+ /// Wait for \a m_value to be equal to \a value.
+ ///
+ /// Waits in a thread safe way for \a m_value to be equal to \a
+ /// value. If \a m_value is already equal to \a value, this
+ /// function will return without waiting.
+ ///
+ /// It is possible for the value to be changed between the time
+ /// the value is set and the time the waiting thread wakes up.
+ /// If the value no longer matches the requested value when the
+ /// waiting thread wakes up, it will go back into a wait state. It
+ /// may be necessary for the calling code to use additional thread
+ /// synchronization methods to detect transitory states.
+ ///
+ /// @param[in] value
+ /// The value we want \a m_value to be equal to.
+ ///
+ /// @param[in] abstime
+ /// If non-nullptr, the absolute time at which we should stop
+ /// waiting, else wait an infinite amount of time.
+ ///
+ /// @param[out] timed_out
+ /// If not null, set to true if we return because of a time out,
+ /// and false if the value was set.
+ ///
+ /// @return
+ /// @li \b true if the \a m_value is equal to \a value
+ /// @li \b false otherwise
+ //------------------------------------------------------------------
+ bool WaitForValueEqualTo(T value, const std::chrono::microseconds &timeout =
+ std::chrono::microseconds(0),
+ bool *timed_out = nullptr) {
+ // pthread_cond_timedwait() or pthread_cond_wait() will atomically
+ // unlock the mutex and wait for the condition to be set. When either
+ // function returns, they will re-lock the mutex. We use an auto lock/unlock
+ // class (std::lock_guard) to allow us to return at any point in this
+ // function and not have to worry about unlocking the mutex.
+ std::unique_lock<std::mutex> lock(m_mutex);
#ifdef DB_PTHREAD_LOG_EVENTS
- printf("%s (value = 0x%8.8x, abstime = %p), m_value = 0x%8.8x\n", __FUNCTION__, value, abstime, m_value);
+ printf("%s (value = 0x%8.8x, timeout = %llu), m_value = 0x%8.8x\n",
+ __FUNCTION__, value, timeout.count(), m_value);
#endif
- if (timed_out)
- *timed_out = false;
-
- while (err == 0 && m_value != value)
- {
- err = m_condition.Wait (m_mutex, abstime, timed_out);
+ if (timed_out)
+ *timed_out = false;
+
+ while (m_value != value) {
+ if (timeout == std::chrono::microseconds(0)) {
+ m_condition.wait(lock);
+ } else {
+ std::cv_status result = m_condition.wait_for(lock, timeout);
+ if (result == std::cv_status::timeout) {
+ if (timed_out)
+ *timed_out = true;
+ break;
}
-
- return m_value == value;
+ }
}
- //------------------------------------------------------------------
- /// Wait for \a m_value to be equal to \a value and then set it to
- /// a new value.
- ///
- /// Waits in a thread safe way for \a m_value to be equal to \a
- /// value and then sets \a m_value to \a new_value. If \a m_value
- /// is already equal to \a value, this function will immediately
- /// set \a m_value to \a new_value and return without waiting.
- ///
- /// It is possible for the value to be changed between the time
- /// the value is set and the time the waiting thread wakes up.
- /// If the value no longer matches the requested value when the
- /// waiting thread wakes up, it will go back into a wait state. It
- /// may be necessary for the calling code to use additional thread
- /// synchronization methods to detect transitory states.
- ///
- /// @param[in] value
- /// The value we want \a m_value to be equal to.
- ///
- /// @param[in] new_value
- /// The value to which \a m_value will be set if \b true is
- /// returned.
- ///
- /// @param[in] abstime
- /// If non-nullptr, the absolute time at which we should stop
- /// waiting, else wait an infinite amount of time.
- ///
- /// @param[out] timed_out
- /// If not null, set to true if we return because of a time out,
- /// and false if the value was set.
- ///
- /// @return
- /// @li \b true if the \a m_value became equal to \a value
- /// @li \b false otherwise
- //------------------------------------------------------------------
- bool
- WaitForValueEqualToAndSetValueTo(T wait_value, T new_value,
- const TimeValue *abstime = nullptr,
- bool *timed_out = nullptr)
- {
- int err = 0;
- // pthread_cond_timedwait() or pthread_cond_wait() will atomically
- // unlock the mutex and wait for the condition to be set. When either
- // function returns, they will re-lock the mutex. We use an auto lock/unlock
- // class (Mutex::Locker) to allow us to return at any point in this
- // function and not have to worry about unlocking the mutex.
- Mutex::Locker locker(m_mutex);
+ return m_value == value;
+ }
+
+ //------------------------------------------------------------------
+ /// Wait for \a m_value to be equal to \a value and then set it to
+ /// a new value.
+ ///
+ /// Waits in a thread safe way for \a m_value to be equal to \a
+ /// value and then sets \a m_value to \a new_value. If \a m_value
+ /// is already equal to \a value, this function will immediately
+ /// set \a m_value to \a new_value and return without waiting.
+ ///
+ /// It is possible for the value to be changed between the time
+ /// the value is set and the time the waiting thread wakes up.
+ /// If the value no longer matches the requested value when the
+ /// waiting thread wakes up, it will go back into a wait state. It
+ /// may be necessary for the calling code to use additional thread
+ /// synchronization methods to detect transitory states.
+ ///
+ /// @param[in] value
+ /// The value we want \a m_value to be equal to.
+ ///
+ /// @param[in] new_value
+ /// The value to which \a m_value will be set if \b true is
+ /// returned.
+ ///
+ /// @param[in] abstime
+ /// If non-nullptr, the absolute time at which we should stop
+ /// waiting, else wait an infinite amount of time.
+ ///
+ /// @param[out] timed_out
+ /// If not null, set to true if we return because of a time out,
+ /// and false if the value was set.
+ ///
+ /// @return
+ /// @li \b true if the \a m_value became equal to \a value
+ /// @li \b false otherwise
+ //------------------------------------------------------------------
+ bool WaitForValueEqualToAndSetValueTo(
+ T wait_value, T new_value,
+ const std::chrono::microseconds &timeout = std::chrono::microseconds(0),
+ bool *timed_out = nullptr) {
+ // pthread_cond_timedwait() or pthread_cond_wait() will atomically
+ // unlock the mutex and wait for the condition to be set. When either
+ // function returns, they will re-lock the mutex. We use an auto lock/unlock
+ // class (std::lock_guard) to allow us to return at any point in this
+ // function and not have to worry about unlocking the mutex.
+ std::unique_lock<std::mutex> lock(m_mutex);
#ifdef DB_PTHREAD_LOG_EVENTS
- printf("%s (wait_value = 0x%8.8x, new_value = 0x%8.8x, abstime = %p), m_value = 0x%8.8x\n", __FUNCTION__, wait_value, new_value, abstime, m_value);
+ printf("%s (wait_value = 0x%8.8x, new_value = 0x%8.8x, timeout = %llu), "
+ "m_value = 0x%8.8x\n",
+ __FUNCTION__, wait_value, new_value, timeout.count(), m_value);
#endif
- if (timed_out)
- *timed_out = false;
-
- while (err == 0 && m_value != wait_value)
- {
- err = m_condition.Wait (m_mutex, abstime, timed_out);
- }
-
- if (m_value == wait_value)
- {
- m_value = new_value;
- return true;
+ if (timed_out)
+ *timed_out = false;
+
+ while (m_value != wait_value) {
+ if (timeout == std::chrono::microseconds(0)) {
+ m_condition.wait(lock);
+ } else {
+ std::cv_status result = m_condition.wait_for(lock, timeout);
+ if (result == std::cv_status::timeout) {
+ if (timed_out)
+ *timed_out = true;
+ break;
}
+ }
+ }
- return false;
+ if (m_value == wait_value) {
+ m_value = new_value;
+ return true;
}
- //------------------------------------------------------------------
- /// Wait for \a m_value to not be equal to \a value.
- ///
- /// Waits in a thread safe way for \a m_value to not be equal to \a
- /// value. If \a m_value is already not equal to \a value, this
- /// function will return without waiting.
- ///
- /// It is possible for the value to be changed between the time
- /// the value is set and the time the waiting thread wakes up.
- /// If the value is equal to the test value when the waiting thread
- /// wakes up, it will go back into a wait state. It may be
- /// necessary for the calling code to use additional thread
- /// synchronization methods to detect transitory states.
- ///
- /// @param[in] value
- /// The value we want \a m_value to not be equal to.
- ///
- /// @param[out] new_value
- /// The new value if \b true is returned.
- ///
- /// @param[in] abstime
- /// If non-nullptr, the absolute time at which we should stop
- /// waiting, else wait an infinite amount of time.
- ///
- /// @return
- /// @li \b true if the \a m_value is equal to \a value
- /// @li \b false otherwise
- //------------------------------------------------------------------
- bool
- WaitForValueNotEqualTo(T value, T &new_value, const TimeValue *abstime = nullptr)
- {
- int err = 0;
- // pthread_cond_timedwait() or pthread_cond_wait() will atomically
- // unlock the mutex and wait for the condition to be set. When either
- // function returns, they will re-lock the mutex. We use an auto lock/unlock
- // class (Mutex::Locker) to allow us to return at any point in this
- // function and not have to worry about unlocking the mutex.
- Mutex::Locker locker(m_mutex);
+ return false;
+ }
+
+ //------------------------------------------------------------------
+ /// Wait for \a m_value to not be equal to \a value.
+ ///
+ /// Waits in a thread safe way for \a m_value to not be equal to \a
+ /// value. If \a m_value is already not equal to \a value, this
+ /// function will return without waiting.
+ ///
+ /// It is possible for the value to be changed between the time
+ /// the value is set and the time the waiting thread wakes up.
+ /// If the value is equal to the test value when the waiting thread
+ /// wakes up, it will go back into a wait state. It may be
+ /// necessary for the calling code to use additional thread
+ /// synchronization methods to detect transitory states.
+ ///
+ /// @param[in] value
+ /// The value we want \a m_value to not be equal to.
+ ///
+ /// @param[out] new_value
+ /// The new value if \b true is returned.
+ ///
+ /// @param[in] abstime
+ /// If non-nullptr, the absolute time at which we should stop
+ /// waiting, else wait an infinite amount of time.
+ ///
+ /// @return
+ /// @li \b true if the \a m_value is equal to \a value
+ /// @li \b false otherwise
+ //------------------------------------------------------------------
+ bool WaitForValueNotEqualTo(
+ T value, T &new_value,
+ const std::chrono::microseconds &timeout = std::chrono::microseconds(0)) {
+ // pthread_cond_timedwait() or pthread_cond_wait() will atomically
+ // unlock the mutex and wait for the condition to be set. When either
+ // function returns, they will re-lock the mutex. We use an auto lock/unlock
+ // class (std::lock_guard) to allow us to return at any point in this
+ // function and not have to worry about unlocking the mutex.
+ std::unique_lock<std::mutex> lock(m_mutex);
#ifdef DB_PTHREAD_LOG_EVENTS
- printf("%s (value = 0x%8.8x, abstime = %p), m_value = 0x%8.8x\n", __FUNCTION__, value, abstime, m_value);
+ printf("%s (value = 0x%8.8x, timeout = %llu), m_value = 0x%8.8x\n",
+ __FUNCTION__, value, timeout.count(), m_value);
#endif
- while (err == 0 && m_value == value)
- {
- err = m_condition.Wait (m_mutex, abstime);
- }
+ while (m_value == value) {
+ if (timeout == std::chrono::microseconds(0)) {
+ m_condition.wait(lock);
+ } else {
+ std::cv_status result = m_condition.wait_for(lock, timeout);
+ if (result == std::cv_status::timeout)
+ break;
+ }
+ }
- if (m_value != value)
- {
- new_value = m_value;
- return true;
- }
- return false;
+ if (m_value != value) {
+ new_value = m_value;
+ return true;
}
+ return false;
+ }
protected:
- //----------------------------------------------------------------------
- // pthread condition and mutex variable to control access and allow
- // blocking between the main thread and the spotlight index thread.
- //----------------------------------------------------------------------
- T m_value; ///< The templatized value T that we are protecting access to
- mutable Mutex m_mutex; ///< The mutex to use when accessing the data
- Condition m_condition; ///< The pthread condition variable to use for signaling that data available or changed.
+ //----------------------------------------------------------------------
+ // pthread condition and mutex variable to control access and allow
+ // blocking between the main thread and the spotlight index thread.
+ //----------------------------------------------------------------------
+ T m_value; ///< The templatized value T that we are protecting access to
+ mutable std::mutex m_mutex; ///< The mutex to use when accessing the data
+ std::condition_variable m_condition; ///< The pthread condition variable to
+ ///use for signaling that data available
+ ///or changed.
private:
- //------------------------------------------------------------------
- /// Broadcast if needed.
- ///
- /// Check to see if we need to broadcast to our condition variable
- /// depending on the \a old_value and on the \a broadcast_type.
- ///
- /// If \a broadcast_type is eBroadcastNever, no broadcast will be
- /// sent.
- ///
- /// If \a broadcast_type is eBroadcastAlways, the condition variable
- /// will always be broadcast.
- ///
- /// If \a broadcast_type is eBroadcastOnChange, the condition
- /// variable be broadcast if the owned value changes.
- //------------------------------------------------------------------
- void
- Broadcast (T old_value, PredicateBroadcastType broadcast_type)
- {
- bool broadcast = (broadcast_type == eBroadcastAlways) || ((broadcast_type == eBroadcastOnChange) && old_value != m_value);
+ //------------------------------------------------------------------
+ /// Broadcast if needed.
+ ///
+ /// Check to see if we need to broadcast to our condition variable
+ /// depending on the \a old_value and on the \a broadcast_type.
+ ///
+ /// If \a broadcast_type is eBroadcastNever, no broadcast will be
+ /// sent.
+ ///
+ /// If \a broadcast_type is eBroadcastAlways, the condition variable
+ /// will always be broadcast.
+ ///
+ /// If \a broadcast_type is eBroadcastOnChange, the condition
+ /// variable be broadcast if the owned value changes.
+ //------------------------------------------------------------------
+ void Broadcast(T old_value, PredicateBroadcastType broadcast_type) {
+ bool broadcast =
+ (broadcast_type == eBroadcastAlways) ||
+ ((broadcast_type == eBroadcastOnChange) && old_value != m_value);
#ifdef DB_PTHREAD_LOG_EVENTS
- printf("%s (old_value = 0x%8.8x, broadcast_type = %i) m_value = 0x%8.8x, broadcast = %u\n", __FUNCTION__, old_value, broadcast_type, m_value, broadcast);
+ printf("%s (old_value = 0x%8.8x, broadcast_type = %i) m_value = 0x%8.8x, "
+ "broadcast = %u\n",
+ __FUNCTION__, old_value, broadcast_type, m_value, broadcast);
#endif
- if (broadcast)
- m_condition.Broadcast();
- }
+ if (broadcast)
+ m_condition.notify_all();
+ }
- DISALLOW_COPY_AND_ASSIGN(Predicate);
+ DISALLOW_COPY_AND_ASSIGN(Predicate);
};
} // namespace lldb_private
diff --git a/include/lldb/Host/ProcessLauncher.h b/include/lldb/Host/ProcessLauncher.h
index 14685fd3c53a..12049a69b3da 100644
--- a/include/lldb/Host/ProcessLauncher.h
+++ b/include/lldb/Host/ProcessLauncher.h
@@ -10,18 +10,17 @@
#ifndef lldb_Host_ProcessLauncher_h_
#define lldb_Host_ProcessLauncher_h_
-namespace lldb_private
-{
+namespace lldb_private {
class ProcessLaunchInfo;
class Error;
class HostProcess;
-class ProcessLauncher
-{
- public:
- virtual ~ProcessLauncher() {}
- virtual HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info, Error &error) = 0;
+class ProcessLauncher {
+public:
+ virtual ~ProcessLauncher() {}
+ virtual HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info,
+ Error &error) = 0;
};
}
diff --git a/include/lldb/Host/ProcessRunLock.h b/include/lldb/Host/ProcessRunLock.h
index 797939a7edee..7044fdbd9ef9 100644
--- a/include/lldb/Host/ProcessRunLock.h
+++ b/include/lldb/Host/ProcessRunLock.h
@@ -18,7 +18,6 @@
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-defines.h"
-#include "lldb/Host/Condition.h"
//----------------------------------------------------------------------
/// Enumerations for broadcasting.
@@ -31,77 +30,61 @@ namespace lldb_private {
/// threads are accessing its data, and prevent access to its data while
/// it is running.
//----------------------------------------------------------------------
-
-class ProcessRunLock
-{
+
+class ProcessRunLock {
public:
- ProcessRunLock();
- ~ProcessRunLock();
-
- bool ReadTryLock ();
- bool ReadUnlock ();
- bool SetRunning ();
- bool TrySetRunning ();
- bool SetStopped ();
-
- class ProcessRunLocker
- {
- public:
- ProcessRunLocker () :
- m_lock (nullptr)
- {
- }
+ ProcessRunLock();
+ ~ProcessRunLock();
- ~ProcessRunLocker()
- {
- Unlock();
- }
+ bool ReadTryLock();
+ bool ReadUnlock();
+ bool SetRunning();
+ bool TrySetRunning();
+ bool SetStopped();
- // Try to lock the read lock, but only do so if there are no writers.
- bool
- TryLock (ProcessRunLock *lock)
- {
- if (m_lock)
- {
- if (m_lock == lock)
- return true; // We already have this lock locked
- else
- Unlock();
- }
- if (lock)
- {
- if (lock->ReadTryLock())
- {
- m_lock = lock;
- return true;
- }
- }
- return false;
- }
+ class ProcessRunLocker {
+ public:
+ ProcessRunLocker() : m_lock(nullptr) {}
- protected:
- void
- Unlock ()
- {
- if (m_lock)
- {
- m_lock->ReadUnlock();
- m_lock = nullptr;
- }
+ ~ProcessRunLocker() { Unlock(); }
+
+ // Try to lock the read lock, but only do so if there are no writers.
+ bool TryLock(ProcessRunLock *lock) {
+ if (m_lock) {
+ if (m_lock == lock)
+ return true; // We already have this lock locked
+ else
+ Unlock();
+ }
+ if (lock) {
+ if (lock->ReadTryLock()) {
+ m_lock = lock;
+ return true;
}
-
- ProcessRunLock *m_lock;
+ }
+ return false;
+ }
+
+ protected:
+ void Unlock() {
+ if (m_lock) {
+ m_lock->ReadUnlock();
+ m_lock = nullptr;
+ }
+ }
+
+ ProcessRunLock *m_lock;
- private:
- DISALLOW_COPY_AND_ASSIGN(ProcessRunLocker);
- };
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ProcessRunLocker);
+ };
protected:
- lldb::rwlock_t m_rwlock;
- bool m_running;
+ lldb::rwlock_t m_rwlock;
+ bool m_running;
private:
- DISALLOW_COPY_AND_ASSIGN(ProcessRunLock);
+ DISALLOW_COPY_AND_ASSIGN(ProcessRunLock);
};
} // namespace lldb_private
diff --git a/include/lldb/Host/Socket.h b/include/lldb/Host/Socket.h
index a38b42f817c6..1ad3ca765cba 100644
--- a/include/lldb/Host/Socket.h
+++ b/include/lldb/Host/Socket.h
@@ -26,91 +26,98 @@
#include <ws2tcpip.h>
#endif
-namespace llvm
-{
- class StringRef;
+namespace llvm {
+class StringRef;
}
namespace lldb_private {
#if defined(_MSC_VER)
- typedef SOCKET NativeSocket;
+typedef SOCKET NativeSocket;
#else
- typedef int NativeSocket;
+typedef int NativeSocket;
#endif
-class Socket : public IOObject
-{
+class Socket : public IOObject {
public:
- typedef enum
- {
- ProtocolTcp,
- ProtocolUdp,
- ProtocolUnixDomain,
- ProtocolUnixAbstract
- } SocketProtocol;
-
- static const NativeSocket kInvalidSocketValue;
-
- ~Socket() override;
-
- static std::unique_ptr<Socket> Create(const SocketProtocol protocol, bool child_processes_inherit, Error &error);
-
- virtual Error Connect(llvm::StringRef name) = 0;
- virtual Error Listen(llvm::StringRef name, int backlog) = 0;
- virtual Error Accept(llvm::StringRef name, bool child_processes_inherit, Socket *&socket) = 0;
-
- // Initialize a Tcp Socket object in listening mode. listen and accept are implemented
- // separately because the caller may wish to manipulate or query the socket after it is
- // initialized, but before entering a blocking accept.
- static Error TcpListen(
- llvm::StringRef host_and_port,
- bool child_processes_inherit,
- Socket *&socket,
- Predicate<uint16_t>* predicate,
- int backlog = 5);
- static Error TcpConnect(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&socket);
- static Error UdpConnect(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&send_socket, Socket *&recv_socket);
- static Error UnixDomainConnect(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&socket);
- static Error UnixDomainAccept(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&socket);
- static Error UnixAbstractConnect(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&socket);
- static Error UnixAbstractAccept(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&socket);
-
- int GetOption (int level, int option_name, int &option_value);
- int SetOption (int level, int option_name, int option_value);
-
- NativeSocket GetNativeSocket () const { return m_socket; }
- SocketProtocol GetSocketProtocol () const { return m_protocol; }
-
- Error Read (void *buf, size_t &num_bytes) override;
- Error Write (const void *buf, size_t &num_bytes) override;
-
- virtual Error PreDisconnect ();
- Error Close() override;
-
- bool IsValid () const override { return m_socket != kInvalidSocketValue; }
- WaitableHandle GetWaitableHandle () override;
-
- static bool
- DecodeHostAndPort (llvm::StringRef host_and_port,
- std::string &host_str,
- std::string &port_str,
- int32_t& port,
- Error *error_ptr);
+ typedef enum {
+ ProtocolTcp,
+ ProtocolUdp,
+ ProtocolUnixDomain,
+ ProtocolUnixAbstract
+ } SocketProtocol;
+
+ static const NativeSocket kInvalidSocketValue;
+
+ ~Socket() override;
+
+ static std::unique_ptr<Socket> Create(const SocketProtocol protocol,
+ bool child_processes_inherit,
+ Error &error);
+
+ virtual Error Connect(llvm::StringRef name) = 0;
+ virtual Error Listen(llvm::StringRef name, int backlog) = 0;
+ virtual Error Accept(llvm::StringRef name, bool child_processes_inherit,
+ Socket *&socket) = 0;
+
+ // Initialize a Tcp Socket object in listening mode. listen and accept are
+ // implemented
+ // separately because the caller may wish to manipulate or query the socket
+ // after it is
+ // initialized, but before entering a blocking accept.
+ static Error TcpListen(llvm::StringRef host_and_port,
+ bool child_processes_inherit, Socket *&socket,
+ Predicate<uint16_t> *predicate, int backlog = 5);
+ static Error TcpConnect(llvm::StringRef host_and_port,
+ bool child_processes_inherit, Socket *&socket);
+ static Error UdpConnect(llvm::StringRef host_and_port,
+ bool child_processes_inherit, Socket *&send_socket,
+ Socket *&recv_socket);
+ static Error UnixDomainConnect(llvm::StringRef host_and_port,
+ bool child_processes_inherit, Socket *&socket);
+ static Error UnixDomainAccept(llvm::StringRef host_and_port,
+ bool child_processes_inherit, Socket *&socket);
+ static Error UnixAbstractConnect(llvm::StringRef host_and_port,
+ bool child_processes_inherit,
+ Socket *&socket);
+ static Error UnixAbstractAccept(llvm::StringRef host_and_port,
+ bool child_processes_inherit,
+ Socket *&socket);
+
+ int GetOption(int level, int option_name, int &option_value);
+ int SetOption(int level, int option_name, int option_value);
+
+ NativeSocket GetNativeSocket() const { return m_socket; }
+ SocketProtocol GetSocketProtocol() const { return m_protocol; }
+
+ Error Read(void *buf, size_t &num_bytes) override;
+ Error Write(const void *buf, size_t &num_bytes) override;
+
+ virtual Error PreDisconnect();
+ Error Close() override;
+
+ bool IsValid() const override { return m_socket != kInvalidSocketValue; }
+ WaitableHandle GetWaitableHandle() override;
+
+ static bool DecodeHostAndPort(llvm::StringRef host_and_port,
+ std::string &host_str, std::string &port_str,
+ int32_t &port, Error *error_ptr);
protected:
- Socket(NativeSocket socket, SocketProtocol protocol, bool should_close);
+ Socket(NativeSocket socket, SocketProtocol protocol, bool should_close);
- virtual size_t Send(const void *buf, const size_t num_bytes);
+ virtual size_t Send(const void *buf, const size_t num_bytes);
- static void SetLastError(Error &error);
- static NativeSocket CreateSocket(
- const int domain, const int type, const int protocol, bool child_processes_inherit, Error& error);
- static NativeSocket AcceptSocket(
- NativeSocket sockfd, struct sockaddr *addr, socklen_t *addrlen, bool child_processes_inherit, Error& error);
+ static void SetLastError(Error &error);
+ static NativeSocket CreateSocket(const int domain, const int type,
+ const int protocol,
+ bool child_processes_inherit, Error &error);
+ static NativeSocket AcceptSocket(NativeSocket sockfd, struct sockaddr *addr,
+ socklen_t *addrlen,
+ bool child_processes_inherit, Error &error);
- SocketProtocol m_protocol;
- NativeSocket m_socket;
+ SocketProtocol m_protocol;
+ NativeSocket m_socket;
};
} // namespace lldb_private
diff --git a/include/lldb/Host/SocketAddress.h b/include/lldb/Host/SocketAddress.h
index 9666f56489f6..3d1ed906e1ef 100644
--- a/include/lldb/Host/SocketAddress.h
+++ b/include/lldb/Host/SocketAddress.h
@@ -19,9 +19,9 @@
#include <ws2tcpip.h>
typedef ADDRESS_FAMILY sa_family_t;
#else
-#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
+#include <sys/socket.h>
#endif
#if defined(__FreeBSD__)
@@ -35,243 +35,180 @@ typedef ADDRESS_FAMILY sa_family_t;
namespace lldb_private {
-class SocketAddress
-{
+class SocketAddress {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- SocketAddress ();
- SocketAddress (const struct sockaddr &s);
- SocketAddress (const struct sockaddr_in &s);
- SocketAddress (const struct sockaddr_in6 &s);
- SocketAddress (const struct sockaddr_storage &s);
- SocketAddress (const SocketAddress& rhs);
- ~SocketAddress ();
-
- //------------------------------------------------------------------
- // Operators
- //------------------------------------------------------------------
- const SocketAddress&
- operator=(const SocketAddress& rhs);
-
- const SocketAddress&
- operator=(const struct addrinfo *addr_info);
-
- const SocketAddress&
- operator=(const struct sockaddr &s);
-
- const SocketAddress&
- operator=(const struct sockaddr_in &s);
-
- const SocketAddress&
- operator=(const struct sockaddr_in6 &s);
-
- const SocketAddress&
- operator=(const struct sockaddr_storage &s);
-
- //------------------------------------------------------------------
- // Clear the contents of this socket address
- //------------------------------------------------------------------
- void
- Clear ();
-
- //------------------------------------------------------------------
- // Get the length for the current socket address family
- //------------------------------------------------------------------
- socklen_t
- GetLength () const;
-
- //------------------------------------------------------------------
- // Get the max length for the largest socket address supported.
- //------------------------------------------------------------------
- static socklen_t
- GetMaxLength ();
-
- //------------------------------------------------------------------
- // Get the socket address family
- //------------------------------------------------------------------
- sa_family_t
- GetFamily () const;
-
- //------------------------------------------------------------------
- // Set the socket address family
- //------------------------------------------------------------------
- void
- SetFamily (sa_family_t family);
-
- //------------------------------------------------------------------
- // Get the address
- //------------------------------------------------------------------
- std::string
- GetIPAddress () const;
-
- //------------------------------------------------------------------
- // Get the port if the socket address for the family has a port
- //------------------------------------------------------------------
- uint16_t
- GetPort () const;
-
- //------------------------------------------------------------------
- // Set the port if the socket address for the family has a port.
- // The family must be set correctly prior to calling this function.
- //------------------------------------------------------------------
- bool
- SetPort (uint16_t port);
-
- //------------------------------------------------------------------
- // Set the socket address according to the first match from a call
- // to getaddrinfo() (or equivalent functions for systems that don't
- // have getaddrinfo(). If "addr_info_ptr" is not NULL, it will get
- // filled in with the match that was used to populate this socket
- // address.
- //------------------------------------------------------------------
- bool
- getaddrinfo (const char *host, // Hostname ("foo.bar.com" or "foo" or IP address string ("123.234.12.1" or "2001:0db8:85a3:0000:0000:8a2e:0370:7334")
- const char *service, // Protocol name ("tcp", "http", etc) or a raw port number string ("81")
- int ai_family = PF_UNSPEC,
- int ai_socktype = 0,
- int ai_protocol = 0,
- int ai_flags = 0);
-
- //------------------------------------------------------------------
- // Quick way to set the SocketAddress to localhost given the family.
- // Returns true if successful, false if "family" doesn't support
- // localhost or if "family" is not supported by this class.
- //------------------------------------------------------------------
- bool
- SetToLocalhost (sa_family_t family,
- uint16_t port);
-
- bool
- SetToAnyAddress (sa_family_t family,
- uint16_t port);
-
- //------------------------------------------------------------------
- // Returns true if there is a valid socket address in this object.
- //------------------------------------------------------------------
- bool
- IsValid () const;
-
- //------------------------------------------------------------------
- // Direct access to all of the sockaddr structures
- //------------------------------------------------------------------
- struct sockaddr &
- sockaddr ()
- {
- return m_socket_addr.sa;
- }
-
- const struct sockaddr &
- sockaddr () const
- {
- return m_socket_addr.sa;
- }
-
- struct sockaddr_in &
- sockaddr_in ()
- {
- return m_socket_addr.sa_ipv4;
- }
-
- const struct sockaddr_in &
- sockaddr_in () const
- {
- return m_socket_addr.sa_ipv4;
- }
-
- struct sockaddr_in6 &
- sockaddr_in6 ()
- {
- return m_socket_addr.sa_ipv6;
- }
-
- const struct sockaddr_in6 &
- sockaddr_in6 () const
- {
- return m_socket_addr.sa_ipv6;
- }
-
- struct sockaddr_storage &
- sockaddr_storage ()
- {
- return m_socket_addr.sa_storage;
- }
-
-
- const struct sockaddr_storage &
- sockaddr_storage () const
- {
- return m_socket_addr.sa_storage;
- }
-
-
- //------------------------------------------------------------------
- // Conversion operators to allow getting the contents of this class
- // as a pointer to the appropriate structure. This allows an instance
- // of this class to be used in calls that take one of the sockaddr
- // structure variants without having to manually use the correct
- // accessor function.
- //------------------------------------------------------------------
-
- operator struct sockaddr * ()
- {
- return &m_socket_addr.sa;
- }
-
- operator const struct sockaddr * () const
- {
- return &m_socket_addr.sa;
- }
-
- operator struct sockaddr_in * ()
- {
- return &m_socket_addr.sa_ipv4;
- }
-
- operator const struct sockaddr_in * () const
- {
- return &m_socket_addr.sa_ipv4;
- }
-
- operator struct sockaddr_in6 * ()
- {
- return &m_socket_addr.sa_ipv6;
- }
-
- operator const struct sockaddr_in6 * () const
- {
- return &m_socket_addr.sa_ipv6;
- }
-
- operator const struct sockaddr_storage * () const
- {
- return &m_socket_addr.sa_storage;
- }
-
- operator struct sockaddr_storage * ()
- {
- return &m_socket_addr.sa_storage;
- }
-
-
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ SocketAddress();
+ SocketAddress(const struct sockaddr &s);
+ SocketAddress(const struct sockaddr_in &s);
+ SocketAddress(const struct sockaddr_in6 &s);
+ SocketAddress(const struct sockaddr_storage &s);
+ SocketAddress(const SocketAddress &rhs);
+ ~SocketAddress();
+
+ //------------------------------------------------------------------
+ // Operators
+ //------------------------------------------------------------------
+ const SocketAddress &operator=(const SocketAddress &rhs);
+
+ const SocketAddress &operator=(const struct addrinfo *addr_info);
+
+ const SocketAddress &operator=(const struct sockaddr &s);
+
+ const SocketAddress &operator=(const struct sockaddr_in &s);
+
+ const SocketAddress &operator=(const struct sockaddr_in6 &s);
+
+ const SocketAddress &operator=(const struct sockaddr_storage &s);
+
+ //------------------------------------------------------------------
+ // Clear the contents of this socket address
+ //------------------------------------------------------------------
+ void Clear();
+
+ //------------------------------------------------------------------
+ // Get the length for the current socket address family
+ //------------------------------------------------------------------
+ socklen_t GetLength() const;
+
+ //------------------------------------------------------------------
+ // Get the max length for the largest socket address supported.
+ //------------------------------------------------------------------
+ static socklen_t GetMaxLength();
+
+ //------------------------------------------------------------------
+ // Get the socket address family
+ //------------------------------------------------------------------
+ sa_family_t GetFamily() const;
+
+ //------------------------------------------------------------------
+ // Set the socket address family
+ //------------------------------------------------------------------
+ void SetFamily(sa_family_t family);
+
+ //------------------------------------------------------------------
+ // Get the address
+ //------------------------------------------------------------------
+ std::string GetIPAddress() const;
+
+ //------------------------------------------------------------------
+ // Get the port if the socket address for the family has a port
+ //------------------------------------------------------------------
+ uint16_t GetPort() const;
+
+ //------------------------------------------------------------------
+ // Set the port if the socket address for the family has a port.
+ // The family must be set correctly prior to calling this function.
+ //------------------------------------------------------------------
+ bool SetPort(uint16_t port);
+
+ //------------------------------------------------------------------
+ // Set the socket address according to the first match from a call
+ // to getaddrinfo() (or equivalent functions for systems that don't
+ // have getaddrinfo(). If "addr_info_ptr" is not NULL, it will get
+ // filled in with the match that was used to populate this socket
+ // address.
+ //------------------------------------------------------------------
+ bool
+ getaddrinfo(const char *host, // Hostname ("foo.bar.com" or "foo" or IP
+ // address string ("123.234.12.1" or
+ // "2001:0db8:85a3:0000:0000:8a2e:0370:7334")
+ const char *service, // Protocol name ("tcp", "http", etc) or a
+ // raw port number string ("81")
+ int ai_family = PF_UNSPEC, int ai_socktype = 0,
+ int ai_protocol = 0, int ai_flags = 0);
+
+ //------------------------------------------------------------------
+ // Quick way to set the SocketAddress to localhost given the family.
+ // Returns true if successful, false if "family" doesn't support
+ // localhost or if "family" is not supported by this class.
+ //------------------------------------------------------------------
+ bool SetToLocalhost(sa_family_t family, uint16_t port);
+
+ bool SetToAnyAddress(sa_family_t family, uint16_t port);
+
+ //------------------------------------------------------------------
+ // Returns true if there is a valid socket address in this object.
+ //------------------------------------------------------------------
+ bool IsValid() const;
+
+ //------------------------------------------------------------------
+ // Direct access to all of the sockaddr structures
+ //------------------------------------------------------------------
+ struct sockaddr &sockaddr() {
+ return m_socket_addr.sa;
+ }
+
+ const struct sockaddr &sockaddr() const { return m_socket_addr.sa; }
+
+ struct sockaddr_in &sockaddr_in() {
+ return m_socket_addr.sa_ipv4;
+ }
+
+ const struct sockaddr_in &sockaddr_in() const {
+ return m_socket_addr.sa_ipv4;
+ }
+
+ struct sockaddr_in6 &sockaddr_in6() {
+ return m_socket_addr.sa_ipv6;
+ }
+
+ const struct sockaddr_in6 &sockaddr_in6() const {
+ return m_socket_addr.sa_ipv6;
+ }
+
+ struct sockaddr_storage &sockaddr_storage() {
+ return m_socket_addr.sa_storage;
+ }
+
+ const struct sockaddr_storage &sockaddr_storage() const {
+ return m_socket_addr.sa_storage;
+ }
+
+ //------------------------------------------------------------------
+ // Conversion operators to allow getting the contents of this class
+ // as a pointer to the appropriate structure. This allows an instance
+ // of this class to be used in calls that take one of the sockaddr
+ // structure variants without having to manually use the correct
+ // accessor function.
+ //------------------------------------------------------------------
+
+ operator struct sockaddr *() { return &m_socket_addr.sa; }
+
+ operator const struct sockaddr *() const { return &m_socket_addr.sa; }
+
+ operator struct sockaddr_in *() { return &m_socket_addr.sa_ipv4; }
+
+ operator const struct sockaddr_in *() const { return &m_socket_addr.sa_ipv4; }
+
+ operator struct sockaddr_in6 *() { return &m_socket_addr.sa_ipv6; }
+
+ operator const struct sockaddr_in6 *() const {
+ return &m_socket_addr.sa_ipv6;
+ }
+
+ operator const struct sockaddr_storage *() const {
+ return &m_socket_addr.sa_storage;
+ }
+
+ operator struct sockaddr_storage *() { return &m_socket_addr.sa_storage; }
+
protected:
- typedef union sockaddr_tag
- {
- struct sockaddr sa;
- struct sockaddr_in sa_ipv4;
- struct sockaddr_in6 sa_ipv6;
- struct sockaddr_storage sa_storage;
- } sockaddr_t;
-
- //------------------------------------------------------------------
- // Classes that inherit from SocketAddress can see and modify these
- //------------------------------------------------------------------
- sockaddr_t m_socket_addr;
+ typedef union sockaddr_tag {
+ struct sockaddr sa;
+ struct sockaddr_in sa_ipv4;
+ struct sockaddr_in6 sa_ipv6;
+ struct sockaddr_storage sa_storage;
+ } sockaddr_t;
+
+ //------------------------------------------------------------------
+ // Classes that inherit from SocketAddress can see and modify these
+ //------------------------------------------------------------------
+ sockaddr_t m_socket_addr;
};
-
} // namespace lldb_private
-
-#endif // liblldb_SocketAddress_h_
+#endif // liblldb_SocketAddress_h_
diff --git a/include/lldb/Host/StringConvert.h b/include/lldb/Host/StringConvert.h
index af5c2a08db87..05bd7808ecd4 100644
--- a/include/lldb/Host/StringConvert.h
+++ b/include/lldb/Host/StringConvert.h
@@ -19,7 +19,7 @@
// Project includes
namespace lldb_private {
-
+
namespace StringConvert {
//----------------------------------------------------------------------
@@ -27,20 +27,20 @@ namespace StringConvert {
/// @brief Utility classes for converting strings into Integers
//----------------------------------------------------------------------
-int32_t
-ToSInt32 (const char *s, int32_t fail_value = 0, int base = 0, bool *success_ptr = nullptr);
+int32_t ToSInt32(const char *s, int32_t fail_value = 0, int base = 0,
+ bool *success_ptr = nullptr);
-uint32_t
-ToUInt32 (const char *s, uint32_t fail_value = 0, int base = 0, bool *success_ptr = nullptr);
+uint32_t ToUInt32(const char *s, uint32_t fail_value = 0, int base = 0,
+ bool *success_ptr = nullptr);
-int64_t
-ToSInt64 (const char *s, int64_t fail_value = 0, int base = 0, bool *success_ptr = nullptr);
+int64_t ToSInt64(const char *s, int64_t fail_value = 0, int base = 0,
+ bool *success_ptr = nullptr);
-uint64_t
-ToUInt64 (const char *s, uint64_t fail_value = 0, int base = 0, bool *success_ptr = nullptr);
+uint64_t ToUInt64(const char *s, uint64_t fail_value = 0, int base = 0,
+ bool *success_ptr = nullptr);
-double
-ToDouble (const char *s, double fail_value = 0.0, bool *success_ptr = nullptr);
+double ToDouble(const char *s, double fail_value = 0.0,
+ bool *success_ptr = nullptr);
} // namespace StringConvert
} // namespace lldb_private
diff --git a/include/lldb/Host/Symbols.h b/include/lldb/Host/Symbols.h
index 0ca864c8c85c..1339c064d54c 100644
--- a/include/lldb/Host/Symbols.h
+++ b/include/lldb/Host/Symbols.h
@@ -20,49 +20,43 @@
namespace lldb_private {
-class Symbols
-{
+class Symbols {
public:
- //----------------------------------------------------------------------
- // Locate the executable file given a module specification.
- //
- // Locating the file should happen only on the local computer or using
- // the current computers global settings.
- //----------------------------------------------------------------------
- static ModuleSpec
- LocateExecutableObjectFile (const ModuleSpec &module_spec);
-
- //----------------------------------------------------------------------
- // Locate the symbol file given a module specification.
- //
- // Locating the file should happen only on the local computer or using
- // the current computers global settings.
- //----------------------------------------------------------------------
- static FileSpec
- LocateExecutableSymbolFile (const ModuleSpec &module_spec);
-
- static FileSpec
- FindSymbolFileInBundle (const FileSpec& dsym_bundle_fspec,
- const lldb_private::UUID *uuid,
- const ArchSpec *arch);
-
- //----------------------------------------------------------------------
- // Locate the object and symbol file given a module specification.
- //
- // Locating the file can try to download the file from a corporate build
- // repository, or using any other means necessary to locate both the
- // unstripped object file and the debug symbols.
- // The force_lookup argument controls whether the external program is called
- // unconditionally to find the symbol file, or if the user's settings are
- // checked to see if they've enabled the external program before calling.
- //
- //----------------------------------------------------------------------
- static bool
- DownloadObjectAndSymbolFile (ModuleSpec &module_spec, bool force_lookup = true);
-
+ //----------------------------------------------------------------------
+ // Locate the executable file given a module specification.
+ //
+ // Locating the file should happen only on the local computer or using
+ // the current computers global settings.
+ //----------------------------------------------------------------------
+ static ModuleSpec LocateExecutableObjectFile(const ModuleSpec &module_spec);
+
+ //----------------------------------------------------------------------
+ // Locate the symbol file given a module specification.
+ //
+ // Locating the file should happen only on the local computer or using
+ // the current computers global settings.
+ //----------------------------------------------------------------------
+ static FileSpec LocateExecutableSymbolFile(const ModuleSpec &module_spec);
+
+ static FileSpec FindSymbolFileInBundle(const FileSpec &dsym_bundle_fspec,
+ const lldb_private::UUID *uuid,
+ const ArchSpec *arch);
+
+ //----------------------------------------------------------------------
+ // Locate the object and symbol file given a module specification.
+ //
+ // Locating the file can try to download the file from a corporate build
+ // repository, or using any other means necessary to locate both the
+ // unstripped object file and the debug symbols.
+ // The force_lookup argument controls whether the external program is called
+ // unconditionally to find the symbol file, or if the user's settings are
+ // checked to see if they've enabled the external program before calling.
+ //
+ //----------------------------------------------------------------------
+ static bool DownloadObjectAndSymbolFile(ModuleSpec &module_spec,
+ bool force_lookup = true);
};
} // namespace lldb_private
-
-#endif // liblldb_Symbols_h_
+#endif // liblldb_Symbols_h_
diff --git a/include/lldb/Host/Terminal.h b/include/lldb/Host/Terminal.h
index 4a6017fc2eee..f0d93ad24ed6 100644
--- a/include/lldb/Host/Terminal.h
+++ b/include/lldb/Host/Terminal.h
@@ -11,64 +11,37 @@
#define liblldb_Terminal_h_
#if defined(__cplusplus)
-#include "lldb/lldb-private.h"
#include "lldb/Host/Config.h"
+#include "lldb/lldb-private.h"
struct termios;
namespace lldb_private {
-class Terminal
-{
+class Terminal {
public:
+ Terminal(int fd = -1) : m_fd(fd) {}
+
+ ~Terminal() {}
+
+ bool IsATerminal() const;
+
+ int GetFileDescriptor() const { return m_fd; }
+
+ void SetFileDescriptor(int fd) { m_fd = fd; }
- Terminal (int fd = -1) :
- m_fd (fd)
- {
- }
-
- ~Terminal ()
- {
- }
-
- bool
- IsATerminal () const;
-
- int
- GetFileDescriptor () const
- {
- return m_fd;
- }
-
- void
- SetFileDescriptor (int fd)
- {
- m_fd = fd;
- }
-
- bool
- FileDescriptorIsValid () const
- {
- return m_fd != -1;
- }
-
- void
- Clear ()
- {
- m_fd = -1;
- }
-
- bool
- SetEcho (bool enabled);
-
- bool
- SetCanonical (bool enabled);
+ bool FileDescriptorIsValid() const { return m_fd != -1; }
+
+ void Clear() { m_fd = -1; }
+
+ bool SetEcho(bool enabled);
+
+ bool SetCanonical(bool enabled);
protected:
- int m_fd; // This may or may not be a terminal file descriptor
+ int m_fd; // This may or may not be a terminal file descriptor
};
-
//----------------------------------------------------------------------
/// @class State Terminal.h "lldb/Host/Terminal.h"
/// @brief A terminal state saving/restoring class.
@@ -76,109 +49,100 @@ protected:
/// This class can be used to remember the terminal state for a file
/// descriptor and later restore that state as it originally was.
//----------------------------------------------------------------------
-class TerminalState
-{
+class TerminalState {
public:
- //------------------------------------------------------------------
- /// Default constructor
- //------------------------------------------------------------------
- TerminalState();
-
- //------------------------------------------------------------------
- /// Destructor
- //------------------------------------------------------------------
- ~TerminalState();
-
- //------------------------------------------------------------------
- /// Save the TTY state for \a fd.
- ///
- /// Save the current state of the TTY for the file descriptor "fd"
- /// and if "save_process_group" is true, attempt to save the process
- /// group info for the TTY.
- ///
- /// @param[in] fd
- /// The file descriptor to save the state of.
- ///
- /// @param[in] save_process_group
- /// If \b true, save the process group settings, else do not
- /// save the process group settings for a TTY.
- ///
- /// @return
- /// Returns \b true if \a fd describes a TTY and if the state
- /// was able to be saved, \b false otherwise.
- //------------------------------------------------------------------
- bool
- Save (int fd, bool save_process_group);
-
- //------------------------------------------------------------------
- /// Restore the TTY state to the cached state.
- ///
- /// Restore the state of the TTY using the cached values from a
- /// previous call to TerminalState::Save(int,bool).
- ///
- /// @return
- /// Returns \b true if the TTY state was successfully restored,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool
- Restore () const;
-
- //------------------------------------------------------------------
- /// Test for valid cached TTY state information.
- ///
- /// @return
- /// Returns \b true if this object has valid saved TTY state
- /// settings that can be used to restore a previous state,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool
- IsValid() const;
-
- void
- Clear ();
+ //------------------------------------------------------------------
+ /// Default constructor
+ //------------------------------------------------------------------
+ TerminalState();
+
+ //------------------------------------------------------------------
+ /// Destructor
+ //------------------------------------------------------------------
+ ~TerminalState();
+
+ //------------------------------------------------------------------
+ /// Save the TTY state for \a fd.
+ ///
+ /// Save the current state of the TTY for the file descriptor "fd"
+ /// and if "save_process_group" is true, attempt to save the process
+ /// group info for the TTY.
+ ///
+ /// @param[in] fd
+ /// The file descriptor to save the state of.
+ ///
+ /// @param[in] save_process_group
+ /// If \b true, save the process group settings, else do not
+ /// save the process group settings for a TTY.
+ ///
+ /// @return
+ /// Returns \b true if \a fd describes a TTY and if the state
+ /// was able to be saved, \b false otherwise.
+ //------------------------------------------------------------------
+ bool Save(int fd, bool save_process_group);
+
+ //------------------------------------------------------------------
+ /// Restore the TTY state to the cached state.
+ ///
+ /// Restore the state of the TTY using the cached values from a
+ /// previous call to TerminalState::Save(int,bool).
+ ///
+ /// @return
+ /// Returns \b true if the TTY state was successfully restored,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool Restore() const;
+
+ //------------------------------------------------------------------
+ /// Test for valid cached TTY state information.
+ ///
+ /// @return
+ /// Returns \b true if this object has valid saved TTY state
+ /// settings that can be used to restore a previous state,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsValid() const;
+
+ void Clear();
protected:
-
- //------------------------------------------------------------------
- /// Test if tflags is valid.
- ///
- /// @return
- /// Returns \b true if \a m_tflags is valid and can be restored,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool
- TFlagsIsValid() const;
-
- //------------------------------------------------------------------
- /// Test if ttystate is valid.
- ///
- /// @return
- /// Returns \b true if \a m_ttystate is valid and can be
- /// restored, \b false otherwise.
- //------------------------------------------------------------------
- bool
- TTYStateIsValid() const;
-
- //------------------------------------------------------------------
- /// Test if the process group information is valid.
- ///
- /// @return
- /// Returns \b true if \a m_process_group is valid and can be
- /// restored, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ProcessGroupIsValid() const;
-
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- Terminal m_tty; ///< A terminal
- int m_tflags; ///< Cached tflags information.
+ //------------------------------------------------------------------
+ /// Test if tflags is valid.
+ ///
+ /// @return
+ /// Returns \b true if \a m_tflags is valid and can be restored,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool TFlagsIsValid() const;
+
+ //------------------------------------------------------------------
+ /// Test if ttystate is valid.
+ ///
+ /// @return
+ /// Returns \b true if \a m_ttystate is valid and can be
+ /// restored, \b false otherwise.
+ //------------------------------------------------------------------
+ bool TTYStateIsValid() const;
+
+ //------------------------------------------------------------------
+ /// Test if the process group information is valid.
+ ///
+ /// @return
+ /// Returns \b true if \a m_process_group is valid and can be
+ /// restored, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ProcessGroupIsValid() const;
+
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ Terminal m_tty; ///< A terminal
+ int m_tflags; ///< Cached tflags information.
#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
- std::unique_ptr<struct termios> m_termios_ap; ///< Cached terminal state information.
+ std::unique_ptr<struct termios>
+ m_termios_ap; ///< Cached terminal state information.
#endif
- lldb::pid_t m_process_group;///< Cached process group information.
-
+ lldb::pid_t m_process_group; ///< Cached process group information.
};
//----------------------------------------------------------------------
@@ -188,70 +152,67 @@ protected:
/// This class can be used to remember 2 TTY states for a given file
/// descriptor and switch between the two states.
//----------------------------------------------------------------------
-class TerminalStateSwitcher
-{
+class TerminalStateSwitcher {
public:
- //------------------------------------------------------------------
- /// Constructor
- //------------------------------------------------------------------
- TerminalStateSwitcher();
-
- //------------------------------------------------------------------
- /// Destructor
- //------------------------------------------------------------------
- ~TerminalStateSwitcher();
-
- //------------------------------------------------------------------
- /// Get the number of possible states to save.
- ///
- /// @return
- /// The number of states that this TTY switcher object contains.
- //------------------------------------------------------------------
- uint32_t
- GetNumberOfStates() const;
-
- //------------------------------------------------------------------
- /// Restore the TTY state for state at index \a idx.
- ///
- /// @return
- /// Returns \b true if the TTY state was successfully restored,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool
- Restore (uint32_t idx) const;
-
- //------------------------------------------------------------------
- /// Save the TTY state information for the state at index \a idx.
- /// The TTY state is saved for the file descriptor \a fd and
- /// the process group information will also be saved if requested
- /// by \a save_process_group.
- ///
- /// @param[in] idx
- /// The index into the state array where the state should be
- /// saved.
- ///
- /// @param[in] fd
- /// The file descriptor for which to save the settings.
- ///
- /// @param[in] save_process_group
- /// If \b true, save the process group information for the TTY.
- ///
- /// @return
- /// Returns \b true if the save was successful, \b false
- /// otherwise.
- //------------------------------------------------------------------
- bool
- Save (uint32_t idx, int fd, bool save_process_group);
+ //------------------------------------------------------------------
+ /// Constructor
+ //------------------------------------------------------------------
+ TerminalStateSwitcher();
+
+ //------------------------------------------------------------------
+ /// Destructor
+ //------------------------------------------------------------------
+ ~TerminalStateSwitcher();
+
+ //------------------------------------------------------------------
+ /// Get the number of possible states to save.
+ ///
+ /// @return
+ /// The number of states that this TTY switcher object contains.
+ //------------------------------------------------------------------
+ uint32_t GetNumberOfStates() const;
+
+ //------------------------------------------------------------------
+ /// Restore the TTY state for state at index \a idx.
+ ///
+ /// @return
+ /// Returns \b true if the TTY state was successfully restored,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool Restore(uint32_t idx) const;
+
+ //------------------------------------------------------------------
+ /// Save the TTY state information for the state at index \a idx.
+ /// The TTY state is saved for the file descriptor \a fd and
+ /// the process group information will also be saved if requested
+ /// by \a save_process_group.
+ ///
+ /// @param[in] idx
+ /// The index into the state array where the state should be
+ /// saved.
+ ///
+ /// @param[in] fd
+ /// The file descriptor for which to save the settings.
+ ///
+ /// @param[in] save_process_group
+ /// If \b true, save the process group information for the TTY.
+ ///
+ /// @return
+ /// Returns \b true if the save was successful, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ bool Save(uint32_t idx, int fd, bool save_process_group);
protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- mutable uint32_t m_currentState; ///< The currently active TTY state index.
- TerminalState m_ttystates[2]; ///< The array of TTY states that holds saved TTY info.
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ mutable uint32_t m_currentState; ///< The currently active TTY state index.
+ TerminalState
+ m_ttystates[2]; ///< The array of TTY states that holds saved TTY info.
};
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif // #ifndef liblldb_Terminal_h_
+#endif // #if defined(__cplusplus)
+#endif // #ifndef liblldb_Terminal_h_
diff --git a/include/lldb/Host/ThisThread.h b/include/lldb/Host/ThisThread.h
index 23acee9d3fc1..1392b10e1382 100644
--- a/include/lldb/Host/ThisThread.h
+++ b/include/lldb/Host/ThisThread.h
@@ -14,26 +14,23 @@
#include <string>
-namespace llvm
-{
+namespace llvm {
template <class T> class SmallVectorImpl;
}
-namespace lldb_private
-{
+namespace lldb_private {
-class ThisThread
-{
- private:
- ThisThread();
+class ThisThread {
+private:
+ ThisThread();
- public:
- // ThisThread common functions.
- static void SetName(llvm::StringRef name, int max_length);
+public:
+ // ThisThread common functions.
+ static void SetName(llvm::StringRef name, int max_length);
- // ThisThread platform-specific functions.
- static void SetName(llvm::StringRef name);
- static void GetName(llvm::SmallVectorImpl<char> &name);
+ // ThisThread platform-specific functions.
+ static void SetName(llvm::StringRef name);
+ static void GetName(llvm::SmallVectorImpl<char> &name);
};
}
diff --git a/include/lldb/Host/ThreadLauncher.h b/include/lldb/Host/ThreadLauncher.h
index b4e4cae4b763..0f2cb37c835a 100644
--- a/include/lldb/Host/ThreadLauncher.h
+++ b/include/lldb/Host/ThreadLauncher.h
@@ -1,4 +1,5 @@
-//===-- ThreadLauncher.h -----------------------------------------*- C++ -*-===//
+//===-- ThreadLauncher.h -----------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,31 +17,27 @@
#include "llvm/ADT/StringRef.h"
-namespace lldb_private
-{
-
-class ThreadLauncher
-{
- public:
- static HostThread LaunchThread(llvm::StringRef name,
- lldb::thread_func_t thread_function,
- lldb::thread_arg_t thread_arg,
- Error *error_ptr,
- size_t min_stack_byte_size = 0); // Minimum stack size in bytes, set stack size to zero for default platform thread stack size
-
- struct HostThreadCreateInfo
- {
- std::string thread_name;
- lldb::thread_func_t thread_fptr;
- lldb::thread_arg_t thread_arg;
-
- HostThreadCreateInfo(const char *name, lldb::thread_func_t fptr, lldb::thread_arg_t arg)
- : thread_name(name ? name : "")
- , thread_fptr(fptr)
- , thread_arg(arg)
- {
- }
- };
+namespace lldb_private {
+
+class ThreadLauncher {
+public:
+ static HostThread
+ LaunchThread(llvm::StringRef name, lldb::thread_func_t thread_function,
+ lldb::thread_arg_t thread_arg, Error *error_ptr,
+ size_t min_stack_byte_size = 0); // Minimum stack size in bytes,
+ // set stack size to zero for
+ // default platform thread stack
+ // size
+
+ struct HostThreadCreateInfo {
+ std::string thread_name;
+ lldb::thread_func_t thread_fptr;
+ lldb::thread_arg_t thread_arg;
+
+ HostThreadCreateInfo(const char *name, lldb::thread_func_t fptr,
+ lldb::thread_arg_t arg)
+ : thread_name(name ? name : ""), thread_fptr(fptr), thread_arg(arg) {}
+ };
};
}
diff --git a/include/lldb/Host/Time.h b/include/lldb/Host/Time.h
index 1481d381053d..3be30dd03375 100644
--- a/include/lldb/Host/Time.h
+++ b/include/lldb/Host/Time.h
@@ -12,13 +12,13 @@
#ifndef liblldb_Host_Time_h_
#define liblldb_Host_Time_h_
-#ifdef __ANDROID_NDK__
+#ifdef __ANDROID__
#include <android/api-level.h>
#endif
#if defined(__ANDROID_API__) && __ANDROID_API__ < 21
#include <time64.h>
-extern time_t timegm(struct tm* t);
+extern time_t timegm(struct tm *t);
#else
#include <time.h>
#endif
diff --git a/include/lldb/Host/TimeValue.h b/include/lldb/Host/TimeValue.h
deleted file mode 100644
index 6de2bfd16a0a..000000000000
--- a/include/lldb/Host/TimeValue.h
+++ /dev/null
@@ -1,129 +0,0 @@
-//===-- TimeValue.h ---------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_TimeValue_h_
-#define liblldb_TimeValue_h_
-
-// C Includes
-#include <stdint.h>
-#ifndef _MSC_VER
-#include <sys/time.h>
-
-
-#endif
-
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/lldb-private.h"
-
-namespace lldb_private {
-
-class TimeValue
-{
-public:
- static const uint64_t MicroSecPerSec = 1000000UL;
- static const uint64_t NanoSecPerSec = 1000000000UL;
- static const uint64_t NanoSecPerMicroSec = 1000U;
- static const uint64_t NanoSecPerMilliSec = 1000000UL;
-
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- TimeValue();
- TimeValue(const TimeValue& rhs);
- TimeValue(const struct timespec& ts);
- explicit TimeValue(uint32_t seconds, uint32_t nanos = 0);
- ~TimeValue();
-
- //------------------------------------------------------------------
- // Operators
- //------------------------------------------------------------------
- const TimeValue&
- operator=(const TimeValue& rhs);
-
- void
- Clear ();
-
- uint64_t
- GetAsNanoSecondsSinceJan1_1970() const;
-
- uint64_t
- GetAsMicroSecondsSinceJan1_1970() const;
-
- uint64_t
- GetAsSecondsSinceJan1_1970() const;
-
- struct timespec
- GetAsTimeSpec () const;
-
- bool
- IsValid () const;
-
- void
- OffsetWithSeconds (uint64_t sec);
-
- void
- OffsetWithMicroSeconds (uint64_t usec);
-
- void
- OffsetWithNanoSeconds (uint64_t nsec);
-
- static TimeValue
- Now();
-
- void
- Dump (Stream *s, uint32_t width = 0) const;
-
- /// Returns only the seconds component of the TimeValue. The nanoseconds
- /// portion is ignored. No rounding is performed.
- /// @brief Retrieve the seconds component
- uint32_t seconds() const { return m_nano_seconds / NanoSecPerSec; }
-
- /// Returns only the nanoseconds component of the TimeValue. The seconds
- /// portion is ignored.
- /// @brief Retrieve the nanoseconds component.
- uint32_t nanoseconds() const { return m_nano_seconds % NanoSecPerSec; }
-
- /// Returns only the fractional portion of the TimeValue rounded down to the
- /// nearest microsecond (divide by one thousand).
- /// @brief Retrieve the fractional part as microseconds;
- uint32_t microseconds() const {
- return (m_nano_seconds % NanoSecPerSec) / NanoSecPerMicroSec;
- }
-
- /// Returns only the fractional portion of the TimeValue rounded down to the
- /// nearest millisecond (divide by one million).
- /// @brief Retrieve the milliseconds component;
- uint32_t
- milliseconds() const
- {
- return m_nano_seconds / NanoSecPerMilliSec;
- }
-
-protected:
- //------------------------------------------------------------------
- // Classes that inherit from TimeValue can see and modify these
- //------------------------------------------------------------------
- uint64_t m_nano_seconds;
-};
-
-bool operator == (const TimeValue &lhs, const TimeValue &rhs);
-bool operator != (const TimeValue &lhs, const TimeValue &rhs);
-bool operator < (const TimeValue &lhs, const TimeValue &rhs);
-bool operator <= (const TimeValue &lhs, const TimeValue &rhs);
-bool operator > (const TimeValue &lhs, const TimeValue &rhs);
-bool operator >= (const TimeValue &lhs, const TimeValue &rhs);
-
-uint64_t operator -(const TimeValue &lhs, const TimeValue &rhs);
-
-} // namespace lldb_private
-
-
-#endif // liblldb_TimeValue_h_
diff --git a/include/lldb/Host/XML.h b/include/lldb/Host/XML.h
index 3ebd2c6f79ec..4113b3318dd0 100644
--- a/include/lldb/Host/XML.h
+++ b/include/lldb/Host/XML.h
@@ -11,7 +11,7 @@
#define liblldb_XML_h_
// C Includes
-#if defined( LIBXML2_DEFINED )
+#if defined(LIBXML2_DEFINED)
#include <libxml/xmlreader.h>
#endif
@@ -24,208 +24,168 @@
#include "llvm/ADT/StringRef.h"
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/StructuredData.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-#if defined( LIBXML2_DEFINED )
- typedef xmlNodePtr XMLNodeImpl;
- typedef xmlDocPtr XMLDocumentImpl;
+#if defined(LIBXML2_DEFINED)
+typedef xmlNodePtr XMLNodeImpl;
+typedef xmlDocPtr XMLDocumentImpl;
#else
- typedef void * XMLNodeImpl;
- typedef void * XMLDocumentImpl;
+typedef void *XMLNodeImpl;
+typedef void *XMLDocumentImpl;
#endif
- class XMLNode;
-
- typedef std::vector<std::string> NamePath;
- typedef std::function <bool(const XMLNode &node)> NodeCallback;
- typedef std::function <bool(const llvm::StringRef &name, const llvm::StringRef &value)> AttributeCallback;
-
- class XMLNode
- {
- public:
- XMLNode();
-
- XMLNode(XMLNodeImpl node);
-
- ~XMLNode();
-
- explicit operator bool() const
- {
- return IsValid();
- }
-
- void
- Clear();
-
- bool
- IsValid() const;
-
- bool
- IsElement () const;
-
- llvm::StringRef
- GetName() const;
-
- bool
- GetElementText (std::string &text) const;
-
- bool
- GetElementTextAsUnsigned (uint64_t &value, uint64_t fail_value = 0, int base = 0) const;
-
- bool
- GetElementTextAsFloat (double &value, double fail_value = 0.0) const;
-
- bool
- NameIs (const char *name) const;
-
- XMLNode
- GetParent() const;
-
- XMLNode
- GetSibling() const;
-
- XMLNode
- GetChild () const;
-
- llvm::StringRef
- GetAttributeValue(const char *name, const char *fail_value = nullptr) const;
-
- XMLNode
- FindFirstChildElementWithName (const char *name) const;
-
- XMLNode
- GetElementForPath (const NamePath &path);
-
- //----------------------------------------------------------------------
- // Iterate through all sibling nodes of any type
- //----------------------------------------------------------------------
- void
- ForEachSiblingNode (NodeCallback const &callback) const;
-
- //----------------------------------------------------------------------
- // Iterate through only the sibling nodes that are elements
- //----------------------------------------------------------------------
- void
- ForEachSiblingElement (NodeCallback const &callback) const;
-
- //----------------------------------------------------------------------
- // Iterate through only the sibling nodes that are elements and whose
- // name matches \a name.
- //----------------------------------------------------------------------
- void
- ForEachSiblingElementWithName (const char *name, NodeCallback const &callback) const;
-
- void
- ForEachChildNode (NodeCallback const &callback) const;
-
- void
- ForEachChildElement (NodeCallback const &callback) const;
-
- void
- ForEachChildElementWithName (const char *name, NodeCallback const &callback) const;
-
- void
- ForEachAttribute (AttributeCallback const &callback) const;
-
- protected:
- XMLNodeImpl m_node;
- };
-
- class XMLDocument
- {
- public:
- XMLDocument ();
-
- ~XMLDocument ();
-
- explicit operator bool() const
- {
- return IsValid();
- }
-
- bool
- IsValid() const;
-
- void
- Clear();
-
- bool
- ParseFile (const char *path);
-
- bool
- ParseMemory (const char *xml, size_t xml_length, const char *url = "untitled.xml");
-
- //----------------------------------------------------------------------
- // If \a name is nullptr, just get the root element node, else only return
- // a value XMLNode if the name of the root element matches \a name.
- //----------------------------------------------------------------------
- XMLNode
- GetRootElement(const char *required_name = nullptr);
-
- const std::string &
- GetErrors() const;
-
- static void
- ErrorCallback (void *ctx, const char *format, ...);
-
- static bool
- XMLEnabled ();
-
- protected:
- XMLDocumentImpl m_document;
- StreamString m_errors;
- };
-
- class ApplePropertyList
- {
- public:
- ApplePropertyList();
-
- ApplePropertyList(const char *path);
-
- ~ApplePropertyList();
-
- bool
- ParseFile (const char *path);
-
- const std::string &
- GetErrors() const;
-
- explicit operator bool() const
- {
- return IsValid();
- }
-
- bool
- IsValid() const;
-
- XMLNode
- GetValueNode (const char *key) const;
-
- bool
- GetValueAsString (const char *key, std::string &value) const;
-
- StructuredData::ObjectSP
- GetStructuredData();
-
- protected:
- // Using a node returned from GetValueNode() extract its value as a
- // string (if possible). Array and dictionary nodes will return false
- // as they have no string value. Boolean nodes will return true and
- // \a value will be "true" or "false" as the string value comes from
- // the element name itself. All other nodes will return the text
- // content of the XMLNode.
- static bool
- ExtractStringFromValueNode (const XMLNode &node, std::string &value);
-
- XMLDocument m_xml_doc;
- XMLNode m_dict_node;
- };
+class XMLNode;
+
+typedef std::vector<std::string> NamePath;
+typedef std::function<bool(const XMLNode &node)> NodeCallback;
+typedef std::function<bool(const llvm::StringRef &name,
+ const llvm::StringRef &value)>
+ AttributeCallback;
+
+class XMLNode {
+public:
+ XMLNode();
+
+ XMLNode(XMLNodeImpl node);
+
+ ~XMLNode();
+
+ explicit operator bool() const { return IsValid(); }
+
+ void Clear();
+
+ bool IsValid() const;
+
+ bool IsElement() const;
+
+ llvm::StringRef GetName() const;
+
+ bool GetElementText(std::string &text) const;
+
+ bool GetElementTextAsUnsigned(uint64_t &value, uint64_t fail_value = 0,
+ int base = 0) const;
+
+ bool GetElementTextAsFloat(double &value, double fail_value = 0.0) const;
+
+ bool NameIs(const char *name) const;
+
+ XMLNode GetParent() const;
+
+ XMLNode GetSibling() const;
+
+ XMLNode GetChild() const;
+
+ llvm::StringRef GetAttributeValue(const char *name,
+ const char *fail_value = nullptr) const;
+
+ XMLNode FindFirstChildElementWithName(const char *name) const;
+
+ XMLNode GetElementForPath(const NamePath &path);
+
+ //----------------------------------------------------------------------
+ // Iterate through all sibling nodes of any type
+ //----------------------------------------------------------------------
+ void ForEachSiblingNode(NodeCallback const &callback) const;
+
+ //----------------------------------------------------------------------
+ // Iterate through only the sibling nodes that are elements
+ //----------------------------------------------------------------------
+ void ForEachSiblingElement(NodeCallback const &callback) const;
+
+ //----------------------------------------------------------------------
+ // Iterate through only the sibling nodes that are elements and whose
+ // name matches \a name.
+ //----------------------------------------------------------------------
+ void ForEachSiblingElementWithName(const char *name,
+ NodeCallback const &callback) const;
+
+ void ForEachChildNode(NodeCallback const &callback) const;
+
+ void ForEachChildElement(NodeCallback const &callback) const;
+
+ void ForEachChildElementWithName(const char *name,
+ NodeCallback const &callback) const;
+
+ void ForEachAttribute(AttributeCallback const &callback) const;
+
+protected:
+ XMLNodeImpl m_node;
+};
+
+class XMLDocument {
+public:
+ XMLDocument();
+
+ ~XMLDocument();
+
+ explicit operator bool() const { return IsValid(); }
+
+ bool IsValid() const;
+
+ void Clear();
+
+ bool ParseFile(const char *path);
+
+ bool ParseMemory(const char *xml, size_t xml_length,
+ const char *url = "untitled.xml");
+
+ //----------------------------------------------------------------------
+ // If \a name is nullptr, just get the root element node, else only return
+ // a value XMLNode if the name of the root element matches \a name.
+ //----------------------------------------------------------------------
+ XMLNode GetRootElement(const char *required_name = nullptr);
+
+ llvm::StringRef GetErrors() const;
+
+ static void ErrorCallback(void *ctx, const char *format, ...);
+
+ static bool XMLEnabled();
+
+protected:
+ XMLDocumentImpl m_document;
+ StreamString m_errors;
+};
+
+class ApplePropertyList {
+public:
+ ApplePropertyList();
+
+ ApplePropertyList(const char *path);
+
+ ~ApplePropertyList();
+
+ bool ParseFile(const char *path);
+
+ llvm::StringRef GetErrors() const;
+
+ explicit operator bool() const { return IsValid(); }
+
+ bool IsValid() const;
+
+ XMLNode GetValueNode(const char *key) const;
+
+ bool GetValueAsString(const char *key, std::string &value) const;
+
+ StructuredData::ObjectSP GetStructuredData();
+
+protected:
+ // Using a node returned from GetValueNode() extract its value as a
+ // string (if possible). Array and dictionary nodes will return false
+ // as they have no string value. Boolean nodes will return true and
+ // \a value will be "true" or "false" as the string value comes from
+ // the element name itself. All other nodes will return the text
+ // content of the XMLNode.
+ static bool ExtractStringFromValueNode(const XMLNode &node,
+ std::string &value);
+
+ XMLDocument m_xml_doc;
+ XMLNode m_dict_node;
+};
} // namespace lldb_private
-#endif // liblldb_XML_h_
+#endif // liblldb_XML_h_
diff --git a/include/lldb/Host/android/Android.h b/include/lldb/Host/android/Android.h
deleted file mode 100644
index 08e7dd93b285..000000000000
--- a/include/lldb/Host/android/Android.h
+++ /dev/null
@@ -1,28 +0,0 @@
-//===-- lldb-android.h --------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLDB_lldb_android_h_
-#define LLDB_lldb_android_h_
-
-#include <sstream>
-#include <string>
-#include <errno.h>
-
-namespace std
-{
- template <typename T>
- std::string to_string(T value)
- {
- std::ostringstream os ;
- os << value ;
- return os.str() ;
- }
-}
-
-#endif // LLDB_lldb_android_h_
diff --git a/include/lldb/Host/android/HostInfoAndroid.h b/include/lldb/Host/android/HostInfoAndroid.h
index 08eb1abf3b51..7a52abe31964 100644
--- a/include/lldb/Host/android/HostInfoAndroid.h
+++ b/include/lldb/Host/android/HostInfoAndroid.h
@@ -12,20 +12,20 @@
#include "lldb/Host/linux/HostInfoLinux.h"
-namespace lldb_private
-{
+namespace lldb_private {
-class HostInfoAndroid : public HostInfoLinux
-{
- friend class HostInfoBase;
+class HostInfoAndroid : public HostInfoLinux {
+ friend class HostInfoBase;
- public:
- static FileSpec GetDefaultShell();
- static FileSpec ResolveLibraryPath (const std::string& path, const ArchSpec& arch);
+public:
+ static FileSpec GetDefaultShell();
+ static FileSpec ResolveLibraryPath(const std::string &path,
+ const ArchSpec &arch);
- protected:
- static void ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64);
- static bool ComputeTempFileBaseDirectory(FileSpec &file_spec);
+protected:
+ static void ComputeHostArchitectureSupport(ArchSpec &arch_32,
+ ArchSpec &arch_64);
+ static bool ComputeTempFileBaseDirectory(FileSpec &file_spec);
};
} // end of namespace lldb_private
diff --git a/include/lldb/Host/common/GetOptInc.h b/include/lldb/Host/common/GetOptInc.h
index f79644017ca5..4d5cab5cbec2 100644
--- a/include/lldb/Host/common/GetOptInc.h
+++ b/include/lldb/Host/common/GetOptInc.h
@@ -12,54 +12,41 @@
#if defined(REPLACE_GETOPT)
// from getopt.h
-#define no_argument 0
+#define no_argument 0
#define required_argument 1
#define optional_argument 2
// option structure
-struct option
-{
- const char *name;
- // has_arg can't be an enum because some compilers complain about
- // type mismatches in all the code that assumes it is an int.
- int has_arg;
- int *flag;
- int val;
+struct option {
+ const char *name;
+ // has_arg can't be an enum because some compilers complain about
+ // type mismatches in all the code that assumes it is an int.
+ int has_arg;
+ int *flag;
+ int val;
};
-int getopt( int argc, char * const argv[], const char *optstring );
+int getopt(int argc, char *const argv[], const char *optstring);
// from getopt.h
-extern char * optarg;
-extern int optind;
-extern int opterr;
-extern int optopt;
+extern char *optarg;
+extern int optind;
+extern int opterr;
+extern int optopt;
// defined in unistd.h
-extern int optreset;
+extern int optreset;
#else
-# include <unistd.h>
-# include <getopt.h>
+#include <getopt.h>
+#include <unistd.h>
#endif
#if defined(REPLACE_GETOPT_LONG)
-int getopt_long
-(
- int argc,
- char * const *argv,
- const char *optstring,
- const struct option *longopts,
- int *longindex
-);
+int getopt_long(int argc, char *const *argv, const char *optstring,
+ const struct option *longopts, int *longindex);
#endif
#if defined(REPLACE_GETOPT_LONG_ONLY)
-int getopt_long_only
-(
- int argc,
- char * const *argv,
- const char *optstring,
- const struct option *longopts,
- int *longindex
-);
+int getopt_long_only(int argc, char *const *argv, const char *optstring,
+ const struct option *longopts, int *longindex);
#endif
diff --git a/include/lldb/Host/common/NativeBreakpoint.h b/include/lldb/Host/common/NativeBreakpoint.h
index 367003b94e35..2f872e1d5a52 100644
--- a/include/lldb/Host/common/NativeBreakpoint.h
+++ b/include/lldb/Host/common/NativeBreakpoint.h
@@ -12,55 +12,45 @@
#include "lldb/lldb-types.h"
-namespace lldb_private
-{
- class NativeBreakpointList;
+namespace lldb_private {
+class NativeBreakpointList;
- class NativeBreakpoint
- {
- friend class NativeBreakpointList;
+class NativeBreakpoint {
+ friend class NativeBreakpointList;
- public:
- // The assumption is that derived breakpoints are enabled when created.
- NativeBreakpoint (lldb::addr_t addr);
+public:
+ // The assumption is that derived breakpoints are enabled when created.
+ NativeBreakpoint(lldb::addr_t addr);
- virtual
- ~NativeBreakpoint ();
+ virtual ~NativeBreakpoint();
- Error
- Enable ();
+ Error Enable();
- Error
- Disable ();
+ Error Disable();
- lldb::addr_t
- GetAddress () const { return m_addr; }
+ lldb::addr_t GetAddress() const { return m_addr; }
- bool
- IsEnabled () const { return m_enabled; }
+ bool IsEnabled() const { return m_enabled; }
- virtual bool
- IsSoftwareBreakpoint () const = 0;
+ virtual bool IsSoftwareBreakpoint() const = 0;
- protected:
- const lldb::addr_t m_addr;
- int32_t m_ref_count;
+protected:
+ const lldb::addr_t m_addr;
+ int32_t m_ref_count;
- virtual Error
- DoEnable () = 0;
+ virtual Error DoEnable() = 0;
- virtual Error
- DoDisable () = 0;
+ virtual Error DoDisable() = 0;
- private:
- bool m_enabled;
+private:
+ bool m_enabled;
- // -----------------------------------------------------------
- // interface for NativeBreakpointList
- // -----------------------------------------------------------
- void AddRef ();
- int32_t DecRef ();
- };
+ // -----------------------------------------------------------
+ // interface for NativeBreakpointList
+ // -----------------------------------------------------------
+ void AddRef();
+ int32_t DecRef();
+};
}
#endif // ifndef liblldb_NativeBreakpoint_h_
diff --git a/include/lldb/Host/common/NativeBreakpointList.h b/include/lldb/Host/common/NativeBreakpointList.h
index bd1a9ae09db2..2bb8e565f464 100644
--- a/include/lldb/Host/common/NativeBreakpointList.h
+++ b/include/lldb/Host/common/NativeBreakpointList.h
@@ -10,47 +10,42 @@
#ifndef liblldb_NativeBreakpointList_h_
#define liblldb_NativeBreakpointList_h_
-#include "lldb/lldb-private-forward.h"
#include "lldb/Core/Error.h"
+#include "lldb/lldb-private-forward.h"
// #include "lldb/Host/NativeBreakpoint.h"
#include <functional>
#include <map>
#include <mutex>
-namespace lldb_private
-{
- class NativeBreakpointList
- {
- public:
- typedef std::function<Error (lldb::addr_t addr, size_t size_hint, bool hardware, NativeBreakpointSP &breakpoint_sp)> CreateBreakpointFunc;
+namespace lldb_private {
+class NativeBreakpointList {
+public:
+ typedef std::function<Error(lldb::addr_t addr, size_t size_hint,
+ bool hardware, NativeBreakpointSP &breakpoint_sp)>
+ CreateBreakpointFunc;
- NativeBreakpointList ();
+ NativeBreakpointList();
- Error
- AddRef (lldb::addr_t addr, size_t size_hint, bool hardware, CreateBreakpointFunc create_func);
+ Error AddRef(lldb::addr_t addr, size_t size_hint, bool hardware,
+ CreateBreakpointFunc create_func);
- Error
- DecRef (lldb::addr_t addr);
+ Error DecRef(lldb::addr_t addr);
- Error
- EnableBreakpoint (lldb::addr_t addr);
+ Error EnableBreakpoint(lldb::addr_t addr);
- Error
- DisableBreakpoint (lldb::addr_t addr);
+ Error DisableBreakpoint(lldb::addr_t addr);
- Error
- GetBreakpoint (lldb::addr_t addr, NativeBreakpointSP &breakpoint_sp);
+ Error GetBreakpoint(lldb::addr_t addr, NativeBreakpointSP &breakpoint_sp);
- Error
- RemoveTrapsFromBuffer(lldb::addr_t addr, void *buf, size_t size) const;
+ Error RemoveTrapsFromBuffer(lldb::addr_t addr, void *buf, size_t size) const;
- private:
- typedef std::map<lldb::addr_t, NativeBreakpointSP> BreakpointMap;
+private:
+ typedef std::map<lldb::addr_t, NativeBreakpointSP> BreakpointMap;
- std::recursive_mutex m_mutex;
- BreakpointMap m_breakpoints;
- };
+ std::recursive_mutex m_mutex;
+ BreakpointMap m_breakpoints;
+};
}
#endif // ifndef liblldb_NativeBreakpointList_h_
diff --git a/include/lldb/Host/common/NativeProcessProtocol.h b/include/lldb/Host/common/NativeProcessProtocol.h
index d306a58f3cab..a0f03b0dafa3 100644
--- a/include/lldb/Host/common/NativeProcessProtocol.h
+++ b/include/lldb/Host/common/NativeProcessProtocol.h
@@ -13,413 +13,349 @@
#include <mutex>
#include <vector>
-#include "lldb/lldb-private-forward.h"
-#include "lldb/lldb-types.h"
#include "lldb/Core/Error.h"
#include "lldb/Host/MainLoop.h"
+#include "lldb/lldb-private-forward.h"
+#include "lldb/lldb-types.h"
#include "llvm/ADT/StringRef.h"
#include "NativeBreakpointList.h"
#include "NativeWatchpointList.h"
-namespace lldb_private
-{
- class MemoryRegionInfo;
- class ResumeActionList;
+namespace lldb_private {
+class MemoryRegionInfo;
+class ResumeActionList;
+
+//------------------------------------------------------------------
+// NativeProcessProtocol
+//------------------------------------------------------------------
+class NativeProcessProtocol
+ : public std::enable_shared_from_this<NativeProcessProtocol> {
+ friend class SoftwareBreakpoint;
+
+public:
+ virtual ~NativeProcessProtocol() {}
+
+ virtual Error Resume(const ResumeActionList &resume_actions) = 0;
+
+ virtual Error Halt() = 0;
+
+ virtual Error Detach() = 0;
+
+ //------------------------------------------------------------------
+ /// Sends a process a UNIX signal \a signal.
+ ///
+ /// @return
+ /// Returns an error object.
+ //------------------------------------------------------------------
+ virtual Error Signal(int signo) = 0;
+
+ //------------------------------------------------------------------
+ /// Tells a process to interrupt all operations as if by a Ctrl-C.
+ ///
+ /// The default implementation will send a local host's equivalent of
+ /// a SIGSTOP to the process via the NativeProcessProtocol::Signal()
+ /// operation.
+ ///
+ /// @return
+ /// Returns an error object.
+ //------------------------------------------------------------------
+ virtual Error Interrupt();
+
+ virtual Error Kill() = 0;
+
+ //----------------------------------------------------------------------
+ // Memory and memory region functions
+ //----------------------------------------------------------------------
+
+ virtual Error GetMemoryRegionInfo(lldb::addr_t load_addr,
+ MemoryRegionInfo &range_info);
+
+ virtual Error ReadMemory(lldb::addr_t addr, void *buf, size_t size,
+ size_t &bytes_read) = 0;
+
+ virtual Error ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size,
+ size_t &bytes_read) = 0;
+
+ virtual Error WriteMemory(lldb::addr_t addr, const void *buf, size_t size,
+ size_t &bytes_written) = 0;
+
+ virtual Error AllocateMemory(size_t size, uint32_t permissions,
+ lldb::addr_t &addr) = 0;
+
+ virtual Error DeallocateMemory(lldb::addr_t addr) = 0;
+
+ virtual lldb::addr_t GetSharedLibraryInfoAddress() = 0;
+
+ virtual bool IsAlive() const;
+
+ virtual size_t UpdateThreads() = 0;
+
+ virtual bool GetArchitecture(ArchSpec &arch) const = 0;
+
+ //----------------------------------------------------------------------
+ // Breakpoint functions
+ //----------------------------------------------------------------------
+ virtual Error SetBreakpoint(lldb::addr_t addr, uint32_t size,
+ bool hardware) = 0;
+
+ virtual Error RemoveBreakpoint(lldb::addr_t addr);
+
+ virtual Error EnableBreakpoint(lldb::addr_t addr);
+
+ virtual Error DisableBreakpoint(lldb::addr_t addr);
+
+ //----------------------------------------------------------------------
+ // Watchpoint functions
+ //----------------------------------------------------------------------
+ virtual const NativeWatchpointList::WatchpointMap &GetWatchpointMap() const;
+
+ virtual uint32_t GetMaxWatchpoints() const;
+
+ virtual Error SetWatchpoint(lldb::addr_t addr, size_t size,
+ uint32_t watch_flags, bool hardware);
+
+ virtual Error RemoveWatchpoint(lldb::addr_t addr);
+
+ //----------------------------------------------------------------------
+ // Accessors
+ //----------------------------------------------------------------------
+ lldb::pid_t GetID() const { return m_pid; }
+
+ lldb::StateType GetState() const;
+
+ bool IsRunning() const {
+ return m_state == lldb::eStateRunning || IsStepping();
+ }
+
+ bool IsStepping() const { return m_state == lldb::eStateStepping; }
- //------------------------------------------------------------------
- // NativeProcessProtocol
- //------------------------------------------------------------------
- class NativeProcessProtocol :
- public std::enable_shared_from_this<NativeProcessProtocol>
- {
- friend class SoftwareBreakpoint;
-
- public:
-
- // lldb_private::Host calls should be used to launch a process for debugging, and
- // then the process should be attached to. When attaching to a process
- // lldb_private::Host calls should be used to locate the process to attach to,
- // and then this function should be called.
- NativeProcessProtocol (lldb::pid_t pid);
+ bool CanResume() const { return m_state == lldb::eStateStopped; }
- virtual ~NativeProcessProtocol ()
- {
- }
+ bool GetByteOrder(lldb::ByteOrder &byte_order) const;
- virtual Error
- Resume (const ResumeActionList &resume_actions) = 0;
-
- virtual Error
- Halt () = 0;
-
- virtual Error
- Detach () = 0;
-
- //------------------------------------------------------------------
- /// Sends a process a UNIX signal \a signal.
- ///
- /// @return
- /// Returns an error object.
- //------------------------------------------------------------------
- virtual Error
- Signal (int signo) = 0;
-
- //------------------------------------------------------------------
- /// Tells a process to interrupt all operations as if by a Ctrl-C.
- ///
- /// The default implementation will send a local host's equivalent of
- /// a SIGSTOP to the process via the NativeProcessProtocol::Signal()
- /// operation.
- ///
- /// @return
- /// Returns an error object.
- //------------------------------------------------------------------
- virtual Error
- Interrupt ();
-
- virtual Error
- Kill () = 0;
-
- //----------------------------------------------------------------------
- // Memory and memory region functions
- //----------------------------------------------------------------------
-
- virtual Error
- GetMemoryRegionInfo (lldb::addr_t load_addr, MemoryRegionInfo &range_info);
-
- virtual Error
- ReadMemory(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read) = 0;
-
- virtual Error
- ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read) = 0;
-
- virtual Error
- WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written) = 0;
-
- virtual Error
- AllocateMemory(size_t size, uint32_t permissions, lldb::addr_t &addr) = 0;
-
- virtual Error
- DeallocateMemory (lldb::addr_t addr) = 0;
-
- virtual lldb::addr_t
- GetSharedLibraryInfoAddress () = 0;
-
- virtual bool
- IsAlive () const;
-
- virtual size_t
- UpdateThreads () = 0;
-
- virtual bool
- GetArchitecture (ArchSpec &arch) const = 0;
-
- //----------------------------------------------------------------------
- // Breakpoint functions
- //----------------------------------------------------------------------
- virtual Error
- SetBreakpoint (lldb::addr_t addr, uint32_t size, bool hardware) = 0;
-
- virtual Error
- RemoveBreakpoint (lldb::addr_t addr);
-
- virtual Error
- EnableBreakpoint (lldb::addr_t addr);
-
- virtual Error
- DisableBreakpoint (lldb::addr_t addr);
-
- //----------------------------------------------------------------------
- // Watchpoint functions
- //----------------------------------------------------------------------
- virtual const NativeWatchpointList::WatchpointMap&
- GetWatchpointMap () const;
-
- virtual uint32_t
- GetMaxWatchpoints () const;
-
- virtual Error
- SetWatchpoint (lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware);
-
- virtual Error
- RemoveWatchpoint (lldb::addr_t addr);
-
- //----------------------------------------------------------------------
- // Accessors
- //----------------------------------------------------------------------
- lldb::pid_t
- GetID() const
- {
- return m_pid;
- }
-
- lldb::StateType
- GetState () const;
-
- bool
- IsRunning () const
- {
- return m_state == lldb::eStateRunning || IsStepping();
- }
-
- bool
- IsStepping () const
- {
- return m_state == lldb::eStateStepping;
- }
-
- bool
- CanResume () const
- {
- return m_state == lldb::eStateStopped;
- }
-
- bool
- GetByteOrder (lldb::ByteOrder &byte_order) const;
-
- //----------------------------------------------------------------------
- // Exit Status
- //----------------------------------------------------------------------
- virtual bool
- GetExitStatus (lldb_private::ExitType *exit_type, int *status, std::string &exit_description);
-
- virtual bool
- SetExitStatus (lldb_private::ExitType exit_type, int status, const char *exit_description, bool bNotifyStateChange);
-
- //----------------------------------------------------------------------
- // Access to threads
- //----------------------------------------------------------------------
- NativeThreadProtocolSP
- GetThreadAtIndex (uint32_t idx);
-
- NativeThreadProtocolSP
- GetThreadByID (lldb::tid_t tid);
-
- void
- SetCurrentThreadID (lldb::tid_t tid)
- {
- m_current_thread_id = tid;
- }
-
- lldb::tid_t
- GetCurrentThreadID ()
- {
- return m_current_thread_id;
- }
-
- NativeThreadProtocolSP
- GetCurrentThread ()
- {
- return GetThreadByID (m_current_thread_id);
- }
-
- //----------------------------------------------------------------------
- // Access to inferior stdio
- //----------------------------------------------------------------------
- virtual
- int GetTerminalFileDescriptor ()
- {
- return m_terminal_fd;
- }
-
- //----------------------------------------------------------------------
- // Stop id interface
- //----------------------------------------------------------------------
-
- uint32_t
- GetStopID () const;
-
- // ---------------------------------------------------------------------
- // Callbacks for low-level process state changes
- // ---------------------------------------------------------------------
- class NativeDelegate
- {
- public:
- virtual
- ~NativeDelegate () {}
-
- virtual void
- InitializeDelegate (NativeProcessProtocol *process) = 0;
-
- virtual void
- ProcessStateChanged (NativeProcessProtocol *process, lldb::StateType state) = 0;
-
- virtual void
- DidExec (NativeProcessProtocol *process) = 0;
- };
-
- //------------------------------------------------------------------
- /// Register a native delegate.
- ///
- /// Clients can register nofication callbacks by passing in a
- /// NativeDelegate impl and passing it into this function.
- ///
- /// Note: it is required that the lifetime of the
- /// native_delegate outlive the NativeProcessProtocol.
- ///
- /// @param[in] native_delegate
- /// A NativeDelegate impl to be called when certain events
- /// happen within the NativeProcessProtocol or related threads.
- ///
- /// @return
- /// true if the delegate was registered successfully;
- /// false if the delegate was already registered.
- ///
- /// @see NativeProcessProtocol::NativeDelegate.
- //------------------------------------------------------------------
- bool
- RegisterNativeDelegate (NativeDelegate &native_delegate);
-
- //------------------------------------------------------------------
- /// Unregister a native delegate previously registered.
- ///
- /// @param[in] native_delegate
- /// A NativeDelegate impl previously registered with this process.
- ///
- /// @return Returns \b true if the NativeDelegate was
- /// successfully removed from the process, \b false otherwise.
- ///
- /// @see NativeProcessProtocol::NativeDelegate
- //------------------------------------------------------------------
- bool
- UnregisterNativeDelegate (NativeDelegate &native_delegate);
-
- virtual Error
- GetLoadedModuleFileSpec(const char* module_path, FileSpec& file_spec) = 0;
-
- virtual Error
- GetFileLoadAddress(const llvm::StringRef& file_name, lldb::addr_t& load_addr) = 0;
-
- //------------------------------------------------------------------
- /// Launch a process for debugging. This method will create an concrete
- /// instance of NativeProcessProtocol, based on the host platform.
- /// (e.g. NativeProcessLinux on linux, etc.)
- ///
- /// @param[in] launch_info
- /// Information required to launch the process.
- ///
- /// @param[in] native_delegate
- /// The delegate that will receive messages regarding the
- /// inferior. Must outlive the NativeProcessProtocol
- /// instance.
- ///
- /// @param[in] mainloop
- /// The mainloop instance with which the process can register
- /// callbacks. Must outlive the NativeProcessProtocol
- /// instance.
- ///
- /// @param[out] process_sp
- /// On successful return from the method, this parameter
- /// contains the shared pointer to the
- /// NativeProcessProtocol that can be used to manipulate
- /// the native process.
- ///
- /// @return
- /// An error object indicating if the operation succeeded,
- /// and if not, what error occurred.
- //------------------------------------------------------------------
- static Error
- Launch (ProcessLaunchInfo &launch_info,
- NativeDelegate &native_delegate,
- MainLoop &mainloop,
- NativeProcessProtocolSP &process_sp);
-
- //------------------------------------------------------------------
- /// Attach to an existing process. This method will create an concrete
- /// instance of NativeProcessProtocol, based on the host platform.
- /// (e.g. NativeProcessLinux on linux, etc.)
- ///
- /// @param[in] pid
- /// pid of the process locatable
- ///
- /// @param[in] native_delegate
- /// The delegate that will receive messages regarding the
- /// inferior. Must outlive the NativeProcessProtocol
- /// instance.
- ///
- /// @param[in] mainloop
- /// The mainloop instance with which the process can register
- /// callbacks. Must outlive the NativeProcessProtocol
- /// instance.
- ///
- /// @param[out] process_sp
- /// On successful return from the method, this parameter
- /// contains the shared pointer to the
- /// NativeProcessProtocol that can be used to manipulate
- /// the native process.
- ///
- /// @return
- /// An error object indicating if the operation succeeded,
- /// and if not, what error occurred.
- //------------------------------------------------------------------
- static Error
- Attach (lldb::pid_t pid,
- NativeDelegate &native_delegate,
- MainLoop &mainloop,
- NativeProcessProtocolSP &process_sp);
-
- protected:
- lldb::pid_t m_pid;
-
- std::vector<NativeThreadProtocolSP> m_threads;
- lldb::tid_t m_current_thread_id;
- mutable std::recursive_mutex m_threads_mutex;
-
- lldb::StateType m_state;
- mutable std::recursive_mutex m_state_mutex;
-
- lldb_private::ExitType m_exit_type;
- int m_exit_status;
- std::string m_exit_description;
- std::recursive_mutex m_delegates_mutex;
- std::vector<NativeDelegate*> m_delegates;
- NativeBreakpointList m_breakpoint_list;
- NativeWatchpointList m_watchpoint_list;
- int m_terminal_fd;
- uint32_t m_stop_id;
-
- // -----------------------------------------------------------
- // Internal interface for state handling
- // -----------------------------------------------------------
- void
- SetState (lldb::StateType state, bool notify_delegates = true);
-
- // Derived classes need not implement this. It can be used as a
- // hook to clear internal caches that should be invalidated when
- // stop ids change.
- //
- // Note this function is called with the state mutex obtained
- // by the caller.
- virtual void
- DoStopIDBumped (uint32_t newBumpId);
-
- // -----------------------------------------------------------
- // Internal interface for software breakpoints
- // -----------------------------------------------------------
- Error
- SetSoftwareBreakpoint (lldb::addr_t addr, uint32_t size_hint);
-
- virtual Error
- GetSoftwareBreakpointTrapOpcode (size_t trap_opcode_size_hint, size_t &actual_opcode_size, const uint8_t *&trap_opcode_bytes) = 0;
-
- // -----------------------------------------------------------
- /// Notify the delegate that an exec occurred.
- ///
- /// Provide a mechanism for a delegate to clear out any exec-
- /// sensitive data.
- // -----------------------------------------------------------
- void
- NotifyDidExec ();
-
- NativeThreadProtocolSP
- GetThreadByIDUnlocked (lldb::tid_t tid);
-
- private:
-
- void
- SynchronouslyNotifyProcessStateChanged (lldb::StateType state);
- };
+ //----------------------------------------------------------------------
+ // Exit Status
+ //----------------------------------------------------------------------
+ virtual bool GetExitStatus(lldb_private::ExitType *exit_type, int *status,
+ std::string &exit_description);
+
+ virtual bool SetExitStatus(lldb_private::ExitType exit_type, int status,
+ const char *exit_description,
+ bool bNotifyStateChange);
+
+ //----------------------------------------------------------------------
+ // Access to threads
+ //----------------------------------------------------------------------
+ NativeThreadProtocolSP GetThreadAtIndex(uint32_t idx);
+
+ NativeThreadProtocolSP GetThreadByID(lldb::tid_t tid);
+
+ void SetCurrentThreadID(lldb::tid_t tid) { m_current_thread_id = tid; }
+
+ lldb::tid_t GetCurrentThreadID() { return m_current_thread_id; }
+
+ NativeThreadProtocolSP GetCurrentThread() {
+ return GetThreadByID(m_current_thread_id);
+ }
+
+ //----------------------------------------------------------------------
+ // Access to inferior stdio
+ //----------------------------------------------------------------------
+ virtual int GetTerminalFileDescriptor() { return m_terminal_fd; }
+
+ //----------------------------------------------------------------------
+ // Stop id interface
+ //----------------------------------------------------------------------
+
+ uint32_t GetStopID() const;
+
+ // ---------------------------------------------------------------------
+ // Callbacks for low-level process state changes
+ // ---------------------------------------------------------------------
+ class NativeDelegate {
+ public:
+ virtual ~NativeDelegate() {}
+
+ virtual void InitializeDelegate(NativeProcessProtocol *process) = 0;
+
+ virtual void ProcessStateChanged(NativeProcessProtocol *process,
+ lldb::StateType state) = 0;
+
+ virtual void DidExec(NativeProcessProtocol *process) = 0;
+ };
+
+ //------------------------------------------------------------------
+ /// Register a native delegate.
+ ///
+ /// Clients can register nofication callbacks by passing in a
+ /// NativeDelegate impl and passing it into this function.
+ ///
+ /// Note: it is required that the lifetime of the
+ /// native_delegate outlive the NativeProcessProtocol.
+ ///
+ /// @param[in] native_delegate
+ /// A NativeDelegate impl to be called when certain events
+ /// happen within the NativeProcessProtocol or related threads.
+ ///
+ /// @return
+ /// true if the delegate was registered successfully;
+ /// false if the delegate was already registered.
+ ///
+ /// @see NativeProcessProtocol::NativeDelegate.
+ //------------------------------------------------------------------
+ bool RegisterNativeDelegate(NativeDelegate &native_delegate);
+
+ //------------------------------------------------------------------
+ /// Unregister a native delegate previously registered.
+ ///
+ /// @param[in] native_delegate
+ /// A NativeDelegate impl previously registered with this process.
+ ///
+ /// @return Returns \b true if the NativeDelegate was
+ /// successfully removed from the process, \b false otherwise.
+ ///
+ /// @see NativeProcessProtocol::NativeDelegate
+ //------------------------------------------------------------------
+ bool UnregisterNativeDelegate(NativeDelegate &native_delegate);
+
+ virtual Error GetLoadedModuleFileSpec(const char *module_path,
+ FileSpec &file_spec) = 0;
+
+ virtual Error GetFileLoadAddress(const llvm::StringRef &file_name,
+ lldb::addr_t &load_addr) = 0;
+
+ //------------------------------------------------------------------
+ /// Launch a process for debugging. This method will create an concrete
+ /// instance of NativeProcessProtocol, based on the host platform.
+ /// (e.g. NativeProcessLinux on linux, etc.)
+ ///
+ /// @param[in] launch_info
+ /// Information required to launch the process.
+ ///
+ /// @param[in] native_delegate
+ /// The delegate that will receive messages regarding the
+ /// inferior. Must outlive the NativeProcessProtocol
+ /// instance.
+ ///
+ /// @param[in] mainloop
+ /// The mainloop instance with which the process can register
+ /// callbacks. Must outlive the NativeProcessProtocol
+ /// instance.
+ ///
+ /// @param[out] process_sp
+ /// On successful return from the method, this parameter
+ /// contains the shared pointer to the
+ /// NativeProcessProtocol that can be used to manipulate
+ /// the native process.
+ ///
+ /// @return
+ /// An error object indicating if the operation succeeded,
+ /// and if not, what error occurred.
+ //------------------------------------------------------------------
+ static Error Launch(ProcessLaunchInfo &launch_info,
+ NativeDelegate &native_delegate, MainLoop &mainloop,
+ NativeProcessProtocolSP &process_sp);
+
+ //------------------------------------------------------------------
+ /// Attach to an existing process. This method will create an concrete
+ /// instance of NativeProcessProtocol, based on the host platform.
+ /// (e.g. NativeProcessLinux on linux, etc.)
+ ///
+ /// @param[in] pid
+ /// pid of the process locatable
+ ///
+ /// @param[in] native_delegate
+ /// The delegate that will receive messages regarding the
+ /// inferior. Must outlive the NativeProcessProtocol
+ /// instance.
+ ///
+ /// @param[in] mainloop
+ /// The mainloop instance with which the process can register
+ /// callbacks. Must outlive the NativeProcessProtocol
+ /// instance.
+ ///
+ /// @param[out] process_sp
+ /// On successful return from the method, this parameter
+ /// contains the shared pointer to the
+ /// NativeProcessProtocol that can be used to manipulate
+ /// the native process.
+ ///
+ /// @return
+ /// An error object indicating if the operation succeeded,
+ /// and if not, what error occurred.
+ //------------------------------------------------------------------
+ static Error Attach(lldb::pid_t pid, NativeDelegate &native_delegate,
+ MainLoop &mainloop, NativeProcessProtocolSP &process_sp);
+
+protected:
+ lldb::pid_t m_pid;
+
+ std::vector<NativeThreadProtocolSP> m_threads;
+ lldb::tid_t m_current_thread_id;
+ mutable std::recursive_mutex m_threads_mutex;
+
+ lldb::StateType m_state;
+ mutable std::recursive_mutex m_state_mutex;
+
+ lldb_private::ExitType m_exit_type;
+ int m_exit_status;
+ std::string m_exit_description;
+ std::recursive_mutex m_delegates_mutex;
+ std::vector<NativeDelegate *> m_delegates;
+ NativeBreakpointList m_breakpoint_list;
+ NativeWatchpointList m_watchpoint_list;
+ int m_terminal_fd;
+ uint32_t m_stop_id;
+
+ // lldb_private::Host calls should be used to launch a process for debugging,
+ // and
+ // then the process should be attached to. When attaching to a process
+ // lldb_private::Host calls should be used to locate the process to attach to,
+ // and then this function should be called.
+ NativeProcessProtocol(lldb::pid_t pid);
+
+ // -----------------------------------------------------------
+ // Internal interface for state handling
+ // -----------------------------------------------------------
+ void SetState(lldb::StateType state, bool notify_delegates = true);
+
+ // Derived classes need not implement this. It can be used as a
+ // hook to clear internal caches that should be invalidated when
+ // stop ids change.
+ //
+ // Note this function is called with the state mutex obtained
+ // by the caller.
+ virtual void DoStopIDBumped(uint32_t newBumpId);
+
+ // -----------------------------------------------------------
+ // Internal interface for software breakpoints
+ // -----------------------------------------------------------
+ Error SetSoftwareBreakpoint(lldb::addr_t addr, uint32_t size_hint);
+
+ virtual Error
+ GetSoftwareBreakpointTrapOpcode(size_t trap_opcode_size_hint,
+ size_t &actual_opcode_size,
+ const uint8_t *&trap_opcode_bytes) = 0;
+
+ // -----------------------------------------------------------
+ /// Notify the delegate that an exec occurred.
+ ///
+ /// Provide a mechanism for a delegate to clear out any exec-
+ /// sensitive data.
+ // -----------------------------------------------------------
+ void NotifyDidExec();
+
+ NativeThreadProtocolSP GetThreadByIDUnlocked(lldb::tid_t tid);
+
+ // -----------------------------------------------------------
+ // Static helper methods for derived classes.
+ // -----------------------------------------------------------
+ static Error ResolveProcessArchitecture(lldb::pid_t pid, ArchSpec &arch);
+
+private:
+ void SynchronouslyNotifyProcessStateChanged(lldb::StateType state);
+};
}
#endif // #ifndef liblldb_NativeProcessProtocol_h_
diff --git a/include/lldb/Host/common/NativeRegisterContext.h b/include/lldb/Host/common/NativeRegisterContext.h
index be79bdff1c91..dd583d7866a8 100644
--- a/include/lldb/Host/common/NativeRegisterContext.h
+++ b/include/lldb/Host/common/NativeRegisterContext.h
@@ -14,212 +14,183 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Host/common/NativeWatchpointList.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
class NativeThreadProtocol;
-class NativeRegisterContext:
- public std::enable_shared_from_this<NativeRegisterContext>
-{
+class NativeRegisterContext
+ : public std::enable_shared_from_this<NativeRegisterContext> {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- NativeRegisterContext (NativeThreadProtocol &thread, uint32_t concrete_frame_idx);
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ NativeRegisterContext(NativeThreadProtocol &thread,
+ uint32_t concrete_frame_idx);
- virtual
- ~NativeRegisterContext ();
+ virtual ~NativeRegisterContext();
- // void
- // InvalidateIfNeeded (bool force);
+ // void
+ // InvalidateIfNeeded (bool force);
- //------------------------------------------------------------------
- // Subclasses must override these functions
- //------------------------------------------------------------------
- // virtual void
- // InvalidateAllRegisters () = 0;
+ //------------------------------------------------------------------
+ // Subclasses must override these functions
+ //------------------------------------------------------------------
+ // virtual void
+ // InvalidateAllRegisters () = 0;
- virtual uint32_t
- GetRegisterCount () const = 0;
+ virtual uint32_t GetRegisterCount() const = 0;
- virtual uint32_t
- GetUserRegisterCount () const = 0;
+ virtual uint32_t GetUserRegisterCount() const = 0;
- virtual const RegisterInfo *
- GetRegisterInfoAtIndex (uint32_t reg) const = 0;
+ virtual const RegisterInfo *GetRegisterInfoAtIndex(uint32_t reg) const = 0;
- const char *
- GetRegisterSetNameForRegisterAtIndex (uint32_t reg_index) const;
+ const char *GetRegisterSetNameForRegisterAtIndex(uint32_t reg_index) const;
- virtual uint32_t
- GetRegisterSetCount () const = 0;
+ virtual uint32_t GetRegisterSetCount() const = 0;
- virtual const RegisterSet *
- GetRegisterSet (uint32_t set_index) const = 0;
+ virtual const RegisterSet *GetRegisterSet(uint32_t set_index) const = 0;
- virtual Error
- ReadRegister (const RegisterInfo *reg_info, RegisterValue &reg_value) = 0;
+ virtual Error ReadRegister(const RegisterInfo *reg_info,
+ RegisterValue &reg_value) = 0;
- virtual Error
- WriteRegister (const RegisterInfo *reg_info, const RegisterValue &reg_value) = 0;
+ virtual Error WriteRegister(const RegisterInfo *reg_info,
+ const RegisterValue &reg_value) = 0;
- virtual Error
- ReadAllRegisterValues (lldb::DataBufferSP &data_sp) = 0;
+ virtual Error ReadAllRegisterValues(lldb::DataBufferSP &data_sp) = 0;
- virtual Error
- WriteAllRegisterValues (const lldb::DataBufferSP &data_sp) = 0;
+ virtual Error WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) = 0;
- uint32_t
- ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num) const;
+ uint32_t ConvertRegisterKindToRegisterNumber(uint32_t kind,
+ uint32_t num) const;
- //------------------------------------------------------------------
- // Subclasses can override these functions if desired
- //------------------------------------------------------------------
- virtual uint32_t
- NumSupportedHardwareBreakpoints ();
+ //------------------------------------------------------------------
+ // Subclasses can override these functions if desired
+ //------------------------------------------------------------------
+ virtual uint32_t NumSupportedHardwareBreakpoints();
- virtual uint32_t
- SetHardwareBreakpoint (lldb::addr_t addr, size_t size);
+ virtual uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size);
- virtual bool
- ClearHardwareBreakpoint (uint32_t hw_idx);
+ virtual bool ClearHardwareBreakpoint(uint32_t hw_idx);
- virtual uint32_t
- NumSupportedHardwareWatchpoints ();
+ virtual uint32_t NumSupportedHardwareWatchpoints();
- virtual uint32_t
- SetHardwareWatchpoint (lldb::addr_t addr, size_t size, uint32_t watch_flags);
+ virtual uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size,
+ uint32_t watch_flags);
- virtual bool
- ClearHardwareWatchpoint (uint32_t hw_index);
+ virtual bool ClearHardwareWatchpoint(uint32_t hw_index);
- virtual Error
- ClearAllHardwareWatchpoints ();
+ virtual Error ClearAllHardwareWatchpoints();
- virtual Error
- IsWatchpointHit(uint32_t wp_index, bool &is_hit);
+ virtual Error IsWatchpointHit(uint32_t wp_index, bool &is_hit);
- virtual Error
- GetWatchpointHitIndex(uint32_t &wp_index, lldb::addr_t trap_addr);
+ virtual Error GetWatchpointHitIndex(uint32_t &wp_index,
+ lldb::addr_t trap_addr);
- virtual Error
- IsWatchpointVacant (uint32_t wp_index, bool &is_vacant);
+ virtual Error IsWatchpointVacant(uint32_t wp_index, bool &is_vacant);
- virtual lldb::addr_t
- GetWatchpointAddress (uint32_t wp_index);
+ virtual lldb::addr_t GetWatchpointAddress(uint32_t wp_index);
- // MIPS Linux kernel returns a masked address (last 3bits are masked)
- // when a HW watchpoint is hit. However user may not have set a watchpoint
- // on this address. This function emulates the instruction at PC and
- // finds the base address used in the load/store instruction. This gives the
- // exact address used to read/write the variable being watched.
- // For example:
- // 'n' is at 0x120010d00 and 'm' is 0x120010d04. When a watchpoint is set at 'm',
- // then watch exception is generated even when 'n' is read/written. This function
- // returns address of 'n' so that client can check whether a watchpoint is set
- // on this address or not.
- virtual lldb::addr_t
- GetWatchpointHitAddress (uint32_t wp_index);
+ // MIPS Linux kernel returns a masked address (last 3bits are masked)
+ // when a HW watchpoint is hit. However user may not have set a watchpoint
+ // on this address. This function emulates the instruction at PC and
+ // finds the base address used in the load/store instruction. This gives the
+ // exact address used to read/write the variable being watched.
+ // For example:
+ // 'n' is at 0x120010d00 and 'm' is 0x120010d04. When a watchpoint is set at
+ // 'm',
+ // then watch exception is generated even when 'n' is read/written. This
+ // function
+ // returns address of 'n' so that client can check whether a watchpoint is set
+ // on this address or not.
+ virtual lldb::addr_t GetWatchpointHitAddress(uint32_t wp_index);
- virtual bool
- HardwareSingleStep (bool enable);
+ virtual bool HardwareSingleStep(bool enable);
- virtual Error
- ReadRegisterValueFromMemory (const lldb_private::RegisterInfo *reg_info, lldb::addr_t src_addr, size_t src_len, RegisterValue &reg_value);
+ virtual Error
+ ReadRegisterValueFromMemory(const lldb_private::RegisterInfo *reg_info,
+ lldb::addr_t src_addr, size_t src_len,
+ RegisterValue &reg_value);
- virtual Error
- WriteRegisterValueToMemory (const lldb_private::RegisterInfo *reg_info, lldb::addr_t dst_addr, size_t dst_len, const RegisterValue &reg_value);
+ virtual Error
+ WriteRegisterValueToMemory(const lldb_private::RegisterInfo *reg_info,
+ lldb::addr_t dst_addr, size_t dst_len,
+ const RegisterValue &reg_value);
- //------------------------------------------------------------------
- // Subclasses should not override these
- //------------------------------------------------------------------
- virtual lldb::tid_t
- GetThreadID() const;
+ //------------------------------------------------------------------
+ // Subclasses should not override these
+ //------------------------------------------------------------------
+ virtual lldb::tid_t GetThreadID() const;
- virtual NativeThreadProtocol &
- GetThread ()
- {
- return m_thread;
- }
+ virtual NativeThreadProtocol &GetThread() { return m_thread; }
- const RegisterInfo *
- GetRegisterInfoByName (const char *reg_name, uint32_t start_idx = 0);
+ const RegisterInfo *GetRegisterInfoByName(llvm::StringRef reg_name,
+ uint32_t start_idx = 0);
- const RegisterInfo *
- GetRegisterInfo (uint32_t reg_kind, uint32_t reg_num);
+ const RegisterInfo *GetRegisterInfo(uint32_t reg_kind, uint32_t reg_num);
- lldb::addr_t
- GetPC (lldb::addr_t fail_value = LLDB_INVALID_ADDRESS);
+ lldb::addr_t GetPC(lldb::addr_t fail_value = LLDB_INVALID_ADDRESS);
- virtual lldb::addr_t
- GetPCfromBreakpointLocation (lldb::addr_t fail_value = LLDB_INVALID_ADDRESS);
+ virtual lldb::addr_t
+ GetPCfromBreakpointLocation(lldb::addr_t fail_value = LLDB_INVALID_ADDRESS);
- Error
- SetPC (lldb::addr_t pc);
+ Error SetPC(lldb::addr_t pc);
- lldb::addr_t
- GetSP (lldb::addr_t fail_value = LLDB_INVALID_ADDRESS);
+ lldb::addr_t GetSP(lldb::addr_t fail_value = LLDB_INVALID_ADDRESS);
- Error
- SetSP (lldb::addr_t sp);
+ Error SetSP(lldb::addr_t sp);
- lldb::addr_t
- GetFP (lldb::addr_t fail_value = LLDB_INVALID_ADDRESS);
+ lldb::addr_t GetFP(lldb::addr_t fail_value = LLDB_INVALID_ADDRESS);
- Error
- SetFP (lldb::addr_t fp);
+ Error SetFP(lldb::addr_t fp);
- const char *
- GetRegisterName (uint32_t reg);
+ const char *GetRegisterName(uint32_t reg);
- lldb::addr_t
- GetReturnAddress (lldb::addr_t fail_value = LLDB_INVALID_ADDRESS);
+ lldb::addr_t GetReturnAddress(lldb::addr_t fail_value = LLDB_INVALID_ADDRESS);
- lldb::addr_t
- GetFlags (lldb::addr_t fail_value = 0);
+ lldb::addr_t GetFlags(lldb::addr_t fail_value = 0);
- lldb::addr_t
- ReadRegisterAsUnsigned (uint32_t reg, lldb::addr_t fail_value);
+ lldb::addr_t ReadRegisterAsUnsigned(uint32_t reg, lldb::addr_t fail_value);
- lldb::addr_t
- ReadRegisterAsUnsigned (const RegisterInfo *reg_info, lldb::addr_t fail_value);
+ lldb::addr_t ReadRegisterAsUnsigned(const RegisterInfo *reg_info,
+ lldb::addr_t fail_value);
- Error
- WriteRegisterFromUnsigned (uint32_t reg, uint64_t uval);
+ Error WriteRegisterFromUnsigned(uint32_t reg, uint64_t uval);
- Error
- WriteRegisterFromUnsigned (const RegisterInfo *reg_info, uint64_t uval);
+ Error WriteRegisterFromUnsigned(const RegisterInfo *reg_info, uint64_t uval);
- // uint32_t
- // GetStopID () const
- // {
- // return m_stop_id;
- // }
+ // uint32_t
+ // GetStopID () const
+ // {
+ // return m_stop_id;
+ // }
- // void
- // SetStopID (uint32_t stop_id)
- // {
- // m_stop_id = stop_id;
- // }
+ // void
+ // SetStopID (uint32_t stop_id)
+ // {
+ // m_stop_id = stop_id;
+ // }
protected:
- //------------------------------------------------------------------
- // Classes that inherit from RegisterContext can see and modify these
- //------------------------------------------------------------------
- NativeThreadProtocol &m_thread; // The thread that this register context belongs to.
- uint32_t m_concrete_frame_idx; // The concrete frame index for this register context
- // uint32_t m_stop_id; // The stop ID that any data in this context is valid for
+ //------------------------------------------------------------------
+ // Classes that inherit from RegisterContext can see and modify these
+ //------------------------------------------------------------------
+ NativeThreadProtocol
+ &m_thread; // The thread that this register context belongs to.
+ uint32_t m_concrete_frame_idx; // The concrete frame index for this register
+ // context
+ // uint32_t m_stop_id; // The stop ID that any data in this
+ // context is valid for
private:
- //------------------------------------------------------------------
- // For RegisterContext only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (NativeRegisterContext);
+ //------------------------------------------------------------------
+ // For RegisterContext only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(NativeRegisterContext);
};
} // namespace lldb_private
-#endif // liblldb_NativeRegisterContext_h_
+#endif // liblldb_NativeRegisterContext_h_
diff --git a/include/lldb/Host/common/NativeRegisterContextRegisterInfo.h b/include/lldb/Host/common/NativeRegisterContextRegisterInfo.h
index b2a29de4e5a4..908989a0624e 100644
--- a/include/lldb/Host/common/NativeRegisterContextRegisterInfo.h
+++ b/include/lldb/Host/common/NativeRegisterContextRegisterInfo.h
@@ -1,4 +1,5 @@
-//===-- NativeRegisterContextRegisterInfo.h ----------------------*- C++ -*-===//
+//===-- NativeRegisterContextRegisterInfo.h ----------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -15,33 +16,27 @@
#include "NativeRegisterContext.h"
#include "Plugins/Process/Utility/RegisterInfoInterface.h"
-namespace lldb_private
-{
- class NativeRegisterContextRegisterInfo: public NativeRegisterContext
- {
- public:
- ///
- /// Construct a NativeRegisterContextRegisterInfo, taking ownership
- /// of the register_info_interface pointer.
- ///
- NativeRegisterContextRegisterInfo (NativeThreadProtocol &thread,
- uint32_t concrete_frame_idx,
- RegisterInfoInterface *register_info_interface);
-
- uint32_t
- GetRegisterCount () const override;
-
- uint32_t
- GetUserRegisterCount () const override;
-
- const RegisterInfo *
- GetRegisterInfoAtIndex (uint32_t reg_index) const override;
-
- const RegisterInfoInterface&
- GetRegisterInfoInterface () const;
-
- private:
- std::unique_ptr<RegisterInfoInterface> m_register_info_interface_up;
- };
+namespace lldb_private {
+class NativeRegisterContextRegisterInfo : public NativeRegisterContext {
+public:
+ ///
+ /// Construct a NativeRegisterContextRegisterInfo, taking ownership
+ /// of the register_info_interface pointer.
+ ///
+ NativeRegisterContextRegisterInfo(
+ NativeThreadProtocol &thread, uint32_t concrete_frame_idx,
+ RegisterInfoInterface *register_info_interface);
+
+ uint32_t GetRegisterCount() const override;
+
+ uint32_t GetUserRegisterCount() const override;
+
+ const RegisterInfo *GetRegisterInfoAtIndex(uint32_t reg_index) const override;
+
+ const RegisterInfoInterface &GetRegisterInfoInterface() const;
+
+private:
+ std::unique_ptr<RegisterInfoInterface> m_register_info_interface_up;
+};
}
#endif
diff --git a/include/lldb/Host/common/NativeThreadProtocol.h b/include/lldb/Host/common/NativeThreadProtocol.h
index 954ffb36a94f..450e74630e71 100644
--- a/include/lldb/Host/common/NativeThreadProtocol.h
+++ b/include/lldb/Host/common/NativeThreadProtocol.h
@@ -12,71 +12,54 @@
#include <memory>
+#include "lldb/Host/Debug.h"
#include "lldb/lldb-private-forward.h"
#include "lldb/lldb-types.h"
-#include "lldb/Host/Debug.h"
-namespace lldb_private
-{
- //------------------------------------------------------------------
- // NativeThreadProtocol
- //------------------------------------------------------------------
- class NativeThreadProtocol:
- public std::enable_shared_from_this<NativeThreadProtocol>
- {
- public:
- NativeThreadProtocol (NativeProcessProtocol *process, lldb::tid_t tid);
+namespace lldb_private {
+//------------------------------------------------------------------
+// NativeThreadProtocol
+//------------------------------------------------------------------
+class NativeThreadProtocol
+ : public std::enable_shared_from_this<NativeThreadProtocol> {
+public:
+ NativeThreadProtocol(NativeProcessProtocol *process, lldb::tid_t tid);
- virtual ~NativeThreadProtocol()
- {
- }
+ virtual ~NativeThreadProtocol() {}
- virtual std::string
- GetName() = 0;
+ virtual std::string GetName() = 0;
- virtual lldb::StateType
- GetState () = 0;
+ virtual lldb::StateType GetState() = 0;
- virtual NativeRegisterContextSP
- GetRegisterContext () = 0;
+ virtual NativeRegisterContextSP GetRegisterContext() = 0;
- virtual Error
- ReadRegister (uint32_t reg, RegisterValue &reg_value);
+ virtual Error ReadRegister(uint32_t reg, RegisterValue &reg_value);
- virtual Error
- WriteRegister (uint32_t reg, const RegisterValue &reg_value);
+ virtual Error WriteRegister(uint32_t reg, const RegisterValue &reg_value);
- virtual Error
- SaveAllRegisters (lldb::DataBufferSP &data_sp);
+ virtual Error SaveAllRegisters(lldb::DataBufferSP &data_sp);
- virtual Error
- RestoreAllRegisters (lldb::DataBufferSP &data_sp);
+ virtual Error RestoreAllRegisters(lldb::DataBufferSP &data_sp);
- virtual bool
- GetStopReason (ThreadStopInfo &stop_info, std::string& description) = 0;
+ virtual bool GetStopReason(ThreadStopInfo &stop_info,
+ std::string &description) = 0;
- lldb::tid_t
- GetID() const
- {
- return m_tid;
- }
+ lldb::tid_t GetID() const { return m_tid; }
- NativeProcessProtocolSP
- GetProcess ();
+ NativeProcessProtocolSP GetProcess();
- // ---------------------------------------------------------------------
- // Thread-specific watchpoints
- // ---------------------------------------------------------------------
- virtual Error
- SetWatchpoint (lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware) = 0;
+ // ---------------------------------------------------------------------
+ // Thread-specific watchpoints
+ // ---------------------------------------------------------------------
+ virtual Error SetWatchpoint(lldb::addr_t addr, size_t size,
+ uint32_t watch_flags, bool hardware) = 0;
- virtual Error
- RemoveWatchpoint (lldb::addr_t addr) = 0;
+ virtual Error RemoveWatchpoint(lldb::addr_t addr) = 0;
- protected:
- NativeProcessProtocolWP m_process_wp;
- lldb::tid_t m_tid;
- };
+protected:
+ NativeProcessProtocolWP m_process_wp;
+ lldb::tid_t m_tid;
+};
}
#endif // #ifndef liblldb_NativeThreadProtocol_h_
diff --git a/include/lldb/Host/common/NativeWatchpointList.h b/include/lldb/Host/common/NativeWatchpointList.h
index 7b310e5a0db0..2424e5613332 100644
--- a/include/lldb/Host/common/NativeWatchpointList.h
+++ b/include/lldb/Host/common/NativeWatchpointList.h
@@ -10,38 +10,33 @@
#ifndef liblldb_NativeWatchpointList_h_
#define liblldb_NativeWatchpointList_h_
-#include "lldb/lldb-private-forward.h"
#include "lldb/Core/Error.h"
+#include "lldb/lldb-private-forward.h"
#include <map>
-namespace lldb_private
-{
- struct NativeWatchpoint
- {
- lldb::addr_t m_addr;
- size_t m_size;
- uint32_t m_watch_flags;
- bool m_hardware;
- };
-
- class NativeWatchpointList
- {
- public:
- Error
- Add (lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware);
-
- Error
- Remove (lldb::addr_t addr);
-
- using WatchpointMap = std::map<lldb::addr_t, NativeWatchpoint>;
-
- const WatchpointMap&
- GetWatchpointMap () const;
-
- private:
- WatchpointMap m_watchpoints;
- };
+namespace lldb_private {
+struct NativeWatchpoint {
+ lldb::addr_t m_addr;
+ size_t m_size;
+ uint32_t m_watch_flags;
+ bool m_hardware;
+};
+
+class NativeWatchpointList {
+public:
+ Error Add(lldb::addr_t addr, size_t size, uint32_t watch_flags,
+ bool hardware);
+
+ Error Remove(lldb::addr_t addr);
+
+ using WatchpointMap = std::map<lldb::addr_t, NativeWatchpoint>;
+
+ const WatchpointMap &GetWatchpointMap() const;
+
+private:
+ WatchpointMap m_watchpoints;
+};
}
#endif // ifndef liblldb_NativeWatchpointList_h_
diff --git a/include/lldb/Host/common/SoftwareBreakpoint.h b/include/lldb/Host/common/SoftwareBreakpoint.h
index 83b3d18aa768..703f6bb95d48 100644
--- a/include/lldb/Host/common/SoftwareBreakpoint.h
+++ b/include/lldb/Host/common/SoftwareBreakpoint.h
@@ -10,44 +10,44 @@
#ifndef liblldb_SoftwareBreakpoint_h_
#define liblldb_SoftwareBreakpoint_h_
-#include "lldb/lldb-private-forward.h"
#include "NativeBreakpoint.h"
+#include "lldb/lldb-private-forward.h"
-namespace lldb_private
-{
- class SoftwareBreakpoint : public NativeBreakpoint
- {
- friend class NativeBreakpointList;
-
- public:
- static Error
- CreateSoftwareBreakpoint (NativeProcessProtocol &process, lldb::addr_t addr, size_t size_hint, NativeBreakpointSP &breakpoint_spn);
+namespace lldb_private {
+class SoftwareBreakpoint : public NativeBreakpoint {
+ friend class NativeBreakpointList;
- SoftwareBreakpoint (NativeProcessProtocol &process, lldb::addr_t addr, const uint8_t *saved_opcodes, const uint8_t *trap_opcodes, size_t opcode_size);
+public:
+ static Error CreateSoftwareBreakpoint(NativeProcessProtocol &process,
+ lldb::addr_t addr, size_t size_hint,
+ NativeBreakpointSP &breakpoint_spn);
- protected:
- Error
- DoEnable () override;
+ SoftwareBreakpoint(NativeProcessProtocol &process, lldb::addr_t addr,
+ const uint8_t *saved_opcodes, const uint8_t *trap_opcodes,
+ size_t opcode_size);
- Error
- DoDisable () override;
+protected:
+ Error DoEnable() override;
- bool
- IsSoftwareBreakpoint () const override;
+ Error DoDisable() override;
- private:
- /// Max number of bytes that a software trap opcode sequence can occupy.
- static const size_t MAX_TRAP_OPCODE_SIZE = 8;
+ bool IsSoftwareBreakpoint() const override;
- NativeProcessProtocol &m_process;
- uint8_t m_saved_opcodes [MAX_TRAP_OPCODE_SIZE];
- uint8_t m_trap_opcodes [MAX_TRAP_OPCODE_SIZE];
- const size_t m_opcode_size;
+private:
+ /// Max number of bytes that a software trap opcode sequence can occupy.
+ static const size_t MAX_TRAP_OPCODE_SIZE = 8;
- static Error
- EnableSoftwareBreakpoint (NativeProcessProtocol &process, lldb::addr_t addr, size_t bp_opcode_size, const uint8_t *bp_opcode_bytes, uint8_t *saved_opcode_bytes);
+ NativeProcessProtocol &m_process;
+ uint8_t m_saved_opcodes[MAX_TRAP_OPCODE_SIZE];
+ uint8_t m_trap_opcodes[MAX_TRAP_OPCODE_SIZE];
+ const size_t m_opcode_size;
- };
+ static Error EnableSoftwareBreakpoint(NativeProcessProtocol &process,
+ lldb::addr_t addr,
+ size_t bp_opcode_size,
+ const uint8_t *bp_opcode_bytes,
+ uint8_t *saved_opcode_bytes);
+};
}
#endif // #ifndef liblldb_SoftwareBreakpoint_h_
diff --git a/include/lldb/Host/common/TCPSocket.h b/include/lldb/Host/common/TCPSocket.h
index 0ffe9c87bfa4..2ce8d824f0a0 100644
--- a/include/lldb/Host/common/TCPSocket.h
+++ b/include/lldb/Host/common/TCPSocket.h
@@ -12,35 +12,34 @@
#include "lldb/Host/Socket.h"
-namespace lldb_private
-{
- class TCPSocket: public Socket
- {
- public:
- TCPSocket(NativeSocket socket, bool should_close);
- TCPSocket(bool child_processes_inherit, Error &error);
-
- // returns port number or 0 if error
- uint16_t GetLocalPortNumber () const;
-
- // returns ip address string or empty string if error
- std::string GetLocalIPAddress () const;
-
- // must be connected
- // returns port number or 0 if error
- uint16_t GetRemotePortNumber () const;
-
- // must be connected
- // returns ip address string or empty string if error
- std::string GetRemoteIPAddress () const;
-
- int SetOptionNoDelay();
- int SetOptionReuseAddress();
-
- Error Connect(llvm::StringRef name) override;
- Error Listen(llvm::StringRef name, int backlog) override;
- Error Accept(llvm::StringRef name, bool child_processes_inherit, Socket *&conn_socket) override;
- };
+namespace lldb_private {
+class TCPSocket : public Socket {
+public:
+ TCPSocket(NativeSocket socket, bool should_close);
+ TCPSocket(bool child_processes_inherit, Error &error);
+
+ // returns port number or 0 if error
+ uint16_t GetLocalPortNumber() const;
+
+ // returns ip address string or empty string if error
+ std::string GetLocalIPAddress() const;
+
+ // must be connected
+ // returns port number or 0 if error
+ uint16_t GetRemotePortNumber() const;
+
+ // must be connected
+ // returns ip address string or empty string if error
+ std::string GetRemoteIPAddress() const;
+
+ int SetOptionNoDelay();
+ int SetOptionReuseAddress();
+
+ Error Connect(llvm::StringRef name) override;
+ Error Listen(llvm::StringRef name, int backlog) override;
+ Error Accept(llvm::StringRef name, bool child_processes_inherit,
+ Socket *&conn_socket) override;
+};
}
#endif // ifndef liblldb_TCPSocket_h_
diff --git a/include/lldb/Host/common/UDPSocket.h b/include/lldb/Host/common/UDPSocket.h
index afc1ec719626..153804be2603 100644
--- a/include/lldb/Host/common/UDPSocket.h
+++ b/include/lldb/Host/common/UDPSocket.h
@@ -12,24 +12,25 @@
#include "lldb/Host/Socket.h"
-namespace lldb_private
-{
- class UDPSocket: public Socket
- {
- public:
- UDPSocket(bool child_processes_inherit, Error &error);
-
- static Error Connect(llvm::StringRef name, bool child_processes_inherit, Socket *&send_socket, Socket *&recv_socket);
- private:
- UDPSocket(NativeSocket socket);
-
- size_t Send(const void *buf, const size_t num_bytes) override;
- Error Connect(llvm::StringRef name) override;
- Error Listen(llvm::StringRef name, int backlog) override;
- Error Accept(llvm::StringRef name, bool child_processes_inherit, Socket *&socket) override;
-
- SocketAddress m_send_sockaddr;
- };
+namespace lldb_private {
+class UDPSocket : public Socket {
+public:
+ UDPSocket(bool child_processes_inherit, Error &error);
+
+ static Error Connect(llvm::StringRef name, bool child_processes_inherit,
+ Socket *&send_socket, Socket *&recv_socket);
+
+private:
+ UDPSocket(NativeSocket socket);
+
+ size_t Send(const void *buf, const size_t num_bytes) override;
+ Error Connect(llvm::StringRef name) override;
+ Error Listen(llvm::StringRef name, int backlog) override;
+ Error Accept(llvm::StringRef name, bool child_processes_inherit,
+ Socket *&socket) override;
+
+ SocketAddress m_send_sockaddr;
+};
}
#endif // ifndef liblldb_UDPSocket_h_
diff --git a/include/lldb/Host/freebsd/Config.h b/include/lldb/Host/freebsd/Config.h
index 49d97dd5793c..1e9f55299d52 100644
--- a/include/lldb/Host/freebsd/Config.h
+++ b/include/lldb/Host/freebsd/Config.h
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
//----------------------------------------------------------------------
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
+// LLDB currently doesn't have a dynamic configuration mechanism, so we
// are going to hardcode things for now. Eventually these files will
// be auto generated by some configuration script that can detect
// platform functionality availability.
diff --git a/include/lldb/Host/freebsd/HostInfoFreeBSD.h b/include/lldb/Host/freebsd/HostInfoFreeBSD.h
index 01dd99586f01..a549f87740c0 100644
--- a/include/lldb/Host/freebsd/HostInfoFreeBSD.h
+++ b/include/lldb/Host/freebsd/HostInfoFreeBSD.h
@@ -13,17 +13,15 @@
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/posix/HostInfoPosix.h"
-namespace lldb_private
-{
+namespace lldb_private {
-class HostInfoFreeBSD : public HostInfoPosix
-{
- public:
- static uint32_t GetMaxThreadNameLength();
- static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update);
- static bool GetOSBuildString(std::string &s);
- static bool GetOSKernelDescription(std::string &s);
- static FileSpec GetProgramFileSpec();
+class HostInfoFreeBSD : public HostInfoPosix {
+public:
+ static uint32_t GetMaxThreadNameLength();
+ static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update);
+ static bool GetOSBuildString(std::string &s);
+ static bool GetOSKernelDescription(std::string &s);
+ static FileSpec GetProgramFileSpec();
};
}
diff --git a/include/lldb/Host/freebsd/HostThreadFreeBSD.h b/include/lldb/Host/freebsd/HostThreadFreeBSD.h
index 056957607af4..2f1d6ceae255 100644
--- a/include/lldb/Host/freebsd/HostThreadFreeBSD.h
+++ b/include/lldb/Host/freebsd/HostThreadFreeBSD.h
@@ -12,19 +12,17 @@
#include "lldb/Host/posix/HostThreadPosix.h"
-#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
-namespace lldb_private
-{
+namespace lldb_private {
-class HostThreadFreeBSD : public HostThreadPosix
-{
- public:
- HostThreadFreeBSD();
- HostThreadFreeBSD(lldb::thread_t thread);
+class HostThreadFreeBSD : public HostThreadPosix {
+public:
+ HostThreadFreeBSD();
+ HostThreadFreeBSD(lldb::thread_t thread);
- static void GetName(lldb::tid_t tid, llvm::SmallVectorImpl<char> &name);
+ static void GetName(lldb::tid_t tid, llvm::SmallVectorImpl<char> &name);
};
}
diff --git a/include/lldb/Host/linux/AbstractSocket.h b/include/lldb/Host/linux/AbstractSocket.h
index 7814410a04d7..f73a287cb3f8 100644
--- a/include/lldb/Host/linux/AbstractSocket.h
+++ b/include/lldb/Host/linux/AbstractSocket.h
@@ -12,17 +12,15 @@
#include "lldb/Host/posix/DomainSocket.h"
-namespace lldb_private
-{
- class AbstractSocket: public DomainSocket
- {
- public:
- AbstractSocket(bool child_processes_inherit, Error &error);
+namespace lldb_private {
+class AbstractSocket : public DomainSocket {
+public:
+ AbstractSocket(bool child_processes_inherit, Error &error);
- protected:
- size_t GetNameOffset() const override;
- void DeleteSocketFile(llvm::StringRef name) override;
- };
+protected:
+ size_t GetNameOffset() const override;
+ void DeleteSocketFile(llvm::StringRef name) override;
+};
}
#endif // ifndef liblldb_AbstractSocket_h_
diff --git a/include/lldb/Host/linux/Config.h b/include/lldb/Host/linux/Config.h
index 49d97dd5793c..1e9f55299d52 100644
--- a/include/lldb/Host/linux/Config.h
+++ b/include/lldb/Host/linux/Config.h
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
//----------------------------------------------------------------------
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
+// LLDB currently doesn't have a dynamic configuration mechanism, so we
// are going to hardcode things for now. Eventually these files will
// be auto generated by some configuration script that can detect
// platform functionality availability.
diff --git a/include/lldb/Host/linux/HostInfoLinux.h b/include/lldb/Host/linux/HostInfoLinux.h
index e4b22075325d..8cb97c0b4d6b 100644
--- a/include/lldb/Host/linux/HostInfoLinux.h
+++ b/include/lldb/Host/linux/HostInfoLinux.h
@@ -17,33 +17,32 @@
#include <string>
-namespace lldb_private
-{
-
-class HostInfoLinux : public HostInfoPosix
-{
- friend class HostInfoBase;
-
- private:
- // Static class, unconstructable.
- HostInfoLinux();
- ~HostInfoLinux();
-
- public:
- static void Initialize();
- static uint32_t GetMaxThreadNameLength();
-
- static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update);
- static bool GetOSBuildString(std::string &s);
- static bool GetOSKernelDescription(std::string &s);
- static llvm::StringRef GetDistributionId();
- static FileSpec GetProgramFileSpec();
-
- protected:
- static bool ComputeSupportExeDirectory(FileSpec &file_spec);
- static bool ComputeSystemPluginsDirectory(FileSpec &file_spec);
- static bool ComputeUserPluginsDirectory(FileSpec &file_spec);
- static void ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64);
+namespace lldb_private {
+
+class HostInfoLinux : public HostInfoPosix {
+ friend class HostInfoBase;
+
+private:
+ // Static class, unconstructable.
+ HostInfoLinux();
+ ~HostInfoLinux();
+
+public:
+ static void Initialize();
+ static uint32_t GetMaxThreadNameLength();
+
+ static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update);
+ static bool GetOSBuildString(std::string &s);
+ static bool GetOSKernelDescription(std::string &s);
+ static llvm::StringRef GetDistributionId();
+ static FileSpec GetProgramFileSpec();
+
+protected:
+ static bool ComputeSupportExeDirectory(FileSpec &file_spec);
+ static bool ComputeSystemPluginsDirectory(FileSpec &file_spec);
+ static bool ComputeUserPluginsDirectory(FileSpec &file_spec);
+ static void ComputeHostArchitectureSupport(ArchSpec &arch_32,
+ ArchSpec &arch_64);
};
}
diff --git a/include/lldb/Host/linux/HostThreadLinux.h b/include/lldb/Host/linux/HostThreadLinux.h
index 9091f41dae47..ddfa8633ffed 100644
--- a/include/lldb/Host/linux/HostThreadLinux.h
+++ b/include/lldb/Host/linux/HostThreadLinux.h
@@ -12,20 +12,18 @@
#include "lldb/Host/posix/HostThreadPosix.h"
-#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
-namespace lldb_private
-{
+namespace lldb_private {
-class HostThreadLinux : public HostThreadPosix
-{
- public:
- HostThreadLinux();
- HostThreadLinux(lldb::thread_t thread);
+class HostThreadLinux : public HostThreadPosix {
+public:
+ HostThreadLinux();
+ HostThreadLinux(lldb::thread_t thread);
- static void SetName(lldb::thread_t thread, llvm::StringRef name);
- static void GetName(lldb::thread_t thread, llvm::SmallVectorImpl<char> &name);
+ static void SetName(lldb::thread_t thread, llvm::StringRef name);
+ static void GetName(lldb::thread_t thread, llvm::SmallVectorImpl<char> &name);
};
}
diff --git a/include/lldb/Host/linux/Personality.h b/include/lldb/Host/linux/Personality.h
deleted file mode 100644
index 48fc2e2bdd4c..000000000000
--- a/include/lldb/Host/linux/Personality.h
+++ /dev/null
@@ -1,25 +0,0 @@
-//===-- Personality.h -------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// This file defines personality functions & structures
-
-#ifndef liblldb_Host_linux_Personality_h_
-#define liblldb_Host_linux_Personality_h_
-
-#ifdef __ANDROID_NDK__
-#include <android/api-level.h>
-#endif
-
-#if defined(__ANDROID_API__) && __ANDROID_API__ < 21
-#include <linux/personality.h>
-#else
-#include <sys/personality.h>
-#endif
-
-#endif // liblldb_Host_linux_Personality_h_
diff --git a/include/lldb/Host/android/ProcessLauncherAndroid.h b/include/lldb/Host/linux/ProcessLauncherLinux.h
index 8d4847810028..8ad00d091606 100644
--- a/include/lldb/Host/android/ProcessLauncherAndroid.h
+++ b/include/lldb/Host/linux/ProcessLauncherLinux.h
@@ -12,13 +12,12 @@
#include "lldb/Host/ProcessLauncher.h"
-namespace lldb_private
-{
+namespace lldb_private {
-class ProcessLauncherAndroid : public ProcessLauncher
-{
- public:
- virtual HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info, Error &error);
+class ProcessLauncherLinux : public ProcessLauncher {
+public:
+ virtual HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info,
+ Error &error);
};
} // end of namespace lldb_private
diff --git a/include/lldb/Host/linux/Ptrace.h b/include/lldb/Host/linux/Ptrace.h
index 731e435da0db..1b753c284967 100644
--- a/include/lldb/Host/linux/Ptrace.h
+++ b/include/lldb/Host/linux/Ptrace.h
@@ -22,36 +22,36 @@ typedef int __ptrace_request;
// Support ptrace extensions even when compiled without required kernel support
#ifndef PTRACE_GETREGS
- #define PTRACE_GETREGS 12
+#define PTRACE_GETREGS 12
#endif
#ifndef PTRACE_SETREGS
- #define PTRACE_SETREGS 13
+#define PTRACE_SETREGS 13
#endif
#ifndef PTRACE_GETFPREGS
- #define PTRACE_GETFPREGS 14
+#define PTRACE_GETFPREGS 14
#endif
#ifndef PTRACE_SETFPREGS
- #define PTRACE_SETFPREGS 15
+#define PTRACE_SETFPREGS 15
#endif
#ifndef PTRACE_GETREGSET
- #define PTRACE_GETREGSET 0x4204
+#define PTRACE_GETREGSET 0x4204
#endif
#ifndef PTRACE_SETREGSET
- #define PTRACE_SETREGSET 0x4205
+#define PTRACE_SETREGSET 0x4205
#endif
#ifndef PTRACE_GET_THREAD_AREA
- #define PTRACE_GET_THREAD_AREA 25
+#define PTRACE_GET_THREAD_AREA 25
#endif
#ifndef PTRACE_ARCH_PRCTL
- #define PTRACE_ARCH_PRCTL 30
+#define PTRACE_ARCH_PRCTL 30
#endif
#ifndef ARCH_GET_FS
- #define ARCH_SET_GS 0x1001
- #define ARCH_SET_FS 0x1002
- #define ARCH_GET_FS 0x1003
- #define ARCH_GET_GS 0x1004
+#define ARCH_SET_GS 0x1001
+#define ARCH_SET_FS 0x1002
+#define ARCH_GET_FS 0x1003
+#define ARCH_GET_GS 0x1004
#endif
-#define LLDB_PTRACE_NT_ARM_TLS 0x401 // ARM TLS register
+#define LLDB_PTRACE_NT_ARM_TLS 0x401 // ARM TLS register
#endif // liblldb_Host_linux_Ptrace_h_
diff --git a/include/lldb/Host/linux/Uio.h b/include/lldb/Host/linux/Uio.h
index 08894c0a2ca8..8b964d3f3e25 100644
--- a/include/lldb/Host/linux/Uio.h
+++ b/include/lldb/Host/linux/Uio.h
@@ -12,12 +12,12 @@
#include <sys/uio.h>
-// We shall provide our own implementation of process_vm_readv if it is not present
+// We shall provide our own implementation of process_vm_readv if it is not
+// present
#ifndef HAVE_PROCESS_VM_READV
-ssize_t process_vm_readv(::pid_t pid,
- const struct iovec *local_iov, unsigned long liovcnt,
- const struct iovec *remote_iov, unsigned long riovcnt,
- unsigned long flags);
+ssize_t process_vm_readv(::pid_t pid, const struct iovec *local_iov,
+ unsigned long liovcnt, const struct iovec *remote_iov,
+ unsigned long riovcnt, unsigned long flags);
#endif
#endif // liblldb_Host_linux_Uio_h_
diff --git a/include/lldb/Host/macosx/Config.h b/include/lldb/Host/macosx/Config.h
index c8add4498f27..ef8e02cfa4da 100644
--- a/include/lldb/Host/macosx/Config.h
+++ b/include/lldb/Host/macosx/Config.h
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
//----------------------------------------------------------------------
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
+// LLDB currently doesn't have a dynamic configuration mechanism, so we
// are going to hardcode things for now. Eventually these files will
// be auto generated by some configuration script that can detect
// platform functionality availability.
diff --git a/include/lldb/Host/macosx/HostInfoMacOSX.h b/include/lldb/Host/macosx/HostInfoMacOSX.h
index 4a8ee4fd850e..b182b9bce147 100644
--- a/include/lldb/Host/macosx/HostInfoMacOSX.h
+++ b/include/lldb/Host/macosx/HostInfoMacOSX.h
@@ -13,35 +13,34 @@
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/posix/HostInfoPosix.h"
-namespace lldb_private
-{
+namespace lldb_private {
class ArchSpec;
-class HostInfoMacOSX : public HostInfoPosix
-{
- friend class HostInfoBase;
-
- private:
- // Static class, unconstructable.
- HostInfoMacOSX();
- ~HostInfoMacOSX();
-
- public:
- static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update);
- static bool GetOSBuildString(std::string &s);
- static bool GetOSKernelDescription(std::string &s);
- static FileSpec GetProgramFileSpec();
- static uint32_t GetMaxThreadNameLength();
-
- protected:
- static bool ComputeSupportExeDirectory(FileSpec &file_spec);
- static void ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64);
- static bool ComputeHeaderDirectory(FileSpec &file_spec);
- static bool ComputePythonDirectory(FileSpec &file_spec);
- static bool ComputeClangDirectory(FileSpec &file_spec);
- static bool ComputeSystemPluginsDirectory(FileSpec &file_spec);
- static bool ComputeUserPluginsDirectory(FileSpec &file_spec);
+class HostInfoMacOSX : public HostInfoPosix {
+ friend class HostInfoBase;
+
+private:
+ // Static class, unconstructable.
+ HostInfoMacOSX();
+ ~HostInfoMacOSX();
+
+public:
+ static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update);
+ static bool GetOSBuildString(std::string &s);
+ static bool GetOSKernelDescription(std::string &s);
+ static FileSpec GetProgramFileSpec();
+ static uint32_t GetMaxThreadNameLength();
+
+protected:
+ static bool ComputeSupportExeDirectory(FileSpec &file_spec);
+ static void ComputeHostArchitectureSupport(ArchSpec &arch_32,
+ ArchSpec &arch_64);
+ static bool ComputeHeaderDirectory(FileSpec &file_spec);
+ static bool ComputePythonDirectory(FileSpec &file_spec);
+ static bool ComputeClangDirectory(FileSpec &file_spec);
+ static bool ComputeSystemPluginsDirectory(FileSpec &file_spec);
+ static bool ComputeUserPluginsDirectory(FileSpec &file_spec);
};
}
diff --git a/include/lldb/Host/macosx/HostThreadMacOSX.h b/include/lldb/Host/macosx/HostThreadMacOSX.h
index 9173aaf92f32..16b9a6d6986e 100644
--- a/include/lldb/Host/macosx/HostThreadMacOSX.h
+++ b/include/lldb/Host/macosx/HostThreadMacOSX.h
@@ -12,19 +12,17 @@
#include "lldb/Host/posix/HostThreadPosix.h"
-namespace lldb_private
-{
+namespace lldb_private {
-class HostThreadMacOSX : public HostThreadPosix
-{
- friend class ThreadLauncher;
+class HostThreadMacOSX : public HostThreadPosix {
+ friend class ThreadLauncher;
- public:
- HostThreadMacOSX();
- HostThreadMacOSX(lldb::thread_t thread);
+public:
+ HostThreadMacOSX();
+ HostThreadMacOSX(lldb::thread_t thread);
- protected:
- static lldb::thread_result_t ThreadCreateTrampoline(lldb::thread_arg_t arg);
+protected:
+ static lldb::thread_result_t ThreadCreateTrampoline(lldb::thread_arg_t arg);
};
}
diff --git a/include/lldb/Host/mingw/Config.h b/include/lldb/Host/mingw/Config.h
index cdf6f21e0988..9cf2735ab709 100644
--- a/include/lldb/Host/mingw/Config.h
+++ b/include/lldb/Host/mingw/Config.h
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
//----------------------------------------------------------------------
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
+// LLDB currently doesn't have a dynamic configuration mechanism, so we
// are going to hardcode things for now. Eventually these files will
// be auto generated by some configuration script that can detect
// platform functionality availability.
diff --git a/include/lldb/Host/msvc/Config.h b/include/lldb/Host/msvc/Config.h
index 4a4ed5799c53..37dfbf58a854 100644
--- a/include/lldb/Host/msvc/Config.h
+++ b/include/lldb/Host/msvc/Config.h
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
//----------------------------------------------------------------------
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
+// LLDB currently doesn't have a dynamic configuration mechanism, so we
// are going to hardcode things for now. Eventually these files will
// be auto generated by some configuration script that can detect
// platform functionality availability.
@@ -28,8 +28,10 @@
//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
#if _HAS_EXCEPTIONS == 0
-// Due to a bug in <thread>, when _HAS_EXCEPTIONS == 0 the header will try to call
-// uncaught_exception() without having a declaration for it. The fix for this is
+// Due to a bug in <thread>, when _HAS_EXCEPTIONS == 0 the header will try to
+// call
+// uncaught_exception() without having a declaration for it. The fix for this
+// is
// to manually #include <eh.h>, which contains this declaration.
#include <eh.h>
#endif
diff --git a/include/lldb/Host/netbsd/HostInfoNetBSD.h b/include/lldb/Host/netbsd/HostInfoNetBSD.h
index 34a29346c2ef..684e54e9f052 100644
--- a/include/lldb/Host/netbsd/HostInfoNetBSD.h
+++ b/include/lldb/Host/netbsd/HostInfoNetBSD.h
@@ -13,17 +13,15 @@
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/posix/HostInfoPosix.h"
-namespace lldb_private
-{
+namespace lldb_private {
-class HostInfoNetBSD : public HostInfoPosix
-{
- public:
- static uint32_t GetMaxThreadNameLength();
- static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update);
- static bool GetOSBuildString(std::string &s);
- static bool GetOSKernelDescription(std::string &s);
- static FileSpec GetProgramFileSpec();
+class HostInfoNetBSD : public HostInfoPosix {
+public:
+ static uint32_t GetMaxThreadNameLength();
+ static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update);
+ static bool GetOSBuildString(std::string &s);
+ static bool GetOSKernelDescription(std::string &s);
+ static FileSpec GetProgramFileSpec();
};
}
diff --git a/include/lldb/Host/netbsd/HostThreadNetBSD.h b/include/lldb/Host/netbsd/HostThreadNetBSD.h
index 2ce1e48fa045..385f014899f7 100644
--- a/include/lldb/Host/netbsd/HostThreadNetBSD.h
+++ b/include/lldb/Host/netbsd/HostThreadNetBSD.h
@@ -12,20 +12,18 @@
#include "lldb/Host/posix/HostThreadPosix.h"
-#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
-namespace lldb_private
-{
+namespace lldb_private {
-class HostThreadNetBSD : public HostThreadPosix
-{
- public:
- HostThreadNetBSD();
- HostThreadNetBSD(lldb::thread_t thread);
+class HostThreadNetBSD : public HostThreadPosix {
+public:
+ HostThreadNetBSD();
+ HostThreadNetBSD(lldb::thread_t thread);
- static void SetName(lldb::thread_t tid, llvm::StringRef &name);
- static void GetName(lldb::thread_t tid, llvm::SmallVectorImpl<char> &name);
+ static void SetName(lldb::thread_t tid, llvm::StringRef &name);
+ static void GetName(lldb::thread_t tid, llvm::SmallVectorImpl<char> &name);
};
}
diff --git a/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h b/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
index 0d3ec35ce467..f002dd167ce2 100644
--- a/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
+++ b/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
@@ -20,103 +20,107 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Connection.h"
+#include "lldb/Host/IOObject.h"
#include "lldb/Host/Pipe.h"
#include "lldb/Host/Predicate.h"
-#include "lldb/Host/IOObject.h"
-namespace lldb_private
-{
+namespace lldb_private {
class Error;
class Socket;
class SocketAddress;
-class ConnectionFileDescriptor : public Connection
-{
- public:
- static const char* LISTEN_SCHEME;
- static const char* ACCEPT_SCHEME;
- static const char* UNIX_ACCEPT_SCHEME;
- static const char* CONNECT_SCHEME;
- static const char* TCP_CONNECT_SCHEME;
- static const char* UDP_SCHEME;
- static const char* UNIX_CONNECT_SCHEME;
- static const char* UNIX_ABSTRACT_CONNECT_SCHEME;
- static const char* FD_SCHEME;
- static const char* FILE_SCHEME;
+class ConnectionFileDescriptor : public Connection {
+public:
+ static const char *LISTEN_SCHEME;
+ static const char *ACCEPT_SCHEME;
+ static const char *UNIX_ACCEPT_SCHEME;
+ static const char *CONNECT_SCHEME;
+ static const char *TCP_CONNECT_SCHEME;
+ static const char *UDP_SCHEME;
+ static const char *UNIX_CONNECT_SCHEME;
+ static const char *UNIX_ABSTRACT_CONNECT_SCHEME;
+ static const char *FD_SCHEME;
+ static const char *FILE_SCHEME;
- ConnectionFileDescriptor(bool child_processes_inherit = false);
+ ConnectionFileDescriptor(bool child_processes_inherit = false);
- ConnectionFileDescriptor(int fd, bool owns_fd);
+ ConnectionFileDescriptor(int fd, bool owns_fd);
- ConnectionFileDescriptor(Socket* socket);
+ ConnectionFileDescriptor(Socket *socket);
- ~ConnectionFileDescriptor() override;
+ ~ConnectionFileDescriptor() override;
- bool IsConnected() const override;
+ bool IsConnected() const override;
- lldb::ConnectionStatus Connect(const char *s, Error *error_ptr) override;
+ lldb::ConnectionStatus Connect(llvm::StringRef s, Error *error_ptr) override;
- lldb::ConnectionStatus Disconnect(Error *error_ptr) override;
+ lldb::ConnectionStatus Disconnect(Error *error_ptr) override;
- size_t Read(void *dst, size_t dst_len, uint32_t timeout_usec, lldb::ConnectionStatus &status, Error *error_ptr) override;
+ size_t Read(void *dst, size_t dst_len, const Timeout<std::micro> &timeout,
+ lldb::ConnectionStatus &status, Error *error_ptr) override;
- size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status, Error *error_ptr) override;
+ size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status,
+ Error *error_ptr) override;
- std::string GetURI() override;
+ std::string GetURI() override;
- lldb::ConnectionStatus BytesAvailable(uint32_t timeout_usec, Error *error_ptr);
+ lldb::ConnectionStatus BytesAvailable(const Timeout<std::micro> &timeout,
+ Error *error_ptr);
- bool InterruptRead() override;
+ bool InterruptRead() override;
- lldb::IOObjectSP
- GetReadObject() override
- {
- return m_read_sp;
- }
+ lldb::IOObjectSP GetReadObject() override { return m_read_sp; }
- uint16_t GetListeningPort(uint32_t timeout_sec);
+ uint16_t GetListeningPort(uint32_t timeout_sec);
- bool GetChildProcessesInherit() const;
- void SetChildProcessesInherit(bool child_processes_inherit);
+ bool GetChildProcessesInherit() const;
+ void SetChildProcessesInherit(bool child_processes_inherit);
- protected:
- void OpenCommandPipe();
+protected:
+ void OpenCommandPipe();
- void CloseCommandPipe();
+ void CloseCommandPipe();
- lldb::ConnectionStatus SocketListenAndAccept(const char *host_and_port, Error *error_ptr);
+ lldb::ConnectionStatus SocketListenAndAccept(llvm::StringRef host_and_port,
+ Error *error_ptr);
- lldb::ConnectionStatus ConnectTCP(const char *host_and_port, Error *error_ptr);
+ lldb::ConnectionStatus ConnectTCP(llvm::StringRef host_and_port,
+ Error *error_ptr);
- lldb::ConnectionStatus ConnectUDP(const char *args, Error *error_ptr);
+ lldb::ConnectionStatus ConnectUDP(llvm::StringRef args, Error *error_ptr);
- lldb::ConnectionStatus NamedSocketConnect(const char *socket_name, Error *error_ptr);
+ lldb::ConnectionStatus NamedSocketConnect(llvm::StringRef socket_name,
+ Error *error_ptr);
- lldb::ConnectionStatus NamedSocketAccept(const char *socket_name, Error *error_ptr);
+ lldb::ConnectionStatus NamedSocketAccept(llvm::StringRef socket_name,
+ Error *error_ptr);
- lldb::ConnectionStatus UnixAbstractSocketConnect(const char *socket_name, Error *error_ptr);
+ lldb::ConnectionStatus UnixAbstractSocketConnect(llvm::StringRef socket_name,
+ Error *error_ptr);
- lldb::IOObjectSP m_read_sp;
- lldb::IOObjectSP m_write_sp;
+ lldb::IOObjectSP m_read_sp;
+ lldb::IOObjectSP m_write_sp;
- Predicate<uint16_t> m_port_predicate; // Used when binding to port zero to wait for the thread
- // that creates the socket, binds and listens to resolve
- // the port number.
+ Predicate<uint16_t>
+ m_port_predicate; // Used when binding to port zero to wait for the thread
+ // that creates the socket, binds and listens to resolve
+ // the port number.
- Pipe m_pipe;
- std::recursive_mutex m_mutex;
- std::atomic<bool> m_shutting_down; // This marks that we are shutting down so if we get woken up from
- // BytesAvailable to disconnect, we won't try to read again.
- bool m_waiting_for_accept;
- bool m_child_processes_inherit;
+ Pipe m_pipe;
+ std::recursive_mutex m_mutex;
+ std::atomic<bool> m_shutting_down; // This marks that we are shutting down so
+ // if we get woken up from
+ // BytesAvailable to disconnect, we won't try to read again.
+ bool m_waiting_for_accept;
+ bool m_child_processes_inherit;
- std::string m_uri;
+ std::string m_uri;
- private:
- void InitializeSocket(Socket* socket);
+private:
+ void InitializeSocket(Socket *socket);
- DISALLOW_COPY_AND_ASSIGN(ConnectionFileDescriptor);
+ DISALLOW_COPY_AND_ASSIGN(ConnectionFileDescriptor);
};
} // namespace lldb_private
diff --git a/include/lldb/Host/posix/DomainSocket.h b/include/lldb/Host/posix/DomainSocket.h
index 76f58e4f03b2..3bd4e0141336 100644
--- a/include/lldb/Host/posix/DomainSocket.h
+++ b/include/lldb/Host/posix/DomainSocket.h
@@ -12,26 +12,26 @@
#include "lldb/Host/Socket.h"
-namespace lldb_private
-{
- class DomainSocket: public Socket
- {
- public:
- DomainSocket(bool child_processes_inherit, Error &error);
-
- Error Connect(llvm::StringRef name) override;
- Error Listen(llvm::StringRef name, int backlog) override;
- Error Accept(llvm::StringRef name, bool child_processes_inherit, Socket *&socket) override;
-
- protected:
- DomainSocket(SocketProtocol protocol, bool child_processes_inherit, Error &error);
-
- virtual size_t GetNameOffset() const;
- virtual void DeleteSocketFile(llvm::StringRef name);
-
- private:
- DomainSocket(NativeSocket socket);
- };
+namespace lldb_private {
+class DomainSocket : public Socket {
+public:
+ DomainSocket(bool child_processes_inherit, Error &error);
+
+ Error Connect(llvm::StringRef name) override;
+ Error Listen(llvm::StringRef name, int backlog) override;
+ Error Accept(llvm::StringRef name, bool child_processes_inherit,
+ Socket *&socket) override;
+
+protected:
+ DomainSocket(SocketProtocol protocol, bool child_processes_inherit,
+ Error &error);
+
+ virtual size_t GetNameOffset() const;
+ virtual void DeleteSocketFile(llvm::StringRef name);
+
+private:
+ DomainSocket(NativeSocket socket);
+};
}
#endif // ifndef liblldb_DomainSocket_h_
diff --git a/include/lldb/Host/posix/Fcntl.h b/include/lldb/Host/posix/Fcntl.h
index 3e3a472f0a20..833a90584141 100644
--- a/include/lldb/Host/posix/Fcntl.h
+++ b/include/lldb/Host/posix/Fcntl.h
@@ -12,7 +12,7 @@
#ifndef liblldb_Host_posix_Fcntl_h_
#define liblldb_Host_posix_Fcntl_h_
-#ifdef __ANDROID_NDK__
+#ifdef __ANDROID__
#include <android/api-level.h>
#endif
diff --git a/include/lldb/Host/posix/HostInfoPosix.h b/include/lldb/Host/posix/HostInfoPosix.h
index 2e6c2a22f99c..6d22776e1854 100644
--- a/include/lldb/Host/posix/HostInfoPosix.h
+++ b/include/lldb/Host/posix/HostInfoPosix.h
@@ -13,33 +13,33 @@
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/HostInfoBase.h"
-namespace lldb_private
-{
+namespace lldb_private {
-class HostInfoPosix : public HostInfoBase
-{
- friend class HostInfoBase;
+class HostInfoPosix : public HostInfoBase {
+ friend class HostInfoBase;
- public:
- static size_t GetPageSize();
- static bool GetHostname(std::string &s);
- static const char *LookupUserName(uint32_t uid, std::string &user_name);
- static const char *LookupGroupName(uint32_t gid, std::string &group_name);
+public:
+ static size_t GetPageSize();
+ static bool GetHostname(std::string &s);
+ static const char *LookupUserName(uint32_t uid, std::string &user_name);
+ static const char *LookupGroupName(uint32_t gid, std::string &group_name);
- static uint32_t GetUserID();
- static uint32_t GetGroupID();
- static uint32_t GetEffectiveUserID();
- static uint32_t GetEffectiveGroupID();
+ static uint32_t GetUserID();
+ static uint32_t GetGroupID();
+ static uint32_t GetEffectiveUserID();
+ static uint32_t GetEffectiveGroupID();
- static FileSpec GetDefaultShell();
+ static FileSpec GetDefaultShell();
- static bool
- GetEnvironmentVar(const std::string &var_name, std::string &var);
+ static bool GetEnvironmentVar(const std::string &var_name, std::string &var);
protected:
- static bool ComputeSupportExeDirectory(FileSpec &file_spec);
- static bool ComputeHeaderDirectory(FileSpec &file_spec);
- static bool ComputePythonDirectory(FileSpec &file_spec);
+ static bool ComputeSupportExeDirectory(FileSpec &file_spec);
+ static bool ComputeHeaderDirectory(FileSpec &file_spec);
+ static bool ComputePythonDirectory(FileSpec &file_spec);
+ static bool ComputeClangDirectory(FileSpec &file_spec);
+ static bool ComputePathRelativeToLibrary(FileSpec &file_spec,
+ llvm::StringRef dir);
};
}
diff --git a/include/lldb/Host/posix/HostProcessPosix.h b/include/lldb/Host/posix/HostProcessPosix.h
index 53700fda1acc..1535e679dd53 100644
--- a/include/lldb/Host/posix/HostProcessPosix.h
+++ b/include/lldb/Host/posix/HostProcessPosix.h
@@ -14,33 +14,31 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-types.h"
#include "lldb/Core/Error.h"
#include "lldb/Host/HostNativeProcessBase.h"
+#include "lldb/lldb-types.h"
-namespace lldb_private
-{
+namespace lldb_private {
class FileSpec;
-class HostProcessPosix : public HostNativeProcessBase
-{
- public:
- HostProcessPosix();
- HostProcessPosix(lldb::process_t process);
- ~HostProcessPosix() override;
+class HostProcessPosix : public HostNativeProcessBase {
+public:
+ HostProcessPosix();
+ HostProcessPosix(lldb::process_t process);
+ ~HostProcessPosix() override;
- virtual Error Signal(int signo) const;
- static Error Signal(lldb::process_t process, int signo);
+ virtual Error Signal(int signo) const;
+ static Error Signal(lldb::process_t process, int signo);
- Error Terminate() override;
- Error GetMainModule(FileSpec &file_spec) const override;
+ Error Terminate() override;
+ Error GetMainModule(FileSpec &file_spec) const override;
- lldb::pid_t GetProcessId() const override;
- bool IsRunning() const override;
+ lldb::pid_t GetProcessId() const override;
+ bool IsRunning() const override;
- HostThread
- StartMonitoring(const Host::MonitorChildProcessCallback &callback, bool monitor_signals) override;
+ HostThread StartMonitoring(const Host::MonitorChildProcessCallback &callback,
+ bool monitor_signals) override;
};
} // namespace lldb_private
diff --git a/include/lldb/Host/posix/HostThreadPosix.h b/include/lldb/Host/posix/HostThreadPosix.h
index e044313cd7dc..99b99d767b18 100644
--- a/include/lldb/Host/posix/HostThreadPosix.h
+++ b/include/lldb/Host/posix/HostThreadPosix.h
@@ -12,22 +12,20 @@
#include "lldb/Host/HostNativeThreadBase.h"
-namespace lldb_private
-{
+namespace lldb_private {
-class HostThreadPosix : public HostNativeThreadBase
-{
- DISALLOW_COPY_AND_ASSIGN(HostThreadPosix);
+class HostThreadPosix : public HostNativeThreadBase {
+ DISALLOW_COPY_AND_ASSIGN(HostThreadPosix);
- public:
- HostThreadPosix();
- HostThreadPosix(lldb::thread_t thread);
- ~HostThreadPosix() override;
+public:
+ HostThreadPosix();
+ HostThreadPosix(lldb::thread_t thread);
+ ~HostThreadPosix() override;
- Error Join(lldb::thread_result_t *result) override;
- Error Cancel() override;
+ Error Join(lldb::thread_result_t *result) override;
+ Error Cancel() override;
- Error Detach();
+ Error Detach();
};
} // namespace lldb_private
diff --git a/include/lldb/Host/posix/LockFilePosix.h b/include/lldb/Host/posix/LockFilePosix.h
index 628571c8dacd..dde9bd0eefe6 100644
--- a/include/lldb/Host/posix/LockFilePosix.h
+++ b/include/lldb/Host/posix/LockFilePosix.h
@@ -14,27 +14,21 @@
namespace lldb_private {
-class LockFilePosix : public LockFileBase
-{
+class LockFilePosix : public LockFileBase {
public:
- explicit LockFilePosix (int fd);
- ~LockFilePosix () override;
+ explicit LockFilePosix(int fd);
+ ~LockFilePosix() override;
protected:
- Error
- DoWriteLock (const uint64_t start, const uint64_t len) override;
+ Error DoWriteLock(const uint64_t start, const uint64_t len) override;
- Error
- DoTryWriteLock (const uint64_t start, const uint64_t len) override;
+ Error DoTryWriteLock(const uint64_t start, const uint64_t len) override;
- Error
- DoReadLock (const uint64_t start, const uint64_t len) override;
+ Error DoReadLock(const uint64_t start, const uint64_t len) override;
- Error
- DoTryReadLock (const uint64_t start, const uint64_t len) override;
+ Error DoTryReadLock(const uint64_t start, const uint64_t len) override;
- Error
- DoUnlock () override;
+ Error DoUnlock() override;
};
} // namespace lldb_private
diff --git a/include/lldb/Host/posix/MainLoopPosix.h b/include/lldb/Host/posix/MainLoopPosix.h
index 225cebde4bce..21e02becf872 100644
--- a/include/lldb/Host/posix/MainLoopPosix.h
+++ b/include/lldb/Host/posix/MainLoopPosix.h
@@ -16,85 +16,89 @@
namespace lldb_private {
-// Posix implementation of the MainLoopBase class. It can monitor file descriptors for
-// readability using pselect. In addition to the common base, this class provides the ability to
+// Posix implementation of the MainLoopBase class. It can monitor file
+// descriptors for
+// readability using pselect. In addition to the common base, this class
+// provides the ability to
// invoke a given handler when a signal is received.
//
-// Since this class is primarily intended to be used for single-threaded processing, it does not
-// attempt to perform any internal synchronisation and any concurrent accesses must be protected
-// externally. However, it is perfectly legitimate to have more than one instance of this class
-// running on separate threads, or even a single thread (with some limitations on signal
+// Since this class is primarily intended to be used for single-threaded
+// processing, it does not
+// attempt to perform any internal synchronisation and any concurrent accesses
+// must be protected
+// externally. However, it is perfectly legitimate to have more than one
+// instance of this class
+// running on separate threads, or even a single thread (with some limitations
+// on signal
// monitoring).
// TODO: Add locking if this class is to be used in a multi-threaded context.
-class MainLoopPosix: public MainLoopBase
-{
+class MainLoopPosix : public MainLoopBase {
private:
- class SignalHandle;
+ class SignalHandle;
public:
- typedef std::unique_ptr<SignalHandle> SignalHandleUP;
-
- ~MainLoopPosix() override;
-
- ReadHandleUP
- RegisterReadObject(const lldb::IOObjectSP &object_sp, const Callback &callback, Error &error) override;
-
- // Listening for signals from multiple MainLoopPosix instances is perfectly safe as long as they
- // don't try to listen for the same signal. The callback function is invoked when the control
- // returns to the Run() function, not when the hander is executed. This means that you can
- // treat the callback as a normal function and perform things which would not be safe in a
- // signal handler. However, since the callback is not invoked synchronously, you cannot use
- // this mechanism to handle SIGSEGV and the like.
- SignalHandleUP
- RegisterSignal(int signo, const Callback &callback, Error &error);
-
- Error
- Run() override;
-
- // This should only be performed from a callback. Do not attempt to terminate the processing
- // from another thread.
- // TODO: Add synchronization if we want to be terminated from another thread.
- void
- RequestTermination() override
- { m_terminate_request = true; }
+ typedef std::unique_ptr<SignalHandle> SignalHandleUP;
+
+ ~MainLoopPosix() override;
+
+ ReadHandleUP RegisterReadObject(const lldb::IOObjectSP &object_sp,
+ const Callback &callback,
+ Error &error) override;
+
+ // Listening for signals from multiple MainLoopPosix instances is perfectly
+ // safe as long as they
+ // don't try to listen for the same signal. The callback function is invoked
+ // when the control
+ // returns to the Run() function, not when the hander is executed. This means
+ // that you can
+ // treat the callback as a normal function and perform things which would not
+ // be safe in a
+ // signal handler. However, since the callback is not invoked synchronously,
+ // you cannot use
+ // this mechanism to handle SIGSEGV and the like.
+ SignalHandleUP RegisterSignal(int signo, const Callback &callback,
+ Error &error);
+
+ Error Run() override;
+
+ // This should only be performed from a callback. Do not attempt to terminate
+ // the processing
+ // from another thread.
+ // TODO: Add synchronization if we want to be terminated from another thread.
+ void RequestTermination() override { m_terminate_request = true; }
protected:
- void
- UnregisterReadObject(IOObject::WaitableHandle handle) override;
+ void UnregisterReadObject(IOObject::WaitableHandle handle) override;
- void
- UnregisterSignal(int signo);
+ void UnregisterSignal(int signo);
private:
- class SignalHandle
- {
- public:
- ~SignalHandle() { m_mainloop.UnregisterSignal(m_signo); }
-
- private:
- SignalHandle(MainLoopPosix &mainloop, int signo) : m_mainloop(mainloop), m_signo(signo) { }
-
- MainLoopPosix &m_mainloop;
- int m_signo;
-
- friend class MainLoopPosix;
- DISALLOW_COPY_AND_ASSIGN(SignalHandle);
- };
-
- struct SignalInfo
- {
- Callback callback;
- struct sigaction old_action;
- bool was_blocked : 1;
- };
-
- llvm::DenseMap<IOObject::WaitableHandle, Callback> m_read_fds;
- llvm::DenseMap<int, SignalInfo> m_signals;
- bool m_terminate_request : 1;
+ class SignalHandle {
+ public:
+ ~SignalHandle() { m_mainloop.UnregisterSignal(m_signo); }
+
+ private:
+ SignalHandle(MainLoopPosix &mainloop, int signo)
+ : m_mainloop(mainloop), m_signo(signo) {}
+
+ MainLoopPosix &m_mainloop;
+ int m_signo;
+
+ friend class MainLoopPosix;
+ DISALLOW_COPY_AND_ASSIGN(SignalHandle);
+ };
+
+ struct SignalInfo {
+ Callback callback;
+ struct sigaction old_action;
+ bool was_blocked : 1;
+ };
+
+ llvm::DenseMap<IOObject::WaitableHandle, Callback> m_read_fds;
+ llvm::DenseMap<int, SignalInfo> m_signals;
+ bool m_terminate_request : 1;
};
} // namespace lldb_private
-
#endif // lldb_Host_posix_MainLoopPosix_h_
-
diff --git a/include/lldb/Host/posix/PipePosix.h b/include/lldb/Host/posix/PipePosix.h
index 710b77d34bdc..738f95ed0db8 100644
--- a/include/lldb/Host/posix/PipePosix.h
+++ b/include/lldb/Host/posix/PipePosix.h
@@ -22,67 +22,53 @@ namespace lldb_private {
///
/// A class that abstracts the LLDB core from host pipe functionality.
//----------------------------------------------------------------------
-class PipePosix : public PipeBase
-{
+class PipePosix : public PipeBase {
public:
- static int kInvalidDescriptor;
-
- PipePosix();
- PipePosix(int read_fd, int write_fd);
- PipePosix(const PipePosix &) = delete;
- PipePosix(PipePosix &&pipe_posix);
- PipePosix &operator=(const PipePosix &) = delete;
- PipePosix &operator=(PipePosix &&pipe_posix);
-
- ~PipePosix() override;
-
- Error
- CreateNew(bool child_process_inherit) override;
- Error
- CreateNew(llvm::StringRef name, bool child_process_inherit) override;
- Error
- CreateWithUniqueName(llvm::StringRef prefix, bool child_process_inherit, llvm::SmallVectorImpl<char>& name) override;
- Error
- OpenAsReader(llvm::StringRef name, bool child_process_inherit) override;
- Error
- OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit, const std::chrono::microseconds &timeout) override;
-
- bool
- CanRead() const override;
- bool
- CanWrite() const override;
-
- int
- GetReadFileDescriptor() const override;
- int
- GetWriteFileDescriptor() const override;
- int
- ReleaseReadFileDescriptor() override;
- int
- ReleaseWriteFileDescriptor() override;
- void
- CloseReadFileDescriptor() override;
- void
- CloseWriteFileDescriptor() override;
-
-
- // Close both descriptors
- void
- Close() override;
-
- Error
- Delete(llvm::StringRef name) override;
-
- Error
- Write(const void *buf, size_t size, size_t &bytes_written) override;
- Error
- ReadWithTimeout(void *buf, size_t size, const std::chrono::microseconds &timeout, size_t &bytes_read) override;
+ static int kInvalidDescriptor;
+
+ PipePosix();
+ PipePosix(int read_fd, int write_fd);
+ PipePosix(const PipePosix &) = delete;
+ PipePosix(PipePosix &&pipe_posix);
+ PipePosix &operator=(const PipePosix &) = delete;
+ PipePosix &operator=(PipePosix &&pipe_posix);
+
+ ~PipePosix() override;
+
+ Error CreateNew(bool child_process_inherit) override;
+ Error CreateNew(llvm::StringRef name, bool child_process_inherit) override;
+ Error CreateWithUniqueName(llvm::StringRef prefix, bool child_process_inherit,
+ llvm::SmallVectorImpl<char> &name) override;
+ Error OpenAsReader(llvm::StringRef name, bool child_process_inherit) override;
+ Error
+ OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit,
+ const std::chrono::microseconds &timeout) override;
+
+ bool CanRead() const override;
+ bool CanWrite() const override;
+
+ int GetReadFileDescriptor() const override;
+ int GetWriteFileDescriptor() const override;
+ int ReleaseReadFileDescriptor() override;
+ int ReleaseWriteFileDescriptor() override;
+ void CloseReadFileDescriptor() override;
+ void CloseWriteFileDescriptor() override;
+
+ // Close both descriptors
+ void Close() override;
+
+ Error Delete(llvm::StringRef name) override;
+
+ Error Write(const void *buf, size_t size, size_t &bytes_written) override;
+ Error ReadWithTimeout(void *buf, size_t size,
+ const std::chrono::microseconds &timeout,
+ size_t &bytes_read) override;
private:
- int m_fds[2];
+ int m_fds[2];
};
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif // liblldb_Host_posix_PipePosix_h_
+#endif // #if defined(__cplusplus)
+#endif // liblldb_Host_posix_PipePosix_h_
diff --git a/include/lldb/Host/posix/ProcessLauncherPosix.h b/include/lldb/Host/posix/ProcessLauncherPosix.h
index a5e57ccb26ed..e481e3dc7ea9 100644
--- a/include/lldb/Host/posix/ProcessLauncherPosix.h
+++ b/include/lldb/Host/posix/ProcessLauncherPosix.h
@@ -12,13 +12,12 @@
#include "lldb/Host/ProcessLauncher.h"
-namespace lldb_private
-{
+namespace lldb_private {
-class ProcessLauncherPosix : public ProcessLauncher
-{
- public:
- HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info, Error &error) override;
+class ProcessLauncherPosix : public ProcessLauncher {
+public:
+ HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info,
+ Error &error) override;
};
}
diff --git a/include/lldb/Host/windows/AutoHandle.h b/include/lldb/Host/windows/AutoHandle.h
index 04411c47d9e2..8c8c89767ba9 100644
--- a/include/lldb/Host/windows/AutoHandle.h
+++ b/include/lldb/Host/windows/AutoHandle.h
@@ -10,31 +10,28 @@
#ifndef LLDB_lldb_Host_windows_AutoHandle_h_
#define LLDB_lldb_Host_windows_AutoHandle_h_
-namespace lldb_private {
+#include "lldb/Host/windows/windows.h"
-class AutoHandle {
+namespace lldb_private {
+
+class AutoHandle {
public:
- AutoHandle(HANDLE handle, HANDLE invalid_value = INVALID_HANDLE_VALUE)
- : m_handle(handle)
- , m_invalid_value(invalid_value)
- {
- }
+ AutoHandle(HANDLE handle, HANDLE invalid_value = INVALID_HANDLE_VALUE)
+ : m_handle(handle), m_invalid_value(invalid_value) {}
+
+ ~AutoHandle() {
+ if (m_handle != m_invalid_value)
+ ::CloseHandle(m_handle);
+ }
- ~AutoHandle()
- {
- if (m_handle != m_invalid_value)
- ::CloseHandle(m_handle);
- }
+ bool IsValid() const { return m_handle != m_invalid_value; }
- bool IsValid() const { return m_handle != m_invalid_value; }
+ HANDLE get() const { return m_handle; }
- HANDLE get() const { return m_handle; }
private:
- HANDLE m_handle;
- HANDLE m_invalid_value;
+ HANDLE m_handle;
+ HANDLE m_invalid_value;
};
-
}
#endif
-
diff --git a/include/lldb/Host/windows/ConnectionGenericFileWindows.h b/include/lldb/Host/windows/ConnectionGenericFileWindows.h
index bfe9b2e0c7b8..4a5a3858a826 100644
--- a/include/lldb/Host/windows/ConnectionGenericFileWindows.h
+++ b/include/lldb/Host/windows/ConnectionGenericFileWindows.h
@@ -14,54 +14,50 @@
#include "lldb/Host/windows/windows.h"
#include "lldb/lldb-types.h"
-namespace lldb_private
-{
+namespace lldb_private {
class Error;
-class ConnectionGenericFile : public lldb_private::Connection
-{
- public:
- ConnectionGenericFile();
+class ConnectionGenericFile : public lldb_private::Connection {
+public:
+ ConnectionGenericFile();
- ConnectionGenericFile(lldb::file_t file, bool owns_file);
+ ConnectionGenericFile(lldb::file_t file, bool owns_file);
- ~ConnectionGenericFile() override;
+ ~ConnectionGenericFile() override;
- bool IsConnected() const override;
+ bool IsConnected() const override;
- lldb::ConnectionStatus Connect(const char *s, Error *error_ptr) override;
+ lldb::ConnectionStatus Connect(llvm::StringRef s, Error *error_ptr) override;
- lldb::ConnectionStatus Disconnect(Error *error_ptr) override;
+ lldb::ConnectionStatus Disconnect(Error *error_ptr) override;
- size_t Read(void *dst, size_t dst_len, uint32_t timeout_usec, lldb::ConnectionStatus &status, Error *error_ptr) override;
+ size_t Read(void *dst, size_t dst_len, const Timeout<std::micro> &timeout,
+ lldb::ConnectionStatus &status, Error *error_ptr) override;
- size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status, Error *error_ptr) override;
+ size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status,
+ Error *error_ptr) override;
- std::string GetURI() override;
+ std::string GetURI() override;
- bool InterruptRead() override;
+ bool InterruptRead() override;
- protected:
- OVERLAPPED m_overlapped;
- HANDLE m_file;
- HANDLE m_event_handles[2];
- bool m_owns_file;
- LARGE_INTEGER m_file_position;
+protected:
+ OVERLAPPED m_overlapped;
+ HANDLE m_file;
+ HANDLE m_event_handles[2];
+ bool m_owns_file;
+ LARGE_INTEGER m_file_position;
- enum
- {
- kBytesAvailableEvent,
- kInterruptEvent
- };
+ enum { kBytesAvailableEvent, kInterruptEvent };
- private:
- void InitializeEventHandles();
- void IncrementFilePointer(DWORD amount);
+private:
+ void InitializeEventHandles();
+ void IncrementFilePointer(DWORD amount);
- std::string m_uri;
+ std::string m_uri;
- DISALLOW_COPY_AND_ASSIGN(ConnectionGenericFile);
+ DISALLOW_COPY_AND_ASSIGN(ConnectionGenericFile);
};
}
diff --git a/include/lldb/Host/windows/HostInfoWindows.h b/include/lldb/Host/windows/HostInfoWindows.h
index 23d52e7810e7..5a5d72c2466c 100644
--- a/include/lldb/Host/windows/HostInfoWindows.h
+++ b/include/lldb/Host/windows/HostInfoWindows.h
@@ -10,51 +10,39 @@
#ifndef lldb_Host_windows_HostInfoWindows_h_
#define lldb_Host_windows_HostInfoWindows_h_
-#include "lldb/Host/HostInfoBase.h"
#include "lldb/Host/FileSpec.h"
+#include "lldb/Host/HostInfoBase.h"
+
+namespace lldb_private {
+
+class HostInfoWindows : public HostInfoBase {
+ friend class HostInfoBase;
+
+private:
+ // Static class, unconstructable.
+ HostInfoWindows();
+ ~HostInfoWindows();
+
+public:
+ static void Initialize();
+ static void Terminate();
+
+ static size_t GetPageSize();
+
+ static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update);
+ static bool GetOSBuildString(std::string &s);
+ static bool GetOSKernelDescription(std::string &s);
+ static bool GetHostname(std::string &s);
+ static FileSpec GetProgramFileSpec();
+ static FileSpec GetDefaultShell();
+
+ static bool GetEnvironmentVar(const std::string &var_name, std::string &var);
+
+protected:
+ static bool ComputePythonDirectory(FileSpec &file_spec);
-namespace lldb_private
-{
-
-class HostInfoWindows : public HostInfoBase
-{
- friend class HostInfoBase;
-
- private:
- // Static class, unconstructable.
- HostInfoWindows();
- ~HostInfoWindows();
-
- public:
- static void
- Initialize();
- static void
- Terminate();
-
- static size_t
- GetPageSize();
-
- static bool
- GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update);
- static bool
- GetOSBuildString(std::string &s);
- static bool
- GetOSKernelDescription(std::string &s);
- static bool
- GetHostname(std::string &s);
- static FileSpec
- GetProgramFileSpec();
- static FileSpec
- GetDefaultShell();
-
- static bool
- GetEnvironmentVar(const std::string &var_name, std::string &var);
-
- protected:
- static bool ComputePythonDirectory(FileSpec &file_spec);
-
- private:
- static FileSpec m_program_filespec;
+private:
+ static FileSpec m_program_filespec;
};
}
diff --git a/include/lldb/Host/windows/HostProcessWindows.h b/include/lldb/Host/windows/HostProcessWindows.h
index 2d2ad0e70e8d..2896c7be793f 100644
--- a/include/lldb/Host/windows/HostProcessWindows.h
+++ b/include/lldb/Host/windows/HostProcessWindows.h
@@ -13,35 +13,33 @@
#include "lldb/Host/HostNativeProcessBase.h"
#include "lldb/lldb-types.h"
-namespace lldb_private
-{
+namespace lldb_private {
class FileSpec;
-class HostProcessWindows : public HostNativeProcessBase
-{
- public:
- HostProcessWindows();
- explicit HostProcessWindows(lldb::process_t process);
- ~HostProcessWindows();
+class HostProcessWindows : public HostNativeProcessBase {
+public:
+ HostProcessWindows();
+ explicit HostProcessWindows(lldb::process_t process);
+ ~HostProcessWindows();
- void SetOwnsHandle(bool owns);
+ void SetOwnsHandle(bool owns);
- virtual Error Terminate();
- virtual Error GetMainModule(FileSpec &file_spec) const;
+ Error Terminate() override;
+ Error GetMainModule(FileSpec &file_spec) const override;
- virtual lldb::pid_t GetProcessId() const;
- virtual bool IsRunning() const;
+ lldb::pid_t GetProcessId() const override;
+ bool IsRunning() const override;
- HostThread
- StartMonitoring(const Host::MonitorChildProcessCallback &callback, bool monitor_signals) override;
+ HostThread StartMonitoring(const Host::MonitorChildProcessCallback &callback,
+ bool monitor_signals) override;
private:
- static lldb::thread_result_t MonitorThread(void *thread_arg);
+ static lldb::thread_result_t MonitorThread(void *thread_arg);
- void Close();
+ void Close();
- bool m_owns_handle;
+ bool m_owns_handle;
};
}
diff --git a/include/lldb/Host/windows/HostThreadWindows.h b/include/lldb/Host/windows/HostThreadWindows.h
index e0c78c37d69a..2acc28e29b5c 100644
--- a/include/lldb/Host/windows/HostThreadWindows.h
+++ b/include/lldb/Host/windows/HostThreadWindows.h
@@ -14,28 +14,26 @@
#include "llvm/ADT/SmallString.h"
-namespace lldb_private
-{
+namespace lldb_private {
-class HostThreadWindows : public HostNativeThreadBase
-{
- DISALLOW_COPY_AND_ASSIGN(HostThreadWindows);
+class HostThreadWindows : public HostNativeThreadBase {
+ DISALLOW_COPY_AND_ASSIGN(HostThreadWindows);
- public:
- HostThreadWindows();
- HostThreadWindows(lldb::thread_t thread);
- virtual ~HostThreadWindows();
+public:
+ HostThreadWindows();
+ HostThreadWindows(lldb::thread_t thread);
+ virtual ~HostThreadWindows();
- void SetOwnsHandle(bool owns);
+ void SetOwnsHandle(bool owns);
- virtual Error Join(lldb::thread_result_t *result);
- virtual Error Cancel();
- virtual void Reset();
+ virtual Error Join(lldb::thread_result_t *result);
+ virtual Error Cancel();
+ virtual void Reset();
- lldb::tid_t GetThreadId() const;
+ lldb::tid_t GetThreadId() const;
- private:
- bool m_owns_handle;
+private:
+ bool m_owns_handle;
};
}
diff --git a/include/lldb/Host/windows/LockFileWindows.h b/include/lldb/Host/windows/LockFileWindows.h
index b2b8896f18c4..9cd1faedc262 100644
--- a/include/lldb/Host/windows/LockFileWindows.h
+++ b/include/lldb/Host/windows/LockFileWindows.h
@@ -15,35 +15,28 @@
namespace lldb_private {
-class LockFileWindows : public LockFileBase
-{
+class LockFileWindows : public LockFileBase {
public:
- explicit LockFileWindows (int fd);
- ~LockFileWindows ();
+ explicit LockFileWindows(int fd);
+ ~LockFileWindows();
protected:
- Error
- DoWriteLock (const uint64_t start, const uint64_t len) override;
+ Error DoWriteLock(const uint64_t start, const uint64_t len) override;
- Error
- DoTryWriteLock (const uint64_t start, const uint64_t len) override;
+ Error DoTryWriteLock(const uint64_t start, const uint64_t len) override;
- Error
- DoReadLock (const uint64_t start, const uint64_t len) override;
+ Error DoReadLock(const uint64_t start, const uint64_t len) override;
- Error
- DoTryReadLock (const uint64_t start, const uint64_t len) override;
+ Error DoTryReadLock(const uint64_t start, const uint64_t len) override;
- Error
- DoUnlock () override;
+ Error DoUnlock() override;
- bool
- IsValidFile () const override;
+ bool IsValidFile() const override;
private:
- HANDLE m_file;
+ HANDLE m_file;
};
-} // namespace lldb_private
+} // namespace lldb_private
-#endif // liblldb_Host_posix_LockFileWindows_h_
+#endif // liblldb_Host_posix_LockFileWindows_h_
diff --git a/include/lldb/Host/windows/PipeWindows.h b/include/lldb/Host/windows/PipeWindows.h
index 7170c7c36815..e9468ffc4153 100644
--- a/include/lldb/Host/windows/PipeWindows.h
+++ b/include/lldb/Host/windows/PipeWindows.h
@@ -13,8 +13,7 @@
#include "lldb/Host/PipeBase.h"
#include "lldb/Host/windows/windows.h"
-namespace lldb_private
-{
+namespace lldb_private {
//----------------------------------------------------------------------
/// @class Pipe PipeWindows.h "lldb/Host/windows/PipeWindows.h"
@@ -23,50 +22,56 @@ namespace lldb_private
///
/// A class that abstracts the LLDB core from host pipe functionality.
//----------------------------------------------------------------------
-class PipeWindows : public PipeBase
-{
- public:
- PipeWindows();
- ~PipeWindows() override;
-
- Error CreateNew(bool child_process_inherit) override;
- Error CreateNew(llvm::StringRef name, bool child_process_inherit) override;
- Error CreateWithUniqueName(llvm::StringRef prefix, bool child_process_inherit, llvm::SmallVectorImpl<char>& name) override;
- Error OpenAsReader(llvm::StringRef name, bool child_process_inherit) override;
- Error OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit, const std::chrono::microseconds &timeout) override;
-
- bool CanRead() const override;
- bool CanWrite() const override;
-
- int GetReadFileDescriptor() const override;
- int GetWriteFileDescriptor() const override;
- int ReleaseReadFileDescriptor() override;
- int ReleaseWriteFileDescriptor() override;
- void CloseReadFileDescriptor() override;
- void CloseWriteFileDescriptor() override;
-
- void Close() override;
-
- Error Delete(llvm::StringRef name) override;
-
- Error Write(const void *buf, size_t size, size_t &bytes_written) override;
- Error ReadWithTimeout(void *buf, size_t size, const std::chrono::microseconds &timeout, size_t &bytes_read) override;
-
- // PipeWindows specific methods. These allow access to the underlying OS handle.
- HANDLE GetReadNativeHandle();
- HANDLE GetWriteNativeHandle();
-
- private:
- Error OpenNamedPipe(llvm::StringRef name, bool child_process_inherit, bool is_read);
-
- HANDLE m_read;
- HANDLE m_write;
-
- int m_read_fd;
- int m_write_fd;
-
- OVERLAPPED m_read_overlapped;
- OVERLAPPED m_write_overlapped;
+class PipeWindows : public PipeBase {
+public:
+ PipeWindows();
+ ~PipeWindows() override;
+
+ Error CreateNew(bool child_process_inherit) override;
+ Error CreateNew(llvm::StringRef name, bool child_process_inherit) override;
+ Error CreateWithUniqueName(llvm::StringRef prefix, bool child_process_inherit,
+ llvm::SmallVectorImpl<char> &name) override;
+ Error OpenAsReader(llvm::StringRef name, bool child_process_inherit) override;
+ Error
+ OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit,
+ const std::chrono::microseconds &timeout) override;
+
+ bool CanRead() const override;
+ bool CanWrite() const override;
+
+ int GetReadFileDescriptor() const override;
+ int GetWriteFileDescriptor() const override;
+ int ReleaseReadFileDescriptor() override;
+ int ReleaseWriteFileDescriptor() override;
+ void CloseReadFileDescriptor() override;
+ void CloseWriteFileDescriptor() override;
+
+ void Close() override;
+
+ Error Delete(llvm::StringRef name) override;
+
+ Error Write(const void *buf, size_t size, size_t &bytes_written) override;
+ Error ReadWithTimeout(void *buf, size_t size,
+ const std::chrono::microseconds &timeout,
+ size_t &bytes_read) override;
+
+ // PipeWindows specific methods. These allow access to the underlying OS
+ // handle.
+ HANDLE GetReadNativeHandle();
+ HANDLE GetWriteNativeHandle();
+
+private:
+ Error OpenNamedPipe(llvm::StringRef name, bool child_process_inherit,
+ bool is_read);
+
+ HANDLE m_read;
+ HANDLE m_write;
+
+ int m_read_fd;
+ int m_write_fd;
+
+ OVERLAPPED m_read_overlapped;
+ OVERLAPPED m_write_overlapped;
};
} // namespace lldb_private
diff --git a/include/lldb/Host/windows/PosixApi.h b/include/lldb/Host/windows/PosixApi.h
new file mode 100644
index 000000000000..4f2573781620
--- /dev/null
+++ b/include/lldb/Host/windows/PosixApi.h
@@ -0,0 +1,107 @@
+//===-- windows/PosixApi.h --------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_Host_windows_PosixApi_h
+#define liblldb_Host_windows_PosixApi_h
+
+#include "llvm/Support/Compiler.h"
+#if !defined(LLVM_ON_WIN32)
+#error "windows/PosixApi.h being #included on non Windows system!"
+#endif
+
+// va_start, va_end, etc macros.
+#include <stdarg.h>
+
+// time_t, timespec, etc.
+#include <time.h>
+
+#ifndef PATH_MAX
+#define PATH_MAX 32768
+#endif
+
+#define O_NOCTTY 0
+#define O_NONBLOCK 0
+#define SIGTRAP 5
+#define SIGKILL 9
+#define SIGSTOP 20
+
+#if defined(_MSC_VER)
+#define S_IRUSR S_IREAD /* read, user */
+#define S_IWUSR S_IWRITE /* write, user */
+#define S_IXUSR 0 /* execute, user */
+#endif
+#define S_IRGRP 0 /* read, group */
+#define S_IWGRP 0 /* write, group */
+#define S_IXGRP 0 /* execute, group */
+#define S_IROTH 0 /* read, others */
+#define S_IWOTH 0 /* write, others */
+#define S_IXOTH 0 /* execute, others */
+#define S_IRWXU 0
+#define S_IRWXG 0
+#define S_IRWXO 0
+
+#ifdef _MSC_VER
+
+// PRIxxx format macros for printf()
+#include <inttypes.h>
+
+// open(), close(), creat(), etc.
+#include <io.h>
+
+typedef unsigned short mode_t;
+
+// pyconfig.h typedefs this. We require python headers to be included before
+// any LLDB headers, but there's no way to prevent python's pid_t definition
+// from leaking, so this is the best option.
+#ifndef NO_PID_T
+typedef uint32_t pid_t;
+#endif
+
+#define STDIN_FILENO 0
+#define STDOUT_FILENO 1
+#define STDERR_FILENO 2
+
+#define S_IFDIR _S_IFDIR
+
+#ifndef S_ISDIR
+#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
+#endif
+
+#endif // _MSC_VER
+
+// Various useful posix functions that are not present in Windows. We provide
+// custom implementations.
+int vasprintf(char **ret, const char *fmt, va_list ap);
+char *strcasestr(const char *s, const char *find);
+char *realpath(const char *name, char *resolved);
+
+int usleep(uint32_t useconds);
+char *getcwd(char *path, int max);
+int chdir(const char *path);
+char *basename(char *path);
+char *dirname(char *path);
+
+int strcasecmp(const char *s1, const char *s2);
+int strncasecmp(const char *s1, const char *s2, size_t n);
+
+// empty functions
+inline int posix_openpt(int flag) { LLVM_BUILTIN_UNREACHABLE; }
+
+inline int strerror_r(int errnum, char *buf, size_t buflen) {
+ LLVM_BUILTIN_UNREACHABLE;
+}
+
+inline int unlockpt(int fd) { LLVM_BUILTIN_UNREACHABLE; }
+inline int grantpt(int fd) { LLVM_BUILTIN_UNREACHABLE; }
+inline char *ptsname(int fd) { LLVM_BUILTIN_UNREACHABLE; }
+
+inline pid_t fork(void) { LLVM_BUILTIN_UNREACHABLE; }
+inline pid_t setsid(void) { LLVM_BUILTIN_UNREACHABLE; }
+
+#endif
diff --git a/include/lldb/Host/windows/ProcessLauncherWindows.h b/include/lldb/Host/windows/ProcessLauncherWindows.h
index a2fe665dcfaf..9f9e39709375 100644
--- a/include/lldb/Host/windows/ProcessLauncherWindows.h
+++ b/include/lldb/Host/windows/ProcessLauncherWindows.h
@@ -13,18 +13,17 @@
#include "lldb/Host/ProcessLauncher.h"
#include "lldb/Host/windows/windows.h"
-namespace lldb_private
-{
+namespace lldb_private {
class ProcessLaunchInfo;
-class ProcessLauncherWindows : public ProcessLauncher
-{
- public:
- virtual HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info, Error &error);
+class ProcessLauncherWindows : public ProcessLauncher {
+public:
+ virtual HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info,
+ Error &error);
- protected:
- HANDLE GetStdioHandle(const ProcessLaunchInfo &launch_info, int fd);
+protected:
+ HANDLE GetStdioHandle(const ProcessLaunchInfo &launch_info, int fd);
};
}
diff --git a/include/lldb/Host/windows/editlinewin.h b/include/lldb/Host/windows/editlinewin.h
index 907ef373a372..4522f0dd41b0 100644
--- a/include/lldb/Host/windows/editlinewin.h
+++ b/include/lldb/Host/windows/editlinewin.h
@@ -13,111 +13,104 @@
// EditLine editor function return codes.
// For user-defined function interface
-#define CC_NORM 0
-#define CC_NEWLINE 1
-#define CC_EOF 2
-#define CC_ARGHACK 3
-#define CC_REFRESH 4
-#define CC_CURSOR 5
-#define CC_ERROR 6
-#define CC_FATAL 7
-#define CC_REDISPLAY 8
+#define CC_NORM 0
+#define CC_NEWLINE 1
+#define CC_EOF 2
+#define CC_ARGHACK 3
+#define CC_REFRESH 4
+#define CC_CURSOR 5
+#define CC_ERROR 6
+#define CC_FATAL 7
+#define CC_REDISPLAY 8
#define CC_REFRESH_BEEP 9
// el_set/el_get parameters
-#define EL_PROMPT 0 // , el_pfunc_t
-#define EL_TERMINAL 1 // , const char *
-#define EL_EDITOR 2 // , const char *
-#define EL_SIGNAL 3 // , int);
-#define EL_BIND 4 // , const char *, ..., NULL
-#define EL_TELLTC 5 // , const char *, ..., NULL
-#define EL_SETTC 6 // , const char *, ..., NULL
-#define EL_ECHOTC 7 // , const char *, ..., NULL
-#define EL_SETTY 8 // , const char *, ..., NULL
-#define EL_ADDFN 9 // , const char *, const char *, el_func_t
-#define EL_HIST 10 // , hist_fun_t, const char *
-#define EL_EDITMODE 11 // , int
-#define EL_RPROMPT 12 // , el_pfunc_t
-#define EL_GETCFN 13 // , el_rfunc_t
-#define EL_CLIENTDATA 14 // , void *
-#define EL_UNBUFFERED 15 // , int
-#define EL_PREP_TERM 16 // , int
-#define EL_GETTC 17 // , const char *, ..., NULL
-#define EL_GETFP 18 // , int, FILE **
-#define EL_SETFP 19 // , int, FILE *
-#define EL_REFRESH 20 // , void
-#define EL_PROMPT_ESC 21 // , prompt_func, Char); set/get
+#define EL_PROMPT 0 // , el_pfunc_t
+#define EL_TERMINAL 1 // , const char *
+#define EL_EDITOR 2 // , const char *
+#define EL_SIGNAL 3 // , int);
+#define EL_BIND 4 // , const char *, ..., NULL
+#define EL_TELLTC 5 // , const char *, ..., NULL
+#define EL_SETTC 6 // , const char *, ..., NULL
+#define EL_ECHOTC 7 // , const char *, ..., NULL
+#define EL_SETTY 8 // , const char *, ..., NULL
+#define EL_ADDFN 9 // , const char *, const char *, el_func_t
+#define EL_HIST 10 // , hist_fun_t, const char *
+#define EL_EDITMODE 11 // , int
+#define EL_RPROMPT 12 // , el_pfunc_t
+#define EL_GETCFN 13 // , el_rfunc_t
+#define EL_CLIENTDATA 14 // , void *
+#define EL_UNBUFFERED 15 // , int
+#define EL_PREP_TERM 16 // , int
+#define EL_GETTC 17 // , const char *, ..., NULL
+#define EL_GETFP 18 // , int, FILE **
+#define EL_SETFP 19 // , int, FILE *
+#define EL_REFRESH 20 // , void
+#define EL_PROMPT_ESC 21 // , prompt_func, Char); set/get
#define EL_BUILTIN_GETCFN (NULL)
// history defines
-#define H_FUNC 0 // , UTSL
-#define H_SETSIZE 1 // , const int
-#define H_GETSIZE 2 // , void
-#define H_FIRST 3 // , void
-#define H_LAST 4 // , void
-#define H_PREV 5 // , void
-#define H_NEXT 6 // , void
-#define H_CURR 8 // , const int
-#define H_SET 7 // , int
-#define H_ADD 9 // , const char *
-#define H_ENTER 10 // , const char *
-#define H_APPEND 11 // , const char *
-#define H_END 12 // , void
-#define H_NEXT_STR 13 // , const char *
-#define H_PREV_STR 14 // , const char *
-#define H_NEXT_EVENT 15 // , const int
-#define H_PREV_EVENT 16 // , const int
-#define H_LOAD 17 // , const char *
-#define H_SAVE 18 // , const char *
-#define H_CLEAR 19 // , void
-#define H_SETUNIQUE 20 // , int
-#define H_GETUNIQUE 21 // , void
-#define H_DEL 22 // , int
+#define H_FUNC 0 // , UTSL
+#define H_SETSIZE 1 // , const int
+#define H_GETSIZE 2 // , void
+#define H_FIRST 3 // , void
+#define H_LAST 4 // , void
+#define H_PREV 5 // , void
+#define H_NEXT 6 // , void
+#define H_CURR 8 // , const int
+#define H_SET 7 // , int
+#define H_ADD 9 // , const char *
+#define H_ENTER 10 // , const char *
+#define H_APPEND 11 // , const char *
+#define H_END 12 // , void
+#define H_NEXT_STR 13 // , const char *
+#define H_PREV_STR 14 // , const char *
+#define H_NEXT_EVENT 15 // , const int
+#define H_PREV_EVENT 16 // , const int
+#define H_LOAD 17 // , const char *
+#define H_SAVE 18 // , const char *
+#define H_CLEAR 19 // , void
+#define H_SETUNIQUE 20 // , int
+#define H_GETUNIQUE 21 // , void
+#define H_DEL 22 // , int
-struct EditLine
-{
-};
+struct EditLine {};
-struct LineInfo
-{
- const char *buffer;
- const char *cursor;
- const char *lastchar;
+struct LineInfo {
+ const char *buffer;
+ const char *cursor;
+ const char *lastchar;
};
-struct History
-{
-};
+struct History {};
-struct HistEvent
-{
- int num;
- const char *str;
+struct HistEvent {
+ int num;
+ const char *str;
};
-extern "C"
-{
- // edit line API
- EditLine *el_init ( const char *, FILE *, FILE *, FILE * );
- const char *el_gets ( EditLine *, int * );
- int el_set ( EditLine *, int, ... );
+extern "C" {
+// edit line API
+EditLine *el_init(const char *, FILE *, FILE *, FILE *);
+const char *el_gets(EditLine *, int *);
+int el_set(EditLine *, int, ...);
- void el_end ( EditLine * );
- void el_reset ( EditLine * );
- int el_getc ( EditLine *, char * );
- void el_push ( EditLine *, const char * );
- void el_beep ( EditLine * );
- int el_parse ( EditLine *, int, const char ** );
- int el_get ( EditLine *, int, ... );
- int el_source ( EditLine *, const char * );
- void el_resize ( EditLine * );
- const LineInfo *el_line ( EditLine * );
- int el_insertstr( EditLine *, const char * );
- void el_deletestr( EditLine *, int );
+void el_end(EditLine *);
+void el_reset(EditLine *);
+int el_getc(EditLine *, char *);
+void el_push(EditLine *, const char *);
+void el_beep(EditLine *);
+int el_parse(EditLine *, int, const char **);
+int el_get(EditLine *, int, ...);
+int el_source(EditLine *, const char *);
+void el_resize(EditLine *);
+const LineInfo *el_line(EditLine *);
+int el_insertstr(EditLine *, const char *);
+void el_deletestr(EditLine *, int);
- // history API
- History *history_init( void );
- void history_end ( History * );
- int history ( History *, HistEvent *, int, ... );
+// history API
+History *history_init(void);
+void history_end(History *);
+int history(History *, HistEvent *, int, ...);
}; \ No newline at end of file
diff --git a/include/lldb/Host/windows/win32.h b/include/lldb/Host/windows/win32.h
deleted file mode 100644
index 2789a4b84f07..000000000000
--- a/include/lldb/Host/windows/win32.h
+++ /dev/null
@@ -1,107 +0,0 @@
-//===-- lldb-win32.h --------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLDB_lldb_win32_h_
-#define LLDB_lldb_win32_h_
-
-#include <stdarg.h>
-#include <time.h>
-
-// posix utilities
-int vasprintf(char **ret, const char *fmt, va_list ap);
-char * strcasestr(const char *s, const char* find);
-char* realpath(const char * name, char * resolved);
-
-#ifndef PATH_MAX
-#define PATH_MAX 32768
-#endif
-
-#define O_NOCTTY 0
-#define O_NONBLOCK 0
-#define SIGTRAP 5
-#define SIGKILL 9
-#define SIGSTOP 20
-
-#if defined(_MSC_VER)
-# define S_IRUSR S_IREAD /* read, user */
-# define S_IWUSR S_IWRITE /* write, user */
-# define S_IXUSR 0 /* execute, user */
-#endif
-#define S_IRGRP 0 /* read, group */
-#define S_IWGRP 0 /* write, group */
-#define S_IXGRP 0 /* execute, group */
-#define S_IROTH 0 /* read, others */
-#define S_IWOTH 0 /* write, others */
-#define S_IXOTH 0 /* execute, others */
-#define S_IRWXU 0
-#define S_IRWXG 0
-#define S_IRWXO 0
-
-#ifdef _MSC_VER
-
-#include <inttypes.h>
-#include <stdint.h>
-#include <io.h>
-typedef unsigned short mode_t;
-
-#ifdef LLDB_DISABLE_PYTHON
-typedef uint32_t pid_t;
-#endif // LLDB_DISABLE_PYTHON
-
-int usleep(uint32_t useconds);
-
-char* getcwd(char* path, int max);
-int chdir(const char* path);
-char* basename(char *path);
-char *dirname(char *path);
-
-int strcasecmp(const char* s1, const char* s2);
-int strncasecmp(const char* s1, const char* s2, size_t n);
-
-#if _MSC_VER < 1900
-namespace lldb_private {
-int vsnprintf(char *buffer, size_t count, const char *format, va_list argptr);
-}
-
-// inline to avoid linkage conflicts
-int inline snprintf(char *buffer, size_t count, const char *format, ...)
-{
- va_list argptr;
- va_start(argptr, format);
- int r = lldb_private::vsnprintf(buffer, count, format, argptr);
- va_end(argptr);
- return r;
-}
-#endif
-
-#define STDIN_FILENO 0
-#define STDOUT_FILENO 1
-#define STDERR_FILENO 2
-
-#define __PRETTY_FUNCTION__ __FUNCSIG__
-
-#define S_IFDIR _S_IFDIR
-#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
-
-#endif // _MSC_VER
-
-// timespec
-// MSVC 2015 and higher have timespec. Otherwise we need to define it ourselves.
-#if defined(_MSC_VER) && _MSC_VER >= 1900
-#include <time.h>
-#else
-struct timespec
-{
- time_t tv_sec;
- long tv_nsec;
-};
-#endif
-
-
-#endif // LLDB_lldb_win32_h_
diff --git a/include/lldb/Host/windows/windows.h b/include/lldb/Host/windows/windows.h
index 124e8de1dc90..3dc9f77f8e24 100644
--- a/include/lldb/Host/windows/windows.h
+++ b/include/lldb/Host/windows/windows.h
@@ -11,9 +11,11 @@
#define LLDB_lldb_windows_h_
#define NTDDI_VERSION NTDDI_VISTA
+#undef _WIN32_WINNT // undef a previous definition to avoid warning
#define _WIN32_WINNT _WIN32_WINNT_VISTA
#define WIN32_LEAN_AND_MEAN
#define NOGDI
+#undef NOMINMAX // undef a previous definition to avoid warning
#define NOMINMAX
#include <windows.h>
#undef GetUserName
@@ -26,4 +28,4 @@
#define FAR
#define NEAR
-#endif // LLDB_lldb_windows_h_
+#endif // LLDB_lldb_windows_h_
diff --git a/include/lldb/Initialization/SystemInitializer.h b/include/lldb/Initialization/SystemInitializer.h
index c7f98f24ae48..58bbb44b1f34 100644
--- a/include/lldb/Initialization/SystemInitializer.h
+++ b/include/lldb/Initialization/SystemInitializer.h
@@ -10,16 +10,14 @@
#ifndef LLDB_INITIALIZATION_SYSTEM_INITIALIZER_H
#define LLDB_INITIALIZATION_SYSTEM_INITIALIZER_H
-namespace lldb_private
-{
-class SystemInitializer
-{
- public:
- SystemInitializer();
- virtual ~SystemInitializer();
+namespace lldb_private {
+class SystemInitializer {
+public:
+ SystemInitializer();
+ virtual ~SystemInitializer();
- virtual void Initialize() = 0;
- virtual void Terminate() = 0;
+ virtual void Initialize() = 0;
+ virtual void Terminate() = 0;
};
}
diff --git a/include/lldb/Initialization/SystemInitializerCommon.h b/include/lldb/Initialization/SystemInitializerCommon.h
index b46bf506998b..2a9851c6a34c 100644
--- a/include/lldb/Initialization/SystemInitializerCommon.h
+++ b/include/lldb/Initialization/SystemInitializerCommon.h
@@ -12,8 +12,7 @@
#include "SystemInitializer.h"
-namespace lldb_private
-{
+namespace lldb_private {
//------------------------------------------------------------------
/// Initializes common lldb functionality.
///
@@ -24,14 +23,13 @@ namespace lldb_private
/// an instance of SystemLifetimeManager with this class passed to
/// the constructor.
//------------------------------------------------------------------
-class SystemInitializerCommon : public SystemInitializer
-{
- public:
- SystemInitializerCommon();
- ~SystemInitializerCommon() override;
+class SystemInitializerCommon : public SystemInitializer {
+public:
+ SystemInitializerCommon();
+ ~SystemInitializerCommon() override;
- void Initialize() override;
- void Terminate() override;
+ void Initialize() override;
+ void Terminate() override;
};
} // namespace lldb_private
diff --git a/include/lldb/Initialization/SystemLifetimeManager.h b/include/lldb/Initialization/SystemLifetimeManager.h
index 2dd7b22c240a..0ebd4a50a342 100644
--- a/include/lldb/Initialization/SystemLifetimeManager.h
+++ b/include/lldb/Initialization/SystemLifetimeManager.h
@@ -15,28 +15,26 @@
#include <memory>
#include <mutex>
-namespace lldb_private
-{
+namespace lldb_private {
class SystemInitializer;
-class SystemLifetimeManager
-{
- public:
- SystemLifetimeManager();
- ~SystemLifetimeManager();
+class SystemLifetimeManager {
+public:
+ SystemLifetimeManager();
+ ~SystemLifetimeManager();
- void Initialize(std::unique_ptr<SystemInitializer> initializer, LoadPluginCallbackType plugin_callback);
- void Terminate();
+ void Initialize(std::unique_ptr<SystemInitializer> initializer,
+ LoadPluginCallbackType plugin_callback);
+ void Terminate();
- private:
- std::recursive_mutex m_mutex;
- std::unique_ptr<SystemInitializer> m_initializer;
- bool m_initialized;
+private:
+ std::recursive_mutex m_mutex;
+ std::unique_ptr<SystemInitializer> m_initializer;
+ bool m_initialized;
- // Noncopyable.
- SystemLifetimeManager(const SystemLifetimeManager &other) = delete;
- SystemLifetimeManager &
- operator=(const SystemLifetimeManager &other) = delete;
+ // Noncopyable.
+ SystemLifetimeManager(const SystemLifetimeManager &other) = delete;
+ SystemLifetimeManager &operator=(const SystemLifetimeManager &other) = delete;
};
}
diff --git a/include/lldb/Interpreter/Args.h b/include/lldb/Interpreter/Args.h
index bd54d5d3db5d..6610be14d0dd 100644
--- a/include/lldb/Interpreter/Args.h
+++ b/include/lldb/Interpreter/Args.h
@@ -14,42 +14,32 @@
// C++ Includes
#include <list>
#include <string>
-#include <vector>
#include <utility>
+#include <vector>
// Other libraries and framework includes
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
// Project includes
-#include "lldb/lldb-private-types.h"
-#include "lldb/lldb-types.h"
#include "lldb/Core/Error.h"
#include "lldb/Host/OptionParser.h"
+#include "lldb/lldb-private-types.h"
+#include "lldb/lldb-types.h"
namespace lldb_private {
-typedef std::pair<int, std::string> OptionArgValue;
-typedef std::pair<std::string, OptionArgValue> OptionArgPair;
-typedef std::vector<OptionArgPair> OptionArgVector;
+typedef std::vector<std::tuple<std::string, int, std::string>> OptionArgVector;
typedef std::shared_ptr<OptionArgVector> OptionArgVectorSP;
-struct OptionArgElement
-{
- enum {
- eUnrecognizedArg = -1,
- eBareDash = -2,
- eBareDoubleDash = -3
- };
-
- OptionArgElement (int defs_index, int pos, int arg_pos) :
- opt_defs_index(defs_index),
- opt_pos (pos),
- opt_arg_pos (arg_pos)
- {
- }
-
- int opt_defs_index;
- int opt_pos;
- int opt_arg_pos;
+struct OptionArgElement {
+ enum { eUnrecognizedArg = -1, eBareDash = -2, eBareDoubleDash = -3 };
+
+ OptionArgElement(int defs_index, int pos, int arg_pos)
+ : opt_defs_index(defs_index), opt_pos(pos), opt_arg_pos(arg_pos) {}
+
+ int opt_defs_index;
+ int opt_pos;
+ int opt_arg_pos;
};
typedef std::vector<OptionArgElement> OptionElementVector;
@@ -65,417 +55,415 @@ typedef std::vector<OptionArgElement> OptionElementVector;
/// can be escaped using a \ character to avoid having to surround an
/// argument that contains a space with quotes.
//----------------------------------------------------------------------
-class Args
-{
+class Args {
public:
-
- //------------------------------------------------------------------
- /// Construct with an option command string.
- ///
- /// @param[in] command
- /// A NULL terminated command that will be copied and split up
- /// into arguments.
- ///
- /// @see Args::SetCommandString(llvm::StringRef)
- //------------------------------------------------------------------
- Args (llvm::StringRef command = llvm::StringRef());
-
- Args (const Args &rhs);
-
- const Args &
- operator= (const Args &rhs);
-
- //------------------------------------------------------------------
- /// Destructor.
- //------------------------------------------------------------------
- ~Args();
-
- //------------------------------------------------------------------
- /// Dump all entries to the stream \a s using label \a label_name.
- ///
- /// If label_name is nullptr, the dump operation is skipped.
- ///
- /// @param[in] s
- /// The stream to which to dump all arguments in the argument
- /// vector.
- /// @param[in] label_name
- /// The label_name to use as the label printed for each
- /// entry of the args like so:
- /// {label_name}[{index}]={value}
- //------------------------------------------------------------------
- void
- Dump (Stream &s, const char *label_name = "argv") const;
-
- //------------------------------------------------------------------
- /// Sets the command string contained by this object.
- ///
- /// The command string will be copied and split up into arguments
- /// that can be accessed via the accessor functions.
- ///
- /// @param[in] command
- /// A command StringRef that will be copied and split up
- /// into arguments.
- ///
- /// @see Args::GetArgumentCount() const
- /// @see Args::GetArgumentAtIndex (size_t) const
- /// @see Args::GetArgumentVector ()
- /// @see Args::Shift ()
- /// @see Args::Unshift (const char *)
- //------------------------------------------------------------------
- void
- SetCommandString (llvm::StringRef command);
-
- bool
- GetCommandString (std::string &command) const;
-
- bool
- GetQuotedCommandString (std::string &command) const;
-
- //------------------------------------------------------------------
- /// Gets the number of arguments left in this command object.
- ///
- /// @return
- /// The number or arguments in this object.
- //------------------------------------------------------------------
- size_t
- GetArgumentCount () const;
-
- //------------------------------------------------------------------
- /// Gets the NULL terminated C string argument pointer for the
- /// argument at index \a idx.
- ///
- /// @return
- /// The NULL terminated C string argument pointer if \a idx is a
- /// valid argument index, NULL otherwise.
- //------------------------------------------------------------------
- const char *
- GetArgumentAtIndex (size_t idx) const;
-
- char
- GetArgumentQuoteCharAtIndex (size_t idx) const;
-
- //------------------------------------------------------------------
- /// Gets the argument vector.
- ///
- /// The value returned by this function can be used by any function
- /// that takes and vector. The return value is just like \a argv
- /// in the standard C entry point function:
- /// \code
- /// int main (int argc, const char **argv);
- /// \endcode
- ///
- /// @return
- /// An array of NULL terminated C string argument pointers that
- /// also has a terminating NULL C string pointer
- //------------------------------------------------------------------
- char **
- GetArgumentVector ();
-
- //------------------------------------------------------------------
- /// Gets the argument vector.
- ///
- /// The value returned by this function can be used by any function
- /// that takes and vector. The return value is just like \a argv
- /// in the standard C entry point function:
- /// \code
- /// int main (int argc, const char **argv);
- /// \endcode
- ///
- /// @return
- /// An array of NULL terminate C string argument pointers that
- /// also has a terminating NULL C string pointer
- //------------------------------------------------------------------
- const char **
- GetConstArgumentVector () const;
-
-
- //------------------------------------------------------------------
- /// Appends a new argument to the end of the list argument list.
- ///
- /// @param[in] arg_cstr
- /// The new argument as a NULL terminated C string.
- ///
- /// @param[in] quote_char
- /// If the argument was originally quoted, put in the quote char here.
- ///
- /// @return
- /// The NULL terminated C string of the copy of \a arg_cstr.
- //------------------------------------------------------------------
- const char *
- AppendArgument (const char *arg_cstr, char quote_char = '\0');
-
- void
- AppendArguments (const Args &rhs);
-
- void
- AppendArguments (const char **argv);
-
- //------------------------------------------------------------------
- /// Insert the argument value at index \a idx to \a arg_cstr.
- ///
- /// @param[in] idx
- /// The index of where to insert the argument.
- ///
- /// @param[in] arg_cstr
- /// The new argument as a NULL terminated C string.
- ///
- /// @param[in] quote_char
- /// If the argument was originally quoted, put in the quote char here.
- ///
- /// @return
- /// The NULL terminated C string of the copy of \a arg_cstr.
- //------------------------------------------------------------------
- const char *
- InsertArgumentAtIndex (size_t idx, const char *arg_cstr, char quote_char = '\0');
-
- //------------------------------------------------------------------
- /// Replaces the argument value at index \a idx to \a arg_cstr
- /// if \a idx is a valid argument index.
- ///
- /// @param[in] idx
- /// The index of the argument that will have its value replaced.
- ///
- /// @param[in] arg_cstr
- /// The new argument as a NULL terminated C string.
- ///
- /// @param[in] quote_char
- /// If the argument was originally quoted, put in the quote char here.
- ///
- /// @return
- /// The NULL terminated C string of the copy of \a arg_cstr if
- /// \a idx was a valid index, NULL otherwise.
- //------------------------------------------------------------------
- const char *
- ReplaceArgumentAtIndex (size_t idx, const char *arg_cstr, char quote_char = '\0');
-
- //------------------------------------------------------------------
- /// Deletes the argument value at index
- /// if \a idx is a valid argument index.
- ///
- /// @param[in] idx
- /// The index of the argument that will have its value replaced.
- ///
- //------------------------------------------------------------------
- void
- DeleteArgumentAtIndex (size_t idx);
-
- //------------------------------------------------------------------
- /// Sets the argument vector value, optionally copying all
- /// arguments into an internal buffer.
- ///
- /// Sets the arguments to match those found in \a argv. All argument
- /// strings will be copied into an internal buffers.
- //
- // FIXME: Handle the quote character somehow.
- //------------------------------------------------------------------
- void
- SetArguments (size_t argc, const char **argv);
-
- void
- SetArguments (const char **argv);
-
- //------------------------------------------------------------------
- /// Shifts the first argument C string value of the array off the
- /// argument array.
- ///
- /// The string value will be freed, so a copy of the string should
- /// be made by calling Args::GetArgumentAtIndex (size_t) const
- /// first and copying the returned value before calling
- /// Args::Shift().
- ///
- /// @see Args::GetArgumentAtIndex (size_t) const
- //------------------------------------------------------------------
- void
- Shift ();
-
- //------------------------------------------------------------------
- /// Inserts a class owned copy of \a arg_cstr at the beginning of
- /// the argument vector.
- ///
- /// A copy \a arg_cstr will be made.
- ///
- /// @param[in] arg_cstr
- /// The argument to push on the front of the argument stack.
- ///
- /// @param[in] quote_char
- /// If the argument was originally quoted, put in the quote char here.
- ///
- /// @return
- /// A pointer to the copy of \a arg_cstr that was made.
- //------------------------------------------------------------------
- const char *
- Unshift (const char *arg_cstr, char quote_char = '\0');
-
- //------------------------------------------------------------------
- /// Parse the arguments in the contained arguments.
- ///
- /// The arguments that are consumed by the argument parsing process
- /// will be removed from the argument vector. The arguments that
- /// get processed start at the second argument. The first argument
- /// is assumed to be the command and will not be touched.
- ///
- /// @see class Options
- //------------------------------------------------------------------
- Error
- ParseOptions (Options &options);
-
- size_t
- FindArgumentIndexForOption (Option *long_options, int long_options_index);
-
- bool
- IsPositionalArgument (const char *arg);
-
- // The following works almost identically to ParseOptions, except that no option is required to have arguments,
- // and it builds up the option_arg_vector as it parses the options.
-
- void
- ParseAliasOptions (Options &options, CommandReturnObject &result, OptionArgVector *option_arg_vector,
- std::string &raw_input_line);
-
- void
- ParseArgsForCompletion (Options &options, OptionElementVector &option_element_vector, uint32_t cursor_index);
-
- //------------------------------------------------------------------
- // Clear the arguments.
- //
- // For re-setting or blanking out the list of arguments.
- //------------------------------------------------------------------
- void
- Clear ();
-
- static const char *
- StripSpaces (std::string &s,
- bool leading = true,
- bool trailing = true,
- bool return_null_if_empty = true);
-
- static bool
- UInt64ValueIsValidForByteSize (uint64_t uval64, size_t total_byte_size)
- {
- if (total_byte_size > 8)
- return false;
-
- if (total_byte_size == 8)
- return true;
-
- const uint64_t max = ((uint64_t)1 << (uint64_t)(total_byte_size * 8)) - 1;
- return uval64 <= max;
- }
-
- static bool
- SInt64ValueIsValidForByteSize (int64_t sval64, size_t total_byte_size)
- {
- if (total_byte_size > 8)
- return false;
-
- if (total_byte_size == 8)
- return true;
-
- const int64_t max = ((int64_t)1 << (uint64_t)(total_byte_size * 8 - 1)) - 1;
- const int64_t min = ~(max);
- return min <= sval64 && sval64 <= max;
- }
-
- static lldb::addr_t
- StringToAddress (const ExecutionContext *exe_ctx,
- const char *s,
- lldb::addr_t fail_value,
- Error *error);
-
- static bool
- StringToBoolean (const char *s, bool fail_value, bool *success_ptr);
-
- static char StringToChar(const char *s, char fail_value, bool *success_ptr);
-
- static int64_t
- StringToOptionEnum (const char *s, OptionEnumValueElement *enum_values, int32_t fail_value, Error &error);
-
- static lldb::ScriptLanguage
- StringToScriptLanguage (const char *s, lldb::ScriptLanguage fail_value, bool *success_ptr);
-
- static Error
- StringToFormat (const char *s,
- lldb::Format &format,
- size_t *byte_size_ptr); // If non-NULL, then a byte size can precede the format character
-
- static lldb::Encoding
- StringToEncoding (const char *s,
- lldb::Encoding fail_value = lldb::eEncodingInvalid);
-
- static uint32_t
- StringToGenericRegister (const char *s);
-
- static const char *
- StringToVersion (const char *s, uint32_t &major, uint32_t &minor, uint32_t &update);
-
- static const char *
- GetShellSafeArgument (const FileSpec& shell, const char *unsafe_arg, std::string &safe_arg);
-
- // EncodeEscapeSequences will change the textual representation of common
- // escape sequences like "\n" (two characters) into a single '\n'. It does
- // this for all of the supported escaped sequences and for the \0ooo (octal)
- // and \xXX (hex). The resulting "dst" string will contain the character
- // versions of all supported escape sequences. The common supported escape
- // sequences are: "\a", "\b", "\f", "\n", "\r", "\t", "\v", "\'", "\"", "\\".
-
- static void
- EncodeEscapeSequences (const char *src, std::string &dst);
-
- // ExpandEscapeSequences will change a string of possibly non-printable
- // characters and expand them into text. So '\n' will turn into two characters
- // like "\n" which is suitable for human reading. When a character is not
- // printable and isn't one of the common in escape sequences listed in the
- // help for EncodeEscapeSequences, then it will be encoded as octal. Printable
- // characters are left alone.
- static void
- ExpandEscapedCharacters (const char *src, std::string &dst);
-
- static std::string
- EscapeLLDBCommandArgument (const std::string& arg, char quote_char);
-
- // This one isn't really relevant to Arguments per se, but we're using the Args as a
- // general strings container, so...
- void
- LongestCommonPrefix (std::string &common_prefix);
-
- //------------------------------------------------------------------
- /// Return whether a given environment variable exists.
- ///
- /// This command treats Args like a list of environment variables,
- /// as used in ProcessLaunchInfo. It treats each argument as
- /// an {env_var_name}={value} or an {env_var_name} entry.
- ///
- /// @param[in] env_var_name
- /// Specifies the name of the environment variable to check.
- ///
- /// @return
- /// true if the specified env var name exists in the list in
- /// either of the above-mentioned formats; otherwise, false.
- //------------------------------------------------------------------
- bool
- ContainsEnvironmentVariable(const char *env_var_name) const;
-
-protected:
- //------------------------------------------------------------------
- // Classes that inherit from Args can see and modify these
- //------------------------------------------------------------------
- typedef std::list<std::string> arg_sstr_collection;
- typedef std::vector<const char *> arg_cstr_collection;
- typedef std::vector<char> arg_quote_char_collection;
- arg_sstr_collection m_args;
- arg_cstr_collection m_argv; ///< The current argument vector.
- arg_quote_char_collection m_args_quote_char;
-
- void
- UpdateArgsAfterOptionParsing ();
-
- void
- UpdateArgvFromArgs ();
-
- llvm::StringRef
- ParseSingleArgument (llvm::StringRef command);
+ struct ArgEntry {
+ private:
+ friend class Args;
+ std::unique_ptr<char[]> ptr;
+
+ char *data() { return ptr.get(); }
+
+ public:
+ ArgEntry() = default;
+ ArgEntry(llvm::StringRef str, char quote);
+
+ llvm::StringRef ref;
+ char quote;
+ const char *c_str() const { return ptr.get(); }
+ };
+
+ //------------------------------------------------------------------
+ /// Construct with an option command string.
+ ///
+ /// @param[in] command
+ /// A NULL terminated command that will be copied and split up
+ /// into arguments.
+ ///
+ /// @see Args::SetCommandString(llvm::StringRef)
+ //------------------------------------------------------------------
+ Args(llvm::StringRef command = llvm::StringRef());
+
+ Args(const Args &rhs);
+
+ Args &operator=(const Args &rhs);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ //------------------------------------------------------------------
+ ~Args();
+
+ //------------------------------------------------------------------
+ /// Dump all entries to the stream \a s using label \a label_name.
+ ///
+ /// If label_name is nullptr, the dump operation is skipped.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump all arguments in the argument
+ /// vector.
+ /// @param[in] label_name
+ /// The label_name to use as the label printed for each
+ /// entry of the args like so:
+ /// {label_name}[{index}]={value}
+ //------------------------------------------------------------------
+ void Dump(Stream &s, const char *label_name = "argv") const;
+
+ //------------------------------------------------------------------
+ /// Sets the command string contained by this object.
+ ///
+ /// The command string will be copied and split up into arguments
+ /// that can be accessed via the accessor functions.
+ ///
+ /// @param[in] command
+ /// A command StringRef that will be copied and split up
+ /// into arguments.
+ ///
+ /// @see Args::GetArgumentCount() const
+ /// @see Args::GetArgumentAtIndex (size_t) const
+ /// @see Args::GetArgumentVector ()
+ /// @see Args::Shift ()
+ /// @see Args::Unshift (const char *)
+ //------------------------------------------------------------------
+ void SetCommandString(llvm::StringRef command);
+
+ bool GetCommandString(std::string &command) const;
+
+ bool GetQuotedCommandString(std::string &command) const;
+
+ //------------------------------------------------------------------
+ /// Gets the number of arguments left in this command object.
+ ///
+ /// @return
+ /// The number or arguments in this object.
+ //------------------------------------------------------------------
+ size_t GetArgumentCount() const;
+ bool empty() const { return GetArgumentCount() == 0; }
+
+ //------------------------------------------------------------------
+ /// Gets the NULL terminated C string argument pointer for the
+ /// argument at index \a idx.
+ ///
+ /// @return
+ /// The NULL terminated C string argument pointer if \a idx is a
+ /// valid argument index, NULL otherwise.
+ //------------------------------------------------------------------
+ const char *GetArgumentAtIndex(size_t idx) const;
+
+ llvm::ArrayRef<ArgEntry> entries() const { return m_entries; }
+ char GetArgumentQuoteCharAtIndex(size_t idx) const;
+
+ std::vector<ArgEntry>::const_iterator begin() const {
+ return m_entries.begin();
+ }
+ std::vector<ArgEntry>::const_iterator end() const { return m_entries.end(); }
+
+ size_t size() const { return GetArgumentCount(); }
+ const ArgEntry &operator[](size_t n) const { return m_entries[n]; }
+
+ //------------------------------------------------------------------
+ /// Gets the argument vector.
+ ///
+ /// The value returned by this function can be used by any function
+ /// that takes and vector. The return value is just like \a argv
+ /// in the standard C entry point function:
+ /// \code
+ /// int main (int argc, const char **argv);
+ /// \endcode
+ ///
+ /// @return
+ /// An array of NULL terminated C string argument pointers that
+ /// also has a terminating NULL C string pointer
+ //------------------------------------------------------------------
+ char **GetArgumentVector();
+
+ //------------------------------------------------------------------
+ /// Gets the argument vector.
+ ///
+ /// The value returned by this function can be used by any function
+ /// that takes and vector. The return value is just like \a argv
+ /// in the standard C entry point function:
+ /// \code
+ /// int main (int argc, const char **argv);
+ /// \endcode
+ ///
+ /// @return
+ /// An array of NULL terminate C string argument pointers that
+ /// also has a terminating NULL C string pointer
+ //------------------------------------------------------------------
+ const char **GetConstArgumentVector() const;
+
+ //------------------------------------------------------------------
+ /// Appends a new argument to the end of the list argument list.
+ ///
+ /// @param[in] arg_cstr
+ /// The new argument as a NULL terminated C string.
+ ///
+ /// @param[in] quote_char
+ /// If the argument was originally quoted, put in the quote char here.
+ //------------------------------------------------------------------
+ void AppendArgument(llvm::StringRef arg_str, char quote_char = '\0');
+
+ void AppendArguments(const Args &rhs);
+
+ void AppendArguments(const char **argv);
+
+ //------------------------------------------------------------------
+ /// Insert the argument value at index \a idx to \a arg_cstr.
+ ///
+ /// @param[in] idx
+ /// The index of where to insert the argument.
+ ///
+ /// @param[in] arg_cstr
+ /// The new argument as a NULL terminated C string.
+ ///
+ /// @param[in] quote_char
+ /// If the argument was originally quoted, put in the quote char here.
+ ///
+ /// @return
+ /// The NULL terminated C string of the copy of \a arg_cstr.
+ //------------------------------------------------------------------
+ void InsertArgumentAtIndex(size_t idx, llvm::StringRef arg_str,
+ char quote_char = '\0');
+
+ //------------------------------------------------------------------
+ /// Replaces the argument value at index \a idx to \a arg_cstr
+ /// if \a idx is a valid argument index.
+ ///
+ /// @param[in] idx
+ /// The index of the argument that will have its value replaced.
+ ///
+ /// @param[in] arg_cstr
+ /// The new argument as a NULL terminated C string.
+ ///
+ /// @param[in] quote_char
+ /// If the argument was originally quoted, put in the quote char here.
+ //------------------------------------------------------------------
+ void ReplaceArgumentAtIndex(size_t idx, llvm::StringRef arg_str,
+ char quote_char = '\0');
+
+ //------------------------------------------------------------------
+ /// Deletes the argument value at index
+ /// if \a idx is a valid argument index.
+ ///
+ /// @param[in] idx
+ /// The index of the argument that will have its value replaced.
+ ///
+ //------------------------------------------------------------------
+ void DeleteArgumentAtIndex(size_t idx);
+
+ //------------------------------------------------------------------
+ /// Sets the argument vector value, optionally copying all
+ /// arguments into an internal buffer.
+ ///
+ /// Sets the arguments to match those found in \a argv. All argument
+ /// strings will be copied into an internal buffers.
+ //
+ // FIXME: Handle the quote character somehow.
+ //------------------------------------------------------------------
+ void SetArguments(size_t argc, const char **argv);
+
+ void SetArguments(const char **argv);
+
+ //------------------------------------------------------------------
+ /// Shifts the first argument C string value of the array off the
+ /// argument array.
+ ///
+ /// The string value will be freed, so a copy of the string should
+ /// be made by calling Args::GetArgumentAtIndex (size_t) const
+ /// first and copying the returned value before calling
+ /// Args::Shift().
+ ///
+ /// @see Args::GetArgumentAtIndex (size_t) const
+ //------------------------------------------------------------------
+ void Shift();
+
+ //------------------------------------------------------------------
+ /// Inserts a class owned copy of \a arg_cstr at the beginning of
+ /// the argument vector.
+ ///
+ /// A copy \a arg_cstr will be made.
+ ///
+ /// @param[in] arg_cstr
+ /// The argument to push on the front of the argument stack.
+ ///
+ /// @param[in] quote_char
+ /// If the argument was originally quoted, put in the quote char here.
+ //------------------------------------------------------------------
+ void Unshift(llvm::StringRef arg_str, char quote_char = '\0');
+
+ //------------------------------------------------------------------
+ /// Parse the arguments in the contained arguments.
+ ///
+ /// The arguments that are consumed by the argument parsing process
+ /// will be removed from the argument vector. The arguments that
+ /// get processed start at the second argument. The first argument
+ /// is assumed to be the command and will not be touched.
+ ///
+ /// param[in] platform_sp
+ /// The platform used for option validation. This is necessary
+ /// because an empty execution_context is not enough to get us
+ /// to a reasonable platform. If the platform isn't given,
+ /// we'll try to get it from the execution context. If we can't
+ /// get it from the execution context, we'll skip validation.
+ ///
+ /// param[in] require_validation
+ /// When true, it will fail option parsing if validation could
+ /// not occur due to not having a platform.
+ ///
+ /// @see class Options
+ //------------------------------------------------------------------
+ Error ParseOptions(Options &options, ExecutionContext *execution_context,
+ lldb::PlatformSP platform_sp, bool require_validation);
+
+ bool IsPositionalArgument(const char *arg);
+
+ // The following works almost identically to ParseOptions, except that no
+ // option is required to have arguments, and it builds up the
+ // option_arg_vector as it parses the options.
+
+ std::string ParseAliasOptions(Options &options, CommandReturnObject &result,
+ OptionArgVector *option_arg_vector,
+ llvm::StringRef raw_input_line);
+
+ void ParseArgsForCompletion(Options &options,
+ OptionElementVector &option_element_vector,
+ uint32_t cursor_index);
+
+ //------------------------------------------------------------------
+ // Clear the arguments.
+ //
+ // For re-setting or blanking out the list of arguments.
+ //------------------------------------------------------------------
+ void Clear();
+
+ static const char *StripSpaces(std::string &s, bool leading = true,
+ bool trailing = true,
+ bool return_null_if_empty = true);
+
+ static bool UInt64ValueIsValidForByteSize(uint64_t uval64,
+ size_t total_byte_size) {
+ if (total_byte_size > 8)
+ return false;
+
+ if (total_byte_size == 8)
+ return true;
+
+ const uint64_t max = ((uint64_t)1 << (uint64_t)(total_byte_size * 8)) - 1;
+ return uval64 <= max;
+ }
+
+ static bool SInt64ValueIsValidForByteSize(int64_t sval64,
+ size_t total_byte_size) {
+ if (total_byte_size > 8)
+ return false;
+
+ if (total_byte_size == 8)
+ return true;
+
+ const int64_t max = ((int64_t)1 << (uint64_t)(total_byte_size * 8 - 1)) - 1;
+ const int64_t min = ~(max);
+ return min <= sval64 && sval64 <= max;
+ }
+
+ static lldb::addr_t StringToAddress(const ExecutionContext *exe_ctx,
+ llvm::StringRef s,
+ lldb::addr_t fail_value, Error *error);
+
+ static bool StringToBoolean(llvm::StringRef s, bool fail_value,
+ bool *success_ptr);
+
+ static char StringToChar(llvm::StringRef s, char fail_value,
+ bool *success_ptr);
+
+ static int64_t StringToOptionEnum(llvm::StringRef s,
+ OptionEnumValueElement *enum_values,
+ int32_t fail_value, Error &error);
+
+ static lldb::ScriptLanguage
+ StringToScriptLanguage(llvm::StringRef s, lldb::ScriptLanguage fail_value,
+ bool *success_ptr);
+
+ // TODO: Use StringRef
+ static Error StringToFormat(const char *s, lldb::Format &format,
+ size_t *byte_size_ptr); // If non-NULL, then a
+ // byte size can precede
+ // the format character
+
+ static lldb::Encoding
+ StringToEncoding(llvm::StringRef s,
+ lldb::Encoding fail_value = lldb::eEncodingInvalid);
+
+ static uint32_t StringToGenericRegister(llvm::StringRef s);
+
+ static bool StringToVersion(llvm::StringRef string, uint32_t &major,
+ uint32_t &minor, uint32_t &update);
+
+ static const char *GetShellSafeArgument(const FileSpec &shell,
+ const char *unsafe_arg,
+ std::string &safe_arg);
+
+ // EncodeEscapeSequences will change the textual representation of common
+ // escape sequences like "\n" (two characters) into a single '\n'. It does
+ // this for all of the supported escaped sequences and for the \0ooo (octal)
+ // and \xXX (hex). The resulting "dst" string will contain the character
+ // versions of all supported escape sequences. The common supported escape
+ // sequences are: "\a", "\b", "\f", "\n", "\r", "\t", "\v", "\'", "\"", "\\".
+
+ static void EncodeEscapeSequences(const char *src, std::string &dst);
+
+ // ExpandEscapeSequences will change a string of possibly non-printable
+ // characters and expand them into text. So '\n' will turn into two characters
+ // like "\n" which is suitable for human reading. When a character is not
+ // printable and isn't one of the common in escape sequences listed in the
+ // help for EncodeEscapeSequences, then it will be encoded as octal. Printable
+ // characters are left alone.
+ static void ExpandEscapedCharacters(const char *src, std::string &dst);
+
+ static std::string EscapeLLDBCommandArgument(const std::string &arg,
+ char quote_char);
+
+ //------------------------------------------------------------------
+ /// Add or replace an environment variable with the given value.
+ ///
+ /// This command adds the environment variable if it is not already
+ /// present using the given value. If the environment variable is
+ /// already in the list, it replaces the first such occurrence
+ /// with the new value.
+ //------------------------------------------------------------------
+ void AddOrReplaceEnvironmentVariable(llvm::StringRef env_var_name,
+ llvm::StringRef new_value);
+
+ /// Return whether a given environment variable exists.
+ ///
+ /// This command treats Args like a list of environment variables,
+ /// as used in ProcessLaunchInfo. It treats each argument as
+ /// an {env_var_name}={value} or an {env_var_name} entry.
+ ///
+ /// @param[in] env_var_name
+ /// Specifies the name of the environment variable to check.
+ ///
+ /// @param[out] argument_index
+ /// If non-null, then when the environment variable is found,
+ /// the index of the argument position will be returned in
+ /// the size_t pointed to by this argument.
+ ///
+ /// @return
+ /// true if the specified env var name exists in the list in
+ /// either of the above-mentioned formats; otherwise, false.
+ //------------------------------------------------------------------
+ bool ContainsEnvironmentVariable(llvm::StringRef env_var_name,
+ size_t *argument_index = nullptr) const;
+
+private:
+ size_t FindArgumentIndexForOption(Option *long_options,
+ int long_options_index) const;
+
+ std::vector<ArgEntry> m_entries;
+ std::vector<char *> m_argv;
+
+ void UpdateArgsAfterOptionParsing();
};
} // namespace lldb_private
-#endif // liblldb_Command_h_
+#endif // liblldb_Command_h_
diff --git a/include/lldb/Interpreter/CommandAlias.h b/include/lldb/Interpreter/CommandAlias.h
index d48719f821ec..4658a1e444f4 100644
--- a/include/lldb/Interpreter/CommandAlias.h
+++ b/include/lldb/Interpreter/CommandAlias.h
@@ -16,107 +16,78 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-forward.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandObject.h"
+#include "lldb/lldb-forward.h"
namespace lldb_private {
-class CommandAlias : public CommandObject
-{
+class CommandAlias : public CommandObject {
public:
- typedef std::unique_ptr<CommandAlias> UniquePointer;
-
- CommandAlias (CommandInterpreter &interpreter,
- lldb::CommandObjectSP cmd_sp,
- const char *options_args,
- const char *name,
- const char *help = nullptr,
- const char *syntax = nullptr,
- uint32_t flags = 0);
-
- void
- GetAliasExpansion (StreamString &help_string);
-
- bool
- IsValid ()
- {
- return m_underlying_command_sp && m_option_args_sp;
- }
-
- explicit operator bool ()
- {
- return IsValid();
- }
-
- bool
- WantsRawCommandString() override;
-
- bool
- WantsCompletion() override;
-
- int
- HandleCompletion (Args &input,
- int &cursor_index,
- int &cursor_char_position,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches) override;
-
- int
- HandleArgumentCompletion (Args &input,
- int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches) override;
-
- Options*
- GetOptions() override;
-
- bool
- IsAlias () override { return true; }
-
- bool
- IsDashDashCommand () override;
-
- const char*
- GetHelp () override;
-
- const char*
- GetHelpLong () override;
-
- void
- SetHelp (const char * str) override;
-
- void
- SetHelpLong (const char * str) override;
-
- bool
- Execute(const char *args_string, CommandReturnObject &result) override;
-
- lldb::CommandObjectSP GetUnderlyingCommand() { return m_underlying_command_sp; }
- OptionArgVectorSP GetOptionArguments() { return m_option_args_sp; }
- const char* GetOptionString() { return m_option_string.c_str(); }
-
- // this takes an alias - potentially nested (i.e. an alias to an alias)
- // and expands it all the way to a non-alias command
- std::pair<lldb::CommandObjectSP, OptionArgVectorSP>
- Desugar ();
-
+ typedef std::unique_ptr<CommandAlias> UniquePointer;
+
+ CommandAlias(CommandInterpreter &interpreter, lldb::CommandObjectSP cmd_sp,
+ llvm::StringRef options_args, llvm::StringRef name,
+ llvm::StringRef help = llvm::StringRef(),
+ llvm::StringRef syntax = llvm::StringRef(), uint32_t flags = 0);
+
+ void GetAliasExpansion(StreamString &help_string) const;
+
+ bool IsValid() const { return m_underlying_command_sp && m_option_args_sp; }
+
+ explicit operator bool() const { return IsValid(); }
+
+ bool WantsRawCommandString() override;
+
+ bool WantsCompletion() override;
+
+ int HandleCompletion(Args &input, int &cursor_index,
+ int &cursor_char_position, int match_start_point,
+ int max_return_elements, bool &word_complete,
+ StringList &matches) override;
+
+ int HandleArgumentCompletion(Args &input, int &cursor_index,
+ int &cursor_char_position,
+ OptionElementVector &opt_element_vector,
+ int match_start_point, int max_return_elements,
+ bool &word_complete,
+ StringList &matches) override;
+
+ Options *GetOptions() override;
+
+ bool IsAlias() override { return true; }
+
+ bool IsDashDashCommand() override;
+
+ llvm::StringRef GetHelp() override;
+
+ llvm::StringRef GetHelpLong() override;
+
+ void SetHelp(llvm::StringRef str) override;
+
+ void SetHelpLong(llvm::StringRef str) override;
+
+ bool Execute(const char *args_string, CommandReturnObject &result) override;
+
+ lldb::CommandObjectSP GetUnderlyingCommand() {
+ return m_underlying_command_sp;
+ }
+ OptionArgVectorSP GetOptionArguments() const { return m_option_args_sp; }
+ const char *GetOptionString() { return m_option_string.c_str(); }
+
+ // this takes an alias - potentially nested (i.e. an alias to an alias)
+ // and expands it all the way to a non-alias command
+ std::pair<lldb::CommandObjectSP, OptionArgVectorSP> Desugar();
+
protected:
- bool
- IsNestedAlias ();
-
+ bool IsNestedAlias();
+
private:
- lldb::CommandObjectSP m_underlying_command_sp;
- std::string m_option_string;
- OptionArgVectorSP m_option_args_sp ;
- LazyBool m_is_dashdash_alias;
- bool m_did_set_help : 1;
- bool m_did_set_help_long : 1;
+ lldb::CommandObjectSP m_underlying_command_sp;
+ std::string m_option_string;
+ OptionArgVectorSP m_option_args_sp;
+ LazyBool m_is_dashdash_alias;
+ bool m_did_set_help : 1;
+ bool m_did_set_help_long : 1;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/CommandCompletions.h b/include/lldb/Interpreter/CommandCompletions.h
index 27ab45b3fa1f..2e117358c399 100644
--- a/include/lldb/Interpreter/CommandCompletions.h
+++ b/include/lldb/Interpreter/CommandCompletions.h
@@ -16,288 +16,232 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
-#include "lldb/Core/SearchFilter.h"
#include "lldb/Core/FileSpecList.h"
#include "lldb/Core/RegularExpression.h"
+#include "lldb/Core/SearchFilter.h"
+#include "lldb/lldb-private.h"
-namespace lldb_private
-{
-class CommandCompletions
-{
+namespace lldb_private {
+class CommandCompletions {
public:
-
- //----------------------------------------------------------------------
- // This is the command completion callback that is used to complete the argument of the option
- // it is bound to (in the OptionDefinition table below). Return the total number of matches.
- //----------------------------------------------------------------------
- typedef int (*CompletionCallback) (CommandInterpreter &interpreter,
- const char *completion_str, // This is the argument we are completing
- int match_start_point, // This is the point in the list of matches that you should start returning elements
- int max_return_elements, // This is the number of matches requested.
- lldb_private::SearchFilter *searcher,// A search filter to limit the search...
- bool &word_complete,
- lldb_private::StringList &matches); // The array of matches we return.
- typedef enum
- {
- eNoCompletion = 0u,
- eSourceFileCompletion = (1u << 0),
- eDiskFileCompletion = (1u << 1),
- eDiskDirectoryCompletion = (1u << 2),
- eSymbolCompletion = (1u << 3),
- eModuleCompletion = (1u << 4),
- eSettingsNameCompletion = (1u << 5),
- ePlatformPluginCompletion = (1u << 6),
- eArchitectureCompletion = (1u << 7),
- eVariablePathCompletion = (1u << 8),
- // This item serves two purposes. It is the last element in the enum,
- // so you can add custom enums starting from here in your Option class.
- // Also if you & in this bit the base code will not process the option.
- eCustomCompletion = (1u << 9)
- } CommonCompletionTypes;
-
- struct CommonCompletionElement
- {
- uint32_t type;
- CompletionCallback callback;
- };
-
- static bool InvokeCommonCompletionCallbacks (CommandInterpreter &interpreter,
- uint32_t completion_mask,
- const char *completion_str,
- int match_start_point,
- int max_return_elements,
- SearchFilter *searcher,
- bool &word_complete,
- StringList &matches);
-
- //----------------------------------------------------------------------
- // These are the generic completer functions:
- //----------------------------------------------------------------------
- static int
- DiskFiles (CommandInterpreter &interpreter,
- const char *partial_file_name,
- int match_start_point,
- int max_return_elements,
- SearchFilter *searcher,
- bool &word_complete,
- StringList &matches);
-
- static int
- DiskDirectories (CommandInterpreter &interpreter,
- const char *partial_file_name,
- int match_start_point,
- int max_return_elements,
- SearchFilter *searcher,
- bool &word_complete,
- StringList &matches);
-
- static int
- SourceFiles (CommandInterpreter &interpreter,
- const char *partial_file_name,
- int match_start_point,
- int max_return_elements,
- SearchFilter *searcher,
- bool &word_complete,
- StringList &matches);
-
- static int
- Modules (CommandInterpreter &interpreter,
- const char *partial_file_name,
- int match_start_point,
- int max_return_elements,
- SearchFilter *searcher,
- bool &word_complete,
- lldb_private::StringList &matches);
-
- static int
- Symbols (CommandInterpreter &interpreter,
- const char *partial_file_name,
- int match_start_point,
- int max_return_elements,
- SearchFilter *searcher,
- bool &word_complete,
- lldb_private::StringList &matches);
-
- static int
- SettingsNames (CommandInterpreter &interpreter,
- const char *partial_file_name,
- int match_start_point,
- int max_return_elements,
- SearchFilter *searcher,
- bool &word_complete,
- lldb_private::StringList &matches);
-
- static int
- PlatformPluginNames (CommandInterpreter &interpreter,
- const char *partial_file_name,
- int match_start_point,
- int max_return_elements,
- SearchFilter *searcher,
- bool &word_complete,
- lldb_private::StringList &matches);
-
-
- static int
- ArchitectureNames (CommandInterpreter &interpreter,
- const char *partial_file_name,
- int match_start_point,
- int max_return_elements,
- SearchFilter *searcher,
- bool &word_complete,
- lldb_private::StringList &matches);
-
- static int
- VariablePath (CommandInterpreter &interpreter,
- const char *partial_file_name,
- int match_start_point,
- int max_return_elements,
- SearchFilter *searcher,
- bool &word_complete,
- lldb_private::StringList &matches);
-
- //----------------------------------------------------------------------
- // The Completer class is a convenient base class for building searchers
- // that go along with the SearchFilter passed to the standard Completer
- // functions.
- //----------------------------------------------------------------------
- class Completer : public Searcher
- {
- public:
- Completer (CommandInterpreter &interpreter,
- const char *completion_str,
- int match_start_point,
- int max_return_elements,
- StringList &matches);
-
- ~Completer() override;
-
- CallbackReturn
- SearchCallback(SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool complete) override = 0;
-
- Depth
- GetDepth() override = 0;
-
- virtual size_t
- DoCompletion (SearchFilter *filter) = 0;
-
- protected:
- CommandInterpreter &m_interpreter;
- std::string m_completion_str;
- int m_match_start_point;
- int m_max_return_elements;
- StringList &m_matches;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Completer);
- };
-
- //----------------------------------------------------------------------
- // SourceFileCompleter implements the source file completer
- //----------------------------------------------------------------------
- class SourceFileCompleter : public Completer
- {
- public:
- SourceFileCompleter (CommandInterpreter &interpreter,
- bool include_support_files,
- const char *completion_str,
- int match_start_point,
- int max_return_elements,
+ //----------------------------------------------------------------------
+ // This is the command completion callback that is used to complete the
+ // argument of the option
+ // it is bound to (in the OptionDefinition table below). Return the total
+ // number of matches.
+ //----------------------------------------------------------------------
+ typedef int (*CompletionCallback)(
+ CommandInterpreter &interpreter,
+ llvm::StringRef completion_str, // This is the argument we are completing
+ int match_start_point, // This is the point in the list of matches that
+ // you should start returning elements
+ int max_return_elements, // This is the number of matches requested.
+ lldb_private::SearchFilter
+ *searcher, // A search filter to limit the search...
+ bool &word_complete,
+ lldb_private::StringList &matches); // The array of matches we return.
+ typedef enum {
+ eNoCompletion = 0u,
+ eSourceFileCompletion = (1u << 0),
+ eDiskFileCompletion = (1u << 1),
+ eDiskDirectoryCompletion = (1u << 2),
+ eSymbolCompletion = (1u << 3),
+ eModuleCompletion = (1u << 4),
+ eSettingsNameCompletion = (1u << 5),
+ ePlatformPluginCompletion = (1u << 6),
+ eArchitectureCompletion = (1u << 7),
+ eVariablePathCompletion = (1u << 8),
+ // This item serves two purposes. It is the last element in the enum,
+ // so you can add custom enums starting from here in your Option class.
+ // Also if you & in this bit the base code will not process the option.
+ eCustomCompletion = (1u << 9)
+ } CommonCompletionTypes;
+
+ struct CommonCompletionElement {
+ uint32_t type;
+ CompletionCallback callback;
+ };
+
+ static bool InvokeCommonCompletionCallbacks(
+ CommandInterpreter &interpreter, uint32_t completion_mask,
+ llvm::StringRef completion_str, int match_start_point,
+ int max_return_elements, SearchFilter *searcher, bool &word_complete,
+ StringList &matches);
+
+ //----------------------------------------------------------------------
+ // These are the generic completer functions:
+ //----------------------------------------------------------------------
+ static int DiskFiles(CommandInterpreter &interpreter,
+ llvm::StringRef partial_file_name, int match_start_point,
+ int max_return_elements, SearchFilter *searcher,
+ bool &word_complete, StringList &matches);
+
+ static int DiskDirectories(CommandInterpreter &interpreter,
+ llvm::StringRef partial_file_name,
+ int match_start_point, int max_return_elements,
+ SearchFilter *searcher, bool &word_complete,
StringList &matches);
-
- Searcher::Depth GetDepth() override;
-
- Searcher::CallbackReturn
- SearchCallback(SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool complete) override;
-
- size_t
- DoCompletion(SearchFilter *filter) override;
-
- private:
- bool m_include_support_files;
- FileSpecList m_matching_files;
- const char *m_file_name;
- const char *m_dir_name;
-
- DISALLOW_COPY_AND_ASSIGN(SourceFileCompleter);
- };
-
- //----------------------------------------------------------------------
- // ModuleCompleter implements the module completer
- //----------------------------------------------------------------------
- class ModuleCompleter : public Completer
- {
- public:
- ModuleCompleter (CommandInterpreter &interpreter,
- const char *completion_str,
- int match_start_point,
- int max_return_elements,
- StringList &matches);
-
- Searcher::Depth GetDepth() override;
-
- Searcher::CallbackReturn
- SearchCallback(SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool complete) override;
-
- size_t
- DoCompletion(SearchFilter *filter) override;
-
- private:
- const char *m_file_name;
- const char *m_dir_name;
-
- DISALLOW_COPY_AND_ASSIGN(ModuleCompleter);
- };
-
- //----------------------------------------------------------------------
- // SymbolCompleter implements the symbol completer
- //----------------------------------------------------------------------
- class SymbolCompleter : public Completer
- {
- public:
- SymbolCompleter (CommandInterpreter &interpreter,
- const char *completion_str,
- int match_start_point,
- int max_return_elements,
- StringList &matches);
-
- Searcher::Depth GetDepth() override;
-
- Searcher::CallbackReturn
- SearchCallback(SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool complete) override;
-
- size_t
- DoCompletion(SearchFilter *filter) override;
- private:
-// struct NameCmp {
-// bool operator() (const ConstString& lhs, const ConstString& rhs) const
-// {
-// return lhs < rhs;
-// }
-// };
-
- RegularExpression m_regex;
- typedef std::set<ConstString> collection;
- collection m_match_set;
+ static int SourceFiles(CommandInterpreter &interpreter,
+ llvm::StringRef partial_file_name,
+ int match_start_point, int max_return_elements,
+ SearchFilter *searcher, bool &word_complete,
+ StringList &matches);
- DISALLOW_COPY_AND_ASSIGN(SymbolCompleter);
- };
+ static int Modules(CommandInterpreter &interpreter,
+ llvm::StringRef partial_file_name, int match_start_point,
+ int max_return_elements, SearchFilter *searcher,
+ bool &word_complete, lldb_private::StringList &matches);
+
+ static int Symbols(CommandInterpreter &interpreter,
+ llvm::StringRef partial_file_name, int match_start_point,
+ int max_return_elements, SearchFilter *searcher,
+ bool &word_complete, lldb_private::StringList &matches);
+
+ static int SettingsNames(CommandInterpreter &interpreter,
+ llvm::StringRef partial_file_name,
+ int match_start_point, int max_return_elements,
+ SearchFilter *searcher, bool &word_complete,
+ lldb_private::StringList &matches);
+
+ static int PlatformPluginNames(CommandInterpreter &interpreter,
+ llvm::StringRef partial_file_name,
+ int match_start_point, int max_return_elements,
+ SearchFilter *searcher, bool &word_complete,
+ lldb_private::StringList &matches);
+
+ static int ArchitectureNames(CommandInterpreter &interpreter,
+ llvm::StringRef partial_file_name,
+ int match_start_point, int max_return_elements,
+ SearchFilter *searcher, bool &word_complete,
+ lldb_private::StringList &matches);
+
+ static int VariablePath(CommandInterpreter &interpreter,
+ llvm::StringRef partial_file_name,
+ int match_start_point, int max_return_elements,
+ SearchFilter *searcher, bool &word_complete,
+ lldb_private::StringList &matches);
+
+ //----------------------------------------------------------------------
+ // The Completer class is a convenient base class for building searchers
+ // that go along with the SearchFilter passed to the standard Completer
+ // functions.
+ //----------------------------------------------------------------------
+ class Completer : public Searcher {
+ public:
+ Completer(CommandInterpreter &interpreter, llvm::StringRef completion_str,
+ int match_start_point, int max_return_elements,
+ StringList &matches);
+
+ ~Completer() override;
+
+ CallbackReturn SearchCallback(SearchFilter &filter, SymbolContext &context,
+ Address *addr, bool complete) override = 0;
+
+ Depth GetDepth() override = 0;
+
+ virtual size_t DoCompletion(SearchFilter *filter) = 0;
+
+ protected:
+ CommandInterpreter &m_interpreter;
+ std::string m_completion_str;
+ int m_match_start_point;
+ int m_max_return_elements;
+ StringList &m_matches;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Completer);
+ };
+
+ //----------------------------------------------------------------------
+ // SourceFileCompleter implements the source file completer
+ //----------------------------------------------------------------------
+ class SourceFileCompleter : public Completer {
+ public:
+ SourceFileCompleter(CommandInterpreter &interpreter,
+ bool include_support_files,
+ llvm::StringRef completion_str, int match_start_point,
+ int max_return_elements, StringList &matches);
+
+ Searcher::Depth GetDepth() override;
+
+ Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
+ SymbolContext &context,
+ Address *addr,
+ bool complete) override;
+
+ size_t DoCompletion(SearchFilter *filter) override;
+
+ private:
+ bool m_include_support_files;
+ FileSpecList m_matching_files;
+ const char *m_file_name;
+ const char *m_dir_name;
+
+ DISALLOW_COPY_AND_ASSIGN(SourceFileCompleter);
+ };
+
+ //----------------------------------------------------------------------
+ // ModuleCompleter implements the module completer
+ //----------------------------------------------------------------------
+ class ModuleCompleter : public Completer {
+ public:
+ ModuleCompleter(CommandInterpreter &interpreter,
+ llvm::StringRef completion_str, int match_start_point,
+ int max_return_elements, StringList &matches);
+
+ Searcher::Depth GetDepth() override;
+
+ Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
+ SymbolContext &context,
+ Address *addr,
+ bool complete) override;
+
+ size_t DoCompletion(SearchFilter *filter) override;
+
+ private:
+ const char *m_file_name;
+ const char *m_dir_name;
+
+ DISALLOW_COPY_AND_ASSIGN(ModuleCompleter);
+ };
+
+ //----------------------------------------------------------------------
+ // SymbolCompleter implements the symbol completer
+ //----------------------------------------------------------------------
+ class SymbolCompleter : public Completer {
+ public:
+ SymbolCompleter(CommandInterpreter &interpreter,
+ llvm::StringRef completion_str, int match_start_point,
+ int max_return_elements, StringList &matches);
+
+ Searcher::Depth GetDepth() override;
+
+ Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
+ SymbolContext &context,
+ Address *addr,
+ bool complete) override;
+
+ size_t DoCompletion(SearchFilter *filter) override;
+
+ private:
+ // struct NameCmp {
+ // bool operator() (const ConstString& lhs, const ConstString&
+ // rhs) const
+ // {
+ // return lhs < rhs;
+ // }
+ // };
+
+ RegularExpression m_regex;
+ typedef std::set<ConstString> collection;
+ collection m_match_set;
+
+ DISALLOW_COPY_AND_ASSIGN(SymbolCompleter);
+ };
private:
- static CommonCompletionElement g_common_completions[];
+ static CommonCompletionElement g_common_completions[];
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/CommandHistory.h b/include/lldb/Interpreter/CommandHistory.h
index ff05f6da6c32..f1a6c855e3b9 100644
--- a/include/lldb/Interpreter/CommandHistory.h
+++ b/include/lldb/Interpreter/CommandHistory.h
@@ -18,58 +18,46 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/Stream.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-
-class CommandHistory
-{
+
+class CommandHistory {
public:
- CommandHistory ();
-
- ~CommandHistory ();
-
- size_t
- GetSize () const;
-
- bool
- IsEmpty () const;
-
- const char*
- FindString (const char* input_str) const;
-
- const char*
- GetStringAtIndex (size_t idx) const;
-
- const char*
- operator [] (size_t idx) const;
-
- const char*
- GetRecentmostString () const;
-
- void
- AppendString (const std::string& str,
- bool reject_if_dupe = true);
-
- void
- Clear ();
-
- void
- Dump (Stream& stream,
- size_t start_idx = 0,
- size_t stop_idx = SIZE_MAX) const;
-
- static const char g_repeat_char = '!';
-
+ CommandHistory();
+
+ ~CommandHistory();
+
+ size_t GetSize() const;
+
+ bool IsEmpty() const;
+
+ llvm::Optional<llvm::StringRef> FindString(llvm::StringRef input_str) const;
+
+ llvm::StringRef GetStringAtIndex(size_t idx) const;
+
+ llvm::StringRef operator[](size_t idx) const;
+
+ llvm::StringRef GetRecentmostString() const;
+
+ void AppendString(llvm::StringRef str, bool reject_if_dupe = true);
+
+ void Clear();
+
+ void Dump(Stream &stream, size_t start_idx = 0,
+ size_t stop_idx = SIZE_MAX) const;
+
+ static const char g_repeat_char = '!';
+
private:
- DISALLOW_COPY_AND_ASSIGN(CommandHistory);
-
- typedef std::vector<std::string> History;
- mutable std::recursive_mutex m_mutex;
- History m_history;
+ DISALLOW_COPY_AND_ASSIGN(CommandHistory);
+
+ typedef std::vector<std::string> History;
+ mutable std::recursive_mutex m_mutex;
+ History m_history;
};
} // namespace lldb_private
-#endif // liblldb_CommandHistory_h_
+#endif // liblldb_CommandHistory_h_
diff --git a/include/lldb/Interpreter/CommandInterpreter.h b/include/lldb/Interpreter/CommandInterpreter.h
index 4dc2c5859f45..00dec5134c8f 100644
--- a/include/lldb/Interpreter/CommandInterpreter.h
+++ b/include/lldb/Interpreter/CommandInterpreter.h
@@ -12,699 +12,545 @@
// C Includes
// C++ Includes
+#include <mutex>
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-forward.h"
-#include "lldb/lldb-private.h"
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Event.h"
#include "lldb/Core/IOHandler.h"
#include "lldb/Core/Log.h"
+#include "lldb/Core/StringList.h"
+#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandAlias.h"
#include "lldb/Interpreter/CommandHistory.h"
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
-#include "lldb/Core/Event.h"
-#include "lldb/Interpreter/Args.h"
-#include "lldb/Core/StringList.h"
+#include "lldb/lldb-forward.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class CommandInterpreterRunOptions
-{
+class CommandInterpreterRunOptions {
public:
- //------------------------------------------------------------------
- /// Construct a CommandInterpreterRunOptions object.
- /// This class is used to control all the instances where we run multiple commands, e.g.
- /// HandleCommands, HandleCommandsFromFile, RunCommandInterpreter.
- /// The meanings of the options in this object are:
- ///
- /// @param[in] stop_on_continue
- /// If \b true execution will end on the first command that causes the process in the
- /// execution context to continue. If \false, we won't check the execution status.
- /// @param[in] stop_on_error
- /// If \b true execution will end on the first command that causes an error.
- /// @param[in] stop_on_crash
- /// If \b true when a command causes the target to run, and the end of the run is a
- /// signal or exception, stop executing the commands.
- /// @param[in] echo_commands
- /// If \b true echo the command before executing it. If \false, execute silently.
- /// @param[in] print_results
- /// If \b true print the results of the command after executing it. If \false, execute silently.
- /// @param[in] add_to_history
- /// If \b true add the commands to the command history. If \false, don't add them.
- //------------------------------------------------------------------
- CommandInterpreterRunOptions (LazyBool stop_on_continue,
- LazyBool stop_on_error,
- LazyBool stop_on_crash,
- LazyBool echo_commands,
- LazyBool print_results,
- LazyBool add_to_history) :
- m_stop_on_continue(stop_on_continue),
- m_stop_on_error(stop_on_error),
- m_stop_on_crash(stop_on_crash),
- m_echo_commands(echo_commands),
- m_print_results(print_results),
- m_add_to_history(add_to_history)
- {}
-
- CommandInterpreterRunOptions () :
- m_stop_on_continue(eLazyBoolCalculate),
+ //------------------------------------------------------------------
+ /// Construct a CommandInterpreterRunOptions object.
+ /// This class is used to control all the instances where we run multiple
+ /// commands, e.g.
+ /// HandleCommands, HandleCommandsFromFile, RunCommandInterpreter.
+ /// The meanings of the options in this object are:
+ ///
+ /// @param[in] stop_on_continue
+ /// If \b true execution will end on the first command that causes the
+ /// process in the
+ /// execution context to continue. If \false, we won't check the execution
+ /// status.
+ /// @param[in] stop_on_error
+ /// If \b true execution will end on the first command that causes an
+ /// error.
+ /// @param[in] stop_on_crash
+ /// If \b true when a command causes the target to run, and the end of the
+ /// run is a
+ /// signal or exception, stop executing the commands.
+ /// @param[in] echo_commands
+ /// If \b true echo the command before executing it. If \false, execute
+ /// silently.
+ /// @param[in] print_results
+ /// If \b true print the results of the command after executing it. If
+ /// \false, execute silently.
+ /// @param[in] add_to_history
+ /// If \b true add the commands to the command history. If \false, don't
+ /// add them.
+ //------------------------------------------------------------------
+ CommandInterpreterRunOptions(LazyBool stop_on_continue,
+ LazyBool stop_on_error, LazyBool stop_on_crash,
+ LazyBool echo_commands, LazyBool print_results,
+ LazyBool add_to_history)
+ : m_stop_on_continue(stop_on_continue), m_stop_on_error(stop_on_error),
+ m_stop_on_crash(stop_on_crash), m_echo_commands(echo_commands),
+ m_print_results(print_results), m_add_to_history(add_to_history) {}
+
+ CommandInterpreterRunOptions()
+ : m_stop_on_continue(eLazyBoolCalculate),
m_stop_on_error(eLazyBoolCalculate),
m_stop_on_crash(eLazyBoolCalculate),
m_echo_commands(eLazyBoolCalculate),
m_print_results(eLazyBoolCalculate),
- m_add_to_history(eLazyBoolCalculate)
- {}
+ m_add_to_history(eLazyBoolCalculate) {}
- void
- SetSilent (bool silent)
- {
- LazyBool value = silent ? eLazyBoolNo : eLazyBoolYes;
+ void SetSilent(bool silent) {
+ LazyBool value = silent ? eLazyBoolNo : eLazyBoolYes;
- m_echo_commands = value;
- m_print_results = value;
- m_add_to_history = value;
- }
- // These return the default behaviors if the behavior is not eLazyBoolCalculate.
- // But I've also left the ivars public since for different ways of running the
- // interpreter you might want to force different defaults... In that case, just grab
- // the LazyBool ivars directly and do what you want with eLazyBoolCalculate.
- bool
- GetStopOnContinue () const
- {
- return DefaultToNo (m_stop_on_continue);
- }
+ m_echo_commands = value;
+ m_print_results = value;
+ m_add_to_history = value;
+ }
+ // These return the default behaviors if the behavior is not
+ // eLazyBoolCalculate.
+ // But I've also left the ivars public since for different ways of running the
+ // interpreter you might want to force different defaults... In that case,
+ // just grab
+ // the LazyBool ivars directly and do what you want with eLazyBoolCalculate.
+ bool GetStopOnContinue() const { return DefaultToNo(m_stop_on_continue); }
- void
- SetStopOnContinue (bool stop_on_continue)
- {
- m_stop_on_continue = stop_on_continue ? eLazyBoolYes : eLazyBoolNo;
- }
+ void SetStopOnContinue(bool stop_on_continue) {
+ m_stop_on_continue = stop_on_continue ? eLazyBoolYes : eLazyBoolNo;
+ }
- bool
- GetStopOnError () const
- {
- return DefaultToNo (m_stop_on_continue);
- }
+ bool GetStopOnError() const { return DefaultToNo(m_stop_on_continue); }
- void
- SetStopOnError (bool stop_on_error)
- {
- m_stop_on_error = stop_on_error ? eLazyBoolYes : eLazyBoolNo;
- }
+ void SetStopOnError(bool stop_on_error) {
+ m_stop_on_error = stop_on_error ? eLazyBoolYes : eLazyBoolNo;
+ }
- bool
- GetStopOnCrash () const
- {
- return DefaultToNo (m_stop_on_crash);
- }
+ bool GetStopOnCrash() const { return DefaultToNo(m_stop_on_crash); }
- void
- SetStopOnCrash (bool stop_on_crash)
- {
- m_stop_on_crash = stop_on_crash ? eLazyBoolYes : eLazyBoolNo;
- }
+ void SetStopOnCrash(bool stop_on_crash) {
+ m_stop_on_crash = stop_on_crash ? eLazyBoolYes : eLazyBoolNo;
+ }
- bool
- GetEchoCommands () const
- {
- return DefaultToYes (m_echo_commands);
- }
+ bool GetEchoCommands() const { return DefaultToYes(m_echo_commands); }
- void
- SetEchoCommands (bool echo_commands)
- {
- m_echo_commands = echo_commands ? eLazyBoolYes : eLazyBoolNo;
- }
+ void SetEchoCommands(bool echo_commands) {
+ m_echo_commands = echo_commands ? eLazyBoolYes : eLazyBoolNo;
+ }
- bool
- GetPrintResults () const
- {
- return DefaultToYes (m_print_results);
- }
+ bool GetPrintResults() const { return DefaultToYes(m_print_results); }
- void
- SetPrintResults (bool print_results)
- {
- m_print_results = print_results ? eLazyBoolYes : eLazyBoolNo;
- }
+ void SetPrintResults(bool print_results) {
+ m_print_results = print_results ? eLazyBoolYes : eLazyBoolNo;
+ }
- bool
- GetAddToHistory () const
- {
- return DefaultToYes (m_add_to_history);
- }
+ bool GetAddToHistory() const { return DefaultToYes(m_add_to_history); }
- void
- SetAddToHistory (bool add_to_history)
- {
- m_add_to_history = add_to_history ? eLazyBoolYes : eLazyBoolNo;
- }
+ void SetAddToHistory(bool add_to_history) {
+ m_add_to_history = add_to_history ? eLazyBoolYes : eLazyBoolNo;
+ }
- LazyBool m_stop_on_continue;
- LazyBool m_stop_on_error;
- LazyBool m_stop_on_crash;
- LazyBool m_echo_commands;
- LazyBool m_print_results;
- LazyBool m_add_to_history;
-
- private:
- static bool
- DefaultToYes (LazyBool flag)
- {
- switch (flag)
- {
- case eLazyBoolNo:
- return false;
- default:
- return true;
- }
- }
+ LazyBool m_stop_on_continue;
+ LazyBool m_stop_on_error;
+ LazyBool m_stop_on_crash;
+ LazyBool m_echo_commands;
+ LazyBool m_print_results;
+ LazyBool m_add_to_history;
- static bool
- DefaultToNo (LazyBool flag)
- {
- switch (flag)
- {
- case eLazyBoolYes:
- return true;
- default:
- return false;
- }
- }
+private:
+ static bool DefaultToYes(LazyBool flag) {
+ switch (flag) {
+ case eLazyBoolNo:
+ return false;
+ default:
+ return true;
+ }
+ }
+
+ static bool DefaultToNo(LazyBool flag) {
+ switch (flag) {
+ case eLazyBoolYes:
+ return true;
+ default:
+ return false;
+ }
+ }
};
-class CommandInterpreter :
- public Broadcaster,
- public Properties,
- public IOHandlerDelegate
-{
+class CommandInterpreter : public Broadcaster,
+ public Properties,
+ public IOHandlerDelegate {
public:
- enum
- {
- eBroadcastBitThreadShouldExit = (1 << 0),
- eBroadcastBitResetPrompt = (1 << 1),
- eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit
- eBroadcastBitAsynchronousOutputData = (1 << 3),
- eBroadcastBitAsynchronousErrorData = (1 << 4)
- };
-
- enum ChildrenTruncatedWarningStatus // tristate boolean to manage children truncation warning
- {
- eNoTruncation = 0, // never truncated
- eUnwarnedTruncation = 1, // truncated but did not notify
- eWarnedTruncation = 2 // truncated and notified
- };
-
- enum CommandTypes
- {
- eCommandTypesBuiltin = 0x0001, // native commands such as "frame"
- eCommandTypesUserDef = 0x0002, // scripted commands
- eCommandTypesAliases = 0x0004, // aliases such as "po"
- eCommandTypesHidden = 0x0008, // commands prefixed with an underscore
- eCommandTypesAllThem = 0xFFFF // all commands
- };
-
- CommandInterpreter(Debugger &debugger,
- lldb::ScriptLanguage script_language,
- bool synchronous_execution);
-
- ~CommandInterpreter() override;
-
- // These two functions fill out the Broadcaster interface:
-
- static ConstString &GetStaticBroadcasterClass ();
-
- ConstString &GetBroadcasterClass() const override
- {
- return GetStaticBroadcasterClass();
- }
+ enum {
+ eBroadcastBitThreadShouldExit = (1 << 0),
+ eBroadcastBitResetPrompt = (1 << 1),
+ eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit
+ eBroadcastBitAsynchronousOutputData = (1 << 3),
+ eBroadcastBitAsynchronousErrorData = (1 << 4)
+ };
+
+ enum ChildrenTruncatedWarningStatus // tristate boolean to manage children
+ // truncation warning
+ { eNoTruncation = 0, // never truncated
+ eUnwarnedTruncation = 1, // truncated but did not notify
+ eWarnedTruncation = 2 // truncated and notified
+ };
+
+ enum CommandTypes {
+ eCommandTypesBuiltin = 0x0001, // native commands such as "frame"
+ eCommandTypesUserDef = 0x0002, // scripted commands
+ eCommandTypesAliases = 0x0004, // aliases such as "po"
+ eCommandTypesHidden = 0x0008, // commands prefixed with an underscore
+ eCommandTypesAllThem = 0xFFFF // all commands
+ };
+
+ CommandInterpreter(Debugger &debugger, lldb::ScriptLanguage script_language,
+ bool synchronous_execution);
+
+ ~CommandInterpreter() override;
+
+ // These two functions fill out the Broadcaster interface:
+
+ static ConstString &GetStaticBroadcasterClass();
+
+ ConstString &GetBroadcasterClass() const override {
+ return GetStaticBroadcasterClass();
+ }
+
+ void SourceInitFile(bool in_cwd, CommandReturnObject &result);
+
+ bool AddCommand(llvm::StringRef name, const lldb::CommandObjectSP &cmd_sp,
+ bool can_replace);
+
+ bool AddUserCommand(llvm::StringRef name, const lldb::CommandObjectSP &cmd_sp,
+ bool can_replace);
+
+ lldb::CommandObjectSP GetCommandSPExact(llvm::StringRef cmd,
+ bool include_aliases) const;
+
+ CommandObject *GetCommandObject(llvm::StringRef cmd,
+ StringList *matches = nullptr) const;
+
+ bool CommandExists(llvm::StringRef cmd) const;
+
+ bool AliasExists(llvm::StringRef cmd) const;
+
+ bool UserCommandExists(llvm::StringRef cmd) const;
+
+ CommandAlias *AddAlias(llvm::StringRef alias_name,
+ lldb::CommandObjectSP &command_obj_sp,
+ llvm::StringRef args_string = llvm::StringRef());
+
+ // Remove a command if it is removable (python or regex command)
+ bool RemoveCommand(llvm::StringRef cmd);
+
+ bool RemoveAlias(llvm::StringRef alias_name);
+
+ bool GetAliasFullName(llvm::StringRef cmd, std::string &full_name) const;
+
+ bool RemoveUser(llvm::StringRef alias_name);
+
+ void RemoveAllUser() { m_user_dict.clear(); }
+
+ const CommandAlias *GetAlias(llvm::StringRef alias_name) const;
+
+ CommandObject *BuildAliasResult(llvm::StringRef alias_name,
+ std::string &raw_input_string,
+ std::string &alias_result,
+ CommandReturnObject &result);
+
+ bool HandleCommand(const char *command_line, LazyBool add_to_history,
+ CommandReturnObject &result,
+ ExecutionContext *override_context = nullptr,
+ bool repeat_on_empty_command = true,
+ bool no_context_switching = false);
+
+ //------------------------------------------------------------------
+ /// Execute a list of commands in sequence.
+ ///
+ /// @param[in] commands
+ /// The list of commands to execute.
+ /// @param[in,out] context
+ /// The execution context in which to run the commands. Can be nullptr in
+ /// which case the default
+ /// context will be used.
+ /// @param[in] options
+ /// This object holds the options used to control when to stop, whether to
+ /// execute commands,
+ /// etc.
+ /// @param[out] result
+ /// This is marked as succeeding with no output if all commands execute
+ /// safely,
+ /// and failed with some explanation if we aborted executing the commands
+ /// at some point.
+ //------------------------------------------------------------------
+ void HandleCommands(const StringList &commands, ExecutionContext *context,
+ CommandInterpreterRunOptions &options,
+ CommandReturnObject &result);
- void
- SourceInitFile (bool in_cwd,
- CommandReturnObject &result);
-
- bool
- AddCommand (const char *name,
- const lldb::CommandObjectSP &cmd_sp,
- bool can_replace);
-
- bool
- AddUserCommand (std::string name,
- const lldb::CommandObjectSP &cmd_sp,
- bool can_replace);
-
- lldb::CommandObjectSP
- GetCommandSPExact (const char *cmd,
- bool include_aliases);
-
- CommandObject *
- GetCommandObjectExact (const char *cmd_cstr,
- bool include_aliases);
-
- CommandObject *
- GetCommandObject(const char *cmd,
- StringList *matches = nullptr);
-
- bool
- CommandExists (const char *cmd);
-
- bool
- AliasExists (const char *cmd);
-
- bool
- UserCommandExists (const char *cmd);
-
- CommandAlias*
- AddAlias (const char *alias_name,
- lldb::CommandObjectSP& command_obj_sp,
- const char *args_string = nullptr);
-
- // Remove a command if it is removable (python or regex command)
- bool
- RemoveCommand (const char *cmd);
-
- bool
- RemoveAlias (const char *alias_name);
-
- bool
- GetAliasFullName (const char *cmd, std::string &full_name);
-
- bool
- RemoveUser (const char *alias_name);
-
- void
- RemoveAllUser ()
- {
- m_user_dict.clear();
- }
+ //------------------------------------------------------------------
+ /// Execute a list of commands from a file.
+ ///
+ /// @param[in] file
+ /// The file from which to read in commands.
+ /// @param[in,out] context
+ /// The execution context in which to run the commands. Can be nullptr in
+ /// which case the default
+ /// context will be used.
+ /// @param[in] options
+ /// This object holds the options used to control when to stop, whether to
+ /// execute commands,
+ /// etc.
+ /// @param[out] result
+ /// This is marked as succeeding with no output if all commands execute
+ /// safely,
+ /// and failed with some explanation if we aborted executing the commands
+ /// at some point.
+ //------------------------------------------------------------------
+ void HandleCommandsFromFile(FileSpec &file, ExecutionContext *context,
+ CommandInterpreterRunOptions &options,
+ CommandReturnObject &result);
+
+ CommandObject *GetCommandObjectForCommand(llvm::StringRef &command_line);
+
+ // This handles command line completion. You are given a pointer to the
+ // command string buffer, to the current cursor,
+ // and to the end of the string (in case it is not NULL terminated).
+ // You also passed in an StringList object to fill with the returns.
+ // The first element of the array will be filled with the string that you
+ // would need to insert at
+ // the cursor point to complete the cursor point to the longest common
+ // matching prefix.
+ // If you want to limit the number of elements returned, set
+ // max_return_elements to the number of elements
+ // you want returned. Otherwise set max_return_elements to -1.
+ // If you want to start some way into the match list, then set
+ // match_start_point to the desired start
+ // point.
+ // Returns:
+ // -1 if the completion character should be inserted
+ // -2 if the entire command line should be deleted and replaced with
+ // matches.GetStringAtIndex(0)
+ // INT_MAX if the number of matches is > max_return_elements, but it is
+ // expensive to compute.
+ // Otherwise, returns the number of matches.
+ //
+ // FIXME: Only max_return_elements == -1 is supported at present.
+ int HandleCompletion(const char *current_line, const char *cursor,
+ const char *last_char, int match_start_point,
+ int max_return_elements, StringList &matches);
+
+ // This version just returns matches, and doesn't compute the substring. It
+ // is here so the
+ // Help command can call it for the first argument.
+ // word_complete tells whether the completions are considered a "complete"
+ // response (so the
+ // completer should complete the quote & put a space after the word.
+ int HandleCompletionMatches(Args &input, int &cursor_index,
+ int &cursor_char_position, int match_start_point,
+ int max_return_elements, bool &word_complete,
+ StringList &matches);
+
+ int GetCommandNamesMatchingPartialString(const char *cmd_cstr,
+ bool include_aliases,
+ StringList &matches);
+
+ void GetHelp(CommandReturnObject &result,
+ uint32_t types = eCommandTypesAllThem);
+
+ void GetAliasHelp(const char *alias_name, StreamString &help_string);
+
+ void OutputFormattedHelpText(Stream &strm, llvm::StringRef prefix,
+ llvm::StringRef help_text);
+
+ void OutputFormattedHelpText(Stream &stream, llvm::StringRef command_word,
+ llvm::StringRef separator,
+ llvm::StringRef help_text, size_t max_word_len);
+
+ // this mimics OutputFormattedHelpText but it does perform a much simpler
+ // formatting, basically ensuring line alignment. This is only good if you
+ // have some complicated layout for your help text and want as little help as
+ // reasonable in properly displaying it. Most of the times, you simply want
+ // to type some text and have it printed in a reasonable way on screen. If
+ // so, use OutputFormattedHelpText
+ void OutputHelpText(Stream &stream, llvm::StringRef command_word,
+ llvm::StringRef separator, llvm::StringRef help_text,
+ uint32_t max_word_len);
+
+ Debugger &GetDebugger() { return m_debugger; }
+
+ ExecutionContext GetExecutionContext() {
+ const bool thread_and_frame_only_if_stopped = true;
+ return m_exe_ctx_ref.Lock(thread_and_frame_only_if_stopped);
+ }
+
+ void UpdateExecutionContext(ExecutionContext *override_context);
+
+ lldb::PlatformSP GetPlatform(bool prefer_target_platform);
+
+ const char *ProcessEmbeddedScriptCommands(const char *arg);
+
+ void UpdatePrompt(llvm::StringRef prompt);
+
+ bool Confirm(llvm::StringRef message, bool default_answer);
+
+ void LoadCommandDictionary();
+
+ void Initialize();
+
+ void Clear();
+
+ void SetScriptLanguage(lldb::ScriptLanguage lang);
- CommandAlias*
- GetAlias (const char *alias_name);
+ bool HasCommands() const;
- CommandObject *
- BuildAliasResult (const char *alias_name,
- std::string &raw_input_string,
- std::string &alias_result,
- CommandReturnObject &result);
+ bool HasAliases() const;
- bool
- HandleCommand(const char *command_line,
- LazyBool add_to_history,
- CommandReturnObject &result,
- ExecutionContext *override_context = nullptr,
- bool repeat_on_empty_command = true,
- bool no_context_switching = false);
-
- //------------------------------------------------------------------
- /// Execute a list of commands in sequence.
- ///
- /// @param[in] commands
- /// The list of commands to execute.
- /// @param[in,out] context
- /// The execution context in which to run the commands. Can be nullptr in which case the default
- /// context will be used.
- /// @param[in] options
- /// This object holds the options used to control when to stop, whether to execute commands,
- /// etc.
- /// @param[out] result
- /// This is marked as succeeding with no output if all commands execute safely,
- /// and failed with some explanation if we aborted executing the commands at some point.
- //------------------------------------------------------------------
- void
- HandleCommands (const StringList &commands,
- ExecutionContext *context,
- CommandInterpreterRunOptions &options,
- CommandReturnObject &result);
-
- //------------------------------------------------------------------
- /// Execute a list of commands from a file.
- ///
- /// @param[in] file
- /// The file from which to read in commands.
- /// @param[in,out] context
- /// The execution context in which to run the commands. Can be nullptr in which case the default
- /// context will be used.
- /// @param[in] options
- /// This object holds the options used to control when to stop, whether to execute commands,
- /// etc.
- /// @param[out] result
- /// This is marked as succeeding with no output if all commands execute safely,
- /// and failed with some explanation if we aborted executing the commands at some point.
- //------------------------------------------------------------------
- void
- HandleCommandsFromFile (FileSpec &file,
- ExecutionContext *context,
- CommandInterpreterRunOptions &options,
- CommandReturnObject &result);
-
- CommandObject *
- GetCommandObjectForCommand (std::string &command_line);
-
- // This handles command line completion. You are given a pointer to the command string buffer, to the current cursor,
- // and to the end of the string (in case it is not NULL terminated).
- // You also passed in an StringList object to fill with the returns.
- // The first element of the array will be filled with the string that you would need to insert at
- // the cursor point to complete the cursor point to the longest common matching prefix.
- // If you want to limit the number of elements returned, set max_return_elements to the number of elements
- // you want returned. Otherwise set max_return_elements to -1.
- // If you want to start some way into the match list, then set match_start_point to the desired start
- // point.
- // Returns:
- // -1 if the completion character should be inserted
- // -2 if the entire command line should be deleted and replaced with matches.GetStringAtIndex(0)
- // INT_MAX if the number of matches is > max_return_elements, but it is expensive to compute.
- // Otherwise, returns the number of matches.
- //
- // FIXME: Only max_return_elements == -1 is supported at present.
- int
- HandleCompletion (const char *current_line,
- const char *cursor,
- const char *last_char,
- int match_start_point,
- int max_return_elements,
- StringList &matches);
-
- // This version just returns matches, and doesn't compute the substring. It is here so the
- // Help command can call it for the first argument.
- // word_complete tells whether the completions are considered a "complete" response (so the
- // completer should complete the quote & put a space after the word.
- int
- HandleCompletionMatches (Args &input,
- int &cursor_index,
- int &cursor_char_position,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches);
-
- int
- GetCommandNamesMatchingPartialString (const char *cmd_cstr,
- bool include_aliases,
- StringList &matches);
-
- void
- GetHelp (CommandReturnObject &result,
- uint32_t types = eCommandTypesAllThem);
-
- void
- GetAliasHelp (const char *alias_name,
- StreamString &help_string);
-
- void
- OutputFormattedHelpText (Stream &strm,
- const char *prefix,
- const char *help_text);
-
- void
- OutputFormattedHelpText (Stream &stream,
- const char *command_word,
- const char *separator,
- const char *help_text,
- size_t max_word_len);
-
- // this mimics OutputFormattedHelpText but it does perform a much simpler
- // formatting, basically ensuring line alignment. This is only good if you have
- // some complicated layout for your help text and want as little help as reasonable
- // in properly displaying it. Most of the times, you simply want to type some text
- // and have it printed in a reasonable way on screen. If so, use OutputFormattedHelpText
- void
- OutputHelpText (Stream &stream,
- const char *command_word,
- const char *separator,
- const char *help_text,
- uint32_t max_word_len);
-
- Debugger &
- GetDebugger ()
- {
- return m_debugger;
- }
-
- ExecutionContext
- GetExecutionContext()
- {
- const bool thread_and_frame_only_if_stopped = true;
- return m_exe_ctx_ref.Lock(thread_and_frame_only_if_stopped);
- }
-
- void
- UpdateExecutionContext (ExecutionContext *override_context);
-
- lldb::PlatformSP
- GetPlatform (bool prefer_target_platform);
-
- const char *
- ProcessEmbeddedScriptCommands (const char *arg);
-
- void
- UpdatePrompt (const char *);
-
- bool
- Confirm (const char *message,
- bool default_answer);
-
- void
- LoadCommandDictionary ();
-
- void
- Initialize ();
-
- void
- Clear ();
-
- void
- SetScriptLanguage (lldb::ScriptLanguage lang);
-
- bool
- HasCommands ();
-
- bool
- HasAliases ();
-
- bool
- HasUserCommands ();
-
- bool
- HasAliasOptions ();
-
- void
- BuildAliasCommandArgs (CommandObject *alias_cmd_obj,
- const char *alias_name,
- Args &cmd_args,
- std::string &raw_input_string,
- CommandReturnObject &result);
-
- int
- GetOptionArgumentPosition (const char *in_string);
-
- ScriptInterpreter *
- GetScriptInterpreter(bool can_create = true);
-
- void
- SetScriptInterpreter();
-
- void
- SkipLLDBInitFiles (bool skip_lldbinit_files)
- {
- m_skip_lldbinit_files = skip_lldbinit_files;
- }
+ bool HasUserCommands() const;
- void
- SkipAppInitFiles (bool skip_app_init_files)
- {
- m_skip_app_init_files = m_skip_lldbinit_files;
- }
+ bool HasAliasOptions() const;
- bool
- GetSynchronous ();
-
- void
- FindCommandsForApropos (const char *word,
- StringList &commands_found,
- StringList &commands_help,
- bool search_builtin_commands,
- bool search_user_commands,
- bool search_alias_commands);
-
- bool
- GetBatchCommandMode () { return m_batch_command_mode; }
-
- bool
- SetBatchCommandMode (bool value) {
- const bool old_value = m_batch_command_mode;
- m_batch_command_mode = value;
- return old_value;
- }
-
- void
- ChildrenTruncated ()
- {
- if (m_truncation_warning == eNoTruncation)
- m_truncation_warning = eUnwarnedTruncation;
- }
-
- bool
- TruncationWarningNecessary ()
- {
- return (m_truncation_warning == eUnwarnedTruncation);
- }
-
- void
- TruncationWarningGiven ()
- {
- m_truncation_warning = eWarnedTruncation;
- }
-
- const char *
- TruncationWarningText ()
- {
- return "*** Some of your variables have more members than the debugger will show by default. To show all of them, you can either use the --show-all-children option to %s or raise the limit by changing the target.max-children-count setting.\n";
- }
-
- const CommandHistory&
- GetCommandHistory () const
- {
- return m_command_history;
- }
-
- CommandHistory&
- GetCommandHistory ()
- {
- return m_command_history;
- }
-
- bool
- IsActive ();
-
- void
- RunCommandInterpreter (bool auto_handle_events,
- bool spawn_thread,
- CommandInterpreterRunOptions &options);
- void
- GetLLDBCommandsFromIOHandler (const char *prompt,
- IOHandlerDelegate &delegate,
- bool asynchronously,
- void *baton);
-
- void
- GetPythonCommandsFromIOHandler (const char *prompt,
+ void BuildAliasCommandArgs(CommandObject *alias_cmd_obj,
+ const char *alias_name, Args &cmd_args,
+ std::string &raw_input_string,
+ CommandReturnObject &result);
+
+ int GetOptionArgumentPosition(const char *in_string);
+
+ ScriptInterpreter *GetScriptInterpreter(bool can_create = true);
+
+ void SetScriptInterpreter();
+
+ void SkipLLDBInitFiles(bool skip_lldbinit_files) {
+ m_skip_lldbinit_files = skip_lldbinit_files;
+ }
+
+ void SkipAppInitFiles(bool skip_app_init_files) {
+ m_skip_app_init_files = m_skip_lldbinit_files;
+ }
+
+ bool GetSynchronous();
+
+ void FindCommandsForApropos(llvm::StringRef word, StringList &commands_found,
+ StringList &commands_help,
+ bool search_builtin_commands,
+ bool search_user_commands,
+ bool search_alias_commands);
+
+ bool GetBatchCommandMode() { return m_batch_command_mode; }
+
+ bool SetBatchCommandMode(bool value) {
+ const bool old_value = m_batch_command_mode;
+ m_batch_command_mode = value;
+ return old_value;
+ }
+
+ void ChildrenTruncated() {
+ if (m_truncation_warning == eNoTruncation)
+ m_truncation_warning = eUnwarnedTruncation;
+ }
+
+ bool TruncationWarningNecessary() {
+ return (m_truncation_warning == eUnwarnedTruncation);
+ }
+
+ void TruncationWarningGiven() { m_truncation_warning = eWarnedTruncation; }
+
+ const char *TruncationWarningText() {
+ return "*** Some of your variables have more members than the debugger "
+ "will show by default. To show all of them, you can either use the "
+ "--show-all-children option to %s or raise the limit by changing "
+ "the target.max-children-count setting.\n";
+ }
+
+ const CommandHistory &GetCommandHistory() const { return m_command_history; }
+
+ CommandHistory &GetCommandHistory() { return m_command_history; }
+
+ bool IsActive();
+
+ void RunCommandInterpreter(bool auto_handle_events, bool spawn_thread,
+ CommandInterpreterRunOptions &options);
+ void GetLLDBCommandsFromIOHandler(const char *prompt,
IOHandlerDelegate &delegate,
- bool asynchronously,
- void *baton);
-
- const char *
- GetCommandPrefix ();
-
- //------------------------------------------------------------------
- // Properties
- //------------------------------------------------------------------
- bool
- GetExpandRegexAliases () const;
-
- bool
- GetPromptOnQuit () const;
-
- void
- SetPromptOnQuit (bool b);
-
- void
- ResolveCommand(const char *command_line, CommandReturnObject &result);
-
- bool
- GetStopCmdSourceOnError () const;
-
- uint32_t
- GetNumErrors() const
- {
- return m_num_errors;
- }
+ bool asynchronously, void *baton);
- bool
- GetQuitRequested () const
- {
- return m_quit_requested;
- }
+ void GetPythonCommandsFromIOHandler(const char *prompt,
+ IOHandlerDelegate &delegate,
+ bool asynchronously, void *baton);
- lldb::IOHandlerSP
- GetIOHandler(bool force_create = false, CommandInterpreterRunOptions *options = nullptr);
+ const char *GetCommandPrefix();
+
+ //------------------------------------------------------------------
+ // Properties
+ //------------------------------------------------------------------
+ bool GetExpandRegexAliases() const;
+
+ bool GetPromptOnQuit() const;
+
+ void SetPromptOnQuit(bool b);
+
+ void ResolveCommand(const char *command_line, CommandReturnObject &result);
+
+ bool GetStopCmdSourceOnError() const;
+
+ uint32_t GetNumErrors() const { return m_num_errors; }
+
+ bool GetQuitRequested() const { return m_quit_requested; }
+
+ lldb::IOHandlerSP
+ GetIOHandler(bool force_create = false,
+ CommandInterpreterRunOptions *options = nullptr);
+
+ bool GetStoppedForCrash() const { return m_stopped_for_crash; }
+
+ bool GetSpaceReplPrompts() const;
- bool
- GetStoppedForCrash () const
- {
- return m_stopped_for_crash;
- }
-
- bool
- GetSpaceReplPrompts () const;
-
protected:
- friend class Debugger;
-
- //------------------------------------------------------------------
- // IOHandlerDelegate functions
- //------------------------------------------------------------------
- void
- IOHandlerInputComplete(IOHandler &io_handler,
- std::string &line) override;
-
- ConstString
- IOHandlerGetControlSequence(char ch) override
- {
- if (ch == 'd')
- return ConstString("quit\n");
- return ConstString();
- }
-
- bool
- IOHandlerInterrupt(IOHandler &io_handler) override;
+ friend class Debugger;
+
+ //------------------------------------------------------------------
+ // IOHandlerDelegate functions
+ //------------------------------------------------------------------
+ void IOHandlerInputComplete(IOHandler &io_handler,
+ std::string &line) override;
+
+ ConstString IOHandlerGetControlSequence(char ch) override {
+ if (ch == 'd')
+ return ConstString("quit\n");
+ return ConstString();
+ }
+
+ bool IOHandlerInterrupt(IOHandler &io_handler) override;
+
+ size_t GetProcessOutput();
- size_t
- GetProcessOutput ();
+ void SetSynchronous(bool value);
- void
- SetSynchronous (bool value);
+ lldb::CommandObjectSP GetCommandSP(llvm::StringRef cmd,
+ bool include_aliases = true,
+ bool exact = true,
+ StringList *matches = nullptr) const;
- lldb::CommandObjectSP
- GetCommandSP(const char *cmd, bool include_aliases = true, bool exact = true, StringList *matches = nullptr);
-
private:
- Error
- PreprocessCommand (std::string &command);
-
- // Completely resolves aliases and abbreviations, returning a pointer to the
- // final command object and updating command_line to the fully substituted
- // and translated command.
- CommandObject *
- ResolveCommandImpl(std::string &command_line, CommandReturnObject &result);
-
- void
- FindCommandsForApropos (const char *word,
- StringList &commands_found,
- StringList &commands_help,
- CommandObject::CommandMap &command_map);
-
- Debugger &m_debugger; // The debugger session that this interpreter is associated with
- ExecutionContextRef m_exe_ctx_ref; // The current execution context to use when handling commands
- bool m_synchronous_execution;
- bool m_skip_lldbinit_files;
- bool m_skip_app_init_files;
- CommandObject::CommandMap m_command_dict; // Stores basic built-in commands (they cannot be deleted, removed or overwritten).
- CommandObject::CommandMap m_alias_dict; // Stores user aliases/abbreviations for commands
- CommandObject::CommandMap m_user_dict; // Stores user-defined commands
- CommandHistory m_command_history;
- std::string m_repeat_command; // Stores the command that will be executed for an empty command string.
- lldb::ScriptInterpreterSP m_script_interpreter_sp;
- lldb::IOHandlerSP m_command_io_handler_sp;
- char m_comment_char;
- bool m_batch_command_mode;
- ChildrenTruncatedWarningStatus m_truncation_warning; // Whether we truncated children and whether the user has been told
- uint32_t m_command_source_depth;
- std::vector<uint32_t> m_command_source_flags;
- uint32_t m_num_errors;
- bool m_quit_requested;
- bool m_stopped_for_crash;
+ Error PreprocessCommand(std::string &command);
+
+ // Completely resolves aliases and abbreviations, returning a pointer to the
+ // final command object and updating command_line to the fully substituted
+ // and translated command.
+ CommandObject *ResolveCommandImpl(std::string &command_line,
+ CommandReturnObject &result);
+
+ void FindCommandsForApropos(llvm::StringRef word, StringList &commands_found,
+ StringList &commands_help,
+ CommandObject::CommandMap &command_map);
+
+ Debugger &m_debugger; // The debugger session that this interpreter is
+ // associated with
+ ExecutionContextRef m_exe_ctx_ref; // The current execution context to use
+ // when handling commands
+ bool m_synchronous_execution;
+ bool m_skip_lldbinit_files;
+ bool m_skip_app_init_files;
+ CommandObject::CommandMap m_command_dict; // Stores basic built-in commands
+ // (they cannot be deleted, removed
+ // or overwritten).
+ CommandObject::CommandMap
+ m_alias_dict; // Stores user aliases/abbreviations for commands
+ CommandObject::CommandMap m_user_dict; // Stores user-defined commands
+ CommandHistory m_command_history;
+ std::string m_repeat_command; // Stores the command that will be executed for
+ // an empty command string.
+ lldb::ScriptInterpreterSP m_script_interpreter_sp;
+ std::mutex m_script_interpreter_mutex;
+ lldb::IOHandlerSP m_command_io_handler_sp;
+ char m_comment_char;
+ bool m_batch_command_mode;
+ ChildrenTruncatedWarningStatus m_truncation_warning; // Whether we truncated
+ // children and whether
+ // the user has been told
+ uint32_t m_command_source_depth;
+ std::vector<uint32_t> m_command_source_flags;
+ uint32_t m_num_errors;
+ bool m_quit_requested;
+ bool m_stopped_for_crash;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/CommandObject.h b/include/lldb/Interpreter/CommandObject.h
index b5d39ce83257..9104fd8f9bb7 100644
--- a/include/lldb/Interpreter/CommandObject.h
+++ b/include/lldb/Interpreter/CommandObject.h
@@ -18,572 +18,482 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
+#include "lldb/Core/Flags.h"
+#include "lldb/Core/StringList.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandCompletions.h"
-#include "lldb/Core/StringList.h"
-#include "lldb/Core/Flags.h"
#include "lldb/Target/ExecutionContext.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
// This function really deals with CommandObjectLists, but we didn't make a
// CommandObjectList class, so I'm sticking it here. But we really should have
-// such a class. Anyway, it looks up the commands in the map that match the partial
-// string cmd_str, inserts the matches into matches, and returns the number added.
+// such a class. Anyway, it looks up the commands in the map that match the
+// partial
+// string cmd_str, inserts the matches into matches, and returns the number
+// added.
template <typename ValueType>
-int
-AddNamesMatchingPartialString (std::map<std::string,ValueType> &in_map, const char *cmd_str, StringList &matches)
-{
- int number_added = 0;
-
- const bool add_all = ((cmd_str == nullptr) || (cmd_str[0] == 0));
-
- for (auto iter = in_map.begin(), end = in_map.end();
- iter != end;
- iter++)
- {
- if (add_all ||
- (iter->first.find(cmd_str,0) == 0))
- {
- ++number_added;
- matches.AppendString(iter->first.c_str());
- }
+int AddNamesMatchingPartialString(const std::map<std::string, ValueType> &in_map,
+ llvm::StringRef cmd_str, StringList &matches) {
+ int number_added = 0;
+
+ const bool add_all = cmd_str.empty();
+
+ for (auto iter = in_map.begin(), end = in_map.end(); iter != end; iter++) {
+ if (add_all || (iter->first.find(cmd_str, 0) == 0)) {
+ ++number_added;
+ matches.AppendString(iter->first.c_str());
}
-
- return number_added;
+ }
+
+ return number_added;
}
template <typename ValueType>
-size_t
-FindLongestCommandWord (std::map<std::string,ValueType> &dict)
-{
- auto end = dict.end();
- size_t max_len = 0;
-
- for (auto pos = dict.begin(); pos != end; ++pos)
- {
- size_t len = pos->first.size();
- if (max_len < len)
- max_len = len;
- }
- return max_len;
+size_t FindLongestCommandWord(std::map<std::string, ValueType> &dict) {
+ auto end = dict.end();
+ size_t max_len = 0;
+
+ for (auto pos = dict.begin(); pos != end; ++pos) {
+ size_t len = pos->first.size();
+ if (max_len < len)
+ max_len = len;
+ }
+ return max_len;
}
-class CommandObject
-{
+class CommandObject {
public:
- typedef const char *(ArgumentHelpCallbackFunction) ();
-
- struct ArgumentHelpCallback
- {
- ArgumentHelpCallbackFunction *help_callback;
- bool self_formatting;
-
- const char*
- operator () () const
- {
- return (*help_callback)();
- }
-
- explicit operator bool() const
- {
- return (help_callback != nullptr);
- }
- };
-
- struct ArgumentTableEntry // Entries in the main argument information table
- {
- lldb::CommandArgumentType arg_type;
- const char *arg_name;
- CommandCompletions::CommonCompletionTypes completion_type;
- ArgumentHelpCallback help_function;
- const char *help_text;
- };
-
- struct CommandArgumentData // Used to build individual command argument lists
- {
- lldb::CommandArgumentType arg_type;
- ArgumentRepetitionType arg_repetition;
- uint32_t arg_opt_set_association; // This arg might be associated only with some particular option set(s).
- CommandArgumentData():
- arg_type(lldb::eArgTypeNone),
- arg_repetition(eArgRepeatPlain),
- arg_opt_set_association(LLDB_OPT_SET_ALL) // By default, the arg associates to all option sets.
- {}
- };
-
- typedef std::vector<CommandArgumentData> CommandArgumentEntry; // Used to build individual command argument lists
-
- static ArgumentTableEntry g_arguments_data[lldb::eArgTypeLastArg]; // Main argument information table
-
- typedef std::map<std::string, lldb::CommandObjectSP> CommandMap;
-
- CommandObject(CommandInterpreter &interpreter,
- const char *name,
- const char *help = nullptr,
- const char *syntax = nullptr,
- uint32_t flags = 0);
-
- virtual
- ~CommandObject ();
-
- static const char *
- GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type);
-
- static const char *
- GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type);
-
- CommandInterpreter &
- GetCommandInterpreter ()
- {
- return m_interpreter;
- }
+ typedef llvm::StringRef(ArgumentHelpCallbackFunction)();
- virtual const char *
- GetHelp ();
-
- virtual const char *
- GetHelpLong ();
-
- virtual const char *
- GetSyntax ();
-
- const char *
- GetCommandName ();
-
- virtual void
- SetHelp (const char * str);
-
- virtual void
- SetHelpLong (const char * str);
-
- void
- SetSyntax (const char *str);
-
- // override this to return true if you want to enable the user to delete
- // the Command object from the Command dictionary (aliases have their own
- // deletion scheme, so they do not need to care about this)
- virtual bool
- IsRemovable () const { return false; }
-
- virtual bool
- IsMultiwordObject () { return false; }
-
- virtual CommandObjectMultiword*
- GetAsMultiwordCommand () { return nullptr; }
-
- virtual bool
- IsAlias () { return false; }
-
- // override this to return true if your command is somehow a "dash-dash"
- // form of some other command (e.g. po is expr -O --); this is a powerful
- // hint to the help system that one cannot pass options to this command
- virtual bool
- IsDashDashCommand () { return false; }
-
- virtual lldb::CommandObjectSP
- GetSubcommandSP(const char *sub_cmd, StringList *matches = nullptr)
- {
- return lldb::CommandObjectSP();
- }
-
- virtual CommandObject *
- GetSubcommandObject(const char *sub_cmd, StringList *matches = nullptr)
- {
- return nullptr;
- }
-
- virtual void
- AproposAllSubCommands (const char *prefix,
- const char *search_word,
- StringList &commands_found,
- StringList &commands_help)
- {
- }
+ struct ArgumentHelpCallback {
+ ArgumentHelpCallbackFunction *help_callback;
+ bool self_formatting;
- void
- FormatLongHelpText (Stream &output_strm, const char *long_help);
+ llvm::StringRef operator()() const { return (*help_callback)(); }
- void
- GenerateHelpText (CommandReturnObject &result);
+ explicit operator bool() const { return (help_callback != nullptr); }
+ };
- virtual void
- GenerateHelpText (Stream &result);
+ struct ArgumentTableEntry // Entries in the main argument information table
+ {
+ lldb::CommandArgumentType arg_type;
+ const char *arg_name;
+ CommandCompletions::CommonCompletionTypes completion_type;
+ ArgumentHelpCallback help_function;
+ const char *help_text;
+ };
- // this is needed in order to allow the SBCommand class to
- // transparently try and load subcommands - it will fail on
- // anything but a multiword command, but it avoids us doing
- // type checkings and casts
- virtual bool
- LoadSubCommand (const char *cmd_name,
- const lldb::CommandObjectSP& command_obj)
- {
- return false;
- }
-
- virtual bool
- WantsRawCommandString() = 0;
-
- // By default, WantsCompletion = !WantsRawCommandString.
- // Subclasses who want raw command string but desire, for example,
- // argument completion should override this method to return true.
- virtual bool
- WantsCompletion() { return !WantsRawCommandString(); }
-
- virtual Options *
- GetOptions ();
-
- static const ArgumentTableEntry*
- GetArgumentTable ();
-
- static lldb::CommandArgumentType
- LookupArgumentName (const char *arg_name);
-
- static const ArgumentTableEntry *
- FindArgumentDataByType (lldb::CommandArgumentType arg_type);
-
- int
- GetNumArgumentEntries ();
-
- CommandArgumentEntry *
- GetArgumentEntryAtIndex (int idx);
-
- static void
- GetArgumentHelp (Stream &str, lldb::CommandArgumentType arg_type, CommandInterpreter &interpreter);
-
- static const char *
- GetArgumentName (lldb::CommandArgumentType arg_type);
-
- // Generates a nicely formatted command args string for help command output.
- // By default, all possible args are taken into account, for example,
- // '<expr | variable-name>'. This can be refined by passing a second arg
- // specifying which option set(s) we are interested, which could then, for
- // example, produce either '<expr>' or '<variable-name>'.
- void
- GetFormattedCommandArguments (Stream &str, uint32_t opt_set_mask = LLDB_OPT_SET_ALL);
-
- bool
- IsPairType (ArgumentRepetitionType arg_repeat_type);
-
- bool
- ParseOptions (Args& args, CommandReturnObject &result);
-
- void
- SetCommandName (const char *name);
-
- //------------------------------------------------------------------
- /// The input array contains a parsed version of the line. The insertion
- /// point is given by cursor_index (the index in input of the word containing
- /// the cursor) and cursor_char_position (the position of the cursor in that word.)
- /// This default version handles calling option argument completions and then calls
- /// HandleArgumentCompletion if the cursor is on an argument, not an option.
- /// Don't override this method, override HandleArgumentCompletion instead unless
- /// you have special reasons.
- ///
- /// @param[in] interpreter
- /// The command interpreter doing the completion.
- ///
- /// @param[in] input
- /// The command line parsed into words
- ///
- /// @param[in] cursor_index
- /// The index in \ainput of the word in which the cursor lies.
- ///
- /// @param[in] cursor_char_pos
- /// The character position of the cursor in its argument word.
- ///
- /// @param[in] match_start_point
- /// @param[in] match_return_elements
- /// FIXME: Not yet implemented... If there is a match that is expensive to compute, these are
- /// here to allow you to compute the completions in batches. Start the completion from \amatch_start_point,
- /// and return \amatch_return_elements elements.
- ///
- /// @param[out] word_complete
- /// \btrue if this is a complete option value (a space will be inserted after the
- /// completion.) \bfalse otherwise.
- ///
- /// @param[out] matches
- /// The array of matches returned.
- ///
- /// FIXME: This is the wrong return value, since we also need to make a distinction between
- /// total number of matches, and the window the user wants returned.
- ///
- /// @return
- /// \btrue if we were in an option, \bfalse otherwise.
- //------------------------------------------------------------------
- virtual int
- HandleCompletion (Args &input,
- int &cursor_index,
- int &cursor_char_position,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches);
-
- //------------------------------------------------------------------
- /// The input array contains a parsed version of the line. The insertion
- /// point is given by cursor_index (the index in input of the word containing
- /// the cursor) and cursor_char_position (the position of the cursor in that word.)
- /// We've constructed the map of options and their arguments as well if that is
- /// helpful for the completion.
- ///
- /// @param[in] interpreter
- /// The command interpreter doing the completion.
- ///
- /// @param[in] input
- /// The command line parsed into words
- ///
- /// @param[in] cursor_index
- /// The index in \ainput of the word in which the cursor lies.
- ///
- /// @param[in] cursor_char_pos
- /// The character position of the cursor in its argument word.
- ///
- /// @param[in] opt_element_vector
- /// The results of the options parse of \a input.
- ///
- /// @param[in] match_start_point
- /// @param[in] match_return_elements
- /// See CommandObject::HandleCompletions for a description of how these work.
- ///
- /// @param[out] word_complete
- /// \btrue if this is a complete option value (a space will be inserted after the
- /// completion.) \bfalse otherwise.
- ///
- /// @param[out] matches
- /// The array of matches returned.
- ///
- /// FIXME: This is the wrong return value, since we also need to make a distinction between
- /// total number of matches, and the window the user wants returned.
- ///
- /// @return
- /// The number of completions.
- //------------------------------------------------------------------
- virtual int
- HandleArgumentCompletion (Args &input,
- int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches)
- {
- return 0;
- }
-
- bool
- HelpTextContainsWord (const char *search_word,
- bool search_short_help = true,
- bool search_long_help = true,
- bool search_syntax = true,
- bool search_options = true);
-
- //------------------------------------------------------------------
- /// The flags accessor.
- ///
- /// @return
- /// A reference to the Flags member variable.
- //------------------------------------------------------------------
- Flags&
- GetFlags()
- {
- return m_flags;
- }
+ struct CommandArgumentData // Used to build individual command argument lists
+ {
+ lldb::CommandArgumentType arg_type;
+ ArgumentRepetitionType arg_repetition;
+ uint32_t arg_opt_set_association; // This arg might be associated only with
+ // some particular option set(s).
+ CommandArgumentData()
+ : arg_type(lldb::eArgTypeNone), arg_repetition(eArgRepeatPlain),
+ arg_opt_set_association(LLDB_OPT_SET_ALL) // By default, the arg
+ // associates to all option
+ // sets.
+ {}
+ };
- //------------------------------------------------------------------
- /// The flags const accessor.
- ///
- /// @return
- /// A const reference to the Flags member variable.
- //------------------------------------------------------------------
- const Flags&
- GetFlags() const
- {
- return m_flags;
- }
-
- //------------------------------------------------------------------
- /// Get the command that appropriate for a "repeat" of the current command.
- ///
- /// @param[in] current_command_line
- /// The complete current command line.
- ///
- /// @return
- /// nullptr if there is no special repeat command - it will use the current command line.
- /// Otherwise a pointer to the command to be repeated.
- /// If the returned string is the empty string, the command won't be repeated.
- //------------------------------------------------------------------
- virtual const char *GetRepeatCommand (Args &current_command_args, uint32_t index)
- {
- return nullptr;
- }
+ typedef std::vector<CommandArgumentData>
+ CommandArgumentEntry; // Used to build individual command argument lists
- bool
- HasOverrideCallback () const
- {
- return m_command_override_callback || m_deprecated_command_override_callback;
- }
-
- void
- SetOverrideCallback (lldb::CommandOverrideCallback callback, void *baton)
- {
- m_deprecated_command_override_callback = callback;
- m_command_override_baton = baton;
- }
-
- void
- SetOverrideCallback (lldb::CommandOverrideCallbackWithResult callback, void *baton)
- {
- m_command_override_callback = callback;
- m_command_override_baton = baton;
- }
-
- bool
- InvokeOverrideCallback (const char **argv, CommandReturnObject &result)
- {
- if (m_command_override_callback)
- return m_command_override_callback(m_command_override_baton, argv, result);
- else if (m_deprecated_command_override_callback)
- return m_deprecated_command_override_callback(m_command_override_baton, argv);
- else
- return false;
- }
-
- virtual bool
- Execute (const char *args_string, CommandReturnObject &result) = 0;
+ static ArgumentTableEntry g_arguments_data
+ [lldb::eArgTypeLastArg]; // Main argument information table
-protected:
- virtual const char *
- GetInvalidTargetDescription()
- {
- return "invalid target, create a target using the 'target create' command";
- }
+ typedef std::map<std::string, lldb::CommandObjectSP> CommandMap;
- virtual const char *
- GetInvalidProcessDescription()
- {
- return "invalid process";
- }
+ CommandObject(CommandInterpreter &interpreter, llvm::StringRef name,
+ llvm::StringRef help = "", llvm::StringRef syntax = "",
+ uint32_t flags = 0);
- virtual const char *
- GetInvalidThreadDescription()
- {
- return "invalid thread";
- }
-
- virtual const char *
- GetInvalidFrameDescription()
- {
- return "invalid frame";
- }
-
- virtual const char *
- GetInvalidRegContextDescription ()
- {
- return "invalid frame, no registers";
- }
+ virtual ~CommandObject();
- // This is for use in the command interpreter, when you either want the selected target, or if no target
- // is present you want to prime the dummy target with entities that will be copied over to new targets.
- Target *GetSelectedOrDummyTarget(bool prefer_dummy = false);
- Target *GetDummyTarget();
-
- // If a command needs to use the "current" thread, use this call.
- // Command objects will have an ExecutionContext to use, and that may or may not have a thread in it. If it
- // does, you should use that by default, if not, then use the ExecutionContext's target's selected thread, etc...
- // This call insulates you from the details of this calculation.
- Thread *GetDefaultThread();
-
- //------------------------------------------------------------------
- /// Check the command to make sure anything required by this
- /// command is available.
- ///
- /// @param[out] result
- /// A command result object, if it is not okay to run the command
- /// this will be filled in with a suitable error.
- ///
- /// @return
- /// \b true if it is okay to run this command, \b false otherwise.
- //------------------------------------------------------------------
- bool
- CheckRequirements (CommandReturnObject &result);
-
- void
- Cleanup ();
-
- CommandInterpreter &m_interpreter;
- ExecutionContext m_exe_ctx;
- std::unique_lock<std::recursive_mutex> m_api_locker;
- std::string m_cmd_name;
- std::string m_cmd_help_short;
- std::string m_cmd_help_long;
- std::string m_cmd_syntax;
- Flags m_flags;
- std::vector<CommandArgumentEntry> m_arguments;
- lldb::CommandOverrideCallback m_deprecated_command_override_callback;
- lldb::CommandOverrideCallbackWithResult m_command_override_callback;
- void * m_command_override_baton;
-
- // Helper function to populate IDs or ID ranges as the command argument data
- // to the specified command argument entry.
- static void
- AddIDsArgumentData(CommandArgumentEntry &arg, lldb::CommandArgumentType ID, lldb::CommandArgumentType IDRange);
+ static const char *
+ GetArgumentTypeAsCString(const lldb::CommandArgumentType arg_type);
+
+ static const char *
+ GetArgumentDescriptionAsCString(const lldb::CommandArgumentType arg_type);
+
+ CommandInterpreter &GetCommandInterpreter() { return m_interpreter; }
+
+ virtual llvm::StringRef GetHelp();
+
+ virtual llvm::StringRef GetHelpLong();
+
+ virtual llvm::StringRef GetSyntax();
+
+ llvm::StringRef GetCommandName() const;
+
+ virtual void SetHelp(llvm::StringRef str);
+
+ virtual void SetHelpLong(llvm::StringRef str);
+
+ void SetSyntax(llvm::StringRef str);
+
+ // override this to return true if you want to enable the user to delete
+ // the Command object from the Command dictionary (aliases have their own
+ // deletion scheme, so they do not need to care about this)
+ virtual bool IsRemovable() const { return false; }
+
+ virtual bool IsMultiwordObject() { return false; }
+
+ virtual CommandObjectMultiword *GetAsMultiwordCommand() { return nullptr; }
+
+ virtual bool IsAlias() { return false; }
+
+ // override this to return true if your command is somehow a "dash-dash"
+ // form of some other command (e.g. po is expr -O --); this is a powerful
+ // hint to the help system that one cannot pass options to this command
+ virtual bool IsDashDashCommand() { return false; }
+
+ virtual lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd,
+ StringList *matches = nullptr) {
+ return lldb::CommandObjectSP();
+ }
+
+ virtual CommandObject *GetSubcommandObject(llvm::StringRef sub_cmd,
+ StringList *matches = nullptr) {
+ return nullptr;
+ }
+
+ virtual void AproposAllSubCommands(llvm::StringRef prefix,
+ llvm::StringRef search_word,
+ StringList &commands_found,
+ StringList &commands_help) {}
+
+ void FormatLongHelpText(Stream &output_strm, llvm::StringRef long_help);
+
+ void GenerateHelpText(CommandReturnObject &result);
+
+ virtual void GenerateHelpText(Stream &result);
+
+ // this is needed in order to allow the SBCommand class to
+ // transparently try and load subcommands - it will fail on
+ // anything but a multiword command, but it avoids us doing
+ // type checkings and casts
+ virtual bool LoadSubCommand(llvm::StringRef cmd_name,
+ const lldb::CommandObjectSP &command_obj) {
+ return false;
+ }
+
+ virtual bool WantsRawCommandString() = 0;
+
+ // By default, WantsCompletion = !WantsRawCommandString.
+ // Subclasses who want raw command string but desire, for example,
+ // argument completion should override this method to return true.
+ virtual bool WantsCompletion() { return !WantsRawCommandString(); }
+
+ virtual Options *GetOptions();
+
+ static const ArgumentTableEntry *GetArgumentTable();
+
+ static lldb::CommandArgumentType LookupArgumentName(llvm::StringRef arg_name);
+
+ static const ArgumentTableEntry *
+ FindArgumentDataByType(lldb::CommandArgumentType arg_type);
+
+ int GetNumArgumentEntries();
+
+ CommandArgumentEntry *GetArgumentEntryAtIndex(int idx);
+
+ static void GetArgumentHelp(Stream &str, lldb::CommandArgumentType arg_type,
+ CommandInterpreter &interpreter);
+
+ static const char *GetArgumentName(lldb::CommandArgumentType arg_type);
+
+ // Generates a nicely formatted command args string for help command output.
+ // By default, all possible args are taken into account, for example,
+ // '<expr | variable-name>'. This can be refined by passing a second arg
+ // specifying which option set(s) we are interested, which could then, for
+ // example, produce either '<expr>' or '<variable-name>'.
+ void GetFormattedCommandArguments(Stream &str,
+ uint32_t opt_set_mask = LLDB_OPT_SET_ALL);
+
+ bool IsPairType(ArgumentRepetitionType arg_repeat_type);
+
+ bool ParseOptions(Args &args, CommandReturnObject &result);
+
+ void SetCommandName(llvm::StringRef name);
+
+ //------------------------------------------------------------------
+ /// The input array contains a parsed version of the line. The insertion
+ /// point is given by cursor_index (the index in input of the word containing
+ /// the cursor) and cursor_char_position (the position of the cursor in that
+ /// word.)
+ /// This default version handles calling option argument completions and then
+ /// calls
+ /// HandleArgumentCompletion if the cursor is on an argument, not an option.
+ /// Don't override this method, override HandleArgumentCompletion instead
+ /// unless
+ /// you have special reasons.
+ ///
+ /// @param[in] interpreter
+ /// The command interpreter doing the completion.
+ ///
+ /// @param[in] input
+ /// The command line parsed into words
+ ///
+ /// @param[in] cursor_index
+ /// The index in \ainput of the word in which the cursor lies.
+ ///
+ /// @param[in] cursor_char_pos
+ /// The character position of the cursor in its argument word.
+ ///
+ /// @param[in] match_start_point
+ /// @param[in] match_return_elements
+ /// FIXME: Not yet implemented... If there is a match that is expensive
+ /// to compute, these are
+ /// here to allow you to compute the completions in batches. Start the
+ /// completion from \amatch_start_point,
+ /// and return \amatch_return_elements elements.
+ ///
+ /// @param[out] word_complete
+ /// \btrue if this is a complete option value (a space will be inserted
+ /// after the
+ /// completion.) \bfalse otherwise.
+ ///
+ /// @param[out] matches
+ /// The array of matches returned.
+ ///
+ /// FIXME: This is the wrong return value, since we also need to make a
+ /// distinction between
+ /// total number of matches, and the window the user wants returned.
+ ///
+ /// @return
+ /// \btrue if we were in an option, \bfalse otherwise.
+ //------------------------------------------------------------------
+ virtual int HandleCompletion(Args &input, int &cursor_index,
+ int &cursor_char_position, int match_start_point,
+ int max_return_elements, bool &word_complete,
+ StringList &matches);
+
+ //------------------------------------------------------------------
+ /// The input array contains a parsed version of the line. The insertion
+ /// point is given by cursor_index (the index in input of the word containing
+ /// the cursor) and cursor_char_position (the position of the cursor in that
+ /// word.)
+ /// We've constructed the map of options and their arguments as well if that
+ /// is
+ /// helpful for the completion.
+ ///
+ /// @param[in] interpreter
+ /// The command interpreter doing the completion.
+ ///
+ /// @param[in] input
+ /// The command line parsed into words
+ ///
+ /// @param[in] cursor_index
+ /// The index in \ainput of the word in which the cursor lies.
+ ///
+ /// @param[in] cursor_char_pos
+ /// The character position of the cursor in its argument word.
+ ///
+ /// @param[in] opt_element_vector
+ /// The results of the options parse of \a input.
+ ///
+ /// @param[in] match_start_point
+ /// @param[in] match_return_elements
+ /// See CommandObject::HandleCompletions for a description of how these
+ /// work.
+ ///
+ /// @param[out] word_complete
+ /// \btrue if this is a complete option value (a space will be inserted
+ /// after the
+ /// completion.) \bfalse otherwise.
+ ///
+ /// @param[out] matches
+ /// The array of matches returned.
+ ///
+ /// FIXME: This is the wrong return value, since we also need to make a
+ /// distinction between
+ /// total number of matches, and the window the user wants returned.
+ ///
+ /// @return
+ /// The number of completions.
+ //------------------------------------------------------------------
+ virtual int HandleArgumentCompletion(
+ Args &input, int &cursor_index, int &cursor_char_position,
+ OptionElementVector &opt_element_vector, int match_start_point,
+ int max_return_elements, bool &word_complete, StringList &matches) {
+ return 0;
+ }
+
+ bool HelpTextContainsWord(llvm::StringRef search_word,
+ bool search_short_help = true,
+ bool search_long_help = true,
+ bool search_syntax = true,
+ bool search_options = true);
+
+ //------------------------------------------------------------------
+ /// The flags accessor.
+ ///
+ /// @return
+ /// A reference to the Flags member variable.
+ //------------------------------------------------------------------
+ Flags &GetFlags() { return m_flags; }
+
+ //------------------------------------------------------------------
+ /// The flags const accessor.
+ ///
+ /// @return
+ /// A const reference to the Flags member variable.
+ //------------------------------------------------------------------
+ const Flags &GetFlags() const { return m_flags; }
+
+ //------------------------------------------------------------------
+ /// Get the command that appropriate for a "repeat" of the current command.
+ ///
+ /// @param[in] current_command_line
+ /// The complete current command line.
+ ///
+ /// @return
+ /// nullptr if there is no special repeat command - it will use the
+ /// current command line.
+ /// Otherwise a pointer to the command to be repeated.
+ /// If the returned string is the empty string, the command won't be
+ /// repeated.
+ //------------------------------------------------------------------
+ virtual const char *GetRepeatCommand(Args &current_command_args,
+ uint32_t index) {
+ return nullptr;
+ }
+
+ bool HasOverrideCallback() const {
+ return m_command_override_callback ||
+ m_deprecated_command_override_callback;
+ }
+
+ void SetOverrideCallback(lldb::CommandOverrideCallback callback,
+ void *baton) {
+ m_deprecated_command_override_callback = callback;
+ m_command_override_baton = baton;
+ }
+
+ void SetOverrideCallback(lldb::CommandOverrideCallbackWithResult callback,
+ void *baton) {
+ m_command_override_callback = callback;
+ m_command_override_baton = baton;
+ }
+
+ bool InvokeOverrideCallback(const char **argv, CommandReturnObject &result) {
+ if (m_command_override_callback)
+ return m_command_override_callback(m_command_override_baton, argv,
+ result);
+ else if (m_deprecated_command_override_callback)
+ return m_deprecated_command_override_callback(m_command_override_baton,
+ argv);
+ else
+ return false;
+ }
+
+ virtual bool Execute(const char *args_string,
+ CommandReturnObject &result) = 0;
+
+protected:
+ virtual const char *GetInvalidTargetDescription() {
+ return "invalid target, create a target using the 'target create' command";
+ }
+
+ virtual const char *GetInvalidProcessDescription() {
+ return "invalid process";
+ }
+
+ virtual const char *GetInvalidThreadDescription() { return "invalid thread"; }
+
+ virtual const char *GetInvalidFrameDescription() { return "invalid frame"; }
+
+ virtual const char *GetInvalidRegContextDescription() {
+ return "invalid frame, no registers";
+ }
+
+ // This is for use in the command interpreter, when you either want the
+ // selected target, or if no target
+ // is present you want to prime the dummy target with entities that will be
+ // copied over to new targets.
+ Target *GetSelectedOrDummyTarget(bool prefer_dummy = false);
+ Target *GetDummyTarget();
+
+ // If a command needs to use the "current" thread, use this call.
+ // Command objects will have an ExecutionContext to use, and that may or may
+ // not have a thread in it. If it
+ // does, you should use that by default, if not, then use the
+ // ExecutionContext's target's selected thread, etc...
+ // This call insulates you from the details of this calculation.
+ Thread *GetDefaultThread();
+
+ //------------------------------------------------------------------
+ /// Check the command to make sure anything required by this
+ /// command is available.
+ ///
+ /// @param[out] result
+ /// A command result object, if it is not okay to run the command
+ /// this will be filled in with a suitable error.
+ ///
+ /// @return
+ /// \b true if it is okay to run this command, \b false otherwise.
+ //------------------------------------------------------------------
+ bool CheckRequirements(CommandReturnObject &result);
+
+ void Cleanup();
+
+ CommandInterpreter &m_interpreter;
+ ExecutionContext m_exe_ctx;
+ std::unique_lock<std::recursive_mutex> m_api_locker;
+ std::string m_cmd_name;
+ std::string m_cmd_help_short;
+ std::string m_cmd_help_long;
+ std::string m_cmd_syntax;
+ Flags m_flags;
+ std::vector<CommandArgumentEntry> m_arguments;
+ lldb::CommandOverrideCallback m_deprecated_command_override_callback;
+ lldb::CommandOverrideCallbackWithResult m_command_override_callback;
+ void *m_command_override_baton;
+
+ // Helper function to populate IDs or ID ranges as the command argument data
+ // to the specified command argument entry.
+ static void AddIDsArgumentData(CommandArgumentEntry &arg,
+ lldb::CommandArgumentType ID,
+ lldb::CommandArgumentType IDRange);
};
-class CommandObjectParsed : public CommandObject
-{
+class CommandObjectParsed : public CommandObject {
public:
- CommandObjectParsed(CommandInterpreter &interpreter,
- const char *name,
- const char *help = nullptr,
- const char *syntax = nullptr,
- uint32_t flags = 0) :
- CommandObject (interpreter, name, help, syntax, flags) {}
-
- ~CommandObjectParsed() override = default;
-
- bool
- Execute(const char *args_string, CommandReturnObject &result) override;
-
+ CommandObjectParsed(CommandInterpreter &interpreter, const char *name,
+ const char *help = nullptr, const char *syntax = nullptr,
+ uint32_t flags = 0)
+ : CommandObject(interpreter, name, help, syntax, flags) {}
+
+ ~CommandObjectParsed() override = default;
+
+ bool Execute(const char *args_string, CommandReturnObject &result) override;
+
protected:
- virtual bool
- DoExecute (Args& command,
- CommandReturnObject &result) = 0;
-
- bool
- WantsRawCommandString() override
- {
- return false;
- }
+ virtual bool DoExecute(Args &command, CommandReturnObject &result) = 0;
+
+ bool WantsRawCommandString() override { return false; }
};
-class CommandObjectRaw : public CommandObject
-{
+class CommandObjectRaw : public CommandObject {
public:
- CommandObjectRaw(CommandInterpreter &interpreter,
- const char *name,
- const char *help = nullptr,
- const char *syntax = nullptr,
- uint32_t flags = 0) :
- CommandObject (interpreter, name, help, syntax, flags) {}
-
- ~CommandObjectRaw() override = default;
-
- bool
- Execute(const char *args_string, CommandReturnObject &result) override;
-
-protected:
- virtual bool
- DoExecute (const char *command, CommandReturnObject &result) = 0;
-
- bool
- WantsRawCommandString() override
- {
- return true;
- }
+ CommandObjectRaw(CommandInterpreter &interpreter, llvm::StringRef name,
+ llvm::StringRef help = "", llvm::StringRef syntax = "",
+ uint32_t flags = 0)
+ : CommandObject(interpreter, name, help, syntax, flags) {}
+
+ ~CommandObjectRaw() override = default;
+
+ bool Execute(const char *args_string, CommandReturnObject &result) override;
+
+protected:
+ virtual bool DoExecute(const char *command, CommandReturnObject &result) = 0;
+
+ bool WantsRawCommandString() override { return true; }
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/CommandObjectMultiword.h b/include/lldb/Interpreter/CommandObjectMultiword.h
index 3b7d1868a855..947272f4212e 100644
--- a/include/lldb/Interpreter/CommandObjectMultiword.h
+++ b/include/lldb/Interpreter/CommandObjectMultiword.h
@@ -22,183 +22,126 @@ namespace lldb_private {
// CommandObjectMultiword
//-------------------------------------------------------------------------
-class CommandObjectMultiword : public CommandObject
-{
-// These two want to iterate over the subcommand dictionary.
-friend class CommandInterpreter;
-friend class CommandObjectSyntax;
+class CommandObjectMultiword : public CommandObject {
+ // These two want to iterate over the subcommand dictionary.
+ friend class CommandInterpreter;
+ friend class CommandObjectSyntax;
+
public:
- CommandObjectMultiword(CommandInterpreter &interpreter,
- const char *name,
- const char *help = nullptr,
- const char *syntax = nullptr,
- uint32_t flags = 0);
-
- ~CommandObjectMultiword() override;
-
- bool
- IsMultiwordObject() override
- {
- return true;
- }
-
- CommandObjectMultiword*
- GetAsMultiwordCommand () override
- {
- return this;
- }
-
- bool
- LoadSubCommand(const char *cmd_name,
- const lldb::CommandObjectSP& command_obj) override;
-
- void
- GenerateHelpText(Stream &output_stream) override;
-
- lldb::CommandObjectSP
- GetSubcommandSP(const char *sub_cmd, StringList *matches = nullptr) override;
-
- CommandObject *
- GetSubcommandObject(const char *sub_cmd, StringList *matches = nullptr) override;
-
- void
- AproposAllSubCommands(const char *prefix,
- const char *search_word,
- StringList &commands_found,
- StringList &commands_help) override;
-
- bool
- WantsRawCommandString() override
- {
- return false;
- }
-
- int
- HandleCompletion(Args &input,
- int &cursor_index,
- int &cursor_char_position,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches) override;
-
- const char *
- GetRepeatCommand (Args &current_command_args, uint32_t index) override;
-
- bool
- Execute(const char *args_string,
- CommandReturnObject &result) override;
-
- bool
- IsRemovable() const override
- {
- return m_can_be_removed;
- }
-
- void
- SetRemovable (bool removable)
- {
- m_can_be_removed = removable;
- }
-
+ CommandObjectMultiword(CommandInterpreter &interpreter, const char *name,
+ const char *help = nullptr,
+ const char *syntax = nullptr, uint32_t flags = 0);
+
+ ~CommandObjectMultiword() override;
+
+ bool IsMultiwordObject() override { return true; }
+
+ CommandObjectMultiword *GetAsMultiwordCommand() override { return this; }
+
+ bool LoadSubCommand(llvm::StringRef cmd_name,
+ const lldb::CommandObjectSP &command_obj) override;
+
+ void GenerateHelpText(Stream &output_stream) override;
+
+ lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd,
+ StringList *matches = nullptr) override;
+
+ CommandObject *GetSubcommandObject(llvm::StringRef sub_cmd,
+ StringList *matches = nullptr) override;
+
+ void AproposAllSubCommands(llvm::StringRef prefix,
+ llvm::StringRef search_word,
+ StringList &commands_found,
+ StringList &commands_help) override;
+
+ bool WantsRawCommandString() override { return false; }
+
+ int HandleCompletion(Args &input, int &cursor_index,
+ int &cursor_char_position, int match_start_point,
+ int max_return_elements, bool &word_complete,
+ StringList &matches) override;
+
+ const char *GetRepeatCommand(Args &current_command_args,
+ uint32_t index) override;
+
+ bool Execute(const char *args_string, CommandReturnObject &result) override;
+
+ bool IsRemovable() const override { return m_can_be_removed; }
+
+ void SetRemovable(bool removable) { m_can_be_removed = removable; }
+
protected:
- CommandObject::CommandMap&
- GetSubcommandDictionary ()
- {
- return m_subcommand_dict;
- }
-
- CommandObject::CommandMap m_subcommand_dict;
- bool m_can_be_removed;
+ CommandObject::CommandMap &GetSubcommandDictionary() {
+ return m_subcommand_dict;
+ }
+
+ CommandObject::CommandMap m_subcommand_dict;
+ bool m_can_be_removed;
};
-
-class CommandObjectProxy : public CommandObject
-{
+
+class CommandObjectProxy : public CommandObject {
public:
- CommandObjectProxy(CommandInterpreter &interpreter,
- const char *name,
- const char *help = nullptr,
- const char *syntax = nullptr,
- uint32_t flags = 0);
-
- ~CommandObjectProxy() override;
-
- // Subclasses must provide a command object that will be transparently
- // used for this object.
- virtual CommandObject *
- GetProxyCommandObject() = 0;
-
- const char *
- GetHelpLong() override;
-
- bool
- IsRemovable() const override;
-
- bool
- IsMultiwordObject() override;
-
- CommandObjectMultiword*
- GetAsMultiwordCommand () override;
-
- void
- GenerateHelpText (Stream &result) override;
-
- lldb::CommandObjectSP
- GetSubcommandSP(const char *sub_cmd, StringList *matches = nullptr) override;
-
- CommandObject *
- GetSubcommandObject(const char *sub_cmd, StringList *matches = nullptr) override;
-
- void
- AproposAllSubCommands(const char *prefix,
- const char *search_word,
- StringList &commands_found,
- StringList &commands_help) override;
-
- bool
- LoadSubCommand(const char *cmd_name,
- const lldb::CommandObjectSP& command_obj) override;
-
- bool
- WantsRawCommandString() override;
-
- bool
- WantsCompletion() override;
-
- Options *
- GetOptions() override;
-
- int
- HandleCompletion(Args &input,
- int &cursor_index,
- int &cursor_char_position,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches) override;
-
- int
- HandleArgumentCompletion(Args &input,
- int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches) override;
-
- const char *
- GetRepeatCommand(Args &current_command_args,
- uint32_t index) override;
-
- bool
- Execute(const char *args_string,
- CommandReturnObject &result) override;
+ CommandObjectProxy(CommandInterpreter &interpreter, const char *name,
+ const char *help = nullptr, const char *syntax = nullptr,
+ uint32_t flags = 0);
+
+ ~CommandObjectProxy() override;
+
+ // Subclasses must provide a command object that will be transparently
+ // used for this object.
+ virtual CommandObject *GetProxyCommandObject() = 0;
+
+ llvm::StringRef GetHelpLong() override;
+
+ bool IsRemovable() const override;
+
+ bool IsMultiwordObject() override;
+
+ CommandObjectMultiword *GetAsMultiwordCommand() override;
+
+ void GenerateHelpText(Stream &result) override;
+
+ lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd,
+ StringList *matches = nullptr) override;
+
+ CommandObject *GetSubcommandObject(llvm::StringRef sub_cmd,
+ StringList *matches = nullptr) override;
+
+ void AproposAllSubCommands(llvm::StringRef prefix,
+ llvm::StringRef search_word,
+ StringList &commands_found,
+ StringList &commands_help) override;
+
+ bool LoadSubCommand(llvm::StringRef cmd_name,
+ const lldb::CommandObjectSP &command_obj) override;
+
+ bool WantsRawCommandString() override;
+
+ bool WantsCompletion() override;
+
+ Options *GetOptions() override;
+
+ int HandleCompletion(Args &input, int &cursor_index,
+ int &cursor_char_position, int match_start_point,
+ int max_return_elements, bool &word_complete,
+ StringList &matches) override;
+
+ int HandleArgumentCompletion(Args &input, int &cursor_index,
+ int &cursor_char_position,
+ OptionElementVector &opt_element_vector,
+ int match_start_point, int max_return_elements,
+ bool &word_complete,
+ StringList &matches) override;
+
+ const char *GetRepeatCommand(Args &current_command_args,
+ uint32_t index) override;
+
+ bool Execute(const char *args_string, CommandReturnObject &result) override;
protected:
- // These two want to iterate over the subcommand dictionary.
- friend class CommandInterpreter;
- friend class CommandObjectSyntax;
+ // These two want to iterate over the subcommand dictionary.
+ friend class CommandInterpreter;
+ friend class CommandObjectSyntax;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/CommandObjectRegexCommand.h b/include/lldb/Interpreter/CommandObjectRegexCommand.h
index 9f8974a32bb2..44dc4f2bfd58 100644
--- a/include/lldb/Interpreter/CommandObjectRegexCommand.h
+++ b/include/lldb/Interpreter/CommandObjectRegexCommand.h
@@ -25,58 +25,42 @@ namespace lldb_private {
// CommandObjectRegexCommand
//-------------------------------------------------------------------------
-class CommandObjectRegexCommand : public CommandObjectRaw
-{
+class CommandObjectRegexCommand : public CommandObjectRaw {
public:
- CommandObjectRegexCommand (CommandInterpreter &interpreter,
- const char *name,
- const char *help,
- const char *syntax,
- uint32_t max_matches,
- uint32_t completion_type_mask,
- bool is_removable);
-
- ~CommandObjectRegexCommand() override;
-
- bool
- IsRemovable () const override { return m_is_removable; }
-
- bool
- AddRegexCommand (const char *re_cstr, const char *command_cstr);
-
- bool
- HasRegexEntries () const
- {
- return !m_entries.empty();
- }
-
- int
- HandleCompletion (Args &input,
- int &cursor_index,
- int &cursor_char_position,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches) override;
+ CommandObjectRegexCommand(CommandInterpreter &interpreter, llvm::StringRef name,
+ llvm::StringRef help, llvm::StringRef syntax,
+ uint32_t max_matches, uint32_t completion_type_mask,
+ bool is_removable);
+
+ ~CommandObjectRegexCommand() override;
+
+ bool IsRemovable() const override { return m_is_removable; }
+
+ bool AddRegexCommand(const char *re_cstr, const char *command_cstr);
+
+ bool HasRegexEntries() const { return !m_entries.empty(); }
+
+ int HandleCompletion(Args &input, int &cursor_index,
+ int &cursor_char_position, int match_start_point,
+ int max_return_elements, bool &word_complete,
+ StringList &matches) override;
protected:
- bool
- DoExecute (const char *command, CommandReturnObject &result) override;
+ bool DoExecute(const char *command, CommandReturnObject &result) override;
- struct Entry
- {
- RegularExpression regex;
- std::string command;
- };
+ struct Entry {
+ RegularExpression regex;
+ std::string command;
+ };
- typedef std::list<Entry> EntryCollection;
- const uint32_t m_max_matches;
- const uint32_t m_completion_type_mask;
- EntryCollection m_entries;
- bool m_is_removable;
+ typedef std::list<Entry> EntryCollection;
+ const uint32_t m_max_matches;
+ const uint32_t m_completion_type_mask;
+ EntryCollection m_entries;
+ bool m_is_removable;
private:
- DISALLOW_COPY_AND_ASSIGN (CommandObjectRegexCommand);
+ DISALLOW_COPY_AND_ASSIGN(CommandObjectRegexCommand);
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/CommandOptionValidators.h b/include/lldb/Interpreter/CommandOptionValidators.h
index 395cb8ed3d9e..05724cace172 100644
--- a/include/lldb/Interpreter/CommandOptionValidators.h
+++ b/include/lldb/Interpreter/CommandOptionValidators.h
@@ -21,11 +21,11 @@ namespace lldb_private {
class Platform;
class ExecutionContext;
-class PosixPlatformCommandOptionValidator : public OptionValidator
-{
- bool IsValid(Platform &platform, const ExecutionContext &target) const override;
- const char* ShortConditionString() const override;
- const char* LongConditionString() const override;
+class PosixPlatformCommandOptionValidator : public OptionValidator {
+ bool IsValid(Platform &platform,
+ const ExecutionContext &target) const override;
+ const char *ShortConditionString() const override;
+ const char *LongConditionString() const override;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/CommandReturnObject.h b/include/lldb/Interpreter/CommandReturnObject.h
index e3a1d9f657cb..40db5635afa4 100644
--- a/include/lldb/Interpreter/CommandReturnObject.h
+++ b/include/lldb/Interpreter/CommandReturnObject.h
@@ -14,193 +14,167 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/STLUtils.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/StreamTee.h"
+#include "lldb/lldb-private.h"
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FormatVariadic.h"
+
+#include <memory>
namespace lldb_private {
-class CommandReturnObject
-{
+class CommandReturnObject {
public:
- CommandReturnObject ();
-
- ~CommandReturnObject ();
-
- const char *
- GetOutputData ()
- {
- lldb::StreamSP stream_sp (m_out_stream.GetStreamAtIndex (eStreamStringIndex));
- if (stream_sp)
- return static_cast<StreamString *>(stream_sp.get())->GetData();
- return "";
+ CommandReturnObject();
+
+ ~CommandReturnObject();
+
+ llvm::StringRef GetOutputData() {
+ lldb::StreamSP stream_sp(m_out_stream.GetStreamAtIndex(eStreamStringIndex));
+ if (stream_sp)
+ return static_pointer_cast<StreamString>(stream_sp)->GetString();
+ return llvm::StringRef();
+ }
+
+ llvm::StringRef GetErrorData() {
+ lldb::StreamSP stream_sp(m_err_stream.GetStreamAtIndex(eStreamStringIndex));
+ if (stream_sp)
+ return static_pointer_cast<StreamString>(stream_sp)->GetString();
+ return llvm::StringRef();
+ }
+
+ Stream &GetOutputStream() {
+ // Make sure we at least have our normal string stream output stream
+ lldb::StreamSP stream_sp(m_out_stream.GetStreamAtIndex(eStreamStringIndex));
+ if (!stream_sp) {
+ stream_sp.reset(new StreamString());
+ m_out_stream.SetStreamAtIndex(eStreamStringIndex, stream_sp);
}
-
- const char *
- GetErrorData ()
- {
- lldb::StreamSP stream_sp (m_err_stream.GetStreamAtIndex (eStreamStringIndex));
- if (stream_sp)
- return static_cast<StreamString *>(stream_sp.get())->GetData();
- else
- return "";
+ return m_out_stream;
+ }
+
+ Stream &GetErrorStream() {
+ // Make sure we at least have our normal string stream output stream
+ lldb::StreamSP stream_sp(m_err_stream.GetStreamAtIndex(eStreamStringIndex));
+ if (!stream_sp) {
+ stream_sp.reset(new StreamString());
+ m_err_stream.SetStreamAtIndex(eStreamStringIndex, stream_sp);
}
+ return m_err_stream;
+ }
- Stream &
- GetOutputStream ()
- {
- // Make sure we at least have our normal string stream output stream
- lldb::StreamSP stream_sp (m_out_stream.GetStreamAtIndex (eStreamStringIndex));
- if (!stream_sp)
- {
- stream_sp.reset (new StreamString());
- m_out_stream.SetStreamAtIndex (eStreamStringIndex, stream_sp);
- }
- return m_out_stream;
- }
+ void SetImmediateOutputFile(FILE *fh, bool transfer_fh_ownership = false) {
+ lldb::StreamSP stream_sp(new StreamFile(fh, transfer_fh_ownership));
+ m_out_stream.SetStreamAtIndex(eImmediateStreamIndex, stream_sp);
+ }
- Stream &
- GetErrorStream ()
- {
- // Make sure we at least have our normal string stream output stream
- lldb::StreamSP stream_sp (m_err_stream.GetStreamAtIndex (eStreamStringIndex));
- if (!stream_sp)
- {
- stream_sp.reset (new StreamString());
- m_err_stream.SetStreamAtIndex (eStreamStringIndex, stream_sp);
- }
- return m_err_stream;
- }
+ void SetImmediateErrorFile(FILE *fh, bool transfer_fh_ownership = false) {
+ lldb::StreamSP stream_sp(new StreamFile(fh, transfer_fh_ownership));
+ m_err_stream.SetStreamAtIndex(eImmediateStreamIndex, stream_sp);
+ }
- void
- SetImmediateOutputFile (FILE *fh, bool transfer_fh_ownership = false)
- {
- lldb::StreamSP stream_sp (new StreamFile (fh, transfer_fh_ownership));
- m_out_stream.SetStreamAtIndex (eImmediateStreamIndex, stream_sp);
- }
-
- void
- SetImmediateErrorFile (FILE *fh, bool transfer_fh_ownership = false)
- {
- lldb::StreamSP stream_sp (new StreamFile (fh, transfer_fh_ownership));
- m_err_stream.SetStreamAtIndex (eImmediateStreamIndex, stream_sp);
- }
-
- void
- SetImmediateOutputStream (const lldb::StreamSP &stream_sp)
- {
- m_out_stream.SetStreamAtIndex (eImmediateStreamIndex, stream_sp);
- }
-
- void
- SetImmediateErrorStream (const lldb::StreamSP &stream_sp)
- {
- m_err_stream.SetStreamAtIndex (eImmediateStreamIndex, stream_sp);
- }
-
- lldb::StreamSP
- GetImmediateOutputStream ()
- {
- return m_out_stream.GetStreamAtIndex (eImmediateStreamIndex);
- }
-
- lldb::StreamSP
- GetImmediateErrorStream ()
- {
- return m_err_stream.GetStreamAtIndex (eImmediateStreamIndex);
- }
-
- void
- Clear();
+ void SetImmediateOutputStream(const lldb::StreamSP &stream_sp) {
+ m_out_stream.SetStreamAtIndex(eImmediateStreamIndex, stream_sp);
+ }
- void
- AppendMessage (const char *in_string);
+ void SetImmediateErrorStream(const lldb::StreamSP &stream_sp) {
+ m_err_stream.SetStreamAtIndex(eImmediateStreamIndex, stream_sp);
+ }
- void
- AppendMessageWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
+ lldb::StreamSP GetImmediateOutputStream() {
+ return m_out_stream.GetStreamAtIndex(eImmediateStreamIndex);
+ }
- void
- AppendRawWarning (const char *in_string);
+ lldb::StreamSP GetImmediateErrorStream() {
+ return m_err_stream.GetStreamAtIndex(eImmediateStreamIndex);
+ }
- void
- AppendWarning (const char *in_string);
+ void Clear();
- void
- AppendWarningWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
+ void AppendMessage(llvm::StringRef in_string);
- void
- AppendError (const char *in_string);
+ void AppendMessageWithFormat(const char *format, ...)
+ __attribute__((format(printf, 2, 3)));
- void
- AppendRawError (const char *in_string);
+ void AppendRawWarning(llvm::StringRef in_string);
- void
- AppendErrorWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
+ void AppendWarning(llvm::StringRef in_string);
- void
- SetError(const Error &error,
- const char *fallback_error_cstr = nullptr);
-
- void
- SetError (const char *error_cstr);
+ void AppendWarningWithFormat(const char *format, ...)
+ __attribute__((format(printf, 2, 3)));
- lldb::ReturnStatus
- GetStatus();
+ void AppendError(llvm::StringRef in_string);
- void
- SetStatus (lldb::ReturnStatus status);
+ void AppendRawError(llvm::StringRef in_string);
- bool
- Succeeded ();
+ void AppendErrorWithFormat(const char *format, ...)
+ __attribute__((format(printf, 2, 3)));
- bool
- HasResult ();
+ template <typename... Args>
+ void AppendMessageWithFormatv(const char *format, Args &&... args) {
+ AppendMessage(llvm::formatv(format, std::forward<Args>(args)...).str());
+ }
- bool
- GetDidChangeProcessState ();
+ template <typename... Args>
+ void AppendWarningWithFormatv(const char *format, Args &&... args) {
+ AppendWarning(llvm::formatv(format, std::forward<Args>(args)...).str());
+ }
- void
- SetDidChangeProcessState (bool b);
+ template <typename... Args>
+ void AppendErrorWithFormatv(const char *format, Args &&... args) {
+ AppendError(llvm::formatv(format, std::forward<Args>(args)...).str());
+ }
- bool
- GetInteractive () const;
-
- void
- SetInteractive (bool b);
-
- bool
- GetAbnormalStopWasExpected() const
- {
- return m_abnormal_stop_was_expected;
- }
-
- void
- SetAbnormalStopWasExpected(bool signal_was_expected)
- {
- m_abnormal_stop_was_expected = signal_was_expected;
- }
+ void SetError(const Error &error, const char *fallback_error_cstr = nullptr);
+
+ void SetError(llvm::StringRef error_cstr);
+
+ lldb::ReturnStatus GetStatus();
+
+ void SetStatus(lldb::ReturnStatus status);
+
+ bool Succeeded();
+
+ bool HasResult();
+
+ bool GetDidChangeProcessState();
+
+ void SetDidChangeProcessState(bool b);
+
+ bool GetInteractive() const;
+
+ void SetInteractive(bool b);
+
+ bool GetAbnormalStopWasExpected() const {
+ return m_abnormal_stop_was_expected;
+ }
+
+ void SetAbnormalStopWasExpected(bool signal_was_expected) {
+ m_abnormal_stop_was_expected = signal_was_expected;
+ }
private:
- enum
- {
- eStreamStringIndex = 0,
- eImmediateStreamIndex = 1
- };
-
- StreamTee m_out_stream;
- StreamTee m_err_stream;
-
- lldb::ReturnStatus m_status;
- bool m_did_change_process_state;
- bool m_interactive; // If true, then the input handle from the debugger will be hooked up
- bool m_abnormal_stop_was_expected; // This is to support eHandleCommandFlagStopOnCrash vrs. attach.
- // The attach command often ends up with the process stopped due to a signal.
- // Normally that would mean stop on crash should halt batch execution, but we
- // obviously don't want that for attach. Using this flag, the attach command
- // (and anything else for which this is relevant) can say that the signal is
- // expected, and batch command execution can continue.
+ enum { eStreamStringIndex = 0, eImmediateStreamIndex = 1 };
+
+ StreamTee m_out_stream;
+ StreamTee m_err_stream;
+
+ lldb::ReturnStatus m_status;
+ bool m_did_change_process_state;
+ bool m_interactive; // If true, then the input handle from the debugger will
+ // be hooked up
+ bool m_abnormal_stop_was_expected; // This is to support
+ // eHandleCommandFlagStopOnCrash vrs.
+ // attach.
+ // The attach command often ends up with the process stopped due to a signal.
+ // Normally that would mean stop on crash should halt batch execution, but we
+ // obviously don't want that for attach. Using this flag, the attach command
+ // (and anything else for which this is relevant) can say that the signal is
+ // expected, and batch command execution can continue.
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionGroupArchitecture.h b/include/lldb/Interpreter/OptionGroupArchitecture.h
index 5ee608506c04..742cd6d1321d 100644
--- a/include/lldb/Interpreter/OptionGroupArchitecture.h
+++ b/include/lldb/Interpreter/OptionGroupArchitecture.h
@@ -14,8 +14,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Interpreter/Options.h"
#include "lldb/Core/ArchSpec.h"
+#include "lldb/Interpreter/Options.h"
namespace lldb_private {
@@ -23,44 +23,28 @@ namespace lldb_private {
// OptionGroupArchitecture
//-------------------------------------------------------------------------
-class OptionGroupArchitecture : public OptionGroup
-{
+class OptionGroupArchitecture : public OptionGroup {
public:
- OptionGroupArchitecture ();
-
- ~OptionGroupArchitecture() override;
+ OptionGroupArchitecture();
+
+ ~OptionGroupArchitecture() override;
+
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
+
+ Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
+ ExecutionContext *execution_context) override;
+
+ void OptionParsingStarting(ExecutionContext *execution_context) override;
- uint32_t
- GetNumDefinitions() override;
-
- const OptionDefinition*
- GetDefinitions() override;
-
- Error
- SetOptionValue(CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value) override;
-
- void
- OptionParsingStarting(CommandInterpreter &interpreter) override;
-
- bool
- GetArchitecture (Platform *platform, ArchSpec &arch);
+ bool GetArchitecture(Platform *platform, ArchSpec &arch);
- bool
- ArchitectureWasSpecified () const
- {
- return !m_arch_str.empty();
- }
+ bool ArchitectureWasSpecified() const { return !m_arch_str.empty(); }
- const char *
- GetArchitectureName()
- {
- return (m_arch_str.empty() ? nullptr : m_arch_str.c_str());
- }
+ llvm::StringRef GetArchitectureName() const { return m_arch_str; }
protected:
- std::string m_arch_str; // Save the arch triple in case a platform is specified after the architecture
+ std::string m_arch_str; // Save the arch triple in case a platform is
+ // specified after the architecture
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionGroupBoolean.h b/include/lldb/Interpreter/OptionGroupBoolean.h
index 881a1bdf4be6..931a6d73e728 100644
--- a/include/lldb/Interpreter/OptionGroupBoolean.h
+++ b/include/lldb/Interpreter/OptionGroupBoolean.h
@@ -14,66 +14,44 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/OptionValueBoolean.h"
+#include "lldb/Interpreter/Options.h"
namespace lldb_private {
- //-------------------------------------------------------------------------
- // OptionGroupBoolean
- //-------------------------------------------------------------------------
-
- class OptionGroupBoolean : public OptionGroup
- {
- public:
- // When 'no_argument_toggle_default' is true, then setting the option
- // value does NOT require an argument, it sets the boolean value to the
- // inverse of the default value
- OptionGroupBoolean (uint32_t usage_mask,
- bool required,
- const char *long_option,
- int short_option,
- const char *usage_text,
- bool default_value,
- bool no_argument_toggle_default);
-
- ~OptionGroupBoolean() override;
+//-------------------------------------------------------------------------
+// OptionGroupBoolean
+//-------------------------------------------------------------------------
+
+class OptionGroupBoolean : public OptionGroup {
+public:
+ // When 'no_argument_toggle_default' is true, then setting the option
+ // value does NOT require an argument, it sets the boolean value to the
+ // inverse of the default value
+ OptionGroupBoolean(uint32_t usage_mask, bool required,
+ const char *long_option, int short_option,
+ const char *usage_text, bool default_value,
+ bool no_argument_toggle_default);
+
+ ~OptionGroupBoolean() override;
+
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
+ return llvm::ArrayRef<OptionDefinition>(&m_option_definition, 1);
+ }
+
+ Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
+ ExecutionContext *execution_context) override;
+ Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
+
+ void OptionParsingStarting(ExecutionContext *execution_context) override;
+
+ OptionValueBoolean &GetOptionValue() { return m_value; }
+
+ const OptionValueBoolean &GetOptionValue() const { return m_value; }
- uint32_t
- GetNumDefinitions() override
- {
- return 1;
- }
-
- const OptionDefinition*
- GetDefinitions() override
- {
- return &m_option_definition;
- }
-
- Error
- SetOptionValue(CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value) override;
-
- void
- OptionParsingStarting(CommandInterpreter &interpreter) override;
-
- OptionValueBoolean &
- GetOptionValue ()
- {
- return m_value;
- }
-
- const OptionValueBoolean &
- GetOptionValue () const
- {
- return m_value;
- }
-
- protected:
- OptionValueBoolean m_value;
- OptionDefinition m_option_definition;
- };
+protected:
+ OptionValueBoolean m_value;
+ OptionDefinition m_option_definition;
+};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionGroupFile.h b/include/lldb/Interpreter/OptionGroupFile.h
index 9e35dd43ab7a..93e3ed75d342 100644
--- a/include/lldb/Interpreter/OptionGroupFile.h
+++ b/include/lldb/Interpreter/OptionGroupFile.h
@@ -14,9 +14,9 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/OptionValueFileSpec.h"
#include "lldb/Interpreter/OptionValueFileSpecList.h"
+#include "lldb/Interpreter/Options.h"
namespace lldb_private {
@@ -24,109 +24,65 @@ namespace lldb_private {
// OptionGroupFile
//-------------------------------------------------------------------------
-class OptionGroupFile : public OptionGroup
-{
+class OptionGroupFile : public OptionGroup {
public:
- OptionGroupFile (uint32_t usage_mask,
- bool required,
- const char *long_option,
- int short_option,
- uint32_t completion_type,
- lldb::CommandArgumentType argument_type,
- const char *usage_text);
-
- ~OptionGroupFile() override;
-
- uint32_t
- GetNumDefinitions() override
- {
- return 1;
- }
-
- const OptionDefinition*
- GetDefinitions() override
- {
- return &m_option_definition;
- }
-
- Error
- SetOptionValue(CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value) override;
-
- void
- OptionParsingStarting(CommandInterpreter &interpreter) override;
-
- OptionValueFileSpec &
- GetOptionValue ()
- {
- return m_file;
- }
-
- const OptionValueFileSpec &
- GetOptionValue () const
- {
- return m_file;
- }
+ OptionGroupFile(uint32_t usage_mask, bool required, const char *long_option,
+ int short_option, uint32_t completion_type,
+ lldb::CommandArgumentType argument_type,
+ const char *usage_text);
+
+ ~OptionGroupFile() override;
+
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
+ return llvm::ArrayRef<OptionDefinition>(&m_option_definition, 1);
+ }
+
+ Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
+ ExecutionContext *execution_context) override;
+ Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
+
+ void OptionParsingStarting(ExecutionContext *execution_context) override;
+
+ OptionValueFileSpec &GetOptionValue() { return m_file; }
+
+ const OptionValueFileSpec &GetOptionValue() const { return m_file; }
protected:
- OptionValueFileSpec m_file;
- OptionDefinition m_option_definition;
+ OptionValueFileSpec m_file;
+ OptionDefinition m_option_definition;
};
//-------------------------------------------------------------------------
// OptionGroupFileList
//-------------------------------------------------------------------------
-class OptionGroupFileList : public OptionGroup
-{
+class OptionGroupFileList : public OptionGroup {
public:
-
- OptionGroupFileList (uint32_t usage_mask,
- bool required,
- const char *long_option,
- int short_option,
- uint32_t completion_type,
- lldb::CommandArgumentType argument_type,
- const char *usage_text);
-
- ~OptionGroupFileList() override;
-
- uint32_t
- GetNumDefinitions() override
- {
- return 1;
- }
-
- const OptionDefinition*
- GetDefinitions() override
- {
- return &m_option_definition;
- }
-
- Error
- SetOptionValue(CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value) override;
-
- void
- OptionParsingStarting(CommandInterpreter &interpreter) override;
-
- OptionValueFileSpecList &
- GetOptionValue ()
- {
- return m_file_list;
- }
-
- const OptionValueFileSpecList &
- GetOptionValue () const
- {
- return m_file_list;
- }
-
+ OptionGroupFileList(uint32_t usage_mask, bool required,
+ const char *long_option, int short_option,
+ uint32_t completion_type,
+ lldb::CommandArgumentType argument_type,
+ const char *usage_text);
+
+ ~OptionGroupFileList() override;
+
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
+ return llvm::ArrayRef<OptionDefinition>(&m_option_definition, 1);
+ }
+
+ Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
+ ExecutionContext *execution_context) override;
+ Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
+
+ void OptionParsingStarting(ExecutionContext *execution_context) override;
+
+ OptionValueFileSpecList &GetOptionValue() { return m_file_list; }
+
+ const OptionValueFileSpecList &GetOptionValue() const { return m_file_list; }
+
protected:
- OptionValueFileSpecList m_file_list;
- OptionDefinition m_option_definition;
+ OptionValueFileSpecList m_file_list;
+ OptionDefinition m_option_definition;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionGroupFormat.h b/include/lldb/Interpreter/OptionGroupFormat.h
index 9a96cc505de4..f3a42037afc5 100644
--- a/include/lldb/Interpreter/OptionGroupFormat.h
+++ b/include/lldb/Interpreter/OptionGroupFormat.h
@@ -14,10 +14,10 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/OptionValueFormat.h"
#include "lldb/Interpreter/OptionValueSInt64.h"
#include "lldb/Interpreter/OptionValueUInt64.h"
+#include "lldb/Interpreter/Options.h"
namespace lldb_private {
@@ -25,103 +25,62 @@ namespace lldb_private {
// OptionGroupFormat
//-------------------------------------------------------------------------
-class OptionGroupFormat : public OptionGroup
-{
+class OptionGroupFormat : public OptionGroup {
public:
- static const uint32_t OPTION_GROUP_FORMAT = LLDB_OPT_SET_1;
- static const uint32_t OPTION_GROUP_GDB_FMT = LLDB_OPT_SET_2;
- static const uint32_t OPTION_GROUP_SIZE = LLDB_OPT_SET_3;
- static const uint32_t OPTION_GROUP_COUNT = LLDB_OPT_SET_4;
-
- OptionGroupFormat (lldb::Format default_format,
- uint64_t default_byte_size = UINT64_MAX, // Pass UINT64_MAX to disable the "--size" option
- uint64_t default_count = UINT64_MAX); // Pass UINT64_MAX to disable the "--count" option
-
- ~OptionGroupFormat() override;
-
- uint32_t
- GetNumDefinitions() override;
-
- const OptionDefinition*
- GetDefinitions() override;
-
- Error
- SetOptionValue(CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value) override;
-
- void
- OptionParsingStarting(CommandInterpreter &interpreter) override;
-
- lldb::Format
- GetFormat () const
- {
- return m_format.GetCurrentValue();
- }
-
- OptionValueFormat &
- GetFormatValue()
- {
- return m_format;
- }
-
- const OptionValueFormat &
- GetFormatValue() const
- {
- return m_format;
- }
-
- OptionValueUInt64 &
- GetByteSizeValue()
- {
- return m_byte_size;
- }
-
- const OptionValueUInt64 &
- GetByteSizeValue() const
- {
- return m_byte_size;
- }
-
- OptionValueUInt64 &
- GetCountValue()
- {
- return m_count;
- }
-
- const OptionValueUInt64 &
- GetCountValue() const
- {
- return m_count;
- }
-
- bool
- HasGDBFormat () const
- {
- return m_has_gdb_format;
- }
-
- bool
- AnyOptionWasSet () const
- {
- return m_format.OptionWasSet() ||
- m_byte_size.OptionWasSet() ||
- m_count.OptionWasSet();
- }
+ static const uint32_t OPTION_GROUP_FORMAT = LLDB_OPT_SET_1;
+ static const uint32_t OPTION_GROUP_GDB_FMT = LLDB_OPT_SET_2;
+ static const uint32_t OPTION_GROUP_SIZE = LLDB_OPT_SET_3;
+ static const uint32_t OPTION_GROUP_COUNT = LLDB_OPT_SET_4;
+
+ OptionGroupFormat(
+ lldb::Format default_format,
+ uint64_t default_byte_size =
+ UINT64_MAX, // Pass UINT64_MAX to disable the "--size" option
+ uint64_t default_count =
+ UINT64_MAX); // Pass UINT64_MAX to disable the "--count" option
+
+ ~OptionGroupFormat() override;
+
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
+
+ Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
+ ExecutionContext *execution_context) override;
+ Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
+
+ void OptionParsingStarting(ExecutionContext *execution_context) override;
+
+ lldb::Format GetFormat() const { return m_format.GetCurrentValue(); }
+
+ OptionValueFormat &GetFormatValue() { return m_format; }
+
+ const OptionValueFormat &GetFormatValue() const { return m_format; }
+
+ OptionValueUInt64 &GetByteSizeValue() { return m_byte_size; }
+
+ const OptionValueUInt64 &GetByteSizeValue() const { return m_byte_size; }
+
+ OptionValueUInt64 &GetCountValue() { return m_count; }
+
+ const OptionValueUInt64 &GetCountValue() const { return m_count; }
+
+ bool HasGDBFormat() const { return m_has_gdb_format; }
+
+ bool AnyOptionWasSet() const {
+ return m_format.OptionWasSet() || m_byte_size.OptionWasSet() ||
+ m_count.OptionWasSet();
+ }
protected:
- bool
- ParserGDBFormatLetter (CommandInterpreter &interpreter,
- char format_letter,
- lldb::Format &format,
- uint32_t &byte_size);
-
- OptionValueFormat m_format;
- OptionValueUInt64 m_byte_size;
- OptionValueUInt64 m_count;
- char m_prev_gdb_format;
- char m_prev_gdb_size;
- bool m_has_gdb_format;
+ bool ParserGDBFormatLetter(ExecutionContext *execution_context,
+ char format_letter, lldb::Format &format,
+ uint32_t &byte_size);
+
+ OptionValueFormat m_format;
+ OptionValueUInt64 m_byte_size;
+ OptionValueUInt64 m_count;
+ char m_prev_gdb_format;
+ char m_prev_gdb_size;
+ bool m_has_gdb_format;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionGroupOutputFile.h b/include/lldb/Interpreter/OptionGroupOutputFile.h
index e6083714c48d..cb891f0f7ecb 100644
--- a/include/lldb/Interpreter/OptionGroupOutputFile.h
+++ b/include/lldb/Interpreter/OptionGroupOutputFile.h
@@ -14,57 +14,40 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/OptionValueBoolean.h"
#include "lldb/Interpreter/OptionValueFileSpec.h"
+#include "lldb/Interpreter/Options.h"
namespace lldb_private {
//-------------------------------------------------------------------------
// OptionGroupOutputFile
//-------------------------------------------------------------------------
-class OptionGroupOutputFile : public OptionGroup
-{
+class OptionGroupOutputFile : public OptionGroup {
public:
- OptionGroupOutputFile ();
-
- ~OptionGroupOutputFile() override;
+ OptionGroupOutputFile();
+
+ ~OptionGroupOutputFile() override;
+
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
+
+ Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
+ ExecutionContext *execution_context) override;
+ Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
+
+ void OptionParsingStarting(ExecutionContext *execution_context) override;
+
+ const OptionValueFileSpec &GetFile() { return m_file; }
- uint32_t
- GetNumDefinitions() override;
-
- const OptionDefinition*
- GetDefinitions() override;
-
- Error
- SetOptionValue(CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value) override;
-
- void
- OptionParsingStarting(CommandInterpreter &interpreter) override;
-
- const OptionValueFileSpec &
- GetFile ()
- {
- return m_file;
- }
+ const OptionValueBoolean &GetAppend() { return m_append; }
- const OptionValueBoolean &
- GetAppend ()
- {
- return m_append;
- }
-
- bool
- AnyOptionWasSet () const
- {
- return m_file.OptionWasSet() || m_append.OptionWasSet();
- }
+ bool AnyOptionWasSet() const {
+ return m_file.OptionWasSet() || m_append.OptionWasSet();
+ }
protected:
- OptionValueFileSpec m_file;
- OptionValueBoolean m_append;
+ OptionValueFileSpec m_file;
+ OptionValueBoolean m_append;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionGroupPlatform.h b/include/lldb/Interpreter/OptionGroupPlatform.h
index 68880236accc..c51ff5c1f48d 100644
--- a/include/lldb/Interpreter/OptionGroupPlatform.h
+++ b/include/lldb/Interpreter/OptionGroupPlatform.h
@@ -24,93 +24,58 @@ namespace lldb_private {
//
// Make platform options available to any commands that need the settings.
//-------------------------------------------------------------------------
-class OptionGroupPlatform : public OptionGroup
-{
+class OptionGroupPlatform : public OptionGroup {
public:
- OptionGroupPlatform (bool include_platform_option) :
- OptionGroup(),
- m_platform_name (),
- m_sdk_sysroot (),
- m_os_version_major (UINT32_MAX),
- m_os_version_minor (UINT32_MAX),
- m_os_version_update (UINT32_MAX),
- m_include_platform_option (include_platform_option)
- {
- }
-
- ~OptionGroupPlatform() override = default;
-
- uint32_t
- GetNumDefinitions() override;
-
- const OptionDefinition*
- GetDefinitions() override;
-
- Error
- SetOptionValue(CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value) override;
-
- void
- OptionParsingStarting(CommandInterpreter &interpreter) override;
-
- lldb::PlatformSP
- CreatePlatformWithOptions (CommandInterpreter &interpreter,
- const ArchSpec &arch,
- bool make_selected,
- Error& error,
- ArchSpec &platform_arch) const;
-
- bool
- PlatformWasSpecified () const
- {
- return !m_platform_name.empty();
- }
-
- void
- SetPlatformName (const char *platform_name)
- {
- if (platform_name && platform_name[0])
- m_platform_name.assign (platform_name);
- else
- m_platform_name.clear();
- }
-
- const ConstString &
- GetSDKRootDirectory () const
- {
- return m_sdk_sysroot;
- }
-
- void
- SetSDKRootDirectory (const ConstString &sdk_root_directory)
- {
- m_sdk_sysroot = sdk_root_directory;
- }
-
- const ConstString &
- GetSDKBuild () const
- {
- return m_sdk_build;
- }
-
- void
- SetSDKBuild (const ConstString &sdk_build)
- {
- m_sdk_build = sdk_build;
- }
-
- bool
- PlatformMatches(const lldb::PlatformSP &platform_sp) const;
+ OptionGroupPlatform(bool include_platform_option)
+ : OptionGroup(), m_platform_name(), m_sdk_sysroot(),
+ m_os_version_major(UINT32_MAX), m_os_version_minor(UINT32_MAX),
+ m_os_version_update(UINT32_MAX),
+ m_include_platform_option(include_platform_option) {}
+
+ ~OptionGroupPlatform() override = default;
+
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
+
+ Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
+ ExecutionContext *execution_context) override;
+ Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
+
+ void OptionParsingStarting(ExecutionContext *execution_context) override;
+
+ lldb::PlatformSP CreatePlatformWithOptions(CommandInterpreter &interpreter,
+ const ArchSpec &arch,
+ bool make_selected, Error &error,
+ ArchSpec &platform_arch) const;
+
+ bool PlatformWasSpecified() const { return !m_platform_name.empty(); }
+
+ void SetPlatformName(const char *platform_name) {
+ if (platform_name && platform_name[0])
+ m_platform_name.assign(platform_name);
+ else
+ m_platform_name.clear();
+ }
+
+ const ConstString &GetSDKRootDirectory() const { return m_sdk_sysroot; }
+
+ void SetSDKRootDirectory(const ConstString &sdk_root_directory) {
+ m_sdk_sysroot = sdk_root_directory;
+ }
+
+ const ConstString &GetSDKBuild() const { return m_sdk_build; }
+
+ void SetSDKBuild(const ConstString &sdk_build) { m_sdk_build = sdk_build; }
+
+ bool PlatformMatches(const lldb::PlatformSP &platform_sp) const;
protected:
- std::string m_platform_name;
- ConstString m_sdk_sysroot;
- ConstString m_sdk_build;
- uint32_t m_os_version_major;
- uint32_t m_os_version_minor;
- uint32_t m_os_version_update;
- bool m_include_platform_option;
+ std::string m_platform_name;
+ ConstString m_sdk_sysroot;
+ ConstString m_sdk_build;
+ uint32_t m_os_version_major;
+ uint32_t m_os_version_minor;
+ uint32_t m_os_version_update;
+ bool m_include_platform_option;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionGroupString.h b/include/lldb/Interpreter/OptionGroupString.h
index 6f46bdb79408..21bfc08d130f 100644
--- a/include/lldb/Interpreter/OptionGroupString.h
+++ b/include/lldb/Interpreter/OptionGroupString.h
@@ -14,65 +14,42 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/OptionValueString.h"
+#include "lldb/Interpreter/Options.h"
namespace lldb_private {
- //-------------------------------------------------------------------------
- // OptionGroupString
- //-------------------------------------------------------------------------
-
- class OptionGroupString : public OptionGroup
- {
- public:
- OptionGroupString (uint32_t usage_mask,
- bool required,
- const char *long_option,
- int short_option,
- uint32_t completion_type,
- lldb::CommandArgumentType argument_type,
- const char *usage_text,
- const char *default_value);
-
- ~OptionGroupString() override;
+//-------------------------------------------------------------------------
+// OptionGroupString
+//-------------------------------------------------------------------------
+
+class OptionGroupString : public OptionGroup {
+public:
+ OptionGroupString(uint32_t usage_mask, bool required, const char *long_option,
+ int short_option, uint32_t completion_type,
+ lldb::CommandArgumentType argument_type,
+ const char *usage_text, const char *default_value);
+
+ ~OptionGroupString() override;
+
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
+ return llvm::ArrayRef<OptionDefinition>(&m_option_definition, 1);
+ }
+
+ Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
+ ExecutionContext *execution_context) override;
+ Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
+
+ void OptionParsingStarting(ExecutionContext *execution_context) override;
+
+ OptionValueString &GetOptionValue() { return m_value; }
+
+ const OptionValueString &GetOptionValue() const { return m_value; }
+
+protected:
+ OptionValueString m_value;
+ OptionDefinition m_option_definition;
+};
- uint32_t
- GetNumDefinitions() override
- {
- return 1;
- }
-
- const OptionDefinition*
- GetDefinitions() override
- {
- return &m_option_definition;
- }
-
- Error
- SetOptionValue(CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value) override;
-
- void
- OptionParsingStarting(CommandInterpreter &interpreter) override;
-
- OptionValueString &
- GetOptionValue ()
- {
- return m_value;
- }
-
- const OptionValueString &
- GetOptionValue () const
- {
- return m_value;
- }
-
- protected:
- OptionValueString m_value;
- OptionDefinition m_option_definition;
- };
-
} // namespace lldb_private
#endif // liblldb_OptionGroupString_h_
diff --git a/include/lldb/Interpreter/OptionGroupUInt64.h b/include/lldb/Interpreter/OptionGroupUInt64.h
index b03c1ff889a1..3f04eac72888 100644
--- a/include/lldb/Interpreter/OptionGroupUInt64.h
+++ b/include/lldb/Interpreter/OptionGroupUInt64.h
@@ -14,66 +14,43 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/OptionValueUInt64.h"
+#include "lldb/Interpreter/Options.h"
namespace lldb_private {
- //-------------------------------------------------------------------------
- // OptionGroupUInt64
- //-------------------------------------------------------------------------
-
- class OptionGroupUInt64 : public OptionGroup
- {
- public:
- OptionGroupUInt64 (uint32_t usage_mask,
- bool required,
- const char *long_option,
- int short_option,
- uint32_t completion_type,
- lldb::CommandArgumentType argument_type,
- const char *usage_text,
- uint64_t default_value);
-
- ~OptionGroupUInt64() override;
+//-------------------------------------------------------------------------
+// OptionGroupUInt64
+//-------------------------------------------------------------------------
+
+class OptionGroupUInt64 : public OptionGroup {
+public:
+ OptionGroupUInt64(uint32_t usage_mask, bool required, const char *long_option,
+ int short_option, uint32_t completion_type,
+ lldb::CommandArgumentType argument_type,
+ const char *usage_text, uint64_t default_value);
+
+ ~OptionGroupUInt64() override;
+
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
+ return llvm::ArrayRef<OptionDefinition>(&m_option_definition, 1);
+ }
+
+ Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
+ ExecutionContext *execution_context) override;
+ Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
+
+ void OptionParsingStarting(ExecutionContext *execution_context) override;
+
+ OptionValueUInt64 &GetOptionValue() { return m_value; }
+
+ const OptionValueUInt64 &GetOptionValue() const { return m_value; }
+
+protected:
+ OptionValueUInt64 m_value;
+ OptionDefinition m_option_definition;
+};
- uint32_t
- GetNumDefinitions() override
- {
- return 1;
- }
-
- const OptionDefinition*
- GetDefinitions() override
- {
- return &m_option_definition;
- }
-
- Error
- SetOptionValue(CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value) override;
-
- void
- OptionParsingStarting(CommandInterpreter &interpreter) override;
-
- OptionValueUInt64 &
- GetOptionValue ()
- {
- return m_value;
- }
-
- const OptionValueUInt64 &
- GetOptionValue () const
- {
- return m_value;
- }
-
- protected:
- OptionValueUInt64 m_value;
- OptionDefinition m_option_definition;
- };
-
} // namespace lldb_private
#endif // liblldb_OptionGroupUInt64_h_
diff --git a/include/lldb/Interpreter/OptionGroupUUID.h b/include/lldb/Interpreter/OptionGroupUUID.h
index 6495699dce75..9a7c6cf9cffe 100644
--- a/include/lldb/Interpreter/OptionGroupUUID.h
+++ b/include/lldb/Interpreter/OptionGroupUUID.h
@@ -14,8 +14,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/OptionValueUUID.h"
+#include "lldb/Interpreter/Options.h"
namespace lldb_private {
@@ -23,35 +23,24 @@ namespace lldb_private {
// OptionGroupUUID
//-------------------------------------------------------------------------
-class OptionGroupUUID : public OptionGroup
-{
+class OptionGroupUUID : public OptionGroup {
public:
- OptionGroupUUID ();
-
- ~OptionGroupUUID() override;
-
- uint32_t
- GetNumDefinitions() override;
-
- const OptionDefinition*
- GetDefinitions() override;
-
- Error
- SetOptionValue(CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value) override;
-
- void
- OptionParsingStarting(CommandInterpreter &interpreter) override;
-
- const OptionValueUUID &
- GetOptionValue () const
- {
- return m_uuid;
- }
+ OptionGroupUUID();
+
+ ~OptionGroupUUID() override;
+
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
+
+ Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
+ ExecutionContext *execution_context) override;
+ Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
+
+ void OptionParsingStarting(ExecutionContext *execution_context) override;
+
+ const OptionValueUUID &GetOptionValue() const { return m_uuid; }
protected:
- OptionValueUUID m_uuid;
+ OptionValueUUID m_uuid;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h b/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h
index 86e4c1662e6e..694464b8b917 100644
--- a/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h
+++ b/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h
@@ -23,62 +23,41 @@ namespace lldb_private {
// OptionGroupValueObjectDisplay
//-------------------------------------------------------------------------
-class OptionGroupValueObjectDisplay : public OptionGroup
-{
+class OptionGroupValueObjectDisplay : public OptionGroup {
public:
- OptionGroupValueObjectDisplay ();
-
- ~OptionGroupValueObjectDisplay() override;
+ OptionGroupValueObjectDisplay();
- uint32_t
- GetNumDefinitions() override;
-
- const OptionDefinition*
- GetDefinitions() override;
-
- Error
- SetOptionValue(CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value) override;
-
- void
- OptionParsingStarting(CommandInterpreter &interpreter) override;
-
- bool
- AnyOptionWasSet () const
- {
- return show_types ||
- no_summary_depth != 0 ||
- show_location ||
- flat_output ||
- use_objc ||
- max_depth != UINT32_MAX ||
- ptr_depth != 0 ||
- !use_synth ||
- be_raw ||
- ignore_cap ||
- run_validator;
- }
-
- DumpValueObjectOptions
- GetAsDumpOptions (LanguageRuntimeDescriptionDisplayVerbosity lang_descr_verbosity = eLanguageRuntimeDescriptionDisplayVerbosityFull,
- lldb::Format format = lldb::eFormatDefault,
- lldb::TypeSummaryImplSP summary_sp = lldb::TypeSummaryImplSP());
+ ~OptionGroupValueObjectDisplay() override;
- bool show_types : 1,
- show_location : 1,
- flat_output : 1,
- use_objc : 1,
- use_synth : 1,
- be_raw : 1,
- ignore_cap : 1,
- run_validator : 1;
-
- uint32_t no_summary_depth;
- uint32_t max_depth;
- uint32_t ptr_depth;
- uint32_t elem_count;
- lldb::DynamicValueType use_dynamic;
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
+
+ Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
+ ExecutionContext *execution_context) override;
+ Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
+
+ void OptionParsingStarting(ExecutionContext *execution_context) override;
+
+ bool AnyOptionWasSet() const {
+ return show_types || no_summary_depth != 0 || show_location ||
+ flat_output || use_objc || max_depth != UINT32_MAX ||
+ ptr_depth != 0 || !use_synth || be_raw || ignore_cap ||
+ run_validator;
+ }
+
+ DumpValueObjectOptions GetAsDumpOptions(
+ LanguageRuntimeDescriptionDisplayVerbosity lang_descr_verbosity =
+ eLanguageRuntimeDescriptionDisplayVerbosityFull,
+ lldb::Format format = lldb::eFormatDefault,
+ lldb::TypeSummaryImplSP summary_sp = lldb::TypeSummaryImplSP());
+
+ bool show_types : 1, show_location : 1, flat_output : 1, use_objc : 1,
+ use_synth : 1, be_raw : 1, ignore_cap : 1, run_validator : 1;
+
+ uint32_t no_summary_depth;
+ uint32_t max_depth;
+ uint32_t ptr_depth;
+ uint32_t elem_count;
+ lldb::DynamicValueType use_dynamic;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionGroupVariable.h b/include/lldb/Interpreter/OptionGroupVariable.h
index fd338f1ba8cb..0735de45d1a6 100644
--- a/include/lldb/Interpreter/OptionGroupVariable.h
+++ b/include/lldb/Interpreter/OptionGroupVariable.h
@@ -23,41 +23,32 @@ namespace lldb_private {
// OptionGroupVariable
//-------------------------------------------------------------------------
- class OptionGroupVariable : public OptionGroup
- {
- public:
- OptionGroupVariable (bool show_frame_options);
-
- ~OptionGroupVariable() override;
-
- uint32_t
- GetNumDefinitions() override;
-
- const OptionDefinition*
- GetDefinitions() override;
-
- Error
- SetOptionValue(CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_arg) override;
-
- void
- OptionParsingStarting(CommandInterpreter &interpreter) override;
-
- bool include_frame_options:1,
- show_args:1, // Frame option only (include_frame_options == true)
- show_locals:1, // Frame option only (include_frame_options == true)
- show_globals:1, // Frame option only (include_frame_options == true)
- use_regex:1,
- show_scope:1,
- show_decl:1;
- OptionValueString summary; // the name of a named summary
- OptionValueString summary_string; // a summary string
-
- private:
- DISALLOW_COPY_AND_ASSIGN(OptionGroupVariable);
- };
-
+class OptionGroupVariable : public OptionGroup {
+public:
+ OptionGroupVariable(bool show_frame_options);
+
+ ~OptionGroupVariable() override;
+
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
+
+ Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
+ ExecutionContext *execution_context) override;
+ Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
+
+ void OptionParsingStarting(ExecutionContext *execution_context) override;
+
+ bool include_frame_options : 1,
+ show_args : 1, // Frame option only (include_frame_options == true)
+ show_locals : 1, // Frame option only (include_frame_options == true)
+ show_globals : 1, // Frame option only (include_frame_options == true)
+ use_regex : 1, show_scope : 1, show_decl : 1;
+ OptionValueString summary; // the name of a named summary
+ OptionValueString summary_string; // a summary string
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(OptionGroupVariable);
+};
+
} // namespace lldb_private
#endif // liblldb_OptionGroupVariable_h_
diff --git a/include/lldb/Interpreter/OptionGroupWatchpoint.h b/include/lldb/Interpreter/OptionGroupWatchpoint.h
index ddc4393bdc25..c67c8f071b54 100644
--- a/include/lldb/Interpreter/OptionGroupWatchpoint.h
+++ b/include/lldb/Interpreter/OptionGroupWatchpoint.h
@@ -22,48 +22,40 @@ namespace lldb_private {
// OptionGroupWatchpoint
//-------------------------------------------------------------------------
- class OptionGroupWatchpoint : public OptionGroup
- {
- public:
- OptionGroupWatchpoint ();
+class OptionGroupWatchpoint : public OptionGroup {
+public:
+ OptionGroupWatchpoint();
- ~OptionGroupWatchpoint() override;
+ ~OptionGroupWatchpoint() override;
- static bool
- IsWatchSizeSupported(uint32_t watch_size);
+ static bool IsWatchSizeSupported(uint32_t watch_size);
- uint32_t
- GetNumDefinitions() override;
-
- const OptionDefinition*
- GetDefinitions() override;
-
- Error
- SetOptionValue(CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_arg) override;
-
- void
- OptionParsingStarting(CommandInterpreter &interpreter) override;
-
- // Note:
- // eWatchRead == LLDB_WATCH_TYPE_READ; and
- // eWatchWrite == LLDB_WATCH_TYPE_WRITE
- typedef enum WatchType {
- eWatchInvalid = 0,
- eWatchRead,
- eWatchWrite,
- eWatchReadWrite
- } WatchType;
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
- WatchType watch_type;
- uint32_t watch_size;
- bool watch_type_specified;
+ Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
+ ExecutionContext *execution_context) override;
+ Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
+
+ void OptionParsingStarting(ExecutionContext *execution_context) override;
+
+ // Note:
+ // eWatchRead == LLDB_WATCH_TYPE_READ; and
+ // eWatchWrite == LLDB_WATCH_TYPE_WRITE
+ typedef enum WatchType {
+ eWatchInvalid = 0,
+ eWatchRead,
+ eWatchWrite,
+ eWatchReadWrite
+ } WatchType;
+
+ WatchType watch_type;
+ uint32_t watch_size;
+ bool watch_type_specified;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(OptionGroupWatchpoint);
+};
- private:
- DISALLOW_COPY_AND_ASSIGN(OptionGroupWatchpoint);
- };
-
} // namespace lldb_private
#endif // liblldb_OptionGroupWatchpoint_h_
diff --git a/include/lldb/Interpreter/OptionValue.h b/include/lldb/Interpreter/OptionValue.h
index a05a0fb0b64f..2c1d5df90697 100644
--- a/include/lldb/Interpreter/OptionValue.h
+++ b/include/lldb/Interpreter/OptionValue.h
@@ -14,428 +14,333 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-defines.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/FormatEntity.h"
+#include "lldb/lldb-defines.h"
namespace lldb_private {
- //---------------------------------------------------------------------
- // OptionValue
- //---------------------------------------------------------------------
- class OptionValue
- {
- public:
- typedef enum
- {
- eTypeInvalid = 0,
- eTypeArch,
- eTypeArgs,
- eTypeArray,
- eTypeBoolean,
- eTypeChar,
- eTypeDictionary,
- eTypeEnum,
- eTypeFileSpec,
- eTypeFileSpecList,
- eTypeFormat,
- eTypeLanguage,
- eTypePathMap,
- eTypeProperties,
- eTypeRegex,
- eTypeSInt64,
- eTypeString,
- eTypeUInt64,
- eTypeUUID,
- eTypeFormatEntity
- } Type;
-
- enum {
- eDumpOptionName = (1u << 0),
- eDumpOptionType = (1u << 1),
- eDumpOptionValue = (1u << 2),
- eDumpOptionDescription = (1u << 3),
- eDumpOptionRaw = (1u << 4),
- eDumpGroupValue = (eDumpOptionName | eDumpOptionType | eDumpOptionValue),
- eDumpGroupHelp = (eDumpOptionName | eDumpOptionType | eDumpOptionDescription)
- };
-
- OptionValue () :
- m_callback (nullptr),
- m_baton(nullptr),
- m_value_was_set (false)
- {
- }
-
- OptionValue (const OptionValue &rhs) :
- m_callback (rhs.m_callback),
- m_baton (rhs.m_baton),
- m_value_was_set (rhs.m_value_was_set)
- {
- }
-
- virtual ~OptionValue() = default;
-
- //-----------------------------------------------------------------
- // Subclasses should override these functions
- //-----------------------------------------------------------------
- virtual Type
- GetType () const = 0;
-
- // If this value is always hidden, the avoid showing any info on this
- // value, just show the info for the child values.
- virtual bool
- ValueIsTransparent () const
- {
- return GetType() == eTypeProperties;
- }
-
- virtual const char *
- GetTypeAsCString () const
- {
- return GetBuiltinTypeAsCString(GetType());
- }
-
- static const char *
- GetBuiltinTypeAsCString (Type t);
-
- virtual void
- DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) = 0;
-
- virtual Error
- SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign);
-
- virtual bool
- Clear () = 0;
-
- virtual lldb::OptionValueSP
- DeepCopy () const = 0;
-
- virtual size_t
- AutoComplete (CommandInterpreter &interpreter,
- const char *s,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches);
-
- //-----------------------------------------------------------------
- // Subclasses can override these functions
- //-----------------------------------------------------------------
- virtual lldb::OptionValueSP
- GetSubValue (const ExecutionContext *exe_ctx,
- const char *name,
- bool will_modify,
- Error &error) const
- {
- error.SetErrorStringWithFormat("'%s' is not a value subvalue", name);
- return lldb::OptionValueSP();
- }
-
- virtual Error
- SetSubValue (const ExecutionContext *exe_ctx,
- VarSetOperationType op,
- const char *name,
- const char *value);
-
- virtual bool
- IsAggregateValue () const
- {
- return false;
- }
-
- virtual ConstString
- GetName() const
- {
- return ConstString();
- }
-
- virtual bool
- DumpQualifiedName (Stream &strm) const;
-
- //-----------------------------------------------------------------
- // Subclasses should NOT override these functions as they use the
- // above functions to implement functionality
- //-----------------------------------------------------------------
- uint32_t
- GetTypeAsMask ()
- {
- return 1u << GetType();
- }
-
- static uint32_t
- ConvertTypeToMask (OptionValue::Type type)
- {
- return 1u << type;
- }
-
- static OptionValue::Type
- ConvertTypeMaskToType (uint32_t type_mask)
- {
- // If only one bit is set, then return an appropriate enumeration
- switch (type_mask)
- {
- case 1u << eTypeArch: return eTypeArch;
- case 1u << eTypeArgs: return eTypeArgs;
- case 1u << eTypeArray: return eTypeArray;
- case 1u << eTypeBoolean: return eTypeBoolean;
- case 1u << eTypeChar: return eTypeChar;
- case 1u << eTypeDictionary: return eTypeDictionary;
- case 1u << eTypeEnum: return eTypeEnum;
- case 1u << eTypeFileSpec: return eTypeFileSpec;
- case 1u << eTypeFileSpecList: return eTypeFileSpecList;
- case 1u << eTypeFormat: return eTypeFormat;
- case 1u << eTypeLanguage: return eTypeLanguage;
- case 1u << eTypePathMap: return eTypePathMap;
- case 1u << eTypeProperties: return eTypeProperties;
- case 1u << eTypeRegex: return eTypeRegex;
- case 1u << eTypeSInt64: return eTypeSInt64;
- case 1u << eTypeString: return eTypeString;
- case 1u << eTypeUInt64: return eTypeUInt64;
- case 1u << eTypeUUID: return eTypeUUID;
- }
- // Else return invalid
- return eTypeInvalid;
- }
-
- static lldb::OptionValueSP
- CreateValueFromCStringForTypeMask (const char *value_cstr,
- uint32_t type_mask,
- Error &error);
-
- // Get this value as a uint64_t value if it is encoded as a boolean,
- // uint64_t or int64_t. Other types will cause "fail_value" to be
- // returned
- uint64_t
- GetUInt64Value (uint64_t fail_value, bool *success_ptr);
-
- OptionValueArch *
- GetAsArch ();
-
- const OptionValueArch *
- GetAsArch () const;
-
- OptionValueArray *
- GetAsArray ();
-
- const OptionValueArray *
- GetAsArray () const;
-
- OptionValueArgs *
- GetAsArgs ();
-
- const OptionValueArgs *
- GetAsArgs () const;
-
- OptionValueBoolean *
- GetAsBoolean ();
-
- OptionValueChar *
- GetAsChar ();
-
- const OptionValueBoolean *
- GetAsBoolean () const;
-
- const OptionValueChar *
- GetAsChar () const;
-
- OptionValueDictionary *
- GetAsDictionary ();
-
- const OptionValueDictionary *
- GetAsDictionary () const;
-
- OptionValueEnumeration *
- GetAsEnumeration ();
-
- const OptionValueEnumeration *
- GetAsEnumeration () const;
-
- OptionValueFileSpec *
- GetAsFileSpec ();
-
- const OptionValueFileSpec *
- GetAsFileSpec () const;
-
- OptionValueFileSpecList *
- GetAsFileSpecList ();
-
- const OptionValueFileSpecList *
- GetAsFileSpecList () const;
-
- OptionValueFormat *
- GetAsFormat ();
-
- const OptionValueFormat *
- GetAsFormat () const;
-
- OptionValueLanguage *
- GetAsLanguage ();
-
- const OptionValueLanguage *
- GetAsLanguage () const;
-
- OptionValuePathMappings *
- GetAsPathMappings ();
-
- const OptionValuePathMappings *
- GetAsPathMappings () const;
-
- OptionValueProperties *
- GetAsProperties ();
-
- const OptionValueProperties *
- GetAsProperties () const;
-
- OptionValueRegex *
- GetAsRegex ();
-
- const OptionValueRegex *
- GetAsRegex () const;
-
- OptionValueSInt64 *
- GetAsSInt64 ();
-
- const OptionValueSInt64 *
- GetAsSInt64 () const;
-
- OptionValueString *
- GetAsString ();
-
- const OptionValueString *
- GetAsString () const;
-
- OptionValueUInt64 *
- GetAsUInt64 ();
-
- const OptionValueUInt64 *
- GetAsUInt64 () const;
-
- OptionValueUUID *
- GetAsUUID ();
-
- const OptionValueUUID *
- GetAsUUID () const;
-
- OptionValueFormatEntity *
- GetAsFormatEntity ();
-
- const OptionValueFormatEntity *
- GetAsFormatEntity () const;
-
- bool
- GetBooleanValue (bool fail_value = false) const;
-
- bool
- SetBooleanValue (bool new_value);
-
- char GetCharValue(char fail_value) const;
-
- char SetCharValue(char new_value);
-
- int64_t
- GetEnumerationValue (int64_t fail_value = -1) const;
-
- bool
- SetEnumerationValue (int64_t value);
-
- FileSpec
- GetFileSpecValue () const;
-
- bool
- SetFileSpecValue (const FileSpec &file_spec);
-
- FileSpecList
- GetFileSpecListValue () const;
-
- lldb::Format
- GetFormatValue (lldb::Format fail_value = lldb::eFormatDefault) const;
-
- bool
- SetFormatValue (lldb::Format new_value);
-
- lldb::LanguageType
- GetLanguageValue (lldb::LanguageType fail_value = lldb::eLanguageTypeUnknown) const;
-
- bool
- SetLanguageValue (lldb::LanguageType new_language);
-
- const FormatEntity::Entry *
- GetFormatEntity () const;
-
- const RegularExpression *
- GetRegexValue () const;
-
- int64_t
- GetSInt64Value (int64_t fail_value = 0) const;
-
- bool
- SetSInt64Value (int64_t new_value);
-
- const char *
- GetStringValue(const char *fail_value = nullptr) const;
-
- bool
- SetStringValue (const char *new_value);
-
- uint64_t
- GetUInt64Value (uint64_t fail_value = 0) const;
-
- bool
- SetUInt64Value (uint64_t new_value);
-
- UUID
- GetUUIDValue () const;
-
- bool
- SetUUIDValue (const UUID &uuid);
-
- bool
- OptionWasSet () const
- {
- return m_value_was_set;
- }
-
- void
- SetOptionWasSet ()
- {
- m_value_was_set = true;
- }
-
- void
- SetParent (const lldb::OptionValueSP &parent_sp)
- {
- m_parent_wp = parent_sp;
- }
-
- void
- SetValueChangedCallback (OptionValueChangedCallback callback,
- void *baton)
- {
- assert (m_callback == nullptr);
- m_callback = callback;
- m_baton = baton;
- }
-
- void
- NotifyValueChanged ()
- {
- if (m_callback)
- m_callback (m_baton, this);
- }
-
- protected:
- lldb::OptionValueWP m_parent_wp;
- OptionValueChangedCallback m_callback;
- void *m_baton;
- bool m_value_was_set; // This can be used to see if a value has been set
- // by a call to SetValueFromCString(). It is often
- // handy to know if an option value was set from
- // the command line or as a setting, versus if we
- // just have the default value that was already
- // populated in the option value.
- };
+//---------------------------------------------------------------------
+// OptionValue
+//---------------------------------------------------------------------
+class OptionValue {
+public:
+ typedef enum {
+ eTypeInvalid = 0,
+ eTypeArch,
+ eTypeArgs,
+ eTypeArray,
+ eTypeBoolean,
+ eTypeChar,
+ eTypeDictionary,
+ eTypeEnum,
+ eTypeFileSpec,
+ eTypeFileSpecList,
+ eTypeFormat,
+ eTypeLanguage,
+ eTypePathMap,
+ eTypeProperties,
+ eTypeRegex,
+ eTypeSInt64,
+ eTypeString,
+ eTypeUInt64,
+ eTypeUUID,
+ eTypeFormatEntity
+ } Type;
+
+ enum {
+ eDumpOptionName = (1u << 0),
+ eDumpOptionType = (1u << 1),
+ eDumpOptionValue = (1u << 2),
+ eDumpOptionDescription = (1u << 3),
+ eDumpOptionRaw = (1u << 4),
+ eDumpGroupValue = (eDumpOptionName | eDumpOptionType | eDumpOptionValue),
+ eDumpGroupHelp =
+ (eDumpOptionName | eDumpOptionType | eDumpOptionDescription)
+ };
+
+ OptionValue()
+ : m_callback(nullptr), m_baton(nullptr), m_value_was_set(false) {}
+
+ OptionValue(const OptionValue &rhs)
+ : m_callback(rhs.m_callback), m_baton(rhs.m_baton),
+ m_value_was_set(rhs.m_value_was_set) {}
+
+ virtual ~OptionValue() = default;
+
+ //-----------------------------------------------------------------
+ // Subclasses should override these functions
+ //-----------------------------------------------------------------
+ virtual Type GetType() const = 0;
+
+ // If this value is always hidden, the avoid showing any info on this
+ // value, just show the info for the child values.
+ virtual bool ValueIsTransparent() const {
+ return GetType() == eTypeProperties;
+ }
+
+ virtual const char *GetTypeAsCString() const {
+ return GetBuiltinTypeAsCString(GetType());
+ }
+
+ static const char *GetBuiltinTypeAsCString(Type t);
+
+ virtual void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
+ uint32_t dump_mask) = 0;
+
+ virtual Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign);
+
+ virtual bool Clear() = 0;
+
+ virtual lldb::OptionValueSP DeepCopy() const = 0;
+
+ virtual size_t AutoComplete(CommandInterpreter &interpreter,
+ llvm::StringRef s, int match_start_point,
+ int max_return_elements, bool &word_complete,
+ StringList &matches);
+
+ //-----------------------------------------------------------------
+ // Subclasses can override these functions
+ //-----------------------------------------------------------------
+ virtual lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
+ llvm::StringRef name, bool will_modify,
+ Error &error) const {
+ error.SetErrorStringWithFormat("'%s' is not a value subvalue", name.str().c_str());
+ return lldb::OptionValueSP();
+ }
+
+ virtual Error SetSubValue(const ExecutionContext *exe_ctx,
+ VarSetOperationType op, llvm::StringRef name,
+ llvm::StringRef value);
+
+ virtual bool IsAggregateValue() const { return false; }
+
+ virtual ConstString GetName() const { return ConstString(); }
+
+ virtual bool DumpQualifiedName(Stream &strm) const;
+
+ //-----------------------------------------------------------------
+ // Subclasses should NOT override these functions as they use the
+ // above functions to implement functionality
+ //-----------------------------------------------------------------
+ uint32_t GetTypeAsMask() { return 1u << GetType(); }
+
+ static uint32_t ConvertTypeToMask(OptionValue::Type type) {
+ return 1u << type;
+ }
+
+ static OptionValue::Type ConvertTypeMaskToType(uint32_t type_mask) {
+ // If only one bit is set, then return an appropriate enumeration
+ switch (type_mask) {
+ case 1u << eTypeArch:
+ return eTypeArch;
+ case 1u << eTypeArgs:
+ return eTypeArgs;
+ case 1u << eTypeArray:
+ return eTypeArray;
+ case 1u << eTypeBoolean:
+ return eTypeBoolean;
+ case 1u << eTypeChar:
+ return eTypeChar;
+ case 1u << eTypeDictionary:
+ return eTypeDictionary;
+ case 1u << eTypeEnum:
+ return eTypeEnum;
+ case 1u << eTypeFileSpec:
+ return eTypeFileSpec;
+ case 1u << eTypeFileSpecList:
+ return eTypeFileSpecList;
+ case 1u << eTypeFormat:
+ return eTypeFormat;
+ case 1u << eTypeLanguage:
+ return eTypeLanguage;
+ case 1u << eTypePathMap:
+ return eTypePathMap;
+ case 1u << eTypeProperties:
+ return eTypeProperties;
+ case 1u << eTypeRegex:
+ return eTypeRegex;
+ case 1u << eTypeSInt64:
+ return eTypeSInt64;
+ case 1u << eTypeString:
+ return eTypeString;
+ case 1u << eTypeUInt64:
+ return eTypeUInt64;
+ case 1u << eTypeUUID:
+ return eTypeUUID;
+ }
+ // Else return invalid
+ return eTypeInvalid;
+ }
+
+ static lldb::OptionValueSP
+ CreateValueFromCStringForTypeMask(const char *value_cstr, uint32_t type_mask,
+ Error &error);
+
+ // Get this value as a uint64_t value if it is encoded as a boolean,
+ // uint64_t or int64_t. Other types will cause "fail_value" to be
+ // returned
+ uint64_t GetUInt64Value(uint64_t fail_value, bool *success_ptr);
+
+ OptionValueArch *GetAsArch();
+
+ const OptionValueArch *GetAsArch() const;
+
+ OptionValueArray *GetAsArray();
+
+ const OptionValueArray *GetAsArray() const;
+
+ OptionValueArgs *GetAsArgs();
+
+ const OptionValueArgs *GetAsArgs() const;
+
+ OptionValueBoolean *GetAsBoolean();
+
+ OptionValueChar *GetAsChar();
+
+ const OptionValueBoolean *GetAsBoolean() const;
+
+ const OptionValueChar *GetAsChar() const;
+
+ OptionValueDictionary *GetAsDictionary();
+
+ const OptionValueDictionary *GetAsDictionary() const;
+
+ OptionValueEnumeration *GetAsEnumeration();
+
+ const OptionValueEnumeration *GetAsEnumeration() const;
+
+ OptionValueFileSpec *GetAsFileSpec();
+
+ const OptionValueFileSpec *GetAsFileSpec() const;
+
+ OptionValueFileSpecList *GetAsFileSpecList();
+
+ const OptionValueFileSpecList *GetAsFileSpecList() const;
+
+ OptionValueFormat *GetAsFormat();
+
+ const OptionValueFormat *GetAsFormat() const;
+
+ OptionValueLanguage *GetAsLanguage();
+
+ const OptionValueLanguage *GetAsLanguage() const;
+
+ OptionValuePathMappings *GetAsPathMappings();
+
+ const OptionValuePathMappings *GetAsPathMappings() const;
+
+ OptionValueProperties *GetAsProperties();
+
+ const OptionValueProperties *GetAsProperties() const;
+
+ OptionValueRegex *GetAsRegex();
+
+ const OptionValueRegex *GetAsRegex() const;
+
+ OptionValueSInt64 *GetAsSInt64();
+
+ const OptionValueSInt64 *GetAsSInt64() const;
+
+ OptionValueString *GetAsString();
+
+ const OptionValueString *GetAsString() const;
+
+ OptionValueUInt64 *GetAsUInt64();
+
+ const OptionValueUInt64 *GetAsUInt64() const;
+
+ OptionValueUUID *GetAsUUID();
+
+ const OptionValueUUID *GetAsUUID() const;
+
+ OptionValueFormatEntity *GetAsFormatEntity();
+
+ const OptionValueFormatEntity *GetAsFormatEntity() const;
+
+ bool GetBooleanValue(bool fail_value = false) const;
+
+ bool SetBooleanValue(bool new_value);
+
+ char GetCharValue(char fail_value) const;
+
+ char SetCharValue(char new_value);
+
+ int64_t GetEnumerationValue(int64_t fail_value = -1) const;
+
+ bool SetEnumerationValue(int64_t value);
+
+ FileSpec GetFileSpecValue() const;
+
+ bool SetFileSpecValue(const FileSpec &file_spec);
+
+ FileSpecList GetFileSpecListValue() const;
+
+ lldb::Format
+ GetFormatValue(lldb::Format fail_value = lldb::eFormatDefault) const;
+
+ bool SetFormatValue(lldb::Format new_value);
+
+ lldb::LanguageType GetLanguageValue(
+ lldb::LanguageType fail_value = lldb::eLanguageTypeUnknown) const;
+
+ bool SetLanguageValue(lldb::LanguageType new_language);
+
+ const FormatEntity::Entry *GetFormatEntity() const;
+
+ const RegularExpression *GetRegexValue() const;
+
+ int64_t GetSInt64Value(int64_t fail_value = 0) const;
+
+ bool SetSInt64Value(int64_t new_value);
+
+ llvm::StringRef GetStringValue(llvm::StringRef fail_value) const;
+ llvm::StringRef GetStringValue() const { return GetStringValue(llvm::StringRef()); }
+
+ bool SetStringValue(llvm::StringRef new_value);
+
+ uint64_t GetUInt64Value(uint64_t fail_value = 0) const;
+
+ bool SetUInt64Value(uint64_t new_value);
+
+ UUID GetUUIDValue() const;
+
+ bool SetUUIDValue(const UUID &uuid);
+
+ bool OptionWasSet() const { return m_value_was_set; }
+
+ void SetOptionWasSet() { m_value_was_set = true; }
+
+ void SetParent(const lldb::OptionValueSP &parent_sp) {
+ m_parent_wp = parent_sp;
+ }
+
+ void SetValueChangedCallback(OptionValueChangedCallback callback,
+ void *baton) {
+ assert(m_callback == nullptr);
+ m_callback = callback;
+ m_baton = baton;
+ }
+
+ void NotifyValueChanged() {
+ if (m_callback)
+ m_callback(m_baton, this);
+ }
+
+protected:
+ lldb::OptionValueWP m_parent_wp;
+ OptionValueChangedCallback m_callback;
+ void *m_baton;
+ bool m_value_was_set; // This can be used to see if a value has been set
+ // by a call to SetValueFromCString(). It is often
+ // handy to know if an option value was set from
+ // the command line or as a setting, versus if we
+ // just have the default value that was already
+ // populated in the option value.
+};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionValueArch.h b/include/lldb/Interpreter/OptionValueArch.h
index c83dc8558084..aa548124e2d6 100644
--- a/include/lldb/Interpreter/OptionValueArch.h
+++ b/include/lldb/Interpreter/OptionValueArch.h
@@ -19,118 +19,73 @@
namespace lldb_private {
-class OptionValueArch : public OptionValue
-{
+class OptionValueArch : public OptionValue {
public:
- OptionValueArch () :
- OptionValue(),
- m_current_value (),
- m_default_value ()
- {
- }
-
- OptionValueArch (const char *triple) :
- OptionValue(),
- m_current_value (triple),
- m_default_value ()
- {
- m_default_value = m_current_value;
- }
-
- OptionValueArch (const ArchSpec &value) :
- OptionValue(),
- m_current_value (value),
- m_default_value (value)
- {
- }
-
- OptionValueArch (const ArchSpec &current_value,
- const ArchSpec &default_value) :
- OptionValue(),
- m_current_value (current_value),
- m_default_value (default_value)
- {
- }
-
- ~OptionValueArch() override
- {
- }
-
- //---------------------------------------------------------------------
- // Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
-
- OptionValue::Type
- GetType() const override
- {
- return eTypeArch;
- }
-
- void
- DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
-
- Error
- SetValueFromString(llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign) override;
-
- bool
- Clear() override
- {
- m_current_value = m_default_value;
- m_value_was_set = false;
- return true;
- }
-
- lldb::OptionValueSP
- DeepCopy() const override;
-
- size_t
- AutoComplete(CommandInterpreter &interpreter,
- const char *s,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches) override;
-
- //---------------------------------------------------------------------
- // Subclass specific functions
- //---------------------------------------------------------------------
-
- ArchSpec &
- GetCurrentValue()
- {
- return m_current_value;
- }
-
- const ArchSpec &
- GetCurrentValue() const
- {
- return m_current_value;
- }
-
- const ArchSpec &
- GetDefaultValue() const
- {
- return m_default_value;
- }
-
- void
- SetCurrentValue (const ArchSpec &value, bool set_value_was_set)
- {
- m_current_value = value;
- if (set_value_was_set)
- m_value_was_set = true;
- }
-
- void
- SetDefaultValue (const ArchSpec &value)
- {
- m_default_value = value;
- }
-
+ OptionValueArch() : OptionValue(), m_current_value(), m_default_value() {}
+
+ OptionValueArch(const char *triple)
+ : OptionValue(), m_current_value(triple), m_default_value() {
+ m_default_value = m_current_value;
+ }
+
+ OptionValueArch(const ArchSpec &value)
+ : OptionValue(), m_current_value(value), m_default_value(value) {}
+
+ OptionValueArch(const ArchSpec &current_value, const ArchSpec &default_value)
+ : OptionValue(), m_current_value(current_value),
+ m_default_value(default_value) {}
+
+ ~OptionValueArch() override {}
+
+ //---------------------------------------------------------------------
+ // Virtual subclass pure virtual overrides
+ //---------------------------------------------------------------------
+
+ OptionValue::Type GetType() const override { return eTypeArch; }
+
+ void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
+ uint32_t dump_mask) override;
+
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
+ Error
+ SetValueFromString(const char *,
+ VarSetOperationType = eVarSetOperationAssign) = delete;
+
+ bool Clear() override {
+ m_current_value = m_default_value;
+ m_value_was_set = false;
+ return true;
+ }
+
+ lldb::OptionValueSP DeepCopy() const override;
+
+ size_t AutoComplete(CommandInterpreter &interpreter, llvm::StringRef s,
+ int match_start_point, int max_return_elements,
+ bool &word_complete, StringList &matches) override;
+
+ //---------------------------------------------------------------------
+ // Subclass specific functions
+ //---------------------------------------------------------------------
+
+ ArchSpec &GetCurrentValue() { return m_current_value; }
+
+ const ArchSpec &GetCurrentValue() const { return m_current_value; }
+
+ const ArchSpec &GetDefaultValue() const { return m_default_value; }
+
+ void SetCurrentValue(const ArchSpec &value, bool set_value_was_set) {
+ m_current_value = value;
+ if (set_value_was_set)
+ m_value_was_set = true;
+ }
+
+ void SetDefaultValue(const ArchSpec &value) { m_default_value = value; }
+
protected:
- ArchSpec m_current_value;
- ArchSpec m_default_value;
+ ArchSpec m_current_value;
+ ArchSpec m_default_value;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionValueArgs.h b/include/lldb/Interpreter/OptionValueArgs.h
index ad9505af3015..433679da134e 100644
--- a/include/lldb/Interpreter/OptionValueArgs.h
+++ b/include/lldb/Interpreter/OptionValueArgs.h
@@ -18,26 +18,17 @@
namespace lldb_private {
-class OptionValueArgs : public OptionValueArray
-{
+class OptionValueArgs : public OptionValueArray {
public:
- OptionValueArgs () :
- OptionValueArray (OptionValue::ConvertTypeToMask (OptionValue::eTypeString))
- {
- }
-
- ~OptionValueArgs() override
- {
- }
-
- size_t
- GetArgs (Args &args);
-
- Type
- GetType() const override
- {
- return eTypeArgs;
- }
+ OptionValueArgs()
+ : OptionValueArray(
+ OptionValue::ConvertTypeToMask(OptionValue::eTypeString)) {}
+
+ ~OptionValueArgs() override {}
+
+ size_t GetArgs(Args &args);
+
+ Type GetType() const override { return eTypeArgs; }
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionValueArray.h b/include/lldb/Interpreter/OptionValueArray.h
index 38b9e3c3ee97..1e568cac402d 100644
--- a/include/lldb/Interpreter/OptionValueArray.h
+++ b/include/lldb/Interpreter/OptionValueArray.h
@@ -20,156 +20,116 @@
namespace lldb_private {
-class OptionValueArray : public OptionValue
-{
+class OptionValueArray : public OptionValue {
public:
- OptionValueArray (uint32_t type_mask = UINT32_MAX, bool raw_value_dump = false) :
- m_type_mask (type_mask),
- m_values (),
- m_raw_value_dump(raw_value_dump)
- {
- }
-
- ~OptionValueArray() override
- {
- }
-
- //---------------------------------------------------------------------
- // Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
-
- OptionValue::Type
- GetType() const override
- {
- return eTypeArray;
+ OptionValueArray(uint32_t type_mask = UINT32_MAX, bool raw_value_dump = false)
+ : m_type_mask(type_mask), m_values(), m_raw_value_dump(raw_value_dump) {}
+
+ ~OptionValueArray() override {}
+
+ //---------------------------------------------------------------------
+ // Virtual subclass pure virtual overrides
+ //---------------------------------------------------------------------
+
+ OptionValue::Type GetType() const override { return eTypeArray; }
+
+ void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
+ uint32_t dump_mask) override;
+
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
+ Error
+ SetValueFromString(const char *,
+ VarSetOperationType = eVarSetOperationAssign) = delete;
+
+ bool Clear() override {
+ m_values.clear();
+ m_value_was_set = false;
+ return true;
+ }
+
+ lldb::OptionValueSP DeepCopy() const override;
+
+ bool IsAggregateValue() const override { return true; }
+
+ lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
+ llvm::StringRef name, bool will_modify,
+ Error &error) const override;
+
+ //---------------------------------------------------------------------
+ // Subclass specific functions
+ //---------------------------------------------------------------------
+
+ size_t GetSize() const { return m_values.size(); }
+
+ lldb::OptionValueSP operator[](size_t idx) const {
+ lldb::OptionValueSP value_sp;
+ if (idx < m_values.size())
+ value_sp = m_values[idx];
+ return value_sp;
+ }
+
+ lldb::OptionValueSP GetValueAtIndex(size_t idx) const {
+ lldb::OptionValueSP value_sp;
+ if (idx < m_values.size())
+ value_sp = m_values[idx];
+ return value_sp;
+ }
+
+ bool AppendValue(const lldb::OptionValueSP &value_sp) {
+ // Make sure the value_sp object is allowed to contain
+ // values of the type passed in...
+ if (value_sp && (m_type_mask & value_sp->GetTypeAsMask())) {
+ m_values.push_back(value_sp);
+ return true;
}
-
- void
- DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
-
- Error
- SetValueFromString(llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign) override;
-
- bool
- Clear() override
- {
- m_values.clear();
- m_value_was_set = false;
- return true;
+ return false;
+ }
+
+ bool InsertValue(size_t idx, const lldb::OptionValueSP &value_sp) {
+ // Make sure the value_sp object is allowed to contain
+ // values of the type passed in...
+ if (value_sp && (m_type_mask & value_sp->GetTypeAsMask())) {
+ if (idx < m_values.size())
+ m_values.insert(m_values.begin() + idx, value_sp);
+ else
+ m_values.push_back(value_sp);
+ return true;
}
-
- lldb::OptionValueSP
- DeepCopy() const override;
-
- bool
- IsAggregateValue() const override
- {
+ return false;
+ }
+
+ bool ReplaceValue(size_t idx, const lldb::OptionValueSP &value_sp) {
+ // Make sure the value_sp object is allowed to contain
+ // values of the type passed in...
+ if (value_sp && (m_type_mask & value_sp->GetTypeAsMask())) {
+ if (idx < m_values.size()) {
+ m_values[idx] = value_sp;
return true;
+ }
}
-
- lldb::OptionValueSP
- GetSubValue(const ExecutionContext *exe_ctx,
- const char *name,
- bool will_modify,
- Error &error) const override;
-
- //---------------------------------------------------------------------
- // Subclass specific functions
- //---------------------------------------------------------------------
-
- size_t
- GetSize () const
- {
- return m_values.size();
- }
+ return false;
+ }
- lldb::OptionValueSP
- operator[](size_t idx) const
- {
- lldb::OptionValueSP value_sp;
- if (idx < m_values.size())
- value_sp = m_values[idx];
- return value_sp;
+ bool DeleteValue(size_t idx) {
+ if (idx < m_values.size()) {
+ m_values.erase(m_values.begin() + idx);
+ return true;
}
+ return false;
+ }
- lldb::OptionValueSP
- GetValueAtIndex (size_t idx) const
- {
- lldb::OptionValueSP value_sp;
- if (idx < m_values.size())
- value_sp = m_values[idx];
- return value_sp;
- }
-
- bool
- AppendValue (const lldb::OptionValueSP &value_sp)
- {
- // Make sure the value_sp object is allowed to contain
- // values of the type passed in...
- if (value_sp && (m_type_mask & value_sp->GetTypeAsMask()))
- {
- m_values.push_back(value_sp);
- return true;
- }
- return false;
- }
-
- bool
- InsertValue (size_t idx, const lldb::OptionValueSP &value_sp)
- {
- // Make sure the value_sp object is allowed to contain
- // values of the type passed in...
- if (value_sp && (m_type_mask & value_sp->GetTypeAsMask()))
- {
- if (idx < m_values.size())
- m_values.insert(m_values.begin() + idx, value_sp);
- else
- m_values.push_back(value_sp);
- return true;
- }
- return false;
- }
+ size_t GetArgs(Args &args) const;
- bool
- ReplaceValue (size_t idx, const lldb::OptionValueSP &value_sp)
- {
- // Make sure the value_sp object is allowed to contain
- // values of the type passed in...
- if (value_sp && (m_type_mask & value_sp->GetTypeAsMask()))
- {
- if (idx < m_values.size())
- {
- m_values[idx] = value_sp;
- return true;
- }
- }
- return false;
- }
+ Error SetArgs(const Args &args, VarSetOperationType op);
- bool
- DeleteValue (size_t idx)
- {
- if (idx < m_values.size())
- {
- m_values.erase (m_values.begin() + idx);
- return true;
- }
- return false;
- }
-
- size_t
- GetArgs (Args &args) const;
-
- Error
- SetArgs (const Args &args, VarSetOperationType op);
-
protected:
- typedef std::vector<lldb::OptionValueSP> collection;
-
- uint32_t m_type_mask;
- collection m_values;
- bool m_raw_value_dump;
+ typedef std::vector<lldb::OptionValueSP> collection;
+
+ uint32_t m_type_mask;
+ collection m_values;
+ bool m_raw_value_dump;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionValueBoolean.h b/include/lldb/Interpreter/OptionValueBoolean.h
index 52d39a9b8d27..d429c0577ecb 100644
--- a/include/lldb/Interpreter/OptionValueBoolean.h
+++ b/include/lldb/Interpreter/OptionValueBoolean.h
@@ -18,121 +18,81 @@
namespace lldb_private {
-class OptionValueBoolean : public OptionValue
-{
+class OptionValueBoolean : public OptionValue {
public:
- OptionValueBoolean (bool value) :
- OptionValue(),
- m_current_value (value),
- m_default_value (value)
- {
- }
- OptionValueBoolean (bool current_value,
- bool default_value) :
- OptionValue(),
- m_current_value (current_value),
- m_default_value (default_value)
- {
- }
-
- ~OptionValueBoolean() override
- {
- }
-
- //---------------------------------------------------------------------
- // Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
-
- OptionValue::Type
- GetType() const override
- {
- return eTypeBoolean;
- }
-
- void
- DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
-
- Error
- SetValueFromString(llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign) override;
-
- bool
- Clear() override
- {
- m_current_value = m_default_value;
- m_value_was_set = false;
- return true;
- }
-
- size_t
- AutoComplete(CommandInterpreter &interpreter,
- const char *s,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches) override;
-
- //---------------------------------------------------------------------
- // Subclass specific functions
- //---------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Convert to bool operator.
- ///
- /// This allows code to check a OptionValueBoolean in conditions.
- ///
- /// @code
- /// OptionValueBoolean bool_value(...);
- /// if (bool_value)
- /// { ...
- /// @endcode
- ///
- /// @return
- /// /b True this object contains a valid namespace decl, \b
- /// false otherwise.
- //------------------------------------------------------------------
- explicit operator bool() const
- {
- return m_current_value;
- }
-
- const bool &
- operator = (bool b)
- {
- m_current_value = b;
- return m_current_value;
- }
-
- bool
- GetCurrentValue() const
- {
- return m_current_value;
- }
-
- bool
- GetDefaultValue() const
- {
- return m_default_value;
- }
-
- void
- SetCurrentValue (bool value)
- {
- m_current_value = value;
- }
-
- void
- SetDefaultValue (bool value)
- {
- m_default_value = value;
- }
-
- lldb::OptionValueSP
- DeepCopy() const override;
+ OptionValueBoolean(bool value)
+ : OptionValue(), m_current_value(value), m_default_value(value) {}
+ OptionValueBoolean(bool current_value, bool default_value)
+ : OptionValue(), m_current_value(current_value),
+ m_default_value(default_value) {}
+
+ ~OptionValueBoolean() override {}
+
+ //---------------------------------------------------------------------
+ // Virtual subclass pure virtual overrides
+ //---------------------------------------------------------------------
+
+ OptionValue::Type GetType() const override { return eTypeBoolean; }
+
+ void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
+ uint32_t dump_mask) override;
+
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
+ Error
+ SetValueFromString(const char *,
+ VarSetOperationType = eVarSetOperationAssign) = delete;
+
+ bool Clear() override {
+ m_current_value = m_default_value;
+ m_value_was_set = false;
+ return true;
+ }
+
+ size_t AutoComplete(CommandInterpreter &interpreter, llvm::StringRef s,
+ int match_start_point, int max_return_elements,
+ bool &word_complete, StringList &matches) override;
+
+ //---------------------------------------------------------------------
+ // Subclass specific functions
+ //---------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Convert to bool operator.
+ ///
+ /// This allows code to check a OptionValueBoolean in conditions.
+ ///
+ /// @code
+ /// OptionValueBoolean bool_value(...);
+ /// if (bool_value)
+ /// { ...
+ /// @endcode
+ ///
+ /// @return
+ /// /b True this object contains a valid namespace decl, \b
+ /// false otherwise.
+ //------------------------------------------------------------------
+ explicit operator bool() const { return m_current_value; }
+
+ const bool &operator=(bool b) {
+ m_current_value = b;
+ return m_current_value;
+ }
+
+ bool GetCurrentValue() const { return m_current_value; }
+
+ bool GetDefaultValue() const { return m_default_value; }
+
+ void SetCurrentValue(bool value) { m_current_value = value; }
+
+ void SetDefaultValue(bool value) { m_default_value = value; }
+
+ lldb::OptionValueSP DeepCopy() const override;
protected:
- bool m_current_value;
- bool m_default_value;
+ bool m_current_value;
+ bool m_default_value;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionValueChar.h b/include/lldb/Interpreter/OptionValueChar.h
index b05d9ca098b2..d18644700573 100644
--- a/include/lldb/Interpreter/OptionValueChar.h
+++ b/include/lldb/Interpreter/OptionValueChar.h
@@ -18,94 +18,61 @@
namespace lldb_private {
-class OptionValueChar : public OptionValue
-{
+class OptionValueChar : public OptionValue {
public:
- OptionValueChar (char value) :
- OptionValue(),
- m_current_value (value),
- m_default_value (value)
- {
- }
-
- OptionValueChar (char current_value,
- char default_value) :
- OptionValue(),
- m_current_value (current_value),
- m_default_value (default_value)
- {
- }
-
- ~OptionValueChar() override
- {
- }
-
- //---------------------------------------------------------------------
- // Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
-
- OptionValue::Type
- GetType() const override
- {
- return eTypeChar;
- }
-
- void
- DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
-
- Error
- SetValueFromString(llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign) override;
-
- bool
- Clear() override
- {
- m_current_value = m_default_value;
- m_value_was_set = false;
- return true;
- }
-
- //---------------------------------------------------------------------
- // Subclass specific functions
- //---------------------------------------------------------------------
-
- const char &
- operator = (char c)
- {
- m_current_value = c;
- return m_current_value;
- }
-
- char
- GetCurrentValue() const
- {
- return m_current_value;
- }
-
- char
- GetDefaultValue() const
- {
- return m_default_value;
- }
-
- void
- SetCurrentValue (char value)
- {
- m_current_value = value;
- }
-
- void
- SetDefaultValue (char value)
- {
- m_default_value = value;
- }
-
- lldb::OptionValueSP
- DeepCopy() const override;
+ OptionValueChar(char value)
+ : OptionValue(), m_current_value(value), m_default_value(value) {}
+
+ OptionValueChar(char current_value, char default_value)
+ : OptionValue(), m_current_value(current_value),
+ m_default_value(default_value) {}
+
+ ~OptionValueChar() override {}
+
+ //---------------------------------------------------------------------
+ // Virtual subclass pure virtual overrides
+ //---------------------------------------------------------------------
+
+ OptionValue::Type GetType() const override { return eTypeChar; }
+
+ void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
+ uint32_t dump_mask) override;
+
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
+ Error
+ SetValueFromString(const char *,
+ VarSetOperationType = eVarSetOperationAssign) = delete;
+
+ bool Clear() override {
+ m_current_value = m_default_value;
+ m_value_was_set = false;
+ return true;
+ }
+
+ //---------------------------------------------------------------------
+ // Subclass specific functions
+ //---------------------------------------------------------------------
+
+ const char &operator=(char c) {
+ m_current_value = c;
+ return m_current_value;
+ }
+
+ char GetCurrentValue() const { return m_current_value; }
+
+ char GetDefaultValue() const { return m_default_value; }
+
+ void SetCurrentValue(char value) { m_current_value = value; }
+
+ void SetDefaultValue(char value) { m_default_value = value; }
+
+ lldb::OptionValueSP DeepCopy() const override;
protected:
- char m_current_value;
- char m_default_value;
+ char m_current_value;
+ char m_default_value;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionValueDictionary.h b/include/lldb/Interpreter/OptionValueDictionary.h
index 8ee839775646..5d015a55a8f9 100644
--- a/include/lldb/Interpreter/OptionValueDictionary.h
+++ b/include/lldb/Interpreter/OptionValueDictionary.h
@@ -19,120 +19,75 @@
#include "lldb/Interpreter/OptionValue.h"
namespace lldb_private {
-
-class OptionValueDictionary : public OptionValue
-{
+
+class OptionValueDictionary : public OptionValue {
public:
- OptionValueDictionary (uint32_t type_mask = UINT32_MAX, bool raw_value_dump = true) :
- OptionValue(),
- m_type_mask (type_mask),
- m_values (),
- m_raw_value_dump (raw_value_dump)
- {
- }
-
- ~OptionValueDictionary() override
- {
- }
-
- //---------------------------------------------------------------------
- // Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
-
- OptionValue::Type
- GetType() const override
- {
- return eTypeDictionary;
- }
-
- void
- DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
-
- Error
- SetValueFromString(llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign) override;
-
- bool
- Clear() override
- {
- m_values.clear();
- m_value_was_set = false;
- return true;
- }
-
- lldb::OptionValueSP
- DeepCopy() const override;
-
- bool
- IsAggregateValue() const override
- {
- return true;
- }
-
- bool
- IsHomogenous() const
- {
- return ConvertTypeMaskToType (m_type_mask) != eTypeInvalid;
- }
-
- //---------------------------------------------------------------------
- // Subclass specific functions
- //---------------------------------------------------------------------
-
- size_t
- GetNumValues() const
- {
- return m_values.size();
- }
-
- lldb::OptionValueSP
- GetValueForKey (const ConstString &key) const;
-
- lldb::OptionValueSP
- GetSubValue(const ExecutionContext *exe_ctx,
- const char *name,
- bool will_modify,
- Error &error) const override;
-
- Error
- SetSubValue(const ExecutionContext *exe_ctx,
- VarSetOperationType op,
- const char *name,
- const char *value) override;
-
- //---------------------------------------------------------------------
- // String value getters and setters
- //---------------------------------------------------------------------
- const char *
- GetStringValueForKey (const ConstString &key);
-
- bool
- SetStringValueForKey (const ConstString &key,
- const char *value,
- bool can_replace = true);
-
-
- bool
- SetValueForKey (const ConstString &key,
- const lldb::OptionValueSP &value_sp,
- bool can_replace = true);
-
- bool
- DeleteValueForKey (const ConstString &key);
-
- size_t
- GetArgs (Args &args) const;
-
- Error
- SetArgs (const Args &args, VarSetOperationType op);
-
+ OptionValueDictionary(uint32_t type_mask = UINT32_MAX,
+ bool raw_value_dump = true)
+ : OptionValue(), m_type_mask(type_mask), m_values(),
+ m_raw_value_dump(raw_value_dump) {}
+
+ ~OptionValueDictionary() override {}
+
+ //---------------------------------------------------------------------
+ // Virtual subclass pure virtual overrides
+ //---------------------------------------------------------------------
+
+ OptionValue::Type GetType() const override { return eTypeDictionary; }
+
+ void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
+ uint32_t dump_mask) override;
+
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
+
+ bool Clear() override {
+ m_values.clear();
+ m_value_was_set = false;
+ return true;
+ }
+
+ lldb::OptionValueSP DeepCopy() const override;
+
+ bool IsAggregateValue() const override { return true; }
+
+ bool IsHomogenous() const {
+ return ConvertTypeMaskToType(m_type_mask) != eTypeInvalid;
+ }
+
+ //---------------------------------------------------------------------
+ // Subclass specific functions
+ //---------------------------------------------------------------------
+
+ size_t GetNumValues() const { return m_values.size(); }
+
+ lldb::OptionValueSP GetValueForKey(const ConstString &key) const;
+
+ lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
+ llvm::StringRef name, bool will_modify,
+ Error &error) const override;
+
+ Error SetSubValue(const ExecutionContext *exe_ctx, VarSetOperationType op,
+ llvm::StringRef name, llvm::StringRef value) override;
+
+ bool SetValueForKey(const ConstString &key,
+ const lldb::OptionValueSP &value_sp,
+ bool can_replace = true);
+
+ bool DeleteValueForKey(const ConstString &key);
+
+ size_t GetArgs(Args &args) const;
+
+ Error SetArgs(const Args &args, VarSetOperationType op);
+
protected:
- typedef std::map<ConstString, lldb::OptionValueSP> collection;
- uint32_t m_type_mask;
- collection m_values;
- bool m_raw_value_dump;
+ typedef std::map<ConstString, lldb::OptionValueSP> collection;
+ uint32_t m_type_mask;
+ collection m_values;
+ bool m_raw_value_dump;
};
-
+
} // namespace lldb_private
#endif // liblldb_OptionValueDictionary_h_
diff --git a/include/lldb/Interpreter/OptionValueEnumeration.h b/include/lldb/Interpreter/OptionValueEnumeration.h
index b3fc481dd7fa..273e69cc6d66 100644
--- a/include/lldb/Interpreter/OptionValueEnumeration.h
+++ b/include/lldb/Interpreter/OptionValueEnumeration.h
@@ -23,100 +23,72 @@
namespace lldb_private {
-class OptionValueEnumeration : public OptionValue
-{
+class OptionValueEnumeration : public OptionValue {
public:
- typedef int64_t enum_type;
- struct EnumeratorInfo
- {
- enum_type value;
- const char *description;
- };
- typedef UniqueCStringMap<EnumeratorInfo> EnumerationMap;
- typedef EnumerationMap::Entry EnumerationMapEntry;
-
- OptionValueEnumeration (const OptionEnumValueElement *enumerators, enum_type value);
-
- ~OptionValueEnumeration() override;
-
- //---------------------------------------------------------------------
- // Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
-
- OptionValue::Type
- GetType() const override
- {
- return eTypeEnum;
- }
-
- void
- DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
-
- Error
- SetValueFromString(llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign) override;
-
- bool
- Clear() override
- {
- m_current_value = m_default_value;
- m_value_was_set = false;
- return true;
- }
-
- lldb::OptionValueSP
- DeepCopy() const override;
-
- size_t
- AutoComplete(CommandInterpreter &interpreter,
- const char *s,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches) override;
-
- //---------------------------------------------------------------------
- // Subclass specific functions
- //---------------------------------------------------------------------
-
- enum_type
- operator = (enum_type value)
- {
- m_current_value = value;
- return m_current_value;
- }
-
- enum_type
- GetCurrentValue() const
- {
- return m_current_value;
- }
-
- enum_type
- GetDefaultValue() const
- {
- return m_default_value;
- }
-
- void
- SetCurrentValue (enum_type value)
- {
- m_current_value = value;
- }
-
- void
- SetDefaultValue (enum_type value)
- {
- m_default_value = value;
- }
-
+ typedef int64_t enum_type;
+ struct EnumeratorInfo {
+ enum_type value;
+ const char *description;
+ };
+ typedef UniqueCStringMap<EnumeratorInfo> EnumerationMap;
+ typedef EnumerationMap::Entry EnumerationMapEntry;
+
+ OptionValueEnumeration(const OptionEnumValueElement *enumerators,
+ enum_type value);
+
+ ~OptionValueEnumeration() override;
+
+ //---------------------------------------------------------------------
+ // Virtual subclass pure virtual overrides
+ //---------------------------------------------------------------------
+
+ OptionValue::Type GetType() const override { return eTypeEnum; }
+
+ void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
+ uint32_t dump_mask) override;
+
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
+ Error
+ SetValueFromString(const char *,
+ VarSetOperationType = eVarSetOperationAssign) = delete;
+
+ bool Clear() override {
+ m_current_value = m_default_value;
+ m_value_was_set = false;
+ return true;
+ }
+
+ lldb::OptionValueSP DeepCopy() const override;
+
+ size_t AutoComplete(CommandInterpreter &interpreter, llvm::StringRef s,
+ int match_start_point, int max_return_elements,
+ bool &word_complete, StringList &matches) override;
+
+ //---------------------------------------------------------------------
+ // Subclass specific functions
+ //---------------------------------------------------------------------
+
+ enum_type operator=(enum_type value) {
+ m_current_value = value;
+ return m_current_value;
+ }
+
+ enum_type GetCurrentValue() const { return m_current_value; }
+
+ enum_type GetDefaultValue() const { return m_default_value; }
+
+ void SetCurrentValue(enum_type value) { m_current_value = value; }
+
+ void SetDefaultValue(enum_type value) { m_default_value = value; }
+
protected:
- void
- SetEnumerations (const OptionEnumValueElement *enumerators);
+ void SetEnumerations(const OptionEnumValueElement *enumerators);
- enum_type m_current_value;
- enum_type m_default_value;
- EnumerationMap m_enumerations;
+ enum_type m_current_value;
+ enum_type m_default_value;
+ EnumerationMap m_enumerations;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionValueFileSpec.h b/include/lldb/Interpreter/OptionValueFileSpec.h
index 274c4d064e51..8020aa7fb49d 100644
--- a/include/lldb/Interpreter/OptionValueFileSpec.h
+++ b/include/lldb/Interpreter/OptionValueFileSpec.h
@@ -10,122 +10,84 @@
#ifndef liblldb_OptionValueFileSpec_h_
#define liblldb_OptionValueFileSpec_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Host/FileSpec.h"
#include "lldb/Interpreter/OptionValue.h"
+#include "lldb/Host/FileSpec.h"
+#include "llvm/Support/Chrono.h"
+
namespace lldb_private {
-class OptionValueFileSpec : public OptionValue
-{
+class OptionValueFileSpec : public OptionValue {
public:
- OptionValueFileSpec (bool resolve = true);
-
- OptionValueFileSpec (const FileSpec &value,
- bool resolve = true);
-
- OptionValueFileSpec (const FileSpec &current_value,
- const FileSpec &default_value,
- bool resolve = true);
-
- ~OptionValueFileSpec() override
- {
- }
-
- //---------------------------------------------------------------------
- // Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
-
- OptionValue::Type
- GetType() const override
- {
- return eTypeFileSpec;
- }
-
- void
- DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
-
- Error
- SetValueFromString(llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign) override;
-
- bool
- Clear() override
- {
- m_current_value = m_default_value;
- m_value_was_set = false;
- m_data_sp.reset();
- m_data_mod_time.Clear();
- return true;
- }
-
- lldb::OptionValueSP
- DeepCopy() const override;
-
- size_t
- AutoComplete(CommandInterpreter &interpreter,
- const char *s,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches) override;
-
- //---------------------------------------------------------------------
- // Subclass specific functions
- //---------------------------------------------------------------------
-
- FileSpec &
- GetCurrentValue()
- {
- return m_current_value;
- }
-
- const FileSpec &
- GetCurrentValue() const
- {
- return m_current_value;
- }
-
- const FileSpec &
- GetDefaultValue() const
- {
- return m_default_value;
- }
-
- void
- SetCurrentValue (const FileSpec &value, bool set_value_was_set)
- {
- m_current_value = value;
- if (set_value_was_set)
- m_value_was_set = true;
- m_data_sp.reset();
- }
-
- void
- SetDefaultValue (const FileSpec &value)
- {
- m_default_value = value;
- }
-
- const lldb::DataBufferSP &
- GetFileContents(bool null_terminate);
-
- void
- SetCompletionMask (uint32_t mask)
- {
- m_completion_mask = mask;
- }
+ OptionValueFileSpec(bool resolve = true);
+
+ OptionValueFileSpec(const FileSpec &value, bool resolve = true);
+
+ OptionValueFileSpec(const FileSpec &current_value,
+ const FileSpec &default_value, bool resolve = true);
+
+ ~OptionValueFileSpec() override {}
+
+ //---------------------------------------------------------------------
+ // Virtual subclass pure virtual overrides
+ //---------------------------------------------------------------------
+
+ OptionValue::Type GetType() const override { return eTypeFileSpec; }
+
+ void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
+ uint32_t dump_mask) override;
+
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
+ Error
+ SetValueFromString(const char *,
+ VarSetOperationType = eVarSetOperationAssign) = delete;
+
+ bool Clear() override {
+ m_current_value = m_default_value;
+ m_value_was_set = false;
+ m_data_sp.reset();
+ m_data_mod_time = llvm::sys::TimePoint<>();
+ return true;
+ }
+
+ lldb::OptionValueSP DeepCopy() const override;
+
+ size_t AutoComplete(CommandInterpreter &interpreter, llvm::StringRef s,
+ int match_start_point, int max_return_elements,
+ bool &word_complete, StringList &matches) override;
+
+ //---------------------------------------------------------------------
+ // Subclass specific functions
+ //---------------------------------------------------------------------
+
+ FileSpec &GetCurrentValue() { return m_current_value; }
+
+ const FileSpec &GetCurrentValue() const { return m_current_value; }
+
+ const FileSpec &GetDefaultValue() const { return m_default_value; }
+
+ void SetCurrentValue(const FileSpec &value, bool set_value_was_set) {
+ m_current_value = value;
+ if (set_value_was_set)
+ m_value_was_set = true;
+ m_data_sp.reset();
+ }
+
+ void SetDefaultValue(const FileSpec &value) { m_default_value = value; }
+
+ const lldb::DataBufferSP &GetFileContents(bool null_terminate);
+
+ void SetCompletionMask(uint32_t mask) { m_completion_mask = mask; }
protected:
- FileSpec m_current_value;
- FileSpec m_default_value;
- lldb::DataBufferSP m_data_sp;
- TimeValue m_data_mod_time;
- uint32_t m_completion_mask;
- bool m_resolve;
+ FileSpec m_current_value;
+ FileSpec m_default_value;
+ lldb::DataBufferSP m_data_sp;
+ llvm::sys::TimePoint<> m_data_mod_time;
+ uint32_t m_completion_mask;
+ bool m_resolve;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionValueFileSpecList.h b/include/lldb/Interpreter/OptionValueFileSpecList.h
index 205132358024..1e42362c9163 100644
--- a/include/lldb/Interpreter/OptionValueFileSpecList.h
+++ b/include/lldb/Interpreter/OptionValueFileSpecList.h
@@ -19,83 +19,53 @@
namespace lldb_private {
-class OptionValueFileSpecList : public OptionValue
-{
+class OptionValueFileSpecList : public OptionValue {
public:
- OptionValueFileSpecList () :
- OptionValue(),
- m_current_value ()
- {
- }
-
- OptionValueFileSpecList (const FileSpecList &current_value) :
- OptionValue(),
- m_current_value (current_value)
- {
- }
-
- ~OptionValueFileSpecList() override
- {
- }
-
- //---------------------------------------------------------------------
- // Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
-
- OptionValue::Type
- GetType() const override
- {
- return eTypeFileSpecList;
- }
-
- void
- DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
-
- Error
- SetValueFromString(llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign) override;
-
- bool
- Clear() override
- {
- m_current_value.Clear();
- m_value_was_set = false;
- return true;
- }
-
- lldb::OptionValueSP
- DeepCopy() const override;
-
- bool
- IsAggregateValue() const override
- {
- return true;
- }
-
- //---------------------------------------------------------------------
- // Subclass specific functions
- //---------------------------------------------------------------------
-
- FileSpecList &
- GetCurrentValue()
- {
- return m_current_value;
- }
-
- const FileSpecList &
- GetCurrentValue() const
- {
- return m_current_value;
- }
-
- void
- SetCurrentValue (const FileSpecList &value)
- {
- m_current_value = value;
- }
-
+ OptionValueFileSpecList() : OptionValue(), m_current_value() {}
+
+ OptionValueFileSpecList(const FileSpecList &current_value)
+ : OptionValue(), m_current_value(current_value) {}
+
+ ~OptionValueFileSpecList() override {}
+
+ //---------------------------------------------------------------------
+ // Virtual subclass pure virtual overrides
+ //---------------------------------------------------------------------
+
+ OptionValue::Type GetType() const override { return eTypeFileSpecList; }
+
+ void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
+ uint32_t dump_mask) override;
+
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
+ Error
+ SetValueFromString(const char *,
+ VarSetOperationType = eVarSetOperationAssign) = delete;
+
+ bool Clear() override {
+ m_current_value.Clear();
+ m_value_was_set = false;
+ return true;
+ }
+
+ lldb::OptionValueSP DeepCopy() const override;
+
+ bool IsAggregateValue() const override { return true; }
+
+ //---------------------------------------------------------------------
+ // Subclass specific functions
+ //---------------------------------------------------------------------
+
+ FileSpecList &GetCurrentValue() { return m_current_value; }
+
+ const FileSpecList &GetCurrentValue() const { return m_current_value; }
+
+ void SetCurrentValue(const FileSpecList &value) { m_current_value = value; }
+
protected:
- FileSpecList m_current_value;
+ FileSpecList m_current_value;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionValueFormat.h b/include/lldb/Interpreter/OptionValueFormat.h
index 1c2909459911..5351aeca0627 100644
--- a/include/lldb/Interpreter/OptionValueFormat.h
+++ b/include/lldb/Interpreter/OptionValueFormat.h
@@ -18,87 +18,56 @@
namespace lldb_private {
-class OptionValueFormat : public OptionValue
-{
+class OptionValueFormat : public OptionValue {
public:
- OptionValueFormat (lldb::Format value) :
- OptionValue(),
- m_current_value (value),
- m_default_value (value)
- {
- }
-
- OptionValueFormat (lldb::Format current_value,
- lldb::Format default_value) :
- OptionValue(),
- m_current_value (current_value),
- m_default_value (default_value)
- {
- }
-
- ~OptionValueFormat() override
- {
- }
-
- //---------------------------------------------------------------------
- // Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
-
- OptionValue::Type
- GetType() const override
- {
- return eTypeFormat;
- }
-
- void
- DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
-
- Error
- SetValueFromString(llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign) override;
-
- bool
- Clear() override
- {
- m_current_value = m_default_value;
- m_value_was_set = false;
- return true;
- }
-
- lldb::OptionValueSP
- DeepCopy() const override;
-
- //---------------------------------------------------------------------
- // Subclass specific functions
- //---------------------------------------------------------------------
-
- lldb::Format
- GetCurrentValue() const
- {
- return m_current_value;
- }
-
- lldb::Format
- GetDefaultValue() const
- {
- return m_default_value;
- }
-
- void
- SetCurrentValue (lldb::Format value)
- {
- m_current_value = value;
- }
-
- void
- SetDefaultValue (lldb::Format value)
- {
- m_default_value = value;
- }
-
+ OptionValueFormat(lldb::Format value)
+ : OptionValue(), m_current_value(value), m_default_value(value) {}
+
+ OptionValueFormat(lldb::Format current_value, lldb::Format default_value)
+ : OptionValue(), m_current_value(current_value),
+ m_default_value(default_value) {}
+
+ ~OptionValueFormat() override {}
+
+ //---------------------------------------------------------------------
+ // Virtual subclass pure virtual overrides
+ //---------------------------------------------------------------------
+
+ OptionValue::Type GetType() const override { return eTypeFormat; }
+
+ void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
+ uint32_t dump_mask) override;
+
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
+ Error
+ SetValueFromString(const char *,
+ VarSetOperationType = eVarSetOperationAssign) = delete;
+
+ bool Clear() override {
+ m_current_value = m_default_value;
+ m_value_was_set = false;
+ return true;
+ }
+
+ lldb::OptionValueSP DeepCopy() const override;
+
+ //---------------------------------------------------------------------
+ // Subclass specific functions
+ //---------------------------------------------------------------------
+
+ lldb::Format GetCurrentValue() const { return m_current_value; }
+
+ lldb::Format GetDefaultValue() const { return m_default_value; }
+
+ void SetCurrentValue(lldb::Format value) { m_current_value = value; }
+
+ void SetDefaultValue(lldb::Format value) { m_default_value = value; }
+
protected:
- lldb::Format m_current_value;
- lldb::Format m_default_value;
+ lldb::Format m_current_value;
+ lldb::Format m_default_value;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionValueFormatEntity.h b/include/lldb/Interpreter/OptionValueFormatEntity.h
index 10a456a1b994..472cd9ee4f92 100644
--- a/include/lldb/Interpreter/OptionValueFormatEntity.h
+++ b/include/lldb/Interpreter/OptionValueFormatEntity.h
@@ -1,4 +1,4 @@
-//===-- OptionValueFormatEntity.h --------------------------------------*- C++ -*-===//
+//===-- OptionValueFormatEntity.h --------------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -19,85 +19,57 @@
namespace lldb_private {
-class OptionValueFormatEntity : public OptionValue
-{
+class OptionValueFormatEntity : public OptionValue {
public:
- OptionValueFormatEntity (const char *default_format);
-
- ~OptionValueFormatEntity() override
- {
- }
-
- //---------------------------------------------------------------------
- // Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
-
- OptionValue::Type
- GetType () const override
- {
- return eTypeFormatEntity;
- }
-
- void
- DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
-
- Error
- SetValueFromString (llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign) override;
-
- bool
- Clear () override;
-
- lldb::OptionValueSP
- DeepCopy () const override;
-
- size_t
- AutoComplete (CommandInterpreter &interpreter,
- const char *s,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches) override;
-
- //---------------------------------------------------------------------
- // Subclass specific functions
- //---------------------------------------------------------------------
-
- FormatEntity::Entry &
- GetCurrentValue()
- {
- return m_current_entry;
- }
-
- const FormatEntity::Entry &
- GetCurrentValue() const
- {
- return m_current_entry;
- }
-
- void
- SetCurrentValue (const FormatEntity::Entry &value)
- {
- m_current_entry = value;
- }
-
- FormatEntity::Entry &
- GetDefaultValue()
- {
- return m_default_entry;
- }
-
- const FormatEntity::Entry &
- GetDefaultValue() const
- {
- return m_default_entry;
- }
+ OptionValueFormatEntity(const char *default_format);
+
+ ~OptionValueFormatEntity() override {}
+
+ //---------------------------------------------------------------------
+ // Virtual subclass pure virtual overrides
+ //---------------------------------------------------------------------
+
+ OptionValue::Type GetType() const override { return eTypeFormatEntity; }
+
+ void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
+ uint32_t dump_mask) override;
+
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
+ Error
+ SetValueFromString(const char *,
+ VarSetOperationType = eVarSetOperationAssign) = delete;
+
+ bool Clear() override;
+
+ lldb::OptionValueSP DeepCopy() const override;
+
+ size_t AutoComplete(CommandInterpreter &interpreter, llvm::StringRef s,
+ int match_start_point, int max_return_elements,
+ bool &word_complete, StringList &matches) override;
+
+ //---------------------------------------------------------------------
+ // Subclass specific functions
+ //---------------------------------------------------------------------
+
+ FormatEntity::Entry &GetCurrentValue() { return m_current_entry; }
+
+ const FormatEntity::Entry &GetCurrentValue() const { return m_current_entry; }
+
+ void SetCurrentValue(const FormatEntity::Entry &value) {
+ m_current_entry = value;
+ }
+
+ FormatEntity::Entry &GetDefaultValue() { return m_default_entry; }
+
+ const FormatEntity::Entry &GetDefaultValue() const { return m_default_entry; }
protected:
- std::string m_current_format;
- std::string m_default_format;
- FormatEntity::Entry m_current_entry;
- FormatEntity::Entry m_default_entry;
+ std::string m_current_format;
+ std::string m_default_format;
+ FormatEntity::Entry m_current_entry;
+ FormatEntity::Entry m_default_entry;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionValueLanguage.h b/include/lldb/Interpreter/OptionValueLanguage.h
index bd6df3ea4943..a388a6a92eaf 100644
--- a/include/lldb/Interpreter/OptionValueLanguage.h
+++ b/include/lldb/Interpreter/OptionValueLanguage.h
@@ -1,4 +1,5 @@
-//===-- OptionValueLanguage.h -------------------------------------*- C++ -*-===//
+//===-- OptionValueLanguage.h -------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,91 +15,62 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-enumerations.h"
#include "lldb/Interpreter/OptionValue.h"
+#include "lldb/lldb-enumerations.h"
namespace lldb_private {
-class OptionValueLanguage : public OptionValue
-{
+class OptionValueLanguage : public OptionValue {
public:
- OptionValueLanguage (lldb::LanguageType value) :
- OptionValue(),
- m_current_value (value),
- m_default_value (value)
- {
- }
-
- OptionValueLanguage (lldb::LanguageType current_value,
- lldb::LanguageType default_value) :
- OptionValue(),
- m_current_value (current_value),
- m_default_value (default_value)
- {
- }
-
- ~OptionValueLanguage() override
- {
- }
-
- //---------------------------------------------------------------------
- // Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
-
- OptionValue::Type
- GetType () const override
- {
- return eTypeLanguage;
- }
-
- void
- DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
-
- Error
- SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign) override;
-
- bool
- Clear () override
- {
- m_current_value = m_default_value;
- m_value_was_set = false;
- return true;
- }
-
- lldb::OptionValueSP
- DeepCopy () const override;
-
- //---------------------------------------------------------------------
- // Subclass specific functions
- //---------------------------------------------------------------------
-
- lldb::LanguageType
- GetCurrentValue() const
- {
- return m_current_value;
- }
-
- lldb::LanguageType
- GetDefaultValue() const
- {
- return m_default_value;
- }
-
- void
- SetCurrentValue (lldb::LanguageType value)
- {
- m_current_value = value;
- }
-
- void
- SetDefaultValue (lldb::LanguageType value)
- {
- m_default_value = value;
- }
-
+ OptionValueLanguage(lldb::LanguageType value)
+ : OptionValue(), m_current_value(value), m_default_value(value) {}
+
+ OptionValueLanguage(lldb::LanguageType current_value,
+ lldb::LanguageType default_value)
+ : OptionValue(), m_current_value(current_value),
+ m_default_value(default_value) {}
+
+ ~OptionValueLanguage() override {}
+
+ //---------------------------------------------------------------------
+ // Virtual subclass pure virtual overrides
+ //---------------------------------------------------------------------
+
+ OptionValue::Type GetType() const override { return eTypeLanguage; }
+
+ void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
+ uint32_t dump_mask) override;
+
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
+ Error
+ SetValueFromString(const char *,
+ VarSetOperationType = eVarSetOperationAssign) = delete;
+
+ bool Clear() override {
+ m_current_value = m_default_value;
+ m_value_was_set = false;
+ return true;
+ }
+
+ lldb::OptionValueSP DeepCopy() const override;
+
+ //---------------------------------------------------------------------
+ // Subclass specific functions
+ //---------------------------------------------------------------------
+
+ lldb::LanguageType GetCurrentValue() const { return m_current_value; }
+
+ lldb::LanguageType GetDefaultValue() const { return m_default_value; }
+
+ void SetCurrentValue(lldb::LanguageType value) { m_current_value = value; }
+
+ void SetDefaultValue(lldb::LanguageType value) { m_default_value = value; }
+
protected:
- lldb::LanguageType m_current_value;
- lldb::LanguageType m_default_value;
+ lldb::LanguageType m_current_value;
+ lldb::LanguageType m_default_value;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionValuePathMappings.h b/include/lldb/Interpreter/OptionValuePathMappings.h
index 4ed1c8c848d6..d5336aafc993 100644
--- a/include/lldb/Interpreter/OptionValuePathMappings.h
+++ b/include/lldb/Interpreter/OptionValuePathMappings.h
@@ -14,78 +14,55 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Target/PathMappingList.h"
#include "lldb/Interpreter/OptionValue.h"
+#include "lldb/Target/PathMappingList.h"
namespace lldb_private {
-class OptionValuePathMappings : public OptionValue
-{
+class OptionValuePathMappings : public OptionValue {
public:
- OptionValuePathMappings (bool notify_changes) :
- OptionValue(),
- m_path_mappings (),
- m_notify_changes (notify_changes)
- {
- }
-
- ~OptionValuePathMappings() override
- {
- }
-
- //---------------------------------------------------------------------
- // Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
-
- OptionValue::Type
- GetType() const override
- {
- return eTypePathMap;
- }
-
- void
- DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
-
- Error
- SetValueFromString(llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign) override;
-
- bool
- Clear() override
- {
- m_path_mappings.Clear(m_notify_changes);
- m_value_was_set = false;
- return true;
- }
-
- lldb::OptionValueSP
- DeepCopy() const override;
-
- bool
- IsAggregateValue() const override
- {
- return true;
- }
-
- //---------------------------------------------------------------------
- // Subclass specific functions
- //---------------------------------------------------------------------
-
- PathMappingList &
- GetCurrentValue()
- {
- return m_path_mappings;
- }
-
- const PathMappingList &
- GetCurrentValue() const
- {
- return m_path_mappings;
- }
-
+ OptionValuePathMappings(bool notify_changes)
+ : OptionValue(), m_path_mappings(), m_notify_changes(notify_changes) {}
+
+ ~OptionValuePathMappings() override {}
+
+ //---------------------------------------------------------------------
+ // Virtual subclass pure virtual overrides
+ //---------------------------------------------------------------------
+
+ OptionValue::Type GetType() const override { return eTypePathMap; }
+
+ void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
+ uint32_t dump_mask) override;
+
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
+ Error
+ SetValueFromString(const char *,
+ VarSetOperationType = eVarSetOperationAssign) = delete;
+
+ bool Clear() override {
+ m_path_mappings.Clear(m_notify_changes);
+ m_value_was_set = false;
+ return true;
+ }
+
+ lldb::OptionValueSP DeepCopy() const override;
+
+ bool IsAggregateValue() const override { return true; }
+
+ //---------------------------------------------------------------------
+ // Subclass specific functions
+ //---------------------------------------------------------------------
+
+ PathMappingList &GetCurrentValue() { return m_path_mappings; }
+
+ const PathMappingList &GetCurrentValue() const { return m_path_mappings; }
+
protected:
- PathMappingList m_path_mappings;
- bool m_notify_changes;
+ PathMappingList m_path_mappings;
+ bool m_notify_changes;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionValueProperties.h b/include/lldb/Interpreter/OptionValueProperties.h
index c8783bcf36eb..bb4202a2ec1f 100644
--- a/include/lldb/Interpreter/OptionValueProperties.h
+++ b/include/lldb/Interpreter/OptionValueProperties.h
@@ -24,251 +24,209 @@
namespace lldb_private {
-class OptionValueProperties :
- public OptionValue,
- public std::enable_shared_from_this<OptionValueProperties>
-{
+class OptionValueProperties
+ : public OptionValue,
+ public std::enable_shared_from_this<OptionValueProperties> {
public:
- OptionValueProperties () :
- OptionValue(),
- m_name (),
- m_properties (),
- m_name_to_index ()
- {
- }
-
- OptionValueProperties (const ConstString &name);
-
- OptionValueProperties (const OptionValueProperties &global_properties);
-
- ~OptionValueProperties() override = default;
-
- Type
- GetType() const override
- {
- return eTypeProperties;
- }
-
- bool
- Clear() override;
-
- lldb::OptionValueSP
- DeepCopy() const override;
-
- Error
- SetValueFromString(llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign) override;
-
- void
- DumpValue(const ExecutionContext *exe_ctx,
- Stream &strm,
- uint32_t dump_mask) override;
-
- ConstString
- GetName() const override
- {
- return m_name;
- }
-
- virtual Error
- DumpPropertyValue (const ExecutionContext *exe_ctx,
- Stream &strm,
- const char *property_path,
- uint32_t dump_mask);
-
- virtual void
- DumpAllDescriptions (CommandInterpreter &interpreter,
- Stream &strm) const;
-
- void
- Apropos (const char *keyword,
- std::vector<const Property *> &matching_properties) const;
-
- void
- Initialize (const PropertyDefinition *setting_definitions);
-
-// bool
-// GetQualifiedName (Stream &strm);
-
- //---------------------------------------------------------------------
- // Subclass specific functions
- //---------------------------------------------------------------------
-
- virtual size_t
- GetNumProperties() const;
-
- virtual ConstString
- GetPropertyNameAtIndex (uint32_t idx) const;
-
- virtual const char *
- GetPropertyDescriptionAtIndex (uint32_t idx) const;
-
- //---------------------------------------------------------------------
- // Get the index of a property given its exact name in this property
- // collection, "name" can't be a path to a property path that refers
- // to a property within a property
- //---------------------------------------------------------------------
- virtual uint32_t
- GetPropertyIndex (const ConstString &name) const;
-
- //---------------------------------------------------------------------
- // Get a property by exact name exists in this property collection, name
- // can not be a path to a property path that refers to a property within
- // a property
- //---------------------------------------------------------------------
- virtual const Property *
- GetProperty (const ExecutionContext *exe_ctx,
- bool will_modify,
- const ConstString &name) const;
-
- virtual const Property *
- GetPropertyAtIndex (const ExecutionContext *exe_ctx,
- bool will_modify,
- uint32_t idx) const;
-
- //---------------------------------------------------------------------
- // Property can be be a property path like "target.process.extra-startup-command"
- //---------------------------------------------------------------------
- virtual const Property *
- GetPropertyAtPath (const ExecutionContext *exe_ctx,
- bool will_modify,
- const char *property_path) const;
-
- virtual lldb::OptionValueSP
- GetPropertyValueAtIndex (const ExecutionContext *exe_ctx,
- bool will_modify,
- uint32_t idx) const;
-
- virtual lldb::OptionValueSP
- GetValueForKey (const ExecutionContext *exe_ctx,
- const ConstString &key,
- bool value_will_be_modified) const;
-
- lldb::OptionValueSP
- GetSubValue(const ExecutionContext *exe_ctx,
- const char *name,
- bool value_will_be_modified,
- Error &error) const override;
-
- Error
- SetSubValue(const ExecutionContext *exe_ctx,
- VarSetOperationType op,
- const char *path,
- const char *value) override;
-
- virtual bool
- PredicateMatches (const ExecutionContext *exe_ctx,
- const char *predicate) const
- {
- return false;
- }
-
-
- OptionValueArch *
- GetPropertyAtIndexAsOptionValueArch (const ExecutionContext *exe_ctx, uint32_t idx) const;
-
- OptionValueLanguage *
- GetPropertyAtIndexAsOptionValueLanguage (const ExecutionContext *exe_ctx, uint32_t idx) const;
-
- bool
- GetPropertyAtIndexAsArgs (const ExecutionContext *exe_ctx, uint32_t idx, Args &args) const;
-
- bool
- SetPropertyAtIndexFromArgs (const ExecutionContext *exe_ctx, uint32_t idx, const Args &args);
-
- bool
- GetPropertyAtIndexAsBoolean (const ExecutionContext *exe_ctx, uint32_t idx, bool fail_value) const;
-
- bool
- SetPropertyAtIndexAsBoolean (const ExecutionContext *exe_ctx, uint32_t idx, bool new_value);
-
- OptionValueDictionary *
- GetPropertyAtIndexAsOptionValueDictionary (const ExecutionContext *exe_ctx, uint32_t idx) const;
-
- int64_t
- GetPropertyAtIndexAsEnumeration (const ExecutionContext *exe_ctx, uint32_t idx, int64_t fail_value) const;
-
- bool
- SetPropertyAtIndexAsEnumeration (const ExecutionContext *exe_ctx, uint32_t idx, int64_t new_value);
-
- const FormatEntity::Entry *
- GetPropertyAtIndexAsFormatEntity (const ExecutionContext *exe_ctx, uint32_t idx);
-
- const RegularExpression *
- GetPropertyAtIndexAsOptionValueRegex (const ExecutionContext *exe_ctx, uint32_t idx) const;
-
- OptionValueSInt64 *
- GetPropertyAtIndexAsOptionValueSInt64 (const ExecutionContext *exe_ctx, uint32_t idx) const;
-
- int64_t
- GetPropertyAtIndexAsSInt64 (const ExecutionContext *exe_ctx, uint32_t idx, int64_t fail_value) const;
-
- bool
- SetPropertyAtIndexAsSInt64 (const ExecutionContext *exe_ctx, uint32_t idx, int64_t new_value);
-
- uint64_t
- GetPropertyAtIndexAsUInt64 (const ExecutionContext *exe_ctx, uint32_t idx, uint64_t fail_value) const;
-
- bool
- SetPropertyAtIndexAsUInt64 (const ExecutionContext *exe_ctx, uint32_t idx, uint64_t new_value);
-
- const char *
- GetPropertyAtIndexAsString (const ExecutionContext *exe_ctx, uint32_t idx, const char *fail_value) const;
-
- bool
- SetPropertyAtIndexAsString (const ExecutionContext *exe_ctx, uint32_t idx, const char *new_value);
-
- OptionValueString *
- GetPropertyAtIndexAsOptionValueString (const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
-
- OptionValueFileSpec *
- GetPropertyAtIndexAsOptionValueFileSpec (const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
-
- FileSpec
- GetPropertyAtIndexAsFileSpec (const ExecutionContext *exe_ctx, uint32_t idx) const;
-
- bool
- SetPropertyAtIndexAsFileSpec (const ExecutionContext *exe_ctx, uint32_t idx, const FileSpec &file_spec);
-
- OptionValuePathMappings *
- GetPropertyAtIndexAsOptionValuePathMappings (const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
-
- OptionValueFileSpecList *
- GetPropertyAtIndexAsOptionValueFileSpecList (const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
-
- void
- AppendProperty(const ConstString &name,
- const ConstString &desc,
- bool is_global,
- const lldb::OptionValueSP &value_sp);
-
- lldb::OptionValuePropertiesSP
- GetSubProperty (const ExecutionContext *exe_ctx,
- const ConstString &name);
-
- void
- SetValueChangedCallback (uint32_t property_idx,
- OptionValueChangedCallback callback,
- void *baton);
+ OptionValueProperties()
+ : OptionValue(), m_name(), m_properties(), m_name_to_index() {}
+
+ OptionValueProperties(const ConstString &name);
+
+ OptionValueProperties(const OptionValueProperties &global_properties);
+
+ ~OptionValueProperties() override = default;
+
+ Type GetType() const override { return eTypeProperties; }
+
+ bool Clear() override;
+
+ lldb::OptionValueSP DeepCopy() const override;
+
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
+
+ void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
+ uint32_t dump_mask) override;
+
+ ConstString GetName() const override { return m_name; }
+
+ virtual Error DumpPropertyValue(const ExecutionContext *exe_ctx, Stream &strm,
+ llvm::StringRef property_path,
+ uint32_t dump_mask);
+
+ virtual void DumpAllDescriptions(CommandInterpreter &interpreter,
+ Stream &strm) const;
+
+ void Apropos(llvm::StringRef keyword,
+ std::vector<const Property *> &matching_properties) const;
+
+ void Initialize(const PropertyDefinition *setting_definitions);
+
+ // bool
+ // GetQualifiedName (Stream &strm);
+
+ //---------------------------------------------------------------------
+ // Subclass specific functions
+ //---------------------------------------------------------------------
+
+ virtual size_t GetNumProperties() const;
+
+ //---------------------------------------------------------------------
+ // Get the index of a property given its exact name in this property
+ // collection, "name" can't be a path to a property path that refers
+ // to a property within a property
+ //---------------------------------------------------------------------
+ virtual uint32_t GetPropertyIndex(const ConstString &name) const;
+
+ //---------------------------------------------------------------------
+ // Get a property by exact name exists in this property collection, name
+ // can not be a path to a property path that refers to a property within
+ // a property
+ //---------------------------------------------------------------------
+ virtual const Property *GetProperty(const ExecutionContext *exe_ctx,
+ bool will_modify,
+ const ConstString &name) const;
+
+ virtual const Property *GetPropertyAtIndex(const ExecutionContext *exe_ctx,
+ bool will_modify,
+ uint32_t idx) const;
+
+ //---------------------------------------------------------------------
+ // Property can be be a property path like
+ // "target.process.extra-startup-command"
+ //---------------------------------------------------------------------
+ virtual const Property *GetPropertyAtPath(const ExecutionContext *exe_ctx,
+ bool will_modify,
+ llvm::StringRef property_path) const;
+
+ virtual lldb::OptionValueSP
+ GetPropertyValueAtIndex(const ExecutionContext *exe_ctx, bool will_modify,
+ uint32_t idx) const;
+
+ virtual lldb::OptionValueSP GetValueForKey(const ExecutionContext *exe_ctx,
+ const ConstString &key,
+ bool value_will_be_modified) const;
+
+ lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
+ llvm::StringRef name, bool value_will_be_modified,
+ Error &error) const override;
+
+ Error SetSubValue(const ExecutionContext *exe_ctx, VarSetOperationType op,
+ llvm::StringRef path, llvm::StringRef value) override;
+
+ virtual bool PredicateMatches(const ExecutionContext *exe_ctx,
+ llvm::StringRef predicate) const {
+ return false;
+ }
+
+ OptionValueArch *
+ GetPropertyAtIndexAsOptionValueArch(const ExecutionContext *exe_ctx,
+ uint32_t idx) const;
+
+ OptionValueLanguage *
+ GetPropertyAtIndexAsOptionValueLanguage(const ExecutionContext *exe_ctx,
+ uint32_t idx) const;
+
+ bool GetPropertyAtIndexAsArgs(const ExecutionContext *exe_ctx, uint32_t idx,
+ Args &args) const;
+
+ bool SetPropertyAtIndexFromArgs(const ExecutionContext *exe_ctx, uint32_t idx,
+ const Args &args);
+
+ bool GetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx,
+ uint32_t idx, bool fail_value) const;
+
+ bool SetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx,
+ uint32_t idx, bool new_value);
+
+ OptionValueDictionary *
+ GetPropertyAtIndexAsOptionValueDictionary(const ExecutionContext *exe_ctx,
+ uint32_t idx) const;
+
+ int64_t GetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx,
+ uint32_t idx,
+ int64_t fail_value) const;
+
+ bool SetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx,
+ uint32_t idx, int64_t new_value);
+
+ const FormatEntity::Entry *
+ GetPropertyAtIndexAsFormatEntity(const ExecutionContext *exe_ctx,
+ uint32_t idx);
+
+ const RegularExpression *
+ GetPropertyAtIndexAsOptionValueRegex(const ExecutionContext *exe_ctx,
+ uint32_t idx) const;
+
+ OptionValueSInt64 *
+ GetPropertyAtIndexAsOptionValueSInt64(const ExecutionContext *exe_ctx,
+ uint32_t idx) const;
+
+ int64_t GetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx,
+ uint32_t idx, int64_t fail_value) const;
+
+ bool SetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx, uint32_t idx,
+ int64_t new_value);
+
+ uint64_t GetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx,
+ uint32_t idx, uint64_t fail_value) const;
+
+ bool SetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx, uint32_t idx,
+ uint64_t new_value);
+
+ llvm::StringRef GetPropertyAtIndexAsString(const ExecutionContext *exe_ctx,
+ uint32_t idx,
+ llvm::StringRef fail_value) const;
+
+ bool SetPropertyAtIndexAsString(const ExecutionContext *exe_ctx, uint32_t idx,
+ llvm::StringRef new_value);
+
+ OptionValueString *
+ GetPropertyAtIndexAsOptionValueString(const ExecutionContext *exe_ctx,
+ bool will_modify, uint32_t idx) const;
+
+ OptionValueFileSpec *
+ GetPropertyAtIndexAsOptionValueFileSpec(const ExecutionContext *exe_ctx,
+ bool will_modify, uint32_t idx) const;
+
+ FileSpec GetPropertyAtIndexAsFileSpec(const ExecutionContext *exe_ctx,
+ uint32_t idx) const;
+
+ bool SetPropertyAtIndexAsFileSpec(const ExecutionContext *exe_ctx,
+ uint32_t idx, const FileSpec &file_spec);
+
+ OptionValuePathMappings *GetPropertyAtIndexAsOptionValuePathMappings(
+ const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
+
+ OptionValueFileSpecList *GetPropertyAtIndexAsOptionValueFileSpecList(
+ const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
+
+ void AppendProperty(const ConstString &name, const ConstString &desc,
+ bool is_global, const lldb::OptionValueSP &value_sp);
+
+ lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx,
+ const ConstString &name);
+
+ void SetValueChangedCallback(uint32_t property_idx,
+ OptionValueChangedCallback callback,
+ void *baton);
protected:
- Property *
- ProtectedGetPropertyAtIndex(uint32_t idx)
- {
- return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
- }
-
- const Property *
- ProtectedGetPropertyAtIndex(uint32_t idx) const
- {
- return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
- }
-
- typedef UniqueCStringMap<size_t> NameToIndex;
-
- ConstString m_name;
- std::vector<Property> m_properties;
- NameToIndex m_name_to_index;
+ Property *ProtectedGetPropertyAtIndex(uint32_t idx) {
+ return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
+ }
+
+ const Property *ProtectedGetPropertyAtIndex(uint32_t idx) const {
+ return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
+ }
+
+ typedef UniqueCStringMap<size_t> NameToIndex;
+
+ ConstString m_name;
+ std::vector<Property> m_properties;
+ NameToIndex m_name_to_index;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionValueRegex.h b/include/lldb/Interpreter/OptionValueRegex.h
index a094a402b1a9..7125daffedee 100644
--- a/include/lldb/Interpreter/OptionValueRegex.h
+++ b/include/lldb/Interpreter/OptionValueRegex.h
@@ -19,71 +19,55 @@
namespace lldb_private {
-class OptionValueRegex : public OptionValue
-{
+class OptionValueRegex : public OptionValue {
public:
- OptionValueRegex(const char *value = nullptr) :
- OptionValue(),
- m_regex (value)
- {
- }
-
- ~OptionValueRegex() override = default;
-
- //---------------------------------------------------------------------
- // Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
-
- OptionValue::Type
- GetType() const override
- {
- return eTypeRegex;
- }
-
- void
- DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
-
- Error
- SetValueFromString(llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign) override;
-
- bool
- Clear() override
- {
- m_regex.Clear();
- m_value_was_set = false;
- return true;
- }
-
- lldb::OptionValueSP
- DeepCopy() const override;
-
- //---------------------------------------------------------------------
- // Subclass specific functions
- //---------------------------------------------------------------------
- const RegularExpression *
- GetCurrentValue() const
- {
- return (m_regex.IsValid() ? &m_regex : nullptr);
- }
-
- void
- SetCurrentValue (const char *value)
- {
- if (value && value[0])
- m_regex.Compile (value);
- else
- m_regex.Clear();
- }
-
- bool
- IsValid () const
- {
- return m_regex.IsValid();
- }
-
+ OptionValueRegex(const char *value = nullptr)
+ : OptionValue(), m_regex(llvm::StringRef::withNullAsEmpty(value)) {}
+
+ ~OptionValueRegex() override = default;
+
+ //---------------------------------------------------------------------
+ // Virtual subclass pure virtual overrides
+ //---------------------------------------------------------------------
+
+ OptionValue::Type GetType() const override { return eTypeRegex; }
+
+ void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
+ uint32_t dump_mask) override;
+
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
+ Error
+ SetValueFromString(const char *,
+ VarSetOperationType = eVarSetOperationAssign) = delete;
+
+ bool Clear() override {
+ m_regex.Clear();
+ m_value_was_set = false;
+ return true;
+ }
+
+ lldb::OptionValueSP DeepCopy() const override;
+
+ //---------------------------------------------------------------------
+ // Subclass specific functions
+ //---------------------------------------------------------------------
+ const RegularExpression *GetCurrentValue() const {
+ return (m_regex.IsValid() ? &m_regex : nullptr);
+ }
+
+ void SetCurrentValue(const char *value) {
+ if (value && value[0])
+ m_regex.Compile(llvm::StringRef(value));
+ else
+ m_regex.Clear();
+ }
+
+ bool IsValid() const { return m_regex.IsValid(); }
+
protected:
- RegularExpression m_regex;
+ RegularExpression m_regex;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionValueSInt64.h b/include/lldb/Interpreter/OptionValueSInt64.h
index 8c8b201b6e82..1e1647866873 100644
--- a/include/lldb/Interpreter/OptionValueSInt64.h
+++ b/include/lldb/Interpreter/OptionValueSInt64.h
@@ -1,4 +1,5 @@
-//===-- OptionValueSInt64.h --------------------------------------*- C++ -*-===//
+//===-- OptionValueSInt64.h --------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -18,152 +19,94 @@
namespace lldb_private {
-class OptionValueSInt64 : public OptionValue
-{
+class OptionValueSInt64 : public OptionValue {
public:
- OptionValueSInt64 () :
- OptionValue(),
- m_current_value (0),
- m_default_value (0),
- m_min_value (INT64_MIN),
- m_max_value (INT64_MAX)
- {
- }
+ OptionValueSInt64()
+ : OptionValue(), m_current_value(0), m_default_value(0),
+ m_min_value(INT64_MIN), m_max_value(INT64_MAX) {}
- OptionValueSInt64 (int64_t value) :
- OptionValue(),
- m_current_value (value),
- m_default_value (value),
- m_min_value (INT64_MIN),
- m_max_value (INT64_MAX)
- {
- }
+ OptionValueSInt64(int64_t value)
+ : OptionValue(), m_current_value(value), m_default_value(value),
+ m_min_value(INT64_MIN), m_max_value(INT64_MAX) {}
- OptionValueSInt64 (int64_t current_value,
- int64_t default_value) :
- OptionValue(),
- m_current_value (current_value),
- m_default_value (default_value),
- m_min_value (INT64_MIN),
- m_max_value (INT64_MAX)
- {
- }
-
- OptionValueSInt64 (const OptionValueSInt64 &rhs) :
- OptionValue(rhs),
- m_current_value (rhs.m_current_value),
- m_default_value (rhs.m_default_value),
- m_min_value (rhs.m_min_value),
- m_max_value (rhs.m_max_value)
- {
- }
+ OptionValueSInt64(int64_t current_value, int64_t default_value)
+ : OptionValue(), m_current_value(current_value),
+ m_default_value(default_value), m_min_value(INT64_MIN),
+ m_max_value(INT64_MAX) {}
- ~OptionValueSInt64() override
- {
- }
-
- //---------------------------------------------------------------------
- // Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
-
- OptionValue::Type
- GetType() const override
- {
- return eTypeSInt64;
- }
-
- void
- DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
-
- Error
- SetValueFromString(llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign) override;
-
- bool
- Clear() override
- {
- m_current_value = m_default_value;
- m_value_was_set = false;
- return true;
- }
-
- lldb::OptionValueSP
- DeepCopy() const override;
-
- //---------------------------------------------------------------------
- // Subclass specific functions
- //---------------------------------------------------------------------
-
- const int64_t &
- operator = (int64_t value)
- {
- m_current_value = value;
- return m_current_value;
- }
+ OptionValueSInt64(const OptionValueSInt64 &rhs)
+ : OptionValue(rhs), m_current_value(rhs.m_current_value),
+ m_default_value(rhs.m_default_value), m_min_value(rhs.m_min_value),
+ m_max_value(rhs.m_max_value) {}
- int64_t
- GetCurrentValue() const
- {
- return m_current_value;
- }
-
- int64_t
- GetDefaultValue() const
- {
- return m_default_value;
- }
-
- bool
- SetCurrentValue (int64_t value)
- {
- if (value >= m_min_value && value <= m_max_value)
- {
- m_current_value = value;
- return true;
- }
- return false;
- }
-
- bool
- SetDefaultValue (int64_t value)
- {
- if (value >= m_min_value && value <= m_max_value)
- {
- m_default_value = value;
- return true;
- }
- return false;
- }
-
- void
- SetMinimumValue (int64_t v)
- {
- m_min_value = v;
- }
+ ~OptionValueSInt64() override {}
- int64_t
- GetMinimumValue () const
- {
- return m_min_value;
- }
-
- void
- SetMaximumValue (int64_t v)
- {
- m_max_value = v;
+ //---------------------------------------------------------------------
+ // Virtual subclass pure virtual overrides
+ //---------------------------------------------------------------------
+
+ OptionValue::Type GetType() const override { return eTypeSInt64; }
+
+ void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
+ uint32_t dump_mask) override;
+
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
+ Error
+ SetValueFromString(const char *,
+ VarSetOperationType = eVarSetOperationAssign) = delete;
+
+ bool Clear() override {
+ m_current_value = m_default_value;
+ m_value_was_set = false;
+ return true;
+ }
+
+ lldb::OptionValueSP DeepCopy() const override;
+
+ //---------------------------------------------------------------------
+ // Subclass specific functions
+ //---------------------------------------------------------------------
+
+ const int64_t &operator=(int64_t value) {
+ m_current_value = value;
+ return m_current_value;
+ }
+
+ int64_t GetCurrentValue() const { return m_current_value; }
+
+ int64_t GetDefaultValue() const { return m_default_value; }
+
+ bool SetCurrentValue(int64_t value) {
+ if (value >= m_min_value && value <= m_max_value) {
+ m_current_value = value;
+ return true;
}
+ return false;
+ }
- int64_t
- GetMaximumValue () const
- {
- return m_max_value;
+ bool SetDefaultValue(int64_t value) {
+ if (value >= m_min_value && value <= m_max_value) {
+ m_default_value = value;
+ return true;
}
+ return false;
+ }
+
+ void SetMinimumValue(int64_t v) { m_min_value = v; }
+
+ int64_t GetMinimumValue() const { return m_min_value; }
+
+ void SetMaximumValue(int64_t v) { m_max_value = v; }
+
+ int64_t GetMaximumValue() const { return m_max_value; }
protected:
- int64_t m_current_value;
- int64_t m_default_value;
- int64_t m_min_value;
- int64_t m_max_value;
+ int64_t m_current_value;
+ int64_t m_default_value;
+ int64_t m_min_value;
+ int64_t m_max_value;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionValueString.h b/include/lldb/Interpreter/OptionValueString.h
index bbdd0c8ba55c..5b42003f383f 100644
--- a/include/lldb/Interpreter/OptionValueString.h
+++ b/include/lldb/Interpreter/OptionValueString.h
@@ -21,200 +21,125 @@
namespace lldb_private {
-class OptionValueString : public OptionValue
-{
+class OptionValueString : public OptionValue {
public:
- typedef Error (*ValidatorCallback) (const char* string,
- void* baton);
-
- enum Options
- {
- eOptionEncodeCharacterEscapeSequences = (1u << 0)
- };
-
- OptionValueString () :
- OptionValue(),
- m_current_value (),
- m_default_value (),
- m_options(),
- m_validator(),
- m_validator_baton()
- {
- }
-
- OptionValueString(ValidatorCallback validator,
- void* baton = nullptr) :
- OptionValue(),
- m_current_value (),
- m_default_value (),
- m_options(),
- m_validator(validator),
- m_validator_baton(baton)
- {
- }
+ typedef Error (*ValidatorCallback)(const char *string, void *baton);
- OptionValueString (const char *value) :
- OptionValue(),
- m_current_value (),
- m_default_value (),
- m_options(),
- m_validator(),
- m_validator_baton()
- {
- if (value && value[0])
- {
- m_current_value.assign (value);
- m_default_value.assign (value);
- }
- }
+ enum Options { eOptionEncodeCharacterEscapeSequences = (1u << 0) };
+
+ OptionValueString()
+ : OptionValue(), m_current_value(), m_default_value(), m_options(),
+ m_validator(), m_validator_baton() {}
+
+ OptionValueString(ValidatorCallback validator, void *baton = nullptr)
+ : OptionValue(), m_current_value(), m_default_value(), m_options(),
+ m_validator(validator), m_validator_baton(baton) {}
- OptionValueString (const char *current_value,
- const char *default_value) :
- OptionValue(),
- m_current_value (),
- m_default_value (),
- m_options(),
- m_validator(),
- m_validator_baton()
- {
- if (current_value && current_value[0])
- m_current_value.assign (current_value);
- if (default_value && default_value[0])
- m_default_value.assign (default_value);
- }
-
- OptionValueString(const char *value,
- ValidatorCallback validator,
- void* baton = nullptr) :
- OptionValue(),
- m_current_value (),
- m_default_value (),
- m_options(),
- m_validator(validator),
- m_validator_baton(baton)
- {
- if (value && value[0])
- {
- m_current_value.assign (value);
- m_default_value.assign (value);
- }
+ OptionValueString(const char *value)
+ : OptionValue(), m_current_value(), m_default_value(), m_options(),
+ m_validator(), m_validator_baton() {
+ if (value && value[0]) {
+ m_current_value.assign(value);
+ m_default_value.assign(value);
}
-
- OptionValueString(const char *current_value,
- const char *default_value,
- ValidatorCallback validator,
- void* baton = nullptr) :
- OptionValue(),
- m_current_value (),
- m_default_value (),
- m_options(),
- m_validator(validator),
- m_validator_baton(baton)
- {
- if (current_value && current_value[0])
- m_current_value.assign (current_value);
- if (default_value && default_value[0])
- m_default_value.assign (default_value);
- }
-
- ~OptionValueString() override = default;
-
- //---------------------------------------------------------------------
- // Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
-
- OptionValue::Type
- GetType() const override
- {
- return eTypeString;
- }
-
- void
- DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
-
- Error
- SetValueFromString(llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign) override;
-
- bool
- Clear() override
- {
- m_current_value = m_default_value;
- m_value_was_set = false;
- return true;
+ }
+
+ OptionValueString(const char *current_value, const char *default_value)
+ : OptionValue(), m_current_value(), m_default_value(), m_options(),
+ m_validator(), m_validator_baton() {
+ if (current_value && current_value[0])
+ m_current_value.assign(current_value);
+ if (default_value && default_value[0])
+ m_default_value.assign(default_value);
+ }
+
+ OptionValueString(const char *value, ValidatorCallback validator,
+ void *baton = nullptr)
+ : OptionValue(), m_current_value(), m_default_value(), m_options(),
+ m_validator(validator), m_validator_baton(baton) {
+ if (value && value[0]) {
+ m_current_value.assign(value);
+ m_default_value.assign(value);
}
+ }
- lldb::OptionValueSP
- DeepCopy() const override;
+ OptionValueString(const char *current_value, const char *default_value,
+ ValidatorCallback validator, void *baton = nullptr)
+ : OptionValue(), m_current_value(), m_default_value(), m_options(),
+ m_validator(validator), m_validator_baton(baton) {
+ if (current_value && current_value[0])
+ m_current_value.assign(current_value);
+ if (default_value && default_value[0])
+ m_default_value.assign(default_value);
+ }
- //---------------------------------------------------------------------
- // Subclass specific functions
- //---------------------------------------------------------------------
+ ~OptionValueString() override = default;
- Flags &
- GetOptions ()
- {
- return m_options;
- }
+ //---------------------------------------------------------------------
+ // Virtual subclass pure virtual overrides
+ //---------------------------------------------------------------------
- const Flags &
- GetOptions () const
- {
- return m_options;
- }
-
- const char *
- operator = (const char *value)
- {
- SetCurrentValue(value);
- return m_current_value.c_str();
- }
+ OptionValue::Type GetType() const override { return eTypeString; }
- const char *
- GetCurrentValue() const
- {
- return m_current_value.c_str();
- }
-
- const char *
- GetDefaultValue() const
- {
- return m_default_value.c_str();
- }
-
- Error
- SetCurrentValue (const char *value);
-
- Error
- AppendToCurrentValue (const char *value);
-
- void
- SetDefaultValue (const char *value)
- {
- if (value && value[0])
- m_default_value.assign (value);
- else
- m_default_value.clear();
- }
+ void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
+ uint32_t dump_mask) override;
- bool
- IsCurrentValueEmpty () const
- {
- return m_current_value.empty();
- }
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
+ Error
+ SetValueFromString(const char *,
+ VarSetOperationType = eVarSetOperationAssign) = delete;
- bool
- IsDefaultValueEmpty () const
- {
- return m_default_value.empty();
- }
+ bool Clear() override {
+ m_current_value = m_default_value;
+ m_value_was_set = false;
+ return true;
+ }
+
+ lldb::OptionValueSP DeepCopy() const override;
+
+ //---------------------------------------------------------------------
+ // Subclass specific functions
+ //---------------------------------------------------------------------
+
+ Flags &GetOptions() { return m_options; }
+
+ const Flags &GetOptions() const { return m_options; }
+
+ const char *operator=(const char *value) {
+ SetCurrentValue(llvm::StringRef::withNullAsEmpty(value));
+ return m_current_value.c_str();
+ }
+
+ const char *GetCurrentValue() const { return m_current_value.c_str(); }
+ llvm::StringRef GetCurrentValueAsRef() const { return m_current_value; }
+
+ const char *GetDefaultValue() const { return m_default_value.c_str(); }
+ llvm::StringRef GetDefaultValueAsRef() const { return m_default_value; }
+
+ Error SetCurrentValue(const char *) = delete;
+ Error SetCurrentValue(llvm::StringRef value);
+
+ Error AppendToCurrentValue(const char *value);
+
+ void SetDefaultValue(const char *value) {
+ if (value && value[0])
+ m_default_value.assign(value);
+ else
+ m_default_value.clear();
+ }
+
+ bool IsCurrentValueEmpty() const { return m_current_value.empty(); }
+
+ bool IsDefaultValueEmpty() const { return m_default_value.empty(); }
protected:
- std::string m_current_value;
- std::string m_default_value;
- Flags m_options;
- ValidatorCallback m_validator;
- void* m_validator_baton;
+ std::string m_current_value;
+ std::string m_default_value;
+ Flags m_options;
+ ValidatorCallback m_validator;
+ void *m_validator_baton;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionValueUInt64.h b/include/lldb/Interpreter/OptionValueUInt64.h
index 874e8ca16665..cbf932b1bda4 100644
--- a/include/lldb/Interpreter/OptionValueUInt64.h
+++ b/include/lldb/Interpreter/OptionValueUInt64.h
@@ -1,4 +1,5 @@
-//===-- OptionValueUInt64.h --------------------------------------*- C++ -*-===//
+//===-- OptionValueUInt64.h --------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -17,115 +18,74 @@
#include "lldb/Interpreter/OptionValue.h"
namespace lldb_private {
-
-class OptionValueUInt64 : public OptionValue
-{
+
+class OptionValueUInt64 : public OptionValue {
public:
- OptionValueUInt64 () :
- OptionValue(),
- m_current_value (0),
- m_default_value (0)
- {
- }
-
- OptionValueUInt64 (uint64_t value) :
- OptionValue(),
- m_current_value (value),
- m_default_value (value)
- {
- }
-
- OptionValueUInt64 (uint64_t current_value,
- uint64_t default_value) :
- OptionValue(),
- m_current_value (current_value),
- m_default_value (default_value)
- {
- }
-
- ~OptionValueUInt64() override
- {
- }
-
- //---------------------------------------------------------------------
- // Decode a uint64_t from "value_cstr" return a OptionValueUInt64 object
- // inside of a lldb::OptionValueSP object if all goes well. If the
- // string isn't a uint64_t value or any other error occurs, return an
- // empty lldb::OptionValueSP and fill error in with the correct stuff.
- //---------------------------------------------------------------------
- static lldb::OptionValueSP
- Create (const char *value_cstr, Error &error);
- //---------------------------------------------------------------------
- // Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
-
- OptionValue::Type
- GetType() const override
- {
- return eTypeUInt64;
- }
-
- void
- DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
-
- Error
- SetValueFromString(llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign) override;
-
- bool
- Clear() override
- {
- m_current_value = m_default_value;
- m_value_was_set = false;
- return true;
- }
-
- lldb::OptionValueSP
- DeepCopy() const override;
-
- //---------------------------------------------------------------------
- // Subclass specific functions
- //---------------------------------------------------------------------
-
- const uint64_t &
- operator = (uint64_t value)
- {
- m_current_value = value;
- return m_current_value;
- }
-
- operator uint64_t () const
- {
- return m_current_value;
- }
-
- uint64_t
- GetCurrentValue() const
- {
- return m_current_value;
- }
-
- uint64_t
- GetDefaultValue() const
- {
- return m_default_value;
- }
-
- void
- SetCurrentValue (uint64_t value)
- {
- m_current_value = value;
- }
-
- void
- SetDefaultValue (uint64_t value)
- {
- m_default_value = value;
- }
-
+ OptionValueUInt64() : OptionValue(), m_current_value(0), m_default_value(0) {}
+
+ OptionValueUInt64(uint64_t value)
+ : OptionValue(), m_current_value(value), m_default_value(value) {}
+
+ OptionValueUInt64(uint64_t current_value, uint64_t default_value)
+ : OptionValue(), m_current_value(current_value),
+ m_default_value(default_value) {}
+
+ ~OptionValueUInt64() override {}
+
+ //---------------------------------------------------------------------
+ // Decode a uint64_t from "value_cstr" return a OptionValueUInt64 object
+ // inside of a lldb::OptionValueSP object if all goes well. If the
+ // string isn't a uint64_t value or any other error occurs, return an
+ // empty lldb::OptionValueSP and fill error in with the correct stuff.
+ //---------------------------------------------------------------------
+ static lldb::OptionValueSP Create(const char *, Error &) = delete;
+ static lldb::OptionValueSP Create(llvm::StringRef value_str, Error &error);
+ //---------------------------------------------------------------------
+ // Virtual subclass pure virtual overrides
+ //---------------------------------------------------------------------
+
+ OptionValue::Type GetType() const override { return eTypeUInt64; }
+
+ void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
+ uint32_t dump_mask) override;
+
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
+ Error
+ SetValueFromString(const char *,
+ VarSetOperationType = eVarSetOperationAssign) = delete;
+
+ bool Clear() override {
+ m_current_value = m_default_value;
+ m_value_was_set = false;
+ return true;
+ }
+
+ lldb::OptionValueSP DeepCopy() const override;
+
+ //---------------------------------------------------------------------
+ // Subclass specific functions
+ //---------------------------------------------------------------------
+
+ const uint64_t &operator=(uint64_t value) {
+ m_current_value = value;
+ return m_current_value;
+ }
+
+ operator uint64_t() const { return m_current_value; }
+
+ uint64_t GetCurrentValue() const { return m_current_value; }
+
+ uint64_t GetDefaultValue() const { return m_default_value; }
+
+ void SetCurrentValue(uint64_t value) { m_current_value = value; }
+
+ void SetDefaultValue(uint64_t value) { m_default_value = value; }
+
protected:
- uint64_t m_current_value;
- uint64_t m_default_value;
+ uint64_t m_current_value;
+ uint64_t m_default_value;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionValueUUID.h b/include/lldb/Interpreter/OptionValueUUID.h
index 4aecc39bc8c4..841de88f9263 100644
--- a/include/lldb/Interpreter/OptionValueUUID.h
+++ b/include/lldb/Interpreter/OptionValueUUID.h
@@ -19,85 +19,54 @@
namespace lldb_private {
-class OptionValueUUID : public OptionValue
-{
+class OptionValueUUID : public OptionValue {
public:
- OptionValueUUID () :
- OptionValue(),
- m_uuid ()
- {
- }
-
- OptionValueUUID (const UUID &uuid) :
- OptionValue(),
- m_uuid (uuid)
- {
- }
-
- ~OptionValueUUID() override
- {
- }
-
- //---------------------------------------------------------------------
- // Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
-
- OptionValue::Type
- GetType() const override
- {
- return eTypeUUID;
- }
-
- void
- DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
-
- Error
- SetValueFromString(llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign) override;
-
- bool
- Clear() override
- {
- m_uuid.Clear();
- m_value_was_set = false;
- return true;
- }
-
- lldb::OptionValueSP
- DeepCopy() const override;
-
- //---------------------------------------------------------------------
- // Subclass specific functions
- //---------------------------------------------------------------------
-
- UUID &
- GetCurrentValue()
- {
- return m_uuid;
- }
-
- const UUID &
- GetCurrentValue() const
- {
- return m_uuid;
- }
-
- void
- SetCurrentValue (const UUID &value)
- {
- m_uuid = value;
- }
-
- size_t
- AutoComplete(CommandInterpreter &interpreter,
- const char *s,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches) override;
+ OptionValueUUID() : OptionValue(), m_uuid() {}
+
+ OptionValueUUID(const UUID &uuid) : OptionValue(), m_uuid(uuid) {}
+
+ ~OptionValueUUID() override {}
+
+ //---------------------------------------------------------------------
+ // Virtual subclass pure virtual overrides
+ //---------------------------------------------------------------------
+
+ OptionValue::Type GetType() const override { return eTypeUUID; }
+
+ void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
+ uint32_t dump_mask) override;
+
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
+ Error
+ SetValueFromString(const char *,
+ VarSetOperationType = eVarSetOperationAssign) = delete;
+
+ bool Clear() override {
+ m_uuid.Clear();
+ m_value_was_set = false;
+ return true;
+ }
+
+ lldb::OptionValueSP DeepCopy() const override;
+
+ //---------------------------------------------------------------------
+ // Subclass specific functions
+ //---------------------------------------------------------------------
+
+ UUID &GetCurrentValue() { return m_uuid; }
+
+ const UUID &GetCurrentValue() const { return m_uuid; }
+
+ void SetCurrentValue(const UUID &value) { m_uuid = value; }
+
+ size_t AutoComplete(CommandInterpreter &interpreter, llvm::StringRef s,
+ int match_start_point, int max_return_elements,
+ bool &word_complete, StringList &matches) override;
protected:
- UUID m_uuid;
+ UUID m_uuid;
};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/OptionValues.h b/include/lldb/Interpreter/OptionValues.h
index 44e1f0975826..e177d743ff18 100644
--- a/include/lldb/Interpreter/OptionValues.h
+++ b/include/lldb/Interpreter/OptionValues.h
@@ -21,8 +21,8 @@
#include "lldb/Interpreter/OptionValueFileSpec.h"
#include "lldb/Interpreter/OptionValueFileSpecList.h"
#include "lldb/Interpreter/OptionValueFormat.h"
-#include "lldb/Interpreter/OptionValueLanguage.h"
#include "lldb/Interpreter/OptionValueFormatEntity.h"
+#include "lldb/Interpreter/OptionValueLanguage.h"
#include "lldb/Interpreter/OptionValuePathMappings.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Interpreter/OptionValueRegex.h"
@@ -31,4 +31,4 @@
#include "lldb/Interpreter/OptionValueUInt64.h"
#include "lldb/Interpreter/OptionValueUUID.h"
-#endif // liblldb_OptionValues_h_
+#endif // liblldb_OptionValues_h_
diff --git a/include/lldb/Interpreter/Options.h b/include/lldb/Interpreter/Options.h
index bac26308a8d1..fc5ff972da46 100644
--- a/include/lldb/Interpreter/Options.h
+++ b/include/lldb/Interpreter/Options.h
@@ -17,19 +17,19 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
-#include "lldb/lldb-defines.h"
#include "lldb/Interpreter/Args.h"
+#include "lldb/lldb-defines.h"
+#include "lldb/lldb-private.h"
+
+#include "llvm/ADT/ArrayRef.h"
namespace lldb_private {
- static inline bool
- isprint8 (int ch)
- {
- if (ch & 0xffffff00u)
- return false;
- return isprint(ch);
- }
+static inline bool isprint8(int ch) {
+ if (ch & 0xffffff00u)
+ return false;
+ return isprint(ch);
+}
//----------------------------------------------------------------------
/// @class Options Options.h "lldb/Interpreter/Options.h"
@@ -45,7 +45,8 @@ namespace lldb_private {
/// options parsing function getopt_long_only:
/// \code
/// #include <getopt.h>
-/// int getopt_long_only(int argc, char * const *argv, const char *optstring, const struct option *longopts, int *longindex);
+/// int getopt_long_only(int argc, char * const *argv, const char
+/// *optstring, const struct option *longopts, int *longindex);
/// \endcode
///
/// Example code:
@@ -62,7 +63,8 @@ namespace lldb_private {
/// }
///
/// virtual Error
-/// SetOptionValue (uint32_t option_idx, int option_val, const char *option_arg)
+/// SetOptionValue (uint32_t option_idx, int option_val, const char
+/// *option_arg)
/// {
/// Error error;
/// switch (option_val)
@@ -72,14 +74,16 @@ namespace lldb_private {
/// case 'l': log_file = option_arg; break;
/// case 'f': log_flags = strtoull(option_arg, nullptr, 0); break;
/// default:
-/// error.SetErrorStringWithFormat("unrecognized short option %c", option_val);
+/// error.SetErrorStringWithFormat("unrecognized short option
+/// %c", option_val);
/// break;
/// }
///
/// return error;
/// }
///
-/// CommandOptions (CommandInterpreter &interpreter) : debug (true), verbose (false), log_file (), log_flags (0)
+/// CommandOptions (CommandInterpreter &interpreter) : debug (true),
+/// verbose (false), log_file (), log_flags (0)
/// {}
///
/// bool debug;
@@ -114,377 +118,314 @@ namespace lldb_private {
/// }
/// \endcode
//----------------------------------------------------------------------
-class Options
-{
+class Options {
public:
- Options (CommandInterpreter &interpreter);
-
- virtual
- ~Options ();
-
- void
- BuildGetoptTable ();
-
- void
- BuildValidOptionSets ();
-
- uint32_t
- NumCommandOptions ();
-
- //------------------------------------------------------------------
- /// Get the option definitions to use when parsing Args options.
- ///
- /// @see Args::ParseOptions (Options&)
- /// @see man getopt_long_only
- //------------------------------------------------------------------
- Option *
- GetLongOptions ();
-
- // This gets passed the short option as an integer...
- void
- OptionSeen (int short_option);
-
- bool
- VerifyOptions (CommandReturnObject &result);
-
- // Verify that the options given are in the options table and can
- // be used together, but there may be some required options that are
- // missing (used to verify options that get folded into command aliases).
- bool
- VerifyPartialOptions (CommandReturnObject &result);
-
- void
- OutputFormattedUsageText (Stream &strm,
- const OptionDefinition &option_def,
- uint32_t output_max_columns);
-
- void
- GenerateOptionUsage (Stream &strm,
- CommandObject *cmd);
-
- bool
- SupportsLongOption (const char *long_option);
-
- // The following two pure virtual functions must be defined by every
- // class that inherits from this class.
-
- virtual const OptionDefinition*
- GetDefinitions()
- {
- return nullptr;
- }
-
- // Call this prior to parsing any options. This call will call the
- // subclass OptionParsingStarting() and will avoid the need for all
- // OptionParsingStarting() function instances from having to call the
- // Option::OptionParsingStarting() like they did before. This was error
- // prone and subclasses shouldn't have to do it.
- void
- NotifyOptionParsingStarting ();
-
- Error
- NotifyOptionParsingFinished ();
-
- //------------------------------------------------------------------
- /// Set the value of an option.
- ///
- /// @param[in] option_idx
- /// The index into the "struct option" array that was returned
- /// by Options::GetLongOptions().
- ///
- /// @param[in] option_arg
- /// The argument value for the option that the user entered, or
- /// nullptr if there is no argument for the current option.
- ///
- ///
- /// @see Args::ParseOptions (Options&)
- /// @see man getopt_long_only
- //------------------------------------------------------------------
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg) = 0;
-
- //------------------------------------------------------------------
- /// Handles the generic bits of figuring out whether we are in an
- /// option, and if so completing it.
- ///
- /// @param[in] input
- /// The command line parsed into words
- ///
- /// @param[in] cursor_index
- /// The index in \ainput of the word in which the cursor lies.
- ///
- /// @param[in] char_pos
- /// The character position of the cursor in its argument word.
- ///
- /// @param[in] match_start_point
- /// @param[in] match_return_elements
- /// See CommandObject::HandleCompletions for a description of
- /// how these work.
- ///
- /// @param[in] interpreter
- /// The interpreter that's doing the completing.
- ///
- /// @param[out] word_complete
- /// \btrue if this is a complete option value (a space will be
- /// inserted after the completion.) \b false otherwise.
- ///
- /// @param[out] matches
- /// The array of matches returned.
- ///
- /// FIXME: This is the wrong return value, since we also need to
- /// make a distinction between total number of matches, and the
- /// window the user wants returned.
- ///
- /// @return
- /// \btrue if we were in an option, \bfalse otherwise.
- //------------------------------------------------------------------
- bool
- HandleOptionCompletion (Args &input,
- OptionElementVector &option_map,
- int cursor_index,
- int char_pos,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- lldb_private::StringList &matches);
-
- //------------------------------------------------------------------
- /// Handles the generic bits of figuring out whether we are in an
- /// option, and if so completing it.
- ///
- /// @param[in] interpreter
- /// The command interpreter doing the completion.
- ///
- /// @param[in] input
- /// The command line parsed into words
- ///
- /// @param[in] cursor_index
- /// The index in \ainput of the word in which the cursor lies.
- ///
- /// @param[in] char_pos
- /// The character position of the cursor in its argument word.
- ///
- /// @param[in] opt_element_vector
- /// The results of the options parse of \a input.
- ///
- /// @param[in] opt_element_index
- /// The position in \a opt_element_vector of the word in \a
- /// input containing the cursor.
- ///
- /// @param[in] match_start_point
- /// @param[in] match_return_elements
- /// See CommandObject::HandleCompletions for a description of
- /// how these work.
- ///
- /// @param[out] word_complete
- /// \btrue if this is a complete option value (a space will
- /// be inserted after the completion.) \bfalse otherwise.
- ///
- /// @param[out] matches
- /// The array of matches returned.
- ///
- /// FIXME: This is the wrong return value, since we also need to
- /// make a distinction between total number of matches, and the
- /// window the user wants returned.
- ///
- /// @return
- /// \btrue if we were in an option, \bfalse otherwise.
- //------------------------------------------------------------------
- virtual bool
- HandleOptionArgumentCompletion (Args &input,
- int cursor_index,
- int char_pos,
- OptionElementVector &opt_element_vector,
- int opt_element_index,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches);
-
- CommandInterpreter&
- GetInterpreter()
- {
- return m_interpreter;
- }
-
+ Options();
+
+ virtual ~Options();
+
+ void BuildGetoptTable();
+
+ void BuildValidOptionSets();
+
+ uint32_t NumCommandOptions();
+
+ //------------------------------------------------------------------
+ /// Get the option definitions to use when parsing Args options.
+ ///
+ /// @see Args::ParseOptions (Options&)
+ /// @see man getopt_long_only
+ //------------------------------------------------------------------
+ Option *GetLongOptions();
+
+ // This gets passed the short option as an integer...
+ void OptionSeen(int short_option);
+
+ bool VerifyOptions(CommandReturnObject &result);
+
+ // Verify that the options given are in the options table and can
+ // be used together, but there may be some required options that are
+ // missing (used to verify options that get folded into command aliases).
+ bool VerifyPartialOptions(CommandReturnObject &result);
+
+ void OutputFormattedUsageText(Stream &strm,
+ const OptionDefinition &option_def,
+ uint32_t output_max_columns);
+
+ void GenerateOptionUsage(Stream &strm, CommandObject *cmd,
+ uint32_t screen_width);
+
+ bool SupportsLongOption(const char *long_option);
+
+ // The following two pure virtual functions must be defined by every
+ // class that inherits from this class.
+
+ virtual llvm::ArrayRef<OptionDefinition> GetDefinitions() {
+ return llvm::ArrayRef<OptionDefinition>();
+ }
+
+ // Call this prior to parsing any options. This call will call the
+ // subclass OptionParsingStarting() and will avoid the need for all
+ // OptionParsingStarting() function instances from having to call the
+ // Option::OptionParsingStarting() like they did before. This was error
+ // prone and subclasses shouldn't have to do it.
+ void NotifyOptionParsingStarting(ExecutionContext *execution_context);
+
+ Error NotifyOptionParsingFinished(ExecutionContext *execution_context);
+
+ //------------------------------------------------------------------
+ /// Set the value of an option.
+ ///
+ /// @param[in] option_idx
+ /// The index into the "struct option" array that was returned
+ /// by Options::GetLongOptions().
+ ///
+ /// @param[in] option_arg
+ /// The argument value for the option that the user entered, or
+ /// nullptr if there is no argument for the current option.
+ ///
+ /// @param[in] execution_context
+ /// The execution context to use for evaluating the option.
+ /// May be nullptr if the option is to be evaluated outside any
+ /// particular context.
+ ///
+ /// @see Args::ParseOptions (Options&)
+ /// @see man getopt_long_only
+ //------------------------------------------------------------------
+ virtual Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+ ExecutionContext *execution_context) = 0;
+
+ //------------------------------------------------------------------
+ /// Handles the generic bits of figuring out whether we are in an
+ /// option, and if so completing it.
+ ///
+ /// @param[in] input
+ /// The command line parsed into words
+ ///
+ /// @param[in] cursor_index
+ /// The index in \ainput of the word in which the cursor lies.
+ ///
+ /// @param[in] char_pos
+ /// The character position of the cursor in its argument word.
+ ///
+ /// @param[in] match_start_point
+ /// @param[in] match_return_elements
+ /// See CommandObject::HandleCompletions for a description of
+ /// how these work.
+ ///
+ /// @param[in] interpreter
+ /// The interpreter that's doing the completing.
+ ///
+ /// @param[out] word_complete
+ /// \btrue if this is a complete option value (a space will be
+ /// inserted after the completion.) \b false otherwise.
+ ///
+ /// @param[out] matches
+ /// The array of matches returned.
+ ///
+ /// FIXME: This is the wrong return value, since we also need to
+ /// make a distinction between total number of matches, and the
+ /// window the user wants returned.
+ ///
+ /// @return
+ /// \btrue if we were in an option, \bfalse otherwise.
+ //------------------------------------------------------------------
+ bool HandleOptionCompletion(Args &input, OptionElementVector &option_map,
+ int cursor_index, int char_pos,
+ int match_start_point, int max_return_elements,
+ CommandInterpreter &interpreter,
+ bool &word_complete,
+ lldb_private::StringList &matches);
+
+ //------------------------------------------------------------------
+ /// Handles the generic bits of figuring out whether we are in an
+ /// option, and if so completing it.
+ ///
+ /// @param[in] interpreter
+ /// The command interpreter doing the completion.
+ ///
+ /// @param[in] input
+ /// The command line parsed into words
+ ///
+ /// @param[in] cursor_index
+ /// The index in \ainput of the word in which the cursor lies.
+ ///
+ /// @param[in] char_pos
+ /// The character position of the cursor in its argument word.
+ ///
+ /// @param[in] opt_element_vector
+ /// The results of the options parse of \a input.
+ ///
+ /// @param[in] opt_element_index
+ /// The position in \a opt_element_vector of the word in \a
+ /// input containing the cursor.
+ ///
+ /// @param[in] match_start_point
+ /// @param[in] match_return_elements
+ /// See CommandObject::HandleCompletions for a description of
+ /// how these work.
+ ///
+ /// @param[in] interpreter
+ /// The command interpreter in which we're doing completion.
+ ///
+ /// @param[out] word_complete
+ /// \btrue if this is a complete option value (a space will
+ /// be inserted after the completion.) \bfalse otherwise.
+ ///
+ /// @param[out] matches
+ /// The array of matches returned.
+ ///
+ /// FIXME: This is the wrong return value, since we also need to
+ /// make a distinction between total number of matches, and the
+ /// window the user wants returned.
+ ///
+ /// @return
+ /// \btrue if we were in an option, \bfalse otherwise.
+ //------------------------------------------------------------------
+ virtual bool
+ HandleOptionArgumentCompletion(Args &input, int cursor_index, int char_pos,
+ OptionElementVector &opt_element_vector,
+ int opt_element_index, int match_start_point,
+ int max_return_elements,
+ CommandInterpreter &interpreter,
+ bool &word_complete, StringList &matches);
+
protected:
- // This is a set of options expressed as indexes into the options table for this Option.
- typedef std::set<int> OptionSet;
- typedef std::vector<OptionSet> OptionSetVector;
-
- CommandInterpreter &m_interpreter;
- std::vector<Option> m_getopt_table;
- OptionSet m_seen_options;
- OptionSetVector m_required_options;
- OptionSetVector m_optional_options;
-
- OptionSetVector &GetRequiredOptions ()
- {
- BuildValidOptionSets();
- return m_required_options;
- }
-
- OptionSetVector &GetOptionalOptions ()
- {
- BuildValidOptionSets();
- return m_optional_options;
- }
-
- bool
- IsASubset (const OptionSet& set_a, const OptionSet& set_b);
-
- size_t
- OptionsSetDiff (const OptionSet &set_a, const OptionSet &set_b, OptionSet &diffs);
-
- void
- OptionsSetUnion (const OptionSet &set_a, const OptionSet &set_b, OptionSet &union_set);
-
- // Subclasses must reset their option values prior to starting a new
- // option parse. Each subclass must override this function and revert
- // all option settings to default values.
- virtual void
- OptionParsingStarting () = 0;
-
- virtual Error
- OptionParsingFinished ()
- {
- // If subclasses need to know when the options are done being parsed
- // they can implement this function to do extra checking
- Error error;
- return error;
- }
+ // This is a set of options expressed as indexes into the options table for
+ // this Option.
+ typedef std::set<int> OptionSet;
+ typedef std::vector<OptionSet> OptionSetVector;
+
+ std::vector<Option> m_getopt_table;
+ OptionSet m_seen_options;
+ OptionSetVector m_required_options;
+ OptionSetVector m_optional_options;
+
+ OptionSetVector &GetRequiredOptions() {
+ BuildValidOptionSets();
+ return m_required_options;
+ }
+
+ OptionSetVector &GetOptionalOptions() {
+ BuildValidOptionSets();
+ return m_optional_options;
+ }
+
+ bool IsASubset(const OptionSet &set_a, const OptionSet &set_b);
+
+ size_t OptionsSetDiff(const OptionSet &set_a, const OptionSet &set_b,
+ OptionSet &diffs);
+
+ void OptionsSetUnion(const OptionSet &set_a, const OptionSet &set_b,
+ OptionSet &union_set);
+
+ // Subclasses must reset their option values prior to starting a new
+ // option parse. Each subclass must override this function and revert
+ // all option settings to default values.
+ virtual void OptionParsingStarting(ExecutionContext *execution_context) = 0;
+
+ virtual Error OptionParsingFinished(ExecutionContext *execution_context) {
+ // If subclasses need to know when the options are done being parsed
+ // they can implement this function to do extra checking
+ Error error;
+ return error;
+ }
};
- class OptionGroup
- {
- public:
- OptionGroup() = default;
-
- virtual
- ~OptionGroup() = default;
-
- virtual uint32_t
- GetNumDefinitions () = 0;
-
- virtual const OptionDefinition*
- GetDefinitions () = 0;
-
- virtual Error
- SetOptionValue (CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value) = 0;
-
- virtual void
- OptionParsingStarting (CommandInterpreter &interpreter) = 0;
-
- virtual Error
- OptionParsingFinished (CommandInterpreter &interpreter)
- {
- // If subclasses need to know when the options are done being parsed
- // they can implement this function to do extra checking
- Error error;
- return error;
- }
- };
-
- class OptionGroupOptions : public Options
- {
- public:
- OptionGroupOptions (CommandInterpreter &interpreter) :
- Options (interpreter),
- m_option_defs (),
- m_option_infos (),
- m_did_finalize (false)
- {
- }
-
- ~OptionGroupOptions() override = default;
-
- //----------------------------------------------------------------------
- /// Append options from a OptionGroup class.
- ///
- /// Append all options from \a group using the exact same option groups
- /// that each option is defined with.
- ///
- /// @param[in] group
- /// A group of options to take option values from and copy their
- /// definitions into this class.
- //----------------------------------------------------------------------
- void
- Append (OptionGroup* group);
-
- //----------------------------------------------------------------------
- /// Append options from a OptionGroup class.
- ///
- /// Append options from \a group that have a usage mask that has any bits
- /// in "src_mask" set. After the option definition is copied into the
- /// options definitions in this class, set the usage_mask to "dst_mask".
- ///
- /// @param[in] group
- /// A group of options to take option values from and copy their
- /// definitions into this class.
- ///
- /// @param[in] src_mask
- /// When copying options from \a group, you might only want some of
- /// the options to be appended to this group. This mask allows you
- /// to control which options from \a group get added. It also allows
- /// you to specify the same options from \a group multiple times
- /// for different option sets.
- ///
- /// @param[in] dst_mask
- /// Set the usage mask for any copied options to \a dst_mask after
- /// copying the option definition.
- //----------------------------------------------------------------------
- void
- Append (OptionGroup* group,
- uint32_t src_mask,
- uint32_t dst_mask);
-
- void
- Finalize ();
-
- bool
- DidFinalize ()
- {
- return m_did_finalize;
- }
-
- Error
- SetOptionValue(uint32_t option_idx,
- const char *option_arg) override;
-
- void
- OptionParsingStarting() override;
-
- Error
- OptionParsingFinished() override;
-
- const OptionDefinition*
- GetDefinitions() override
- {
- assert (m_did_finalize);
- return &m_option_defs[0];
- }
-
- const OptionGroup*
- GetGroupWithOption (char short_opt);
-
- struct OptionInfo
- {
- OptionInfo (OptionGroup* g, uint32_t i) :
- option_group (g),
- option_index (i)
- {
- }
- OptionGroup* option_group; // The group that this option came from
- uint32_t option_index; // The original option index from the OptionGroup
- };
- typedef std::vector<OptionInfo> OptionInfos;
-
- std::vector<OptionDefinition> m_option_defs;
- OptionInfos m_option_infos;
- bool m_did_finalize;
- };
+class OptionGroup {
+public:
+ OptionGroup() = default;
+
+ virtual ~OptionGroup() = default;
+
+ virtual llvm::ArrayRef<OptionDefinition> GetDefinitions() = 0;
+
+ virtual Error SetOptionValue(uint32_t option_idx,
+ llvm::StringRef option_value,
+ ExecutionContext *execution_context) = 0;
+
+ virtual void OptionParsingStarting(ExecutionContext *execution_context) = 0;
+
+ virtual Error OptionParsingFinished(ExecutionContext *execution_context) {
+ // If subclasses need to know when the options are done being parsed
+ // they can implement this function to do extra checking
+ Error error;
+ return error;
+ }
+};
+
+class OptionGroupOptions : public Options {
+public:
+ OptionGroupOptions()
+ : Options(), m_option_defs(), m_option_infos(), m_did_finalize(false) {}
+
+ ~OptionGroupOptions() override = default;
+
+ //----------------------------------------------------------------------
+ /// Append options from a OptionGroup class.
+ ///
+ /// Append all options from \a group using the exact same option groups
+ /// that each option is defined with.
+ ///
+ /// @param[in] group
+ /// A group of options to take option values from and copy their
+ /// definitions into this class.
+ //----------------------------------------------------------------------
+ void Append(OptionGroup *group);
+
+ //----------------------------------------------------------------------
+ /// Append options from a OptionGroup class.
+ ///
+ /// Append options from \a group that have a usage mask that has any bits
+ /// in "src_mask" set. After the option definition is copied into the
+ /// options definitions in this class, set the usage_mask to "dst_mask".
+ ///
+ /// @param[in] group
+ /// A group of options to take option values from and copy their
+ /// definitions into this class.
+ ///
+ /// @param[in] src_mask
+ /// When copying options from \a group, you might only want some of
+ /// the options to be appended to this group. This mask allows you
+ /// to control which options from \a group get added. It also allows
+ /// you to specify the same options from \a group multiple times
+ /// for different option sets.
+ ///
+ /// @param[in] dst_mask
+ /// Set the usage mask for any copied options to \a dst_mask after
+ /// copying the option definition.
+ //----------------------------------------------------------------------
+ void Append(OptionGroup *group, uint32_t src_mask, uint32_t dst_mask);
+
+ void Finalize();
+
+ bool DidFinalize() { return m_did_finalize; }
+
+ Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+ ExecutionContext *execution_context) override;
+
+ void OptionParsingStarting(ExecutionContext *execution_context) override;
+
+ Error OptionParsingFinished(ExecutionContext *execution_context) override;
+
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
+ assert(m_did_finalize);
+ return m_option_defs;
+ }
+
+ const OptionGroup *GetGroupWithOption(char short_opt);
+
+ struct OptionInfo {
+ OptionInfo(OptionGroup *g, uint32_t i) : option_group(g), option_index(i) {}
+ OptionGroup *option_group; // The group that this option came from
+ uint32_t option_index; // The original option index from the OptionGroup
+ };
+ typedef std::vector<OptionInfo> OptionInfos;
+
+ std::vector<OptionDefinition> m_option_defs;
+ OptionInfos m_option_infos;
+ bool m_did_finalize;
+};
} // namespace lldb_private
diff --git a/include/lldb/Interpreter/Property.h b/include/lldb/Interpreter/Property.h
index cb4c827ded06..e09df5cf9dad 100644
--- a/include/lldb/Interpreter/Property.h
+++ b/include/lldb/Interpreter/Property.h
@@ -16,97 +16,66 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-defines.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Flags.h"
#include "lldb/Interpreter/OptionValue.h"
+#include "lldb/lldb-defines.h"
namespace lldb_private {
- // A structure that can be used to create a global table for all properties.
- // Property class instances can be constructed using one of these.
- struct PropertyDefinition
- {
- const char *name;
- OptionValue::Type type;
- bool global; // false == this setting is a global setting by default
- uintptr_t default_uint_value;
- const char *default_cstr_value;
- OptionEnumValueElement *enum_values;
- const char *description;
- };
-
- class Property
- {
- public:
- Property (const PropertyDefinition &definition);
-
- Property (const ConstString &name,
- const ConstString &desc,
- bool is_global,
- const lldb::OptionValueSP &value_sp);
-
- const ConstString &
- GetName() const
- {
- return m_name;
- }
-
- const char *
- GetDescription () const
- {
- return m_description.GetCString();
- }
-
- const lldb::OptionValueSP &
- GetValue() const
- {
- return m_value_sp;
- }
-
- void
- SetOptionValue (const lldb::OptionValueSP &value_sp)
- {
- m_value_sp = value_sp;
- }
-
-
- bool
- IsValid() const
- {
- return (bool)m_value_sp;
- }
-
- bool
- IsGlobal () const
- {
- return m_is_global;
- }
-
- void
- Dump (const ExecutionContext *exe_ctx,
- Stream &strm,
- uint32_t dump_mask) const;
-
- bool
- DumpQualifiedName(Stream &strm) const;
-
- void
- DumpDescription (CommandInterpreter &interpreter,
- Stream &strm,
- uint32_t output_width,
- bool display_qualified_name) const;
-
- void
- SetValueChangedCallback (OptionValueChangedCallback callback, void *baton);
-
- protected:
- ConstString m_name;
- ConstString m_description;
- lldb::OptionValueSP m_value_sp;
- bool m_is_global;
- };
+// A structure that can be used to create a global table for all properties.
+// Property class instances can be constructed using one of these.
+struct PropertyDefinition {
+ const char *name;
+ OptionValue::Type type;
+ bool global; // false == this setting is a global setting by default
+ uintptr_t default_uint_value;
+ const char *default_cstr_value;
+ OptionEnumValueElement *enum_values;
+ const char *description;
+};
+
+class Property {
+public:
+ Property(const PropertyDefinition &definition);
+
+ Property(const ConstString &name, const ConstString &desc, bool is_global,
+ const lldb::OptionValueSP &value_sp);
+
+ llvm::StringRef GetName() const { return m_name.GetStringRef(); }
+ llvm::StringRef GetDescription() const {
+ return m_description.GetStringRef();
+ }
+
+ const lldb::OptionValueSP &GetValue() const { return m_value_sp; }
+
+ void SetOptionValue(const lldb::OptionValueSP &value_sp) {
+ m_value_sp = value_sp;
+ }
+
+ bool IsValid() const { return (bool)m_value_sp; }
+
+ bool IsGlobal() const { return m_is_global; }
+
+ void Dump(const ExecutionContext *exe_ctx, Stream &strm,
+ uint32_t dump_mask) const;
+
+ bool DumpQualifiedName(Stream &strm) const;
+
+ void DumpDescription(CommandInterpreter &interpreter, Stream &strm,
+ uint32_t output_width,
+ bool display_qualified_name) const;
+
+ void SetValueChangedCallback(OptionValueChangedCallback callback,
+ void *baton);
+
+protected:
+ ConstString m_name;
+ ConstString m_description;
+ lldb::OptionValueSP m_value_sp;
+ bool m_is_global;
+};
} // namespace lldb_private
-#endif // liblldb_Property_h_
+#endif // liblldb_Property_h_
diff --git a/include/lldb/Interpreter/ScriptInterpreter.h b/include/lldb/Interpreter/ScriptInterpreter.h
index 8cfb3cea44b6..3fdba0818535 100644
--- a/include/lldb/Interpreter/ScriptInterpreter.h
+++ b/include/lldb/Interpreter/ScriptInterpreter.h
@@ -16,6 +16,7 @@
// Project includes
#include "lldb/lldb-private.h"
+#include "lldb/Breakpoint/BreakpointOptions.h"
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/PluginInterface.h"
@@ -24,511 +25,428 @@
#include "lldb/Utility/PseudoTerminal.h"
namespace lldb_private {
-
-class ScriptInterpreterLocker
-{
+
+class ScriptInterpreterLocker {
public:
-
- ScriptInterpreterLocker() = default;
-
- virtual ~ScriptInterpreterLocker() = default;
+ ScriptInterpreterLocker() = default;
+
+ virtual ~ScriptInterpreterLocker() = default;
private:
- DISALLOW_COPY_AND_ASSIGN (ScriptInterpreterLocker);
+ DISALLOW_COPY_AND_ASSIGN(ScriptInterpreterLocker);
};
-class ScriptInterpreter : public PluginInterface
-{
+class ScriptInterpreter : public PluginInterface {
public:
- typedef enum
- {
- eScriptReturnTypeCharPtr,
- eScriptReturnTypeBool,
- eScriptReturnTypeShortInt,
- eScriptReturnTypeShortIntUnsigned,
- eScriptReturnTypeInt,
- eScriptReturnTypeIntUnsigned,
- eScriptReturnTypeLongInt,
- eScriptReturnTypeLongIntUnsigned,
- eScriptReturnTypeLongLong,
- eScriptReturnTypeLongLongUnsigned,
- eScriptReturnTypeFloat,
- eScriptReturnTypeDouble,
- eScriptReturnTypeChar,
- eScriptReturnTypeCharStrOrNone,
- eScriptReturnTypeOpaqueObject
- } ScriptReturnType;
-
- ScriptInterpreter (CommandInterpreter &interpreter, lldb::ScriptLanguage script_lang);
-
- ~ScriptInterpreter() override;
-
- struct ExecuteScriptOptions
- {
- public:
- ExecuteScriptOptions () :
- m_enable_io(true),
- m_set_lldb_globals(true),
- m_maskout_errors(true)
- {
- }
-
- bool
- GetEnableIO () const
- {
- return m_enable_io;
- }
-
- bool
- GetSetLLDBGlobals () const
- {
- return m_set_lldb_globals;
- }
-
- bool
- GetMaskoutErrors () const
- {
- return m_maskout_errors;
- }
-
- ExecuteScriptOptions&
- SetEnableIO (bool enable)
- {
- m_enable_io = enable;
- return *this;
- }
-
- ExecuteScriptOptions&
- SetSetLLDBGlobals (bool set)
- {
- m_set_lldb_globals = set;
- return *this;
- }
-
- ExecuteScriptOptions&
- SetMaskoutErrors (bool maskout)
- {
- m_maskout_errors = maskout;
- return *this;
- }
-
- private:
- bool m_enable_io;
- bool m_set_lldb_globals;
- bool m_maskout_errors;
- };
-
- virtual bool
- Interrupt()
- {
- return false;
- }
-
- virtual bool
- ExecuteOneLine (const char *command,
- CommandReturnObject *result,
- const ExecuteScriptOptions &options = ExecuteScriptOptions()) = 0;
-
- virtual void
- ExecuteInterpreterLoop () = 0;
-
- virtual bool
- ExecuteOneLineWithReturn (const char *in_string,
- ScriptReturnType return_type,
- void *ret_value,
- const ExecuteScriptOptions &options = ExecuteScriptOptions())
- {
- return true;
- }
-
- virtual Error
- ExecuteMultipleLines (const char *in_string,
- const ExecuteScriptOptions &options = ExecuteScriptOptions())
- {
- Error error;
- error.SetErrorString("not implemented");
- return error;
- }
-
- virtual Error
- ExportFunctionDefinitionToInterpreter (StringList &function_def)
- {
- Error error;
- error.SetErrorString("not implemented");
- return error;
- }
-
- virtual Error
- GenerateBreakpointCommandCallbackData (StringList &input, std::string& output)
- {
- Error error;
- error.SetErrorString("not implemented");
- return error;
- }
-
- virtual bool
- GenerateWatchpointCommandCallbackData (StringList &input, std::string& output)
- {
- return false;
- }
-
- virtual bool
- GenerateTypeScriptFunction(const char* oneliner, std::string& output, const void* name_token = nullptr)
- {
- return false;
- }
-
- virtual bool
- GenerateTypeScriptFunction(StringList &input, std::string& output, const void* name_token = nullptr)
- {
- return false;
- }
-
- virtual bool
- GenerateScriptAliasFunction (StringList &input, std::string& output)
- {
- return false;
- }
-
- virtual bool
- GenerateTypeSynthClass(StringList &input, std::string& output, const void* name_token = nullptr)
- {
- return false;
- }
-
- virtual bool
- GenerateTypeSynthClass(const char* oneliner, std::string& output, const void* name_token = nullptr)
- {
- return false;
- }
-
- virtual StructuredData::ObjectSP
- CreateSyntheticScriptedProvider(const char *class_name, lldb::ValueObjectSP valobj)
- {
- return StructuredData::ObjectSP();
- }
-
- virtual StructuredData::GenericSP
- CreateScriptCommandObject (const char *class_name)
- {
- return StructuredData::GenericSP();
- }
-
- virtual StructuredData::GenericSP
- OSPlugin_CreatePluginObject (const char *class_name,
- lldb::ProcessSP process_sp)
- {
- return StructuredData::GenericSP();
- }
-
- virtual StructuredData::DictionarySP
- OSPlugin_RegisterInfo(StructuredData::ObjectSP os_plugin_object_sp)
- {
- return StructuredData::DictionarySP();
- }
-
- virtual StructuredData::ArraySP
- OSPlugin_ThreadsInfo(StructuredData::ObjectSP os_plugin_object_sp)
- {
- return StructuredData::ArraySP();
- }
-
- virtual StructuredData::StringSP
- OSPlugin_RegisterContextData(StructuredData::ObjectSP os_plugin_object_sp, lldb::tid_t thread_id)
- {
- return StructuredData::StringSP();
- }
-
- virtual StructuredData::DictionarySP
- OSPlugin_CreateThread(StructuredData::ObjectSP os_plugin_object_sp, lldb::tid_t tid, lldb::addr_t context)
- {
- return StructuredData::DictionarySP();
- }
-
- virtual StructuredData::ObjectSP
- CreateScriptedThreadPlan(const char *class_name, lldb::ThreadPlanSP thread_plan_sp)
- {
- return StructuredData::ObjectSP();
- }
-
- virtual bool
- ScriptedThreadPlanExplainsStop(StructuredData::ObjectSP implementor_sp, Event *event, bool &script_error)
- {
- script_error = true;
- return true;
- }
-
- virtual bool
- ScriptedThreadPlanShouldStop(StructuredData::ObjectSP implementor_sp, Event *event, bool &script_error)
- {
- script_error = true;
- return true;
- }
-
- virtual lldb::StateType
- ScriptedThreadPlanGetRunState(StructuredData::ObjectSP implementor_sp, bool &script_error)
- {
- script_error = true;
- return lldb::eStateStepping;
- }
-
- virtual StructuredData::ObjectSP
- LoadPluginModule(const FileSpec &file_spec, lldb_private::Error &error)
- {
- return StructuredData::ObjectSP();
- }
-
- virtual StructuredData::DictionarySP
- GetDynamicSettings(StructuredData::ObjectSP plugin_module_sp, Target *target, const char *setting_name, lldb_private::Error &error)
- {
- return StructuredData::DictionarySP();
- }
-
- virtual Error
- GenerateFunction(const char *signature, const StringList &input)
- {
- Error error;
- error.SetErrorString("unimplemented");
- return error;
- }
-
- virtual void
- CollectDataForBreakpointCommandCallback (std::vector<BreakpointOptions *> &options,
- CommandReturnObject &result);
-
- virtual void
- CollectDataForWatchpointCommandCallback (WatchpointOptions *wp_options,
- CommandReturnObject &result);
-
- /// Set the specified text as the callback for the breakpoint.
- Error
- SetBreakpointCommandCallback (std::vector<BreakpointOptions *> &bp_options_vec,
- const char *callback_text);
-
- virtual Error
- SetBreakpointCommandCallback (BreakpointOptions *bp_options,
- const char *callback_text)
- {
- Error error;
- error.SetErrorString("unimplemented");
- return error;
- }
-
- void
- SetBreakpointCommandCallbackFunction (std::vector<BreakpointOptions *> &bp_options_vec,
- const char *function_name);
-
- /// Set a one-liner as the callback for the breakpoint.
- virtual void
- SetBreakpointCommandCallbackFunction (BreakpointOptions *bp_options,
- const char *function_name)
- {
- }
-
- /// Set a one-liner as the callback for the watchpoint.
- virtual void
- SetWatchpointCommandCallback (WatchpointOptions *wp_options,
- const char *oneliner)
- {
- }
-
- virtual bool
- GetScriptedSummary(const char *function_name, lldb::ValueObjectSP valobj, StructuredData::ObjectSP &callee_wrapper_sp,
- const TypeSummaryOptions &options, std::string &retval)
- {
- return false;
- }
-
- virtual void
- Clear ()
- {
- // Clean up any ref counts to SBObjects that might be in global variables
- }
-
- virtual size_t
- CalculateNumChildren(const StructuredData::ObjectSP &implementor, uint32_t max)
- {
- return 0;
- }
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex(const StructuredData::ObjectSP &implementor, uint32_t idx)
- {
- return lldb::ValueObjectSP();
- }
-
- virtual int
- GetIndexOfChildWithName(const StructuredData::ObjectSP &implementor, const char *child_name)
- {
- return UINT32_MAX;
- }
-
- virtual bool
- UpdateSynthProviderInstance(const StructuredData::ObjectSP &implementor)
- {
- return false;
- }
-
- virtual bool
- MightHaveChildrenSynthProviderInstance(const StructuredData::ObjectSP &implementor)
- {
- return true;
- }
-
- virtual lldb::ValueObjectSP
- GetSyntheticValue(const StructuredData::ObjectSP &implementor)
- {
- return nullptr;
- }
-
- virtual ConstString
- GetSyntheticTypeName (const StructuredData::ObjectSP &implementor)
- {
- return ConstString();
- }
-
- virtual bool
- RunScriptBasedCommand (const char* impl_function,
- const char* args,
- ScriptedCommandSynchronicity synchronicity,
- lldb_private::CommandReturnObject& cmd_retobj,
- Error& error,
- const lldb_private::ExecutionContext& exe_ctx)
- {
- return false;
- }
-
- virtual bool
- RunScriptBasedCommand (StructuredData::GenericSP impl_obj_sp,
- const char* args,
- ScriptedCommandSynchronicity synchronicity,
- lldb_private::CommandReturnObject& cmd_retobj,
- Error& error,
- const lldb_private::ExecutionContext& exe_ctx)
- {
- return false;
- }
-
- virtual bool
- RunScriptFormatKeyword (const char* impl_function,
- Process* process,
- std::string& output,
- Error& error)
- {
- error.SetErrorString("unimplemented");
- return false;
- }
-
- virtual bool
- RunScriptFormatKeyword (const char* impl_function,
- Thread* thread,
- std::string& output,
- Error& error)
- {
- error.SetErrorString("unimplemented");
- return false;
- }
-
- virtual bool
- RunScriptFormatKeyword (const char* impl_function,
- Target* target,
- std::string& output,
- Error& error)
- {
- error.SetErrorString("unimplemented");
- return false;
- }
-
- virtual bool
- RunScriptFormatKeyword (const char* impl_function,
- StackFrame* frame,
- std::string& output,
- Error& error)
- {
- error.SetErrorString("unimplemented");
- return false;
- }
-
- virtual bool
- RunScriptFormatKeyword (const char* impl_function,
- ValueObject* value,
- std::string& output,
- Error& error)
- {
- error.SetErrorString("unimplemented");
- return false;
- }
-
- virtual bool
- GetDocumentationForItem (const char* item, std::string& dest)
- {
- dest.clear();
- return false;
- }
-
- virtual bool
- GetShortHelpForCommandObject (StructuredData::GenericSP cmd_obj_sp,
- std::string& dest)
- {
- dest.clear();
- return false;
- }
-
- virtual uint32_t
- GetFlagsForCommandObject (StructuredData::GenericSP cmd_obj_sp)
- {
- return 0;
- }
-
- virtual bool
- GetLongHelpForCommandObject (StructuredData::GenericSP cmd_obj_sp,
- std::string& dest)
- {
- dest.clear();
- return false;
- }
-
- virtual bool
- CheckObjectExists (const char* name)
- {
- return false;
- }
-
- virtual bool
- LoadScriptingModule(const char *filename, bool can_reload, bool init_session, lldb_private::Error &error,
- StructuredData::ObjectSP *module_sp = nullptr)
- {
- error.SetErrorString("loading unimplemented");
- return false;
- }
-
- virtual bool
- IsReservedWord (const char* word)
- {
- return false;
- }
-
- virtual std::unique_ptr<ScriptInterpreterLocker>
- AcquireInterpreterLock ();
-
- const char *
- GetScriptInterpreterPtyName ();
-
- int
- GetMasterFileDescriptor ();
-
- CommandInterpreter &
- GetCommandInterpreter();
-
- static std::string
- LanguageToString (lldb::ScriptLanguage language);
-
- virtual void
- ResetOutputFileHandle (FILE *new_fh) { } //By default, do nothing.
+ typedef enum {
+ eScriptReturnTypeCharPtr,
+ eScriptReturnTypeBool,
+ eScriptReturnTypeShortInt,
+ eScriptReturnTypeShortIntUnsigned,
+ eScriptReturnTypeInt,
+ eScriptReturnTypeIntUnsigned,
+ eScriptReturnTypeLongInt,
+ eScriptReturnTypeLongIntUnsigned,
+ eScriptReturnTypeLongLong,
+ eScriptReturnTypeLongLongUnsigned,
+ eScriptReturnTypeFloat,
+ eScriptReturnTypeDouble,
+ eScriptReturnTypeChar,
+ eScriptReturnTypeCharStrOrNone,
+ eScriptReturnTypeOpaqueObject
+ } ScriptReturnType;
+
+ ScriptInterpreter(CommandInterpreter &interpreter,
+ lldb::ScriptLanguage script_lang);
+
+ ~ScriptInterpreter() override;
+
+ struct ExecuteScriptOptions {
+ public:
+ ExecuteScriptOptions()
+ : m_enable_io(true), m_set_lldb_globals(true), m_maskout_errors(true) {}
+
+ bool GetEnableIO() const { return m_enable_io; }
+
+ bool GetSetLLDBGlobals() const { return m_set_lldb_globals; }
+
+ bool GetMaskoutErrors() const { return m_maskout_errors; }
+
+ ExecuteScriptOptions &SetEnableIO(bool enable) {
+ m_enable_io = enable;
+ return *this;
+ }
+
+ ExecuteScriptOptions &SetSetLLDBGlobals(bool set) {
+ m_set_lldb_globals = set;
+ return *this;
+ }
+
+ ExecuteScriptOptions &SetMaskoutErrors(bool maskout) {
+ m_maskout_errors = maskout;
+ return *this;
+ }
+
+ private:
+ bool m_enable_io;
+ bool m_set_lldb_globals;
+ bool m_maskout_errors;
+ };
+
+ virtual bool Interrupt() { return false; }
+
+ virtual bool ExecuteOneLine(
+ const char *command, CommandReturnObject *result,
+ const ExecuteScriptOptions &options = ExecuteScriptOptions()) = 0;
+
+ virtual void ExecuteInterpreterLoop() = 0;
+
+ virtual bool ExecuteOneLineWithReturn(
+ const char *in_string, ScriptReturnType return_type, void *ret_value,
+ const ExecuteScriptOptions &options = ExecuteScriptOptions()) {
+ return true;
+ }
+
+ virtual Error ExecuteMultipleLines(
+ const char *in_string,
+ const ExecuteScriptOptions &options = ExecuteScriptOptions()) {
+ Error error;
+ error.SetErrorString("not implemented");
+ return error;
+ }
+
+ virtual Error
+ ExportFunctionDefinitionToInterpreter(StringList &function_def) {
+ Error error;
+ error.SetErrorString("not implemented");
+ return error;
+ }
+
+ virtual Error GenerateBreakpointCommandCallbackData(StringList &input,
+ std::string &output) {
+ Error error;
+ error.SetErrorString("not implemented");
+ return error;
+ }
+
+ virtual bool GenerateWatchpointCommandCallbackData(StringList &input,
+ std::string &output) {
+ return false;
+ }
+
+ virtual bool GenerateTypeScriptFunction(const char *oneliner,
+ std::string &output,
+ const void *name_token = nullptr) {
+ return false;
+ }
+
+ virtual bool GenerateTypeScriptFunction(StringList &input,
+ std::string &output,
+ const void *name_token = nullptr) {
+ return false;
+ }
+
+ virtual bool GenerateScriptAliasFunction(StringList &input,
+ std::string &output) {
+ return false;
+ }
+
+ virtual bool GenerateTypeSynthClass(StringList &input, std::string &output,
+ const void *name_token = nullptr) {
+ return false;
+ }
+
+ virtual bool GenerateTypeSynthClass(const char *oneliner, std::string &output,
+ const void *name_token = nullptr) {
+ return false;
+ }
+
+ virtual StructuredData::ObjectSP
+ CreateSyntheticScriptedProvider(const char *class_name,
+ lldb::ValueObjectSP valobj) {
+ return StructuredData::ObjectSP();
+ }
+
+ virtual StructuredData::GenericSP
+ CreateScriptCommandObject(const char *class_name) {
+ return StructuredData::GenericSP();
+ }
+
+ virtual StructuredData::GenericSP
+ OSPlugin_CreatePluginObject(const char *class_name,
+ lldb::ProcessSP process_sp) {
+ return StructuredData::GenericSP();
+ }
+
+ virtual StructuredData::DictionarySP
+ OSPlugin_RegisterInfo(StructuredData::ObjectSP os_plugin_object_sp) {
+ return StructuredData::DictionarySP();
+ }
+
+ virtual StructuredData::ArraySP
+ OSPlugin_ThreadsInfo(StructuredData::ObjectSP os_plugin_object_sp) {
+ return StructuredData::ArraySP();
+ }
+
+ virtual StructuredData::StringSP
+ OSPlugin_RegisterContextData(StructuredData::ObjectSP os_plugin_object_sp,
+ lldb::tid_t thread_id) {
+ return StructuredData::StringSP();
+ }
+
+ virtual StructuredData::DictionarySP
+ OSPlugin_CreateThread(StructuredData::ObjectSP os_plugin_object_sp,
+ lldb::tid_t tid, lldb::addr_t context) {
+ return StructuredData::DictionarySP();
+ }
+
+ virtual StructuredData::ObjectSP
+ CreateScriptedThreadPlan(const char *class_name,
+ lldb::ThreadPlanSP thread_plan_sp) {
+ return StructuredData::ObjectSP();
+ }
+
+ virtual bool
+ ScriptedThreadPlanExplainsStop(StructuredData::ObjectSP implementor_sp,
+ Event *event, bool &script_error) {
+ script_error = true;
+ return true;
+ }
+
+ virtual bool
+ ScriptedThreadPlanShouldStop(StructuredData::ObjectSP implementor_sp,
+ Event *event, bool &script_error) {
+ script_error = true;
+ return true;
+ }
+
+ virtual bool
+ ScriptedThreadPlanIsStale(StructuredData::ObjectSP implementor_sp,
+ bool &script_error) {
+ script_error = true;
+ return true;
+ }
+
+ virtual lldb::StateType
+ ScriptedThreadPlanGetRunState(StructuredData::ObjectSP implementor_sp,
+ bool &script_error) {
+ script_error = true;
+ return lldb::eStateStepping;
+ }
+
+ virtual StructuredData::ObjectSP
+ LoadPluginModule(const FileSpec &file_spec, lldb_private::Error &error) {
+ return StructuredData::ObjectSP();
+ }
+
+ virtual StructuredData::DictionarySP
+ GetDynamicSettings(StructuredData::ObjectSP plugin_module_sp, Target *target,
+ const char *setting_name, lldb_private::Error &error) {
+ return StructuredData::DictionarySP();
+ }
+
+ virtual Error GenerateFunction(const char *signature,
+ const StringList &input) {
+ Error error;
+ error.SetErrorString("unimplemented");
+ return error;
+ }
+
+ virtual void CollectDataForBreakpointCommandCallback(
+ std::vector<BreakpointOptions *> &options, CommandReturnObject &result);
+
+ virtual void
+ CollectDataForWatchpointCommandCallback(WatchpointOptions *wp_options,
+ CommandReturnObject &result);
+
+ /// Set the specified text as the callback for the breakpoint.
+ Error
+ SetBreakpointCommandCallback(std::vector<BreakpointOptions *> &bp_options_vec,
+ const char *callback_text);
+
+ virtual Error SetBreakpointCommandCallback(BreakpointOptions *bp_options,
+ const char *callback_text) {
+ Error error;
+ error.SetErrorString("unimplemented");
+ return error;
+ }
+
+ /// This one is for deserialization:
+ virtual Error SetBreakpointCommandCallback(
+ BreakpointOptions *bp_options,
+ std::unique_ptr<BreakpointOptions::CommandData> &data_up) {
+ Error error;
+ error.SetErrorString("unimplemented");
+ return error;
+ }
+
+ void SetBreakpointCommandCallbackFunction(
+ std::vector<BreakpointOptions *> &bp_options_vec,
+ const char *function_name);
+
+ /// Set a one-liner as the callback for the breakpoint.
+ virtual void
+ SetBreakpointCommandCallbackFunction(BreakpointOptions *bp_options,
+ const char *function_name) {}
+
+ /// Set a one-liner as the callback for the watchpoint.
+ virtual void SetWatchpointCommandCallback(WatchpointOptions *wp_options,
+ const char *oneliner) {}
+
+ virtual bool GetScriptedSummary(const char *function_name,
+ lldb::ValueObjectSP valobj,
+ StructuredData::ObjectSP &callee_wrapper_sp,
+ const TypeSummaryOptions &options,
+ std::string &retval) {
+ return false;
+ }
+
+ virtual void Clear() {
+ // Clean up any ref counts to SBObjects that might be in global variables
+ }
+
+ virtual size_t
+ CalculateNumChildren(const StructuredData::ObjectSP &implementor,
+ uint32_t max) {
+ return 0;
+ }
+
+ virtual lldb::ValueObjectSP
+ GetChildAtIndex(const StructuredData::ObjectSP &implementor, uint32_t idx) {
+ return lldb::ValueObjectSP();
+ }
+
+ virtual int
+ GetIndexOfChildWithName(const StructuredData::ObjectSP &implementor,
+ const char *child_name) {
+ return UINT32_MAX;
+ }
+
+ virtual bool
+ UpdateSynthProviderInstance(const StructuredData::ObjectSP &implementor) {
+ return false;
+ }
+
+ virtual bool MightHaveChildrenSynthProviderInstance(
+ const StructuredData::ObjectSP &implementor) {
+ return true;
+ }
+
+ virtual lldb::ValueObjectSP
+ GetSyntheticValue(const StructuredData::ObjectSP &implementor) {
+ return nullptr;
+ }
+
+ virtual ConstString
+ GetSyntheticTypeName(const StructuredData::ObjectSP &implementor) {
+ return ConstString();
+ }
+
+ virtual bool
+ RunScriptBasedCommand(const char *impl_function, const char *args,
+ ScriptedCommandSynchronicity synchronicity,
+ lldb_private::CommandReturnObject &cmd_retobj,
+ Error &error,
+ const lldb_private::ExecutionContext &exe_ctx) {
+ return false;
+ }
+
+ virtual bool
+ RunScriptBasedCommand(StructuredData::GenericSP impl_obj_sp, const char *args,
+ ScriptedCommandSynchronicity synchronicity,
+ lldb_private::CommandReturnObject &cmd_retobj,
+ Error &error,
+ const lldb_private::ExecutionContext &exe_ctx) {
+ return false;
+ }
+
+ virtual bool RunScriptFormatKeyword(const char *impl_function,
+ Process *process, std::string &output,
+ Error &error) {
+ error.SetErrorString("unimplemented");
+ return false;
+ }
+
+ virtual bool RunScriptFormatKeyword(const char *impl_function, Thread *thread,
+ std::string &output, Error &error) {
+ error.SetErrorString("unimplemented");
+ return false;
+ }
+
+ virtual bool RunScriptFormatKeyword(const char *impl_function, Target *target,
+ std::string &output, Error &error) {
+ error.SetErrorString("unimplemented");
+ return false;
+ }
+
+ virtual bool RunScriptFormatKeyword(const char *impl_function,
+ StackFrame *frame, std::string &output,
+ Error &error) {
+ error.SetErrorString("unimplemented");
+ return false;
+ }
+
+ virtual bool RunScriptFormatKeyword(const char *impl_function,
+ ValueObject *value, std::string &output,
+ Error &error) {
+ error.SetErrorString("unimplemented");
+ return false;
+ }
+
+ virtual bool GetDocumentationForItem(const char *item, std::string &dest) {
+ dest.clear();
+ return false;
+ }
+
+ virtual bool
+ GetShortHelpForCommandObject(StructuredData::GenericSP cmd_obj_sp,
+ std::string &dest) {
+ dest.clear();
+ return false;
+ }
+
+ virtual uint32_t
+ GetFlagsForCommandObject(StructuredData::GenericSP cmd_obj_sp) {
+ return 0;
+ }
+
+ virtual bool GetLongHelpForCommandObject(StructuredData::GenericSP cmd_obj_sp,
+ std::string &dest) {
+ dest.clear();
+ return false;
+ }
+
+ virtual bool CheckObjectExists(const char *name) { return false; }
+
+ virtual bool
+ LoadScriptingModule(const char *filename, bool can_reload, bool init_session,
+ lldb_private::Error &error,
+ StructuredData::ObjectSP *module_sp = nullptr) {
+ error.SetErrorString("loading unimplemented");
+ return false;
+ }
+
+ virtual bool IsReservedWord(const char *word) { return false; }
+
+ virtual std::unique_ptr<ScriptInterpreterLocker> AcquireInterpreterLock();
+
+ const char *GetScriptInterpreterPtyName();
+
+ int GetMasterFileDescriptor();
+
+ CommandInterpreter &GetCommandInterpreter();
+
+ static std::string LanguageToString(lldb::ScriptLanguage language);
+
+ static lldb::ScriptLanguage StringToLanguage(const llvm::StringRef &string);
+
+ virtual void ResetOutputFileHandle(FILE *new_fh) {} // By default, do nothing.
+
+ lldb::ScriptLanguage GetLanguage() { return m_script_lang; }
protected:
- CommandInterpreter &m_interpreter;
- lldb::ScriptLanguage m_script_lang;
+ CommandInterpreter &m_interpreter;
+ lldb::ScriptLanguage m_script_lang;
};
} // namespace lldb_private
diff --git a/include/lldb/Symbol/ArmUnwindInfo.h b/include/lldb/Symbol/ArmUnwindInfo.h
index 8c40f19d2859..cc80c0fa9663 100644
--- a/include/lldb/Symbol/ArmUnwindInfo.h
+++ b/include/lldb/Symbol/ArmUnwindInfo.h
@@ -29,48 +29,42 @@
namespace lldb_private {
-class ArmUnwindInfo
-{
+class ArmUnwindInfo {
public:
- ArmUnwindInfo(const ObjectFile& objfile,
- lldb::SectionSP& arm_exidx,
- lldb::SectionSP& arm_extab);
+ ArmUnwindInfo(const ObjectFile &objfile, lldb::SectionSP &arm_exidx,
+ lldb::SectionSP &arm_extab);
- ~ArmUnwindInfo();
+ ~ArmUnwindInfo();
- bool
- GetUnwindPlan(Target &target, const Address& addr, UnwindPlan& unwind_plan);
+ bool GetUnwindPlan(Target &target, const Address &addr,
+ UnwindPlan &unwind_plan);
private:
- struct ArmExidxEntry
- {
- ArmExidxEntry(uint32_t f, lldb::addr_t a, uint32_t d);
+ struct ArmExidxEntry {
+ ArmExidxEntry(uint32_t f, lldb::addr_t a, uint32_t d);
- bool
- operator<(const ArmExidxEntry& other) const;
+ bool operator<(const ArmExidxEntry &other) const;
- uint32_t file_address;
- lldb::addr_t address;
- uint32_t data;
- };
+ uint32_t file_address;
+ lldb::addr_t address;
+ uint32_t data;
+ };
- const uint8_t*
- GetExceptionHandlingTableEntry(const Address& addr);
+ const uint8_t *GetExceptionHandlingTableEntry(const Address &addr);
- uint8_t
- GetByteAtOffset(const uint32_t* data, uint16_t offset) const;
+ uint8_t GetByteAtOffset(const uint32_t *data, uint16_t offset) const;
- uint64_t
- GetULEB128(const uint32_t* data, uint16_t& offset, uint16_t max_offset) const;
+ uint64_t GetULEB128(const uint32_t *data, uint16_t &offset,
+ uint16_t max_offset) const;
- const lldb::ByteOrder m_byte_order;
- lldb::SectionSP m_arm_exidx_sp; // .ARM.exidx section
- lldb::SectionSP m_arm_extab_sp; // .ARM.extab section
- DataExtractor m_arm_exidx_data; // .ARM.exidx section data
- DataExtractor m_arm_extab_data; // .ARM.extab section data
- std::vector<ArmExidxEntry> m_exidx_entries;
+ const lldb::ByteOrder m_byte_order;
+ lldb::SectionSP m_arm_exidx_sp; // .ARM.exidx section
+ lldb::SectionSP m_arm_extab_sp; // .ARM.extab section
+ DataExtractor m_arm_exidx_data; // .ARM.exidx section data
+ DataExtractor m_arm_extab_data; // .ARM.extab section data
+ std::vector<ArmExidxEntry> m_exidx_entries;
};
} // namespace lldb_private
-#endif // liblldb_ArmUnwindInfo_h_
+#endif // liblldb_ArmUnwindInfo_h_
diff --git a/include/lldb/Symbol/Block.h b/include/lldb/Symbol/Block.h
index 6dbb9c56097b..eb96318dac04 100644
--- a/include/lldb/Symbol/Block.h
+++ b/include/lldb/Symbol/Block.h
@@ -16,14 +16,14 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/AddressRange.h"
#include "lldb/Core/RangeMap.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/UserID.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/LineEntry.h"
#include "lldb/Symbol/SymbolContext.h"
-#include "lldb/Symbol/CompilerType.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -45,451 +45,394 @@ namespace lldb_private {
/// InlineFunctionInfo shared pointer object to a block. Inlined
/// functions are represented as named blocks.
//----------------------------------------------------------------------
-class Block :
- public UserID,
- public SymbolContextScope
-{
+class Block : public UserID, public SymbolContextScope {
public:
- typedef RangeArray<uint32_t, uint32_t, 1> RangeList;
- typedef RangeList::Entry Range;
-
- //------------------------------------------------------------------
- /// Construct with a User ID \a uid, \a depth.
- ///
- /// Initialize this block with the specified UID \a uid. The
- /// \a depth in the \a block_list is used to represent the parent,
- /// sibling, and child block information and also allows for partial
- /// parsing at the block level.
- ///
- /// @param[in] uid
- /// The UID for a given block. This value is given by the
- /// SymbolFile plug-in and can be any value that helps the
- /// SymbolFile plug-in to match this block back to the debug
- /// information data that it parses for further or more in
- /// depth parsing. Common values would be the index into a
- /// table, or an offset into the debug information.
- ///
- /// @param[in] depth
- /// The integer depth of this block in the block list hierarchy.
- ///
- /// @param[in] block_list
- /// The block list that this object belongs to.
- ///
- /// @see BlockList
- //------------------------------------------------------------------
- Block (lldb::user_id_t uid);
-
- //------------------------------------------------------------------
- /// Destructor.
- //------------------------------------------------------------------
- ~Block() override;
-
- //------------------------------------------------------------------
- /// Add a child to this object.
- ///
- /// @param[in] child_block_sp
- /// A shared pointer to a child block that will get added to
- /// this block.
- //------------------------------------------------------------------
- void
- AddChild (const lldb::BlockSP &child_block_sp);
-
- //------------------------------------------------------------------
- /// Add a new offset range to this block.
- ///
- /// @param[in] start_offset
- /// An offset into this Function's address range that
- /// describes the start address of a range for this block.
- ///
- /// @param[in] end_offset
- /// An offset into this Function's address range that
- /// describes the end address of a range for this block.
- //------------------------------------------------------------------
- void
- AddRange (const Range& range);
-
- void
- FinalizeRanges ();
-
- //------------------------------------------------------------------
- /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
- ///
- /// @see SymbolContextScope
- //------------------------------------------------------------------
- void
- CalculateSymbolContext(SymbolContext* sc) override;
-
- lldb::ModuleSP
- CalculateSymbolContextModule() override;
-
- CompileUnit *
- CalculateSymbolContextCompileUnit() override;
-
- Function *
- CalculateSymbolContextFunction() override;
-
- Block *
- CalculateSymbolContextBlock() override;
-
- //------------------------------------------------------------------
- /// Check if an offset is in one of the block offset ranges.
- ///
- /// @param[in] range_offset
- /// An offset into the Function's address range.
- ///
- /// @return
- /// Returns \b true if \a range_offset falls in one of this
- /// block's ranges, \b false otherwise.
- //------------------------------------------------------------------
- bool
- Contains (lldb::addr_t range_offset) const;
-
- //------------------------------------------------------------------
- /// Check if a offset range is in one of the block offset ranges.
- ///
- /// @param[in] range
- /// An offset range into the Function's address range.
- ///
- /// @return
- /// Returns \b true if \a range falls in one of this
- /// block's ranges, \b false otherwise.
- //------------------------------------------------------------------
- bool
- Contains (const Range& range) const;
-
- //------------------------------------------------------------------
- /// Check if this object contains "block" as a child block at any
- /// depth.
- ///
- /// @param[in] block
- /// A potential child block.
- ///
- /// @return
- /// Returns \b true if \a block is a child of this block, \b
- /// false otherwise.
- //------------------------------------------------------------------
- bool
- Contains (const Block *block) const;
-
- //------------------------------------------------------------------
- /// Dump the block contents.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- ///
- /// @param[in] base_addr
- /// The resolved start address of the Function's address
- /// range. This should be resolved as the file or load address
- /// prior to passing the value into this function for dumping.
- ///
- /// @param[in] depth
- /// Limit the number of levels deep that this function should
- /// print as this block can contain child blocks. Specify
- /// INT_MAX to dump all child blocks.
- ///
- /// @param[in] show_context
- /// If \b true, variables will dump their context information.
- //------------------------------------------------------------------
- void
- Dump (Stream *s, lldb::addr_t base_addr, int32_t depth, bool show_context) const;
-
- //------------------------------------------------------------------
- /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
- ///
- /// @see SymbolContextScope
- //------------------------------------------------------------------
- void
- DumpSymbolContext(Stream *s) override;
-
- void
- DumpAddressRanges (Stream *s,
- lldb::addr_t base_addr);
-
- void
- GetDescription (Stream *s,
- Function *function,
- lldb::DescriptionLevel level,
- Target *target) const;
-
- //------------------------------------------------------------------
- /// Get the parent block.
- ///
- /// @return
- /// The parent block pointer, or nullptr if this block has no
- /// parent.
- //------------------------------------------------------------------
- Block *
- GetParent () const;
-
- //------------------------------------------------------------------
- /// Get the inlined block that contains this block.
- ///
- /// @return
- /// If this block contains inlined function info, it will return
- /// this block, else parent blocks will be searched to see if
- /// any contain this block. nullptr will be returned if this block
- /// nor any parent blocks are inlined function blocks.
- //------------------------------------------------------------------
- Block *
- GetContainingInlinedBlock ();
-
- //------------------------------------------------------------------
- /// Get the inlined parent block for this block.
- ///
- /// @return
- /// The parent block pointer, or nullptr if this block has no
- /// parent.
- //------------------------------------------------------------------
- Block *
- GetInlinedParent ();
-
- //------------------------------------------------------------------
- /// Get the sibling block for this block.
- ///
- /// @return
- /// The sibling block pointer, or nullptr if this block has no
- /// sibling.
- //------------------------------------------------------------------
- Block *
- GetSibling () const;
-
- //------------------------------------------------------------------
- /// Get the first child block.
- ///
- /// @return
- /// The first child block pointer, or nullptr if this block has no
- /// children.
- //------------------------------------------------------------------
- Block *
- GetFirstChild () const
- {
- return (m_children.empty() ? nullptr : m_children.front().get());
- }
-
- //------------------------------------------------------------------
- /// Get the variable list for this block only.
- ///
- /// @param[in] can_create
- /// If \b true, the variables can be parsed if they already
- /// haven't been, else the current state of the block will be
- /// returned.
- ///
- /// @return
- /// A variable list shared pointer that contains all variables
- /// for this block.
- //------------------------------------------------------------------
- lldb::VariableListSP
- GetBlockVariableList (bool can_create);
-
- //------------------------------------------------------------------
- /// Get the variable list for this block and optionally all child
- /// blocks if \a get_child_variables is \b true.
- ///
- /// @param[in] get_child_variables
- /// If \b true, all variables from all child blocks will be
- /// added to the variable list.
- ///
- /// @param[in] can_create
- /// If \b true, the variables can be parsed if they already
- /// haven't been, else the current state of the block will be
- /// returned. Passing \b true for this parameter can be used
- /// to see the current state of what has been parsed up to this
- /// point.
- ///
- /// @param[in] add_inline_child_block_variables
- /// If this is \b false, no child variables of child blocks
- /// that are inlined functions will be gotten. If \b true then
- /// all child variables will be added regardless of whether they
- /// come from inlined functions or not.
- ///
- /// @return
- /// A variable list shared pointer that contains all variables
- /// for this block.
- //------------------------------------------------------------------
- uint32_t
- AppendBlockVariables (bool can_create,
- bool get_child_block_variables,
- bool stop_if_child_block_is_inlined_function,
- const std::function<bool(Variable*)>& filter,
- VariableList *variable_list);
-
- //------------------------------------------------------------------
- /// Appends the variables from this block, and optionally from all
- /// parent blocks, to \a variable_list.
- ///
- /// @param[in] can_create
- /// If \b true, the variables can be parsed if they already
- /// haven't been, else the current state of the block will be
- /// returned. Passing \b true for this parameter can be used
- /// to see the current state of what has been parsed up to this
- /// point.
- ///
- /// @param[in] get_parent_variables
- /// If \b true, all variables from all parent blocks will be
- /// added to the variable list.
- ///
- /// @param[in] stop_if_block_is_inlined_function
- /// If \b true, all variables from all parent blocks will be
- /// added to the variable list until there are no parent blocks
- /// or the parent block has inlined function info.
- ///
- /// @param[in,out] variable_list
- /// All variables in this block, and optionally all parent
- /// blocks will be added to this list.
- ///
- /// @return
- /// The number of variable that were appended to \a
- /// variable_list.
- //------------------------------------------------------------------
- uint32_t
- AppendVariables (bool can_create,
- bool get_parent_variables,
- bool stop_if_block_is_inlined_function,
- const std::function<bool(Variable*)>& filter,
- VariableList *variable_list);
-
- //------------------------------------------------------------------
- /// Get const accessor for any inlined function information.
- ///
- /// @return
- /// A const pointer to any inlined function information, or nullptr
- /// if this is a regular block.
- //------------------------------------------------------------------
- const InlineFunctionInfo*
- GetInlinedFunctionInfo () const
- {
- return m_inlineInfoSP.get();
- }
-
- CompilerDeclContext
- GetDeclContext();
-
- //------------------------------------------------------------------
- /// Get the memory cost of this object.
- ///
- /// Returns the cost of this object plus any owned objects from the
- /// ranges, variables, and inline function information.
- ///
- /// @return
- /// The number of bytes that this object occupies in memory.
- //------------------------------------------------------------------
- size_t
- MemorySize() const;
-
- //------------------------------------------------------------------
- /// Set accessor for any inlined function information.
- ///
- /// @param[in] name
- /// The method name for the inlined function. This value should
- /// not be nullptr.
- ///
- /// @param[in] mangled
- /// The mangled method name for the inlined function. This can
- /// be nullptr if there is no mangled name for an inlined function
- /// or if the name is the same as \a name.
- ///
- /// @param[in] decl_ptr
- /// A optional pointer to declaration information for the
- /// inlined function information. This value can be nullptr to
- /// indicate that no declaration information is available.
- ///
- /// @param[in] call_decl_ptr
- /// Optional calling location declaration information that
- /// describes from where this inlined function was called.
- //------------------------------------------------------------------
- void
- SetInlinedFunctionInfo (const char *name,
- const char *mangled,
- const Declaration *decl_ptr,
- const Declaration *call_decl_ptr);
-
- void
- SetParentScope (SymbolContextScope *parent_scope)
- {
- m_parent_scope = parent_scope;
- }
-
- //------------------------------------------------------------------
- /// Set accessor for the variable list.
- ///
- /// Called by the SymbolFile plug-ins after they have parsed the
- /// variable lists and are ready to hand ownership of the list over
- /// to this object.
- ///
- /// @param[in] variable_list_sp
- /// A shared pointer to a VariableList.
- //------------------------------------------------------------------
- void
- SetVariableList (lldb::VariableListSP& variable_list_sp)
- {
- m_variable_list_sp = variable_list_sp;
- }
-
- bool
- BlockInfoHasBeenParsed() const
- {
- return m_parsed_block_info;
- }
-
- void
- SetBlockInfoHasBeenParsed (bool b, bool set_children);
-
- Block *
- FindBlockByID (lldb::user_id_t block_id);
-
- size_t
- GetNumRanges () const
- {
- return m_ranges.GetSize();
- }
-
- bool
- GetRangeContainingOffset (const lldb::addr_t offset, Range &range);
-
- bool
- GetRangeContainingAddress (const Address& addr, AddressRange &range);
-
- bool
- GetRangeContainingLoadAddress (lldb::addr_t load_addr, Target &target, AddressRange &range);
-
- uint32_t
- GetRangeIndexContainingAddress (const Address& addr);
-
- //------------------------------------------------------------------
- // Since blocks might have multiple discontiguous address ranges,
- // we need to be able to get at any of the address ranges in a block.
- //------------------------------------------------------------------
- bool
- GetRangeAtIndex (uint32_t range_idx,
- AddressRange &range);
-
- bool
- GetStartAddress (Address &addr);
-
- void
- SetDidParseVariables (bool b, bool set_children);
+ typedef RangeArray<uint32_t, uint32_t, 1> RangeList;
+ typedef RangeList::Entry Range;
+
+ //------------------------------------------------------------------
+ /// Construct with a User ID \a uid, \a depth.
+ ///
+ /// Initialize this block with the specified UID \a uid. The
+ /// \a depth in the \a block_list is used to represent the parent,
+ /// sibling, and child block information and also allows for partial
+ /// parsing at the block level.
+ ///
+ /// @param[in] uid
+ /// The UID for a given block. This value is given by the
+ /// SymbolFile plug-in and can be any value that helps the
+ /// SymbolFile plug-in to match this block back to the debug
+ /// information data that it parses for further or more in
+ /// depth parsing. Common values would be the index into a
+ /// table, or an offset into the debug information.
+ ///
+ /// @param[in] depth
+ /// The integer depth of this block in the block list hierarchy.
+ ///
+ /// @param[in] block_list
+ /// The block list that this object belongs to.
+ ///
+ /// @see BlockList
+ //------------------------------------------------------------------
+ Block(lldb::user_id_t uid);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ //------------------------------------------------------------------
+ ~Block() override;
+
+ //------------------------------------------------------------------
+ /// Add a child to this object.
+ ///
+ /// @param[in] child_block_sp
+ /// A shared pointer to a child block that will get added to
+ /// this block.
+ //------------------------------------------------------------------
+ void AddChild(const lldb::BlockSP &child_block_sp);
+
+ //------------------------------------------------------------------
+ /// Add a new offset range to this block.
+ ///
+ /// @param[in] start_offset
+ /// An offset into this Function's address range that
+ /// describes the start address of a range for this block.
+ ///
+ /// @param[in] end_offset
+ /// An offset into this Function's address range that
+ /// describes the end address of a range for this block.
+ //------------------------------------------------------------------
+ void AddRange(const Range &range);
+
+ void FinalizeRanges();
+
+ //------------------------------------------------------------------
+ /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
+ ///
+ /// @see SymbolContextScope
+ //------------------------------------------------------------------
+ void CalculateSymbolContext(SymbolContext *sc) override;
+
+ lldb::ModuleSP CalculateSymbolContextModule() override;
+
+ CompileUnit *CalculateSymbolContextCompileUnit() override;
+
+ Function *CalculateSymbolContextFunction() override;
+
+ Block *CalculateSymbolContextBlock() override;
+
+ //------------------------------------------------------------------
+ /// Check if an offset is in one of the block offset ranges.
+ ///
+ /// @param[in] range_offset
+ /// An offset into the Function's address range.
+ ///
+ /// @return
+ /// Returns \b true if \a range_offset falls in one of this
+ /// block's ranges, \b false otherwise.
+ //------------------------------------------------------------------
+ bool Contains(lldb::addr_t range_offset) const;
+
+ //------------------------------------------------------------------
+ /// Check if a offset range is in one of the block offset ranges.
+ ///
+ /// @param[in] range
+ /// An offset range into the Function's address range.
+ ///
+ /// @return
+ /// Returns \b true if \a range falls in one of this
+ /// block's ranges, \b false otherwise.
+ //------------------------------------------------------------------
+ bool Contains(const Range &range) const;
+
+ //------------------------------------------------------------------
+ /// Check if this object contains "block" as a child block at any
+ /// depth.
+ ///
+ /// @param[in] block
+ /// A potential child block.
+ ///
+ /// @return
+ /// Returns \b true if \a block is a child of this block, \b
+ /// false otherwise.
+ //------------------------------------------------------------------
+ bool Contains(const Block *block) const;
+
+ //------------------------------------------------------------------
+ /// Dump the block contents.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ ///
+ /// @param[in] base_addr
+ /// The resolved start address of the Function's address
+ /// range. This should be resolved as the file or load address
+ /// prior to passing the value into this function for dumping.
+ ///
+ /// @param[in] depth
+ /// Limit the number of levels deep that this function should
+ /// print as this block can contain child blocks. Specify
+ /// INT_MAX to dump all child blocks.
+ ///
+ /// @param[in] show_context
+ /// If \b true, variables will dump their context information.
+ //------------------------------------------------------------------
+ void Dump(Stream *s, lldb::addr_t base_addr, int32_t depth,
+ bool show_context) const;
+
+ //------------------------------------------------------------------
+ /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
+ ///
+ /// @see SymbolContextScope
+ //------------------------------------------------------------------
+ void DumpSymbolContext(Stream *s) override;
+
+ void DumpAddressRanges(Stream *s, lldb::addr_t base_addr);
+
+ void GetDescription(Stream *s, Function *function,
+ lldb::DescriptionLevel level, Target *target) const;
+
+ //------------------------------------------------------------------
+ /// Get the parent block.
+ ///
+ /// @return
+ /// The parent block pointer, or nullptr if this block has no
+ /// parent.
+ //------------------------------------------------------------------
+ Block *GetParent() const;
+
+ //------------------------------------------------------------------
+ /// Get the inlined block that contains this block.
+ ///
+ /// @return
+ /// If this block contains inlined function info, it will return
+ /// this block, else parent blocks will be searched to see if
+ /// any contain this block. nullptr will be returned if this block
+ /// nor any parent blocks are inlined function blocks.
+ //------------------------------------------------------------------
+ Block *GetContainingInlinedBlock();
+
+ //------------------------------------------------------------------
+ /// Get the inlined parent block for this block.
+ ///
+ /// @return
+ /// The parent block pointer, or nullptr if this block has no
+ /// parent.
+ //------------------------------------------------------------------
+ Block *GetInlinedParent();
+
+ //------------------------------------------------------------------
+ /// Get the sibling block for this block.
+ ///
+ /// @return
+ /// The sibling block pointer, or nullptr if this block has no
+ /// sibling.
+ //------------------------------------------------------------------
+ Block *GetSibling() const;
+
+ //------------------------------------------------------------------
+ /// Get the first child block.
+ ///
+ /// @return
+ /// The first child block pointer, or nullptr if this block has no
+ /// children.
+ //------------------------------------------------------------------
+ Block *GetFirstChild() const {
+ return (m_children.empty() ? nullptr : m_children.front().get());
+ }
+
+ //------------------------------------------------------------------
+ /// Get the variable list for this block only.
+ ///
+ /// @param[in] can_create
+ /// If \b true, the variables can be parsed if they already
+ /// haven't been, else the current state of the block will be
+ /// returned.
+ ///
+ /// @return
+ /// A variable list shared pointer that contains all variables
+ /// for this block.
+ //------------------------------------------------------------------
+ lldb::VariableListSP GetBlockVariableList(bool can_create);
+
+ //------------------------------------------------------------------
+ /// Get the variable list for this block and optionally all child
+ /// blocks if \a get_child_variables is \b true.
+ ///
+ /// @param[in] get_child_variables
+ /// If \b true, all variables from all child blocks will be
+ /// added to the variable list.
+ ///
+ /// @param[in] can_create
+ /// If \b true, the variables can be parsed if they already
+ /// haven't been, else the current state of the block will be
+ /// returned. Passing \b true for this parameter can be used
+ /// to see the current state of what has been parsed up to this
+ /// point.
+ ///
+ /// @param[in] add_inline_child_block_variables
+ /// If this is \b false, no child variables of child blocks
+ /// that are inlined functions will be gotten. If \b true then
+ /// all child variables will be added regardless of whether they
+ /// come from inlined functions or not.
+ ///
+ /// @return
+ /// A variable list shared pointer that contains all variables
+ /// for this block.
+ //------------------------------------------------------------------
+ uint32_t AppendBlockVariables(bool can_create, bool get_child_block_variables,
+ bool stop_if_child_block_is_inlined_function,
+ const std::function<bool(Variable *)> &filter,
+ VariableList *variable_list);
+
+ //------------------------------------------------------------------
+ /// Appends the variables from this block, and optionally from all
+ /// parent blocks, to \a variable_list.
+ ///
+ /// @param[in] can_create
+ /// If \b true, the variables can be parsed if they already
+ /// haven't been, else the current state of the block will be
+ /// returned. Passing \b true for this parameter can be used
+ /// to see the current state of what has been parsed up to this
+ /// point.
+ ///
+ /// @param[in] get_parent_variables
+ /// If \b true, all variables from all parent blocks will be
+ /// added to the variable list.
+ ///
+ /// @param[in] stop_if_block_is_inlined_function
+ /// If \b true, all variables from all parent blocks will be
+ /// added to the variable list until there are no parent blocks
+ /// or the parent block has inlined function info.
+ ///
+ /// @param[in,out] variable_list
+ /// All variables in this block, and optionally all parent
+ /// blocks will be added to this list.
+ ///
+ /// @return
+ /// The number of variable that were appended to \a
+ /// variable_list.
+ //------------------------------------------------------------------
+ uint32_t AppendVariables(bool can_create, bool get_parent_variables,
+ bool stop_if_block_is_inlined_function,
+ const std::function<bool(Variable *)> &filter,
+ VariableList *variable_list);
+
+ //------------------------------------------------------------------
+ /// Get const accessor for any inlined function information.
+ ///
+ /// @return
+ /// A const pointer to any inlined function information, or nullptr
+ /// if this is a regular block.
+ //------------------------------------------------------------------
+ const InlineFunctionInfo *GetInlinedFunctionInfo() const {
+ return m_inlineInfoSP.get();
+ }
+
+ CompilerDeclContext GetDeclContext();
+
+ //------------------------------------------------------------------
+ /// Get the memory cost of this object.
+ ///
+ /// Returns the cost of this object plus any owned objects from the
+ /// ranges, variables, and inline function information.
+ ///
+ /// @return
+ /// The number of bytes that this object occupies in memory.
+ //------------------------------------------------------------------
+ size_t MemorySize() const;
+
+ //------------------------------------------------------------------
+ /// Set accessor for any inlined function information.
+ ///
+ /// @param[in] name
+ /// The method name for the inlined function. This value should
+ /// not be nullptr.
+ ///
+ /// @param[in] mangled
+ /// The mangled method name for the inlined function. This can
+ /// be nullptr if there is no mangled name for an inlined function
+ /// or if the name is the same as \a name.
+ ///
+ /// @param[in] decl_ptr
+ /// A optional pointer to declaration information for the
+ /// inlined function information. This value can be nullptr to
+ /// indicate that no declaration information is available.
+ ///
+ /// @param[in] call_decl_ptr
+ /// Optional calling location declaration information that
+ /// describes from where this inlined function was called.
+ //------------------------------------------------------------------
+ void SetInlinedFunctionInfo(const char *name, const char *mangled,
+ const Declaration *decl_ptr,
+ const Declaration *call_decl_ptr);
+
+ void SetParentScope(SymbolContextScope *parent_scope) {
+ m_parent_scope = parent_scope;
+ }
+
+ //------------------------------------------------------------------
+ /// Set accessor for the variable list.
+ ///
+ /// Called by the SymbolFile plug-ins after they have parsed the
+ /// variable lists and are ready to hand ownership of the list over
+ /// to this object.
+ ///
+ /// @param[in] variable_list_sp
+ /// A shared pointer to a VariableList.
+ //------------------------------------------------------------------
+ void SetVariableList(lldb::VariableListSP &variable_list_sp) {
+ m_variable_list_sp = variable_list_sp;
+ }
+
+ bool BlockInfoHasBeenParsed() const { return m_parsed_block_info; }
+
+ void SetBlockInfoHasBeenParsed(bool b, bool set_children);
+
+ Block *FindBlockByID(lldb::user_id_t block_id);
+
+ size_t GetNumRanges() const { return m_ranges.GetSize(); }
+
+ bool GetRangeContainingOffset(const lldb::addr_t offset, Range &range);
+
+ bool GetRangeContainingAddress(const Address &addr, AddressRange &range);
+
+ bool GetRangeContainingLoadAddress(lldb::addr_t load_addr, Target &target,
+ AddressRange &range);
+
+ uint32_t GetRangeIndexContainingAddress(const Address &addr);
+
+ //------------------------------------------------------------------
+ // Since blocks might have multiple discontiguous address ranges,
+ // we need to be able to get at any of the address ranges in a block.
+ //------------------------------------------------------------------
+ bool GetRangeAtIndex(uint32_t range_idx, AddressRange &range);
+
+ bool GetStartAddress(Address &addr);
+
+ void SetDidParseVariables(bool b, bool set_children);
protected:
- typedef std::vector<lldb::BlockSP> collection;
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- SymbolContextScope *m_parent_scope;
- collection m_children;
- RangeList m_ranges;
- lldb::InlineFunctionInfoSP m_inlineInfoSP; ///< Inlined function information.
- lldb::VariableListSP m_variable_list_sp; ///< The variable list for all local, static and parameter variables scoped to this block.
- bool m_parsed_block_info:1, ///< Set to true if this block and it's children have all been parsed
- m_parsed_block_variables:1,
- m_parsed_child_blocks:1;
-
- // A parent of child blocks can be asked to find a sibling block given
- // one of its child blocks
- Block *
- GetSiblingForChild (const Block *child_block) const;
+ typedef std::vector<lldb::BlockSP> collection;
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ SymbolContextScope *m_parent_scope;
+ collection m_children;
+ RangeList m_ranges;
+ lldb::InlineFunctionInfoSP m_inlineInfoSP; ///< Inlined function information.
+ lldb::VariableListSP m_variable_list_sp; ///< The variable list for all local,
+ ///static and parameter variables
+ ///scoped to this block.
+ bool m_parsed_block_info : 1, ///< Set to true if this block and it's children
+ ///have all been parsed
+ m_parsed_block_variables : 1, m_parsed_child_blocks : 1;
+
+ // A parent of child blocks can be asked to find a sibling block given
+ // one of its child blocks
+ Block *GetSiblingForChild(const Block *child_block) const;
private:
- DISALLOW_COPY_AND_ASSIGN (Block);
+ DISALLOW_COPY_AND_ASSIGN(Block);
};
} // namespace lldb_private
diff --git a/include/lldb/Symbol/ClangASTContext.h b/include/lldb/Symbol/ClangASTContext.h
index 08f7b6b412dc..4262ecb4bf0e 100644
--- a/include/lldb/Symbol/ClangASTContext.h
+++ b/include/lldb/Symbol/ClangASTContext.h
@@ -20,13 +20,13 @@
#include <memory>
#include <set>
#include <string>
-#include <vector>
#include <utility>
+#include <vector>
// Other libraries and framework includes
-#include "llvm/ADT/SmallVector.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/TemplateBase.h"
+#include "llvm/ADT/SmallVector.h"
// Project includes
#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
@@ -43,1156 +43,934 @@ namespace lldb_private {
class Declaration;
-class ClangASTContext : public TypeSystem
-{
+class ClangASTContext : public TypeSystem {
public:
- typedef void (*CompleteTagDeclCallback)(void *baton, clang::TagDecl *);
- typedef void (*CompleteObjCInterfaceDeclCallback)(void *baton, clang::ObjCInterfaceDecl *);
-
- //------------------------------------------------------------------
- // llvm casting support
- //------------------------------------------------------------------
- static bool classof(const TypeSystem *ts)
- {
- return ts->getKind() == TypeSystem::eKindClang;
- }
+ typedef void (*CompleteTagDeclCallback)(void *baton, clang::TagDecl *);
+ typedef void (*CompleteObjCInterfaceDeclCallback)(void *baton,
+ clang::ObjCInterfaceDecl *);
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- ClangASTContext(const char *triple = nullptr);
+ //------------------------------------------------------------------
+ // llvm casting support
+ //------------------------------------------------------------------
+ static bool classof(const TypeSystem *ts) {
+ return ts->getKind() == TypeSystem::eKindClang;
+ }
- ~ClangASTContext() override;
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ ClangASTContext(const char *triple = nullptr);
- void
- Finalize() override;
+ ~ClangASTContext() override;
- //------------------------------------------------------------------
- // PluginInterface functions
- //------------------------------------------------------------------
- ConstString
- GetPluginName() override;
+ void Finalize() override;
- uint32_t
- GetPluginVersion() override;
+ //------------------------------------------------------------------
+ // PluginInterface functions
+ //------------------------------------------------------------------
+ ConstString GetPluginName() override;
- static ConstString
- GetPluginNameStatic ();
+ uint32_t GetPluginVersion() override;
- static lldb::TypeSystemSP
- CreateInstance (lldb::LanguageType language, Module *module, Target *target);
-
- static void
- EnumerateSupportedLanguages(std::set<lldb::LanguageType> &languages_for_types, std::set<lldb::LanguageType> &languages_for_expressions);
+ static ConstString GetPluginNameStatic();
- static void
- Initialize ();
+ static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language,
+ Module *module, Target *target);
- static void
- Terminate ();
+ static void EnumerateSupportedLanguages(
+ std::set<lldb::LanguageType> &languages_for_types,
+ std::set<lldb::LanguageType> &languages_for_expressions);
- static ClangASTContext*
- GetASTContext (clang::ASTContext* ast_ctx);
+ static void Initialize();
- clang::ASTContext *
- getASTContext();
-
- void setASTContext(clang::ASTContext* ast_ctx);
-
- clang::Builtin::Context *
- getBuiltinContext();
+ static void Terminate();
- clang::IdentifierTable *
- getIdentifierTable();
+ static ClangASTContext *GetASTContext(clang::ASTContext *ast_ctx);
- clang::LangOptions *
- getLanguageOptions();
+ clang::ASTContext *getASTContext();
- clang::SelectorTable *
- getSelectorTable();
+ void setASTContext(clang::ASTContext *ast_ctx);
- clang::FileManager *
- getFileManager();
-
- clang::SourceManager *
- getSourceManager();
+ clang::Builtin::Context *getBuiltinContext();
- clang::DiagnosticsEngine *
- getDiagnosticsEngine();
-
- clang::DiagnosticConsumer *
- getDiagnosticConsumer();
+ clang::IdentifierTable *getIdentifierTable();
- clang::MangleContext *
- getMangleContext();
+ clang::LangOptions *getLanguageOptions();
- std::shared_ptr<clang::TargetOptions> &getTargetOptions();
+ clang::SelectorTable *getSelectorTable();
- clang::TargetInfo *
- getTargetInfo();
+ clang::FileManager *getFileManager();
- void
- Clear();
-
- const char *
- GetTargetTriple ();
+ clang::SourceManager *getSourceManager();
- void
- SetTargetTriple (const char *target_triple);
+ clang::DiagnosticsEngine *getDiagnosticsEngine();
- void
- SetArchitecture (const ArchSpec &arch);
+ clang::DiagnosticConsumer *getDiagnosticConsumer();
- bool
- HasExternalSource ();
+ clang::MangleContext *getMangleContext();
- void
- SetExternalSource (llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> &ast_source_ap);
+ std::shared_ptr<clang::TargetOptions> &getTargetOptions();
- void
- RemoveExternalSource ();
-
- bool
- GetCompleteDecl (clang::Decl *decl)
- {
- return ClangASTContext::GetCompleteDecl(getASTContext(), decl);
- }
+ clang::TargetInfo *getTargetInfo();
- static void
- DumpDeclHiearchy (clang::Decl *decl);
+ void Clear();
- static void
- DumpDeclContextHiearchy (clang::DeclContext *decl_ctx);
+ const char *GetTargetTriple();
- static bool
- DeclsAreEquivalent (clang::Decl *lhs_decl, clang::Decl *rhs_decl);
+ void SetTargetTriple(const char *target_triple);
- static bool
- GetCompleteDecl (clang::ASTContext *ast,
- clang::Decl *decl);
+ void SetArchitecture(const ArchSpec &arch);
- void SetMetadataAsUserID (const void *object,
- lldb::user_id_t user_id);
+ bool HasExternalSource();
- void SetMetadata (const void *object,
- ClangASTMetadata &meta_data)
- {
- SetMetadata(getASTContext(), object, meta_data);
- }
-
- static void
- SetMetadata (clang::ASTContext *ast,
- const void *object,
- ClangASTMetadata &meta_data);
-
- ClangASTMetadata *
- GetMetadata (const void *object)
- {
- return GetMetadata(getASTContext(), object);
- }
-
- static ClangASTMetadata *
- GetMetadata (clang::ASTContext *ast,
- const void *object);
-
- //------------------------------------------------------------------
- // Basic Types
- //------------------------------------------------------------------
- CompilerType
- GetBuiltinTypeForEncodingAndBitSize (lldb::Encoding encoding,
- size_t bit_size) override;
-
- static CompilerType
- GetBuiltinTypeForEncodingAndBitSize (clang::ASTContext *ast,
- lldb::Encoding encoding,
- uint32_t bit_size);
-
- CompilerType
- GetBasicType (lldb::BasicType type);
-
- static CompilerType
- GetBasicType (clang::ASTContext *ast, lldb::BasicType type);
-
- static CompilerType
- GetBasicType (clang::ASTContext *ast, const ConstString &name);
-
- static lldb::BasicType
- GetBasicTypeEnumeration (const ConstString &name);
-
- CompilerType
- GetBuiltinTypeForDWARFEncodingAndBitSize (
- const char *type_name,
- uint32_t dw_ate,
- uint32_t bit_size);
-
- CompilerType
- GetCStringType(bool is_const);
-
- static CompilerType
- GetUnknownAnyType(clang::ASTContext *ast);
-
- CompilerType
- GetUnknownAnyType()
- {
- return ClangASTContext::GetUnknownAnyType(getASTContext());
+ void SetExternalSource(
+ llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> &ast_source_ap);
+
+ void RemoveExternalSource();
+
+ bool GetCompleteDecl(clang::Decl *decl) {
+ return ClangASTContext::GetCompleteDecl(getASTContext(), decl);
+ }
+
+ static void DumpDeclHiearchy(clang::Decl *decl);
+
+ static void DumpDeclContextHiearchy(clang::DeclContext *decl_ctx);
+
+ static bool DeclsAreEquivalent(clang::Decl *lhs_decl, clang::Decl *rhs_decl);
+
+ static bool GetCompleteDecl(clang::ASTContext *ast, clang::Decl *decl);
+
+ void SetMetadataAsUserID(const void *object, lldb::user_id_t user_id);
+
+ void SetMetadata(const void *object, ClangASTMetadata &meta_data) {
+ SetMetadata(getASTContext(), object, meta_data);
+ }
+
+ static void SetMetadata(clang::ASTContext *ast, const void *object,
+ ClangASTMetadata &meta_data);
+
+ ClangASTMetadata *GetMetadata(const void *object) {
+ return GetMetadata(getASTContext(), object);
+ }
+
+ static ClangASTMetadata *GetMetadata(clang::ASTContext *ast,
+ const void *object);
+
+ //------------------------------------------------------------------
+ // Basic Types
+ //------------------------------------------------------------------
+ CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding,
+ size_t bit_size) override;
+
+ static CompilerType GetBuiltinTypeForEncodingAndBitSize(
+ clang::ASTContext *ast, lldb::Encoding encoding, uint32_t bit_size);
+
+ CompilerType GetBasicType(lldb::BasicType type);
+
+ static CompilerType GetBasicType(clang::ASTContext *ast,
+ lldb::BasicType type);
+
+ static CompilerType GetBasicType(clang::ASTContext *ast,
+ const ConstString &name);
+
+ static lldb::BasicType GetBasicTypeEnumeration(const ConstString &name);
+
+ CompilerType GetBuiltinTypeForDWARFEncodingAndBitSize(const char *type_name,
+ uint32_t dw_ate,
+ uint32_t bit_size);
+
+ CompilerType GetCStringType(bool is_const);
+
+ static CompilerType GetUnknownAnyType(clang::ASTContext *ast);
+
+ CompilerType GetUnknownAnyType() {
+ return ClangASTContext::GetUnknownAnyType(getASTContext());
+ }
+
+ static clang::DeclContext *GetDeclContextForType(clang::QualType type);
+
+ static clang::DeclContext *GetDeclContextForType(const CompilerType &type);
+
+ uint32_t GetPointerByteSize() override;
+
+ static clang::DeclContext *GetTranslationUnitDecl(clang::ASTContext *ast);
+
+ clang::DeclContext *GetTranslationUnitDecl() {
+ return GetTranslationUnitDecl(getASTContext());
+ }
+
+ static clang::Decl *CopyDecl(clang::ASTContext *dest_context,
+ clang::ASTContext *source_context,
+ clang::Decl *source_decl);
+
+ static bool AreTypesSame(CompilerType type1, CompilerType type2,
+ bool ignore_qualifiers = false);
+
+ static CompilerType GetTypeForDecl(clang::NamedDecl *decl);
+
+ static CompilerType GetTypeForDecl(clang::TagDecl *decl);
+
+ static CompilerType GetTypeForDecl(clang::ObjCInterfaceDecl *objc_decl);
+
+ template <typename RecordDeclType>
+ CompilerType GetTypeForIdentifier(const ConstString &type_name) {
+ CompilerType compiler_type;
+
+ if (type_name.GetLength()) {
+ clang::ASTContext *ast = getASTContext();
+ if (ast) {
+ clang::IdentifierInfo &myIdent =
+ ast->Idents.get(type_name.GetCString());
+ clang::DeclarationName myName =
+ ast->DeclarationNames.getIdentifier(&myIdent);
+
+ clang::DeclContext::lookup_result result =
+ ast->getTranslationUnitDecl()->lookup(myName);
+
+ if (!result.empty()) {
+ clang::NamedDecl *named_decl = result[0];
+ if (const RecordDeclType *record_decl =
+ llvm::dyn_cast<RecordDeclType>(named_decl))
+ compiler_type.SetCompilerType(
+ ast, clang::QualType(record_decl->getTypeForDecl(), 0));
+ }
+ }
}
-
- static clang::DeclContext *
- GetDeclContextForType (clang::QualType type);
-
- static clang::DeclContext *
- GetDeclContextForType (const CompilerType& type);
-
- uint32_t
- GetPointerByteSize () override;
-
- static clang::DeclContext *
- GetTranslationUnitDecl (clang::ASTContext *ast);
-
- clang::DeclContext *
- GetTranslationUnitDecl ()
- {
- return GetTranslationUnitDecl (getASTContext());
+
+ return compiler_type;
+ }
+
+ CompilerType CreateStructForIdentifier(
+ const ConstString &type_name,
+ const std::initializer_list<std::pair<const char *, CompilerType>>
+ &type_fields,
+ bool packed = false);
+
+ CompilerType GetOrCreateStructForIdentifier(
+ const ConstString &type_name,
+ const std::initializer_list<std::pair<const char *, CompilerType>>
+ &type_fields,
+ bool packed = false);
+
+ //------------------------------------------------------------------
+ // Structure, Unions, Classes
+ //------------------------------------------------------------------
+
+ static clang::AccessSpecifier
+ ConvertAccessTypeToAccessSpecifier(lldb::AccessType access);
+
+ static clang::AccessSpecifier
+ UnifyAccessSpecifiers(clang::AccessSpecifier lhs, clang::AccessSpecifier rhs);
+
+ static uint32_t GetNumBaseClasses(const clang::CXXRecordDecl *cxx_record_decl,
+ bool omit_empty_base_classes);
+
+ CompilerType CreateRecordType(clang::DeclContext *decl_ctx,
+ lldb::AccessType access_type, const char *name,
+ int kind, lldb::LanguageType language,
+ ClangASTMetadata *metadata = nullptr);
+
+ class TemplateParameterInfos {
+ public:
+ bool IsValid() const {
+ if (args.empty())
+ return false;
+ return args.size() == names.size();
}
-
- static clang::Decl *
- CopyDecl (clang::ASTContext *dest_context,
- clang::ASTContext *source_context,
- clang::Decl *source_decl);
-
- static bool
- AreTypesSame(CompilerType type1,
- CompilerType type2,
- bool ignore_qualifiers = false);
-
- static CompilerType
- GetTypeForDecl (clang::NamedDecl *decl);
-
- static CompilerType
- GetTypeForDecl (clang::TagDecl *decl);
-
- static CompilerType
- GetTypeForDecl (clang::ObjCInterfaceDecl *objc_decl);
-
- template <typename RecordDeclType>
- CompilerType
- GetTypeForIdentifier (const ConstString &type_name)
- {
- CompilerType compiler_type;
-
- if (type_name.GetLength())
- {
- clang::ASTContext *ast = getASTContext();
- if (ast)
- {
- clang::IdentifierInfo &myIdent = ast->Idents.get(type_name.GetCString());
- clang::DeclarationName myName = ast->DeclarationNames.getIdentifier(&myIdent);
-
- clang::DeclContext::lookup_result result = ast->getTranslationUnitDecl()->lookup(myName);
-
- if (!result.empty())
- {
- clang::NamedDecl *named_decl = result[0];
- if (const RecordDeclType *record_decl = llvm::dyn_cast<RecordDeclType>(named_decl))
- compiler_type.SetCompilerType(ast, clang::QualType(record_decl->getTypeForDecl(), 0));
- }
- }
- }
-
- return compiler_type;
+
+ size_t GetSize() const {
+ if (IsValid())
+ return args.size();
+ return 0;
}
-
- CompilerType
- CreateStructForIdentifier (const ConstString &type_name,
- const std::initializer_list< std::pair < const char *, CompilerType > >& type_fields,
- bool packed = false);
-
- CompilerType
- GetOrCreateStructForIdentifier (const ConstString &type_name,
- const std::initializer_list< std::pair < const char *, CompilerType > >& type_fields,
- bool packed = false);
-
- //------------------------------------------------------------------
- // Structure, Unions, Classes
- //------------------------------------------------------------------
-
- static clang::AccessSpecifier
- ConvertAccessTypeToAccessSpecifier (lldb::AccessType access);
-
- static clang::AccessSpecifier
- UnifyAccessSpecifiers (clang::AccessSpecifier lhs, clang::AccessSpecifier rhs);
-
- static uint32_t
- GetNumBaseClasses (const clang::CXXRecordDecl *cxx_record_decl,
- bool omit_empty_base_classes);
-
- CompilerType
- CreateRecordType(clang::DeclContext *decl_ctx,
- lldb::AccessType access_type,
- const char *name,
- int kind,
- lldb::LanguageType language,
- ClangASTMetadata *metadata = nullptr);
-
- class TemplateParameterInfos
- {
- public:
- bool
- IsValid() const
- {
- if (args.empty())
- return false;
- return args.size() == names.size();
- }
- size_t
- GetSize () const
- {
- if (IsValid())
- return args.size();
- return 0;
- }
+ llvm::SmallVector<const char *, 2> names;
+ llvm::SmallVector<clang::TemplateArgument, 2> args;
+ };
- llvm::SmallVector<const char *, 2> names;
- llvm::SmallVector<clang::TemplateArgument, 2> args;
- };
-
- clang::FunctionTemplateDecl *
- CreateFunctionTemplateDecl (clang::DeclContext *decl_ctx,
- clang::FunctionDecl *func_decl,
- const char *name,
- const TemplateParameterInfos &infos);
-
- void
- CreateFunctionTemplateSpecializationInfo (clang::FunctionDecl *func_decl,
- clang::FunctionTemplateDecl *Template,
- const TemplateParameterInfos &infos);
-
- clang::ClassTemplateDecl *
- CreateClassTemplateDecl (clang::DeclContext *decl_ctx,
- lldb::AccessType access_type,
- const char *class_name,
- int kind,
+ clang::FunctionTemplateDecl *
+ CreateFunctionTemplateDecl(clang::DeclContext *decl_ctx,
+ clang::FunctionDecl *func_decl, const char *name,
const TemplateParameterInfos &infos);
- clang::ClassTemplateSpecializationDecl *
- CreateClassTemplateSpecializationDecl (clang::DeclContext *decl_ctx,
- clang::ClassTemplateDecl *class_template_decl,
- int kind,
- const TemplateParameterInfos &infos);
-
- CompilerType
- CreateClassTemplateSpecializationType (clang::ClassTemplateSpecializationDecl *class_template_specialization_decl);
-
- static clang::DeclContext *
- GetAsDeclContext (clang::CXXMethodDecl *cxx_method_decl);
-
- static clang::DeclContext *
- GetAsDeclContext (clang::ObjCMethodDecl *objc_method_decl);
-
-
- static bool
- CheckOverloadedOperatorKindParameterCount (uint32_t op_kind,
- uint32_t num_params);
-
- bool
- FieldIsBitfield (clang::FieldDecl* field,
- uint32_t& bitfield_bit_size);
-
- static bool
- FieldIsBitfield (clang::ASTContext *ast,
- clang::FieldDecl* field,
- uint32_t& bitfield_bit_size);
-
- static bool
- RecordHasFields (const clang::RecordDecl *record_decl);
-
- CompilerType
- CreateObjCClass(const char *name,
- clang::DeclContext *decl_ctx,
- bool isForwardDecl,
- bool isInternal,
- ClangASTMetadata *metadata = nullptr);
-
- bool
- SetTagTypeKind (clang::QualType type, int kind) const;
-
- bool
- SetDefaultAccessForRecordFields (clang::RecordDecl* record_decl,
- int default_accessibility,
- int *assigned_accessibilities,
- size_t num_assigned_accessibilities);
-
- // Returns a mask containing bits from the ClangASTContext::eTypeXXX enumerations
-
- //------------------------------------------------------------------
- // Namespace Declarations
- //------------------------------------------------------------------
-
- clang::NamespaceDecl *
- GetUniqueNamespaceDeclaration (const char *name,
- clang::DeclContext *decl_ctx);
-
- static clang::NamespaceDecl *
- GetUniqueNamespaceDeclaration (clang::ASTContext *ast,
- const char *name,
- clang::DeclContext *decl_ctx);
-
- //------------------------------------------------------------------
- // Function Types
- //------------------------------------------------------------------
-
- clang::FunctionDecl *
- CreateFunctionDeclaration (clang::DeclContext *decl_ctx,
- const char *name,
- const CompilerType &function_Type,
- int storage,
- bool is_inline);
-
- static CompilerType
- CreateFunctionType (clang::ASTContext *ast,
- const CompilerType &result_type,
- const CompilerType *args,
- unsigned num_args,
- bool is_variadic,
- unsigned type_quals);
-
- CompilerType
- CreateFunctionType (const CompilerType &result_type,
- const CompilerType *args,
- unsigned num_args,
- bool is_variadic,
- unsigned type_quals)
- {
- return ClangASTContext::CreateFunctionType(getASTContext(),
- result_type,
- args,
- num_args,
- is_variadic,
- type_quals);
- }
-
- clang::ParmVarDecl *
- CreateParameterDeclaration (const char *name,
- const CompilerType &param_type,
- int storage);
-
- void
- SetFunctionParameters (clang::FunctionDecl *function_decl,
- clang::ParmVarDecl **params,
- unsigned num_params);
-
- CompilerType
- CreateBlockPointerType (const CompilerType &function_type);
-
- //------------------------------------------------------------------
- // Array Types
- //------------------------------------------------------------------
-
- CompilerType
- CreateArrayType (const CompilerType &element_type,
- size_t element_count,
- bool is_vector);
-
- //------------------------------------------------------------------
- // Enumeration Types
- //------------------------------------------------------------------
- CompilerType
- CreateEnumerationType (const char *name,
- clang::DeclContext *decl_ctx,
- const Declaration &decl,
- const CompilerType &integer_qual_type);
-
- //------------------------------------------------------------------
- // Integer type functions
- //------------------------------------------------------------------
-
- static CompilerType
- GetIntTypeFromBitSize (clang::ASTContext *ast,
- size_t bit_size, bool is_signed);
-
- CompilerType
- GetPointerSizedIntType (bool is_signed)
- {
- return GetPointerSizedIntType (getASTContext(), is_signed);
- }
-
- static CompilerType
- GetPointerSizedIntType (clang::ASTContext *ast, bool is_signed);
-
- //------------------------------------------------------------------
- // Floating point functions
- //------------------------------------------------------------------
-
- static CompilerType
- GetFloatTypeFromBitSize (clang::ASTContext *ast,
- size_t bit_size);
-
- //------------------------------------------------------------------
- // TypeSystem methods
- //------------------------------------------------------------------
- DWARFASTParser *
- GetDWARFParser() override;
- PDBASTParser *
- GetPDBParser();
-
- //------------------------------------------------------------------
- // ClangASTContext callbacks for external source lookups.
- //------------------------------------------------------------------
- static void
- CompleteTagDecl (void *baton, clang::TagDecl *);
-
- static void
- CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *);
-
- static bool
- LayoutRecordType(void *baton,
- const clang::RecordDecl *record_decl,
- uint64_t &size,
- uint64_t &alignment,
- llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets);
-
- //----------------------------------------------------------------------
- // CompilerDecl override functions
- //----------------------------------------------------------------------
- ConstString
- DeclGetName (void *opaque_decl) override;
-
- ConstString
- DeclGetMangledName (void *opaque_decl) override;
-
- CompilerDeclContext
- DeclGetDeclContext (void *opaque_decl) override;
-
- CompilerType
- DeclGetFunctionReturnType(void *opaque_decl) override;
-
- size_t
- DeclGetFunctionNumArguments(void *opaque_decl) override;
-
- CompilerType
- DeclGetFunctionArgumentType (void *opaque_decl, size_t arg_idx) override;
-
- //----------------------------------------------------------------------
- // CompilerDeclContext override functions
- //----------------------------------------------------------------------
-
- std::vector<CompilerDecl>
- DeclContextFindDeclByName (void *opaque_decl_ctx,
- ConstString name,
- const bool ignore_using_decls) override;
-
- bool
- DeclContextIsStructUnionOrClass (void *opaque_decl_ctx) override;
-
- ConstString
- DeclContextGetName (void *opaque_decl_ctx) override;
-
- ConstString
- DeclContextGetScopeQualifiedName (void *opaque_decl_ctx) override;
-
- bool
- DeclContextIsClassMethod (void *opaque_decl_ctx,
- lldb::LanguageType *language_ptr,
- bool *is_instance_method_ptr,
- ConstString *language_object_name_ptr) override;
-
- //----------------------------------------------------------------------
- // Clang specific clang::DeclContext functions
- //----------------------------------------------------------------------
-
- static clang::DeclContext *
- DeclContextGetAsDeclContext (const CompilerDeclContext &dc);
-
- static clang::ObjCMethodDecl *
- DeclContextGetAsObjCMethodDecl (const CompilerDeclContext &dc);
-
- static clang::CXXMethodDecl *
- DeclContextGetAsCXXMethodDecl (const CompilerDeclContext &dc);
-
- static clang::FunctionDecl *
- DeclContextGetAsFunctionDecl (const CompilerDeclContext &dc);
-
- static clang::NamespaceDecl *
- DeclContextGetAsNamespaceDecl (const CompilerDeclContext &dc);
-
- static ClangASTMetadata *
- DeclContextGetMetaData (const CompilerDeclContext &dc, const void *object);
-
- static clang::ASTContext *
- DeclContextGetClangASTContext (const CompilerDeclContext &dc);
-
- //----------------------------------------------------------------------
- // Tests
- //----------------------------------------------------------------------
-
- bool
- IsArrayType (lldb::opaque_compiler_type_t type,
- CompilerType *element_type,
- uint64_t *size,
- bool *is_incomplete) override;
-
- bool
- IsVectorType (lldb::opaque_compiler_type_t type,
- CompilerType *element_type,
- uint64_t *size) override;
-
- bool
- IsAggregateType (lldb::opaque_compiler_type_t type) override;
-
- bool
- IsAnonymousType (lldb::opaque_compiler_type_t type) override;
-
- bool
- IsBeingDefined (lldb::opaque_compiler_type_t type) override;
-
- bool
- IsCharType (lldb::opaque_compiler_type_t type) override;
-
- bool
- IsCompleteType (lldb::opaque_compiler_type_t type) override;
-
- bool
- IsConst(lldb::opaque_compiler_type_t type) override;
-
- bool
- IsCStringType (lldb::opaque_compiler_type_t type, uint32_t &length) override;
-
- static bool
- IsCXXClassType (const CompilerType& type);
-
- bool
- IsDefined(lldb::opaque_compiler_type_t type) override;
-
- bool
- IsFloatingPointType (lldb::opaque_compiler_type_t type, uint32_t &count, bool &is_complex) override;
-
- bool
- IsFunctionType (lldb::opaque_compiler_type_t type, bool *is_variadic_ptr) override;
-
- uint32_t
- IsHomogeneousAggregate (lldb::opaque_compiler_type_t type, CompilerType* base_type_ptr) override;
-
- size_t
- GetNumberOfFunctionArguments (lldb::opaque_compiler_type_t type) override;
-
- CompilerType
- GetFunctionArgumentAtIndex (lldb::opaque_compiler_type_t type, const size_t index) override;
-
- bool
- IsFunctionPointerType (lldb::opaque_compiler_type_t type) override;
-
- bool
- IsBlockPointerType (lldb::opaque_compiler_type_t type, CompilerType *function_pointer_type_ptr) override;
-
- bool
- IsIntegerType (lldb::opaque_compiler_type_t type, bool &is_signed) override;
-
- bool
- IsEnumerationType (lldb::opaque_compiler_type_t type, bool &is_signed) override;
-
- static bool
- IsObjCClassType (const CompilerType& type);
-
- static bool
- IsObjCClassTypeAndHasIVars (const CompilerType& type, bool check_superclass);
-
- static bool
- IsObjCObjectOrInterfaceType (const CompilerType& type);
-
- static bool
- IsObjCObjectPointerType(const CompilerType& type, CompilerType *target_type = nullptr);
-
- bool
- IsPolymorphicClass (lldb::opaque_compiler_type_t type) override;
-
- static bool
- IsClassType(lldb::opaque_compiler_type_t type);
-
- static bool
- IsEnumType(lldb::opaque_compiler_type_t type);
-
- bool
- IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
- CompilerType *target_type, // Can pass nullptr
- bool check_cplusplus,
- bool check_objc) override;
-
- bool
- IsRuntimeGeneratedType (lldb::opaque_compiler_type_t type) override;
-
- bool
- IsPointerType (lldb::opaque_compiler_type_t type, CompilerType *pointee_type) override;
-
- bool
- IsPointerOrReferenceType (lldb::opaque_compiler_type_t type, CompilerType *pointee_type) override;
-
- bool
- IsReferenceType (lldb::opaque_compiler_type_t type, CompilerType *pointee_type, bool* is_rvalue) override;
-
- bool
- IsScalarType (lldb::opaque_compiler_type_t type) override;
-
- bool
- IsTypedefType (lldb::opaque_compiler_type_t type) override;
-
- bool
- IsVoidType (lldb::opaque_compiler_type_t type) override;
-
- bool
- SupportsLanguage (lldb::LanguageType language) override;
-
- static bool
- GetCXXClassName (const CompilerType& type, std::string &class_name);
-
- static bool
- GetObjCClassName (const CompilerType& type, std::string &class_name);
-
- //----------------------------------------------------------------------
- // Type Completion
- //----------------------------------------------------------------------
-
- bool
- GetCompleteType (lldb::opaque_compiler_type_t type) override;
-
- //----------------------------------------------------------------------
- // Accessors
- //----------------------------------------------------------------------
-
- ConstString
- GetTypeName (lldb::opaque_compiler_type_t type) override;
-
- uint32_t
- GetTypeInfo (lldb::opaque_compiler_type_t type, CompilerType *pointee_or_element_compiler_type) override;
-
- lldb::LanguageType
- GetMinimumLanguage (lldb::opaque_compiler_type_t type) override;
-
- lldb::TypeClass
- GetTypeClass (lldb::opaque_compiler_type_t type) override;
-
- unsigned
- GetTypeQualifiers(lldb::opaque_compiler_type_t type) override;
-
- //----------------------------------------------------------------------
- // Creating related types
- //----------------------------------------------------------------------
-
- // Using the current type, create a new typedef to that type using "typedef_name"
- // as the name and "decl_ctx" as the decl context.
- static CompilerType
- CreateTypedefType (const CompilerType& type,
- const char *typedef_name,
- const CompilerDeclContext &compiler_decl_ctx);
-
- CompilerType
- GetArrayElementType (lldb::opaque_compiler_type_t type, uint64_t *stride) override;
-
- CompilerType
- GetCanonicalType (lldb::opaque_compiler_type_t type) override;
-
- CompilerType
- GetFullyUnqualifiedType (lldb::opaque_compiler_type_t type) override;
-
- // Returns -1 if this isn't a function of if the function doesn't have a prototype
- // Returns a value >= 0 if there is a prototype.
- int
- GetFunctionArgumentCount (lldb::opaque_compiler_type_t type) override;
-
- CompilerType
- GetFunctionArgumentTypeAtIndex (lldb::opaque_compiler_type_t type, size_t idx) override;
-
- CompilerType
- GetFunctionReturnType (lldb::opaque_compiler_type_t type) override;
-
- size_t
- GetNumMemberFunctions (lldb::opaque_compiler_type_t type) override;
-
- TypeMemberFunctionImpl
- GetMemberFunctionAtIndex (lldb::opaque_compiler_type_t type, size_t idx) override;
-
- CompilerType
- GetNonReferenceType (lldb::opaque_compiler_type_t type) override;
-
- CompilerType
- GetPointeeType (lldb::opaque_compiler_type_t type) override;
-
- CompilerType
- GetPointerType (lldb::opaque_compiler_type_t type) override;
-
- CompilerType
- GetLValueReferenceType (lldb::opaque_compiler_type_t type) override;
-
- CompilerType
- GetRValueReferenceType (lldb::opaque_compiler_type_t type) override;
-
- CompilerType
- AddConstModifier (lldb::opaque_compiler_type_t type) override;
-
- CompilerType
- AddVolatileModifier (lldb::opaque_compiler_type_t type) override;
-
- CompilerType
- AddRestrictModifier (lldb::opaque_compiler_type_t type) override;
-
- CompilerType
- CreateTypedef (lldb::opaque_compiler_type_t type, const char *name, const CompilerDeclContext &decl_ctx) override;
-
- // If the current object represents a typedef type, get the underlying type
- CompilerType
- GetTypedefedType (lldb::opaque_compiler_type_t type) override;
-
- //----------------------------------------------------------------------
- // Create related types using the current type's AST
- //----------------------------------------------------------------------
- CompilerType
- GetBasicTypeFromAST (lldb::BasicType basic_type) override;
-
- //----------------------------------------------------------------------
- // Exploring the type
- //----------------------------------------------------------------------
-
- uint64_t
- GetByteSize (lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope)
- {
- return (GetBitSize (type, exe_scope) + 7) / 8;
- }
-
- uint64_t
- GetBitSize (lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override;
-
- lldb::Encoding
- GetEncoding (lldb::opaque_compiler_type_t type, uint64_t &count) override;
-
- lldb::Format
- GetFormat (lldb::opaque_compiler_type_t type) override;
-
- size_t
- GetTypeBitAlign (lldb::opaque_compiler_type_t type) override;
-
- uint32_t
- GetNumChildren (lldb::opaque_compiler_type_t type, bool omit_empty_base_classes) override;
-
- CompilerType
- GetBuiltinTypeByName (const ConstString &name) override;
-
- lldb::BasicType
- GetBasicTypeEnumeration (lldb::opaque_compiler_type_t type) override;
-
- static lldb::BasicType
- GetBasicTypeEnumeration (lldb::opaque_compiler_type_t type, const ConstString &name);
-
- void
- ForEachEnumerator (lldb::opaque_compiler_type_t type, std::function <bool (const CompilerType &integer_type, const ConstString &name, const llvm::APSInt &value)> const &callback) override;
-
- uint32_t
- GetNumFields (lldb::opaque_compiler_type_t type) override;
-
- CompilerType
- GetFieldAtIndex (lldb::opaque_compiler_type_t type,
- size_t idx,
- std::string& name,
- uint64_t *bit_offset_ptr,
- uint32_t *bitfield_bit_size_ptr,
- bool *is_bitfield_ptr) override;
-
- uint32_t
- GetNumDirectBaseClasses (lldb::opaque_compiler_type_t type) override;
-
- uint32_t
- GetNumVirtualBaseClasses (lldb::opaque_compiler_type_t type) override;
-
- CompilerType
- GetDirectBaseClassAtIndex (lldb::opaque_compiler_type_t type,
- size_t idx,
- uint32_t *bit_offset_ptr) override;
-
- CompilerType
- GetVirtualBaseClassAtIndex (lldb::opaque_compiler_type_t type,
- size_t idx,
- uint32_t *bit_offset_ptr) override;
-
- static uint32_t
- GetNumPointeeChildren (clang::QualType type);
-
- CompilerType
- GetChildCompilerTypeAtIndex (lldb::opaque_compiler_type_t type,
- ExecutionContext *exe_ctx,
- size_t idx,
- bool transparent_pointers,
- bool omit_empty_base_classes,
- bool ignore_array_bounds,
- std::string& child_name,
- uint32_t &child_byte_size,
- int32_t &child_byte_offset,
- uint32_t &child_bitfield_bit_size,
- uint32_t &child_bitfield_bit_offset,
- bool &child_is_base_class,
- bool &child_is_deref_of_parent,
- ValueObject *valobj,
- uint64_t &language_flags) override;
-
- // Lookup a child given a name. This function will match base class names
- // and member member names in "clang_type" only, not descendants.
- uint32_t
- GetIndexOfChildWithName (lldb::opaque_compiler_type_t type,
+ void CreateFunctionTemplateSpecializationInfo(
+ clang::FunctionDecl *func_decl, clang::FunctionTemplateDecl *Template,
+ const TemplateParameterInfos &infos);
+
+ clang::ClassTemplateDecl *
+ CreateClassTemplateDecl(clang::DeclContext *decl_ctx,
+ lldb::AccessType access_type, const char *class_name,
+ int kind, const TemplateParameterInfos &infos);
+
+ clang::ClassTemplateSpecializationDecl *CreateClassTemplateSpecializationDecl(
+ clang::DeclContext *decl_ctx,
+ clang::ClassTemplateDecl *class_template_decl, int kind,
+ const TemplateParameterInfos &infos);
+
+ CompilerType
+ CreateClassTemplateSpecializationType(clang::ClassTemplateSpecializationDecl *
+ class_template_specialization_decl);
+
+ static clang::DeclContext *
+ GetAsDeclContext(clang::CXXMethodDecl *cxx_method_decl);
+
+ static clang::DeclContext *
+ GetAsDeclContext(clang::ObjCMethodDecl *objc_method_decl);
+
+ static bool CheckOverloadedOperatorKindParameterCount(
+ bool is_method, clang::OverloadedOperatorKind op_kind,
+ uint32_t num_params);
+
+ bool FieldIsBitfield(clang::FieldDecl *field, uint32_t &bitfield_bit_size);
+
+ static bool FieldIsBitfield(clang::ASTContext *ast, clang::FieldDecl *field,
+ uint32_t &bitfield_bit_size);
+
+ static bool RecordHasFields(const clang::RecordDecl *record_decl);
+
+ CompilerType CreateObjCClass(const char *name, clang::DeclContext *decl_ctx,
+ bool isForwardDecl, bool isInternal,
+ ClangASTMetadata *metadata = nullptr);
+
+ bool SetTagTypeKind(clang::QualType type, int kind) const;
+
+ bool SetDefaultAccessForRecordFields(clang::RecordDecl *record_decl,
+ int default_accessibility,
+ int *assigned_accessibilities,
+ size_t num_assigned_accessibilities);
+
+ // Returns a mask containing bits from the ClangASTContext::eTypeXXX
+ // enumerations
+
+ //------------------------------------------------------------------
+ // Namespace Declarations
+ //------------------------------------------------------------------
+
+ clang::NamespaceDecl *
+ GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx);
+
+ static clang::NamespaceDecl *
+ GetUniqueNamespaceDeclaration(clang::ASTContext *ast, const char *name,
+ clang::DeclContext *decl_ctx);
+
+ //------------------------------------------------------------------
+ // Function Types
+ //------------------------------------------------------------------
+
+ clang::FunctionDecl *
+ CreateFunctionDeclaration(clang::DeclContext *decl_ctx, const char *name,
+ const CompilerType &function_Type, int storage,
+ bool is_inline);
+
+ static CompilerType CreateFunctionType(clang::ASTContext *ast,
+ const CompilerType &result_type,
+ const CompilerType *args,
+ unsigned num_args, bool is_variadic,
+ unsigned type_quals);
+
+ CompilerType CreateFunctionType(const CompilerType &result_type,
+ const CompilerType *args, unsigned num_args,
+ bool is_variadic, unsigned type_quals) {
+ return ClangASTContext::CreateFunctionType(
+ getASTContext(), result_type, args, num_args, is_variadic, type_quals);
+ }
+
+ clang::ParmVarDecl *CreateParameterDeclaration(const char *name,
+ const CompilerType &param_type,
+ int storage);
+
+ void SetFunctionParameters(clang::FunctionDecl *function_decl,
+ clang::ParmVarDecl **params, unsigned num_params);
+
+ CompilerType CreateBlockPointerType(const CompilerType &function_type);
+
+ //------------------------------------------------------------------
+ // Array Types
+ //------------------------------------------------------------------
+
+ CompilerType CreateArrayType(const CompilerType &element_type,
+ size_t element_count, bool is_vector);
+
+ //------------------------------------------------------------------
+ // Enumeration Types
+ //------------------------------------------------------------------
+ CompilerType CreateEnumerationType(const char *name,
+ clang::DeclContext *decl_ctx,
+ const Declaration &decl,
+ const CompilerType &integer_qual_type);
+
+ //------------------------------------------------------------------
+ // Integer type functions
+ //------------------------------------------------------------------
+
+ static CompilerType GetIntTypeFromBitSize(clang::ASTContext *ast,
+ size_t bit_size, bool is_signed);
+
+ CompilerType GetPointerSizedIntType(bool is_signed) {
+ return GetPointerSizedIntType(getASTContext(), is_signed);
+ }
+
+ static CompilerType GetPointerSizedIntType(clang::ASTContext *ast,
+ bool is_signed);
+
+ //------------------------------------------------------------------
+ // Floating point functions
+ //------------------------------------------------------------------
+
+ static CompilerType GetFloatTypeFromBitSize(clang::ASTContext *ast,
+ size_t bit_size);
+
+ //------------------------------------------------------------------
+ // TypeSystem methods
+ //------------------------------------------------------------------
+ DWARFASTParser *GetDWARFParser() override;
+ PDBASTParser *GetPDBParser();
+
+ //------------------------------------------------------------------
+ // ClangASTContext callbacks for external source lookups.
+ //------------------------------------------------------------------
+ static void CompleteTagDecl(void *baton, clang::TagDecl *);
+
+ static void CompleteObjCInterfaceDecl(void *baton,
+ clang::ObjCInterfaceDecl *);
+
+ static bool LayoutRecordType(
+ void *baton, const clang::RecordDecl *record_decl, uint64_t &size,
+ uint64_t &alignment,
+ llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
+ &base_offsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
+ &vbase_offsets);
+
+ //----------------------------------------------------------------------
+ // CompilerDecl override functions
+ //----------------------------------------------------------------------
+ ConstString DeclGetName(void *opaque_decl) override;
+
+ ConstString DeclGetMangledName(void *opaque_decl) override;
+
+ CompilerDeclContext DeclGetDeclContext(void *opaque_decl) override;
+
+ CompilerType DeclGetFunctionReturnType(void *opaque_decl) override;
+
+ size_t DeclGetFunctionNumArguments(void *opaque_decl) override;
+
+ CompilerType DeclGetFunctionArgumentType(void *opaque_decl,
+ size_t arg_idx) override;
+
+ //----------------------------------------------------------------------
+ // CompilerDeclContext override functions
+ //----------------------------------------------------------------------
+
+ std::vector<CompilerDecl>
+ DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name,
+ const bool ignore_using_decls) override;
+
+ bool DeclContextIsStructUnionOrClass(void *opaque_decl_ctx) override;
+
+ ConstString DeclContextGetName(void *opaque_decl_ctx) override;
+
+ ConstString DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) override;
+
+ bool DeclContextIsClassMethod(void *opaque_decl_ctx,
+ lldb::LanguageType *language_ptr,
+ bool *is_instance_method_ptr,
+ ConstString *language_object_name_ptr) override;
+
+ //----------------------------------------------------------------------
+ // Clang specific clang::DeclContext functions
+ //----------------------------------------------------------------------
+
+ static clang::DeclContext *
+ DeclContextGetAsDeclContext(const CompilerDeclContext &dc);
+
+ static clang::ObjCMethodDecl *
+ DeclContextGetAsObjCMethodDecl(const CompilerDeclContext &dc);
+
+ static clang::CXXMethodDecl *
+ DeclContextGetAsCXXMethodDecl(const CompilerDeclContext &dc);
+
+ static clang::FunctionDecl *
+ DeclContextGetAsFunctionDecl(const CompilerDeclContext &dc);
+
+ static clang::NamespaceDecl *
+ DeclContextGetAsNamespaceDecl(const CompilerDeclContext &dc);
+
+ static ClangASTMetadata *DeclContextGetMetaData(const CompilerDeclContext &dc,
+ const void *object);
+
+ static clang::ASTContext *
+ DeclContextGetClangASTContext(const CompilerDeclContext &dc);
+
+ //----------------------------------------------------------------------
+ // Tests
+ //----------------------------------------------------------------------
+
+ bool IsArrayType(lldb::opaque_compiler_type_t type,
+ CompilerType *element_type, uint64_t *size,
+ bool *is_incomplete) override;
+
+ bool IsVectorType(lldb::opaque_compiler_type_t type,
+ CompilerType *element_type, uint64_t *size) override;
+
+ bool IsAggregateType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsAnonymousType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsBeingDefined(lldb::opaque_compiler_type_t type) override;
+
+ bool IsCharType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsCompleteType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsConst(lldb::opaque_compiler_type_t type) override;
+
+ bool IsCStringType(lldb::opaque_compiler_type_t type,
+ uint32_t &length) override;
+
+ static bool IsCXXClassType(const CompilerType &type);
+
+ bool IsDefined(lldb::opaque_compiler_type_t type) override;
+
+ bool IsFloatingPointType(lldb::opaque_compiler_type_t type, uint32_t &count,
+ bool &is_complex) override;
+
+ bool IsFunctionType(lldb::opaque_compiler_type_t type,
+ bool *is_variadic_ptr) override;
+
+ uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type,
+ CompilerType *base_type_ptr) override;
+
+ size_t
+ GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type,
+ const size_t index) override;
+
+ bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsBlockPointerType(lldb::opaque_compiler_type_t type,
+ CompilerType *function_pointer_type_ptr) override;
+
+ bool IsIntegerType(lldb::opaque_compiler_type_t type,
+ bool &is_signed) override;
+
+ bool IsEnumerationType(lldb::opaque_compiler_type_t type,
+ bool &is_signed) override;
+
+ static bool IsObjCClassType(const CompilerType &type);
+
+ static bool IsObjCClassTypeAndHasIVars(const CompilerType &type,
+ bool check_superclass);
+
+ static bool IsObjCObjectOrInterfaceType(const CompilerType &type);
+
+ static bool IsObjCObjectPointerType(const CompilerType &type,
+ CompilerType *target_type = nullptr);
+
+ bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) override;
+
+ static bool IsClassType(lldb::opaque_compiler_type_t type);
+
+ static bool IsEnumType(lldb::opaque_compiler_type_t type);
+
+ bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
+ CompilerType *target_type, // Can pass nullptr
+ bool check_cplusplus, bool check_objc) override;
+
+ bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsPointerType(lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_type) override;
+
+ bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_type) override;
+
+ bool IsReferenceType(lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_type, bool *is_rvalue) override;
+
+ bool IsScalarType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsTypedefType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsVoidType(lldb::opaque_compiler_type_t type) override;
+
+ bool SupportsLanguage(lldb::LanguageType language) override;
+
+ static bool GetCXXClassName(const CompilerType &type,
+ std::string &class_name);
+
+ static bool GetObjCClassName(const CompilerType &type,
+ std::string &class_name);
+
+ //----------------------------------------------------------------------
+ // Type Completion
+ //----------------------------------------------------------------------
+
+ bool GetCompleteType(lldb::opaque_compiler_type_t type) override;
+
+ //----------------------------------------------------------------------
+ // Accessors
+ //----------------------------------------------------------------------
+
+ ConstString GetTypeName(lldb::opaque_compiler_type_t type) override;
+
+ uint32_t GetTypeInfo(lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_or_element_compiler_type) override;
+
+ lldb::LanguageType
+ GetMinimumLanguage(lldb::opaque_compiler_type_t type) override;
+
+ lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override;
+
+ unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override;
+
+ //----------------------------------------------------------------------
+ // Creating related types
+ //----------------------------------------------------------------------
+
+ // Using the current type, create a new typedef to that type using
+ // "typedef_name"
+ // as the name and "decl_ctx" as the decl context.
+ static CompilerType
+ CreateTypedefType(const CompilerType &type, const char *typedef_name,
+ const CompilerDeclContext &compiler_decl_ctx);
+
+ CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type,
+ uint64_t *stride) override;
+
+ CompilerType GetArrayType(lldb::opaque_compiler_type_t type,
+ uint64_t size) override;
+
+ CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType
+ GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override;
+
+ // Returns -1 if this isn't a function of if the function doesn't have a
+ // prototype
+ // Returns a value >= 0 if there is a prototype.
+ int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type,
+ size_t idx) override;
+
+ CompilerType
+ GetFunctionReturnType(lldb::opaque_compiler_type_t type) override;
+
+ size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) override;
+
+ TypeMemberFunctionImpl
+ GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type,
+ size_t idx) override;
+
+ CompilerType GetNonReferenceType(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetPointerType(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType
+ GetLValueReferenceType(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType
+ GetRValueReferenceType(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType AddConstModifier(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType AddVolatileModifier(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType AddRestrictModifier(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType CreateTypedef(lldb::opaque_compiler_type_t type,
const char *name,
- bool omit_empty_base_classes) override;
-
- // Lookup a child member given a name. This function will match member names
- // only and will descend into "clang_type" children in search for the first
- // member in this class, or any base class that matches "name".
- // TODO: Return all matches for a given name by returning a vector<vector<uint32_t>>
- // so we catch all names that match a given child name, not just the first.
- size_t
- GetIndexOfChildMemberWithName (lldb::opaque_compiler_type_t type,
+ const CompilerDeclContext &decl_ctx) override;
+
+ // If the current object represents a typedef type, get the underlying type
+ CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) override;
+
+ //----------------------------------------------------------------------
+ // Create related types using the current type's AST
+ //----------------------------------------------------------------------
+ CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override;
+
+ //----------------------------------------------------------------------
+ // Exploring the type
+ //----------------------------------------------------------------------
+
+ uint64_t GetByteSize(lldb::opaque_compiler_type_t type,
+ ExecutionContextScope *exe_scope) {
+ return (GetBitSize(type, exe_scope) + 7) / 8;
+ }
+
+ uint64_t GetBitSize(lldb::opaque_compiler_type_t type,
+ ExecutionContextScope *exe_scope) override;
+
+ lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type,
+ uint64_t &count) override;
+
+ lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override;
+
+ size_t GetTypeBitAlign(lldb::opaque_compiler_type_t type) override;
+
+ uint32_t GetNumChildren(lldb::opaque_compiler_type_t type,
+ bool omit_empty_base_classes) override;
+
+ CompilerType GetBuiltinTypeByName(const ConstString &name) override;
+
+ lldb::BasicType
+ GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) override;
+
+ static lldb::BasicType
+ GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type,
+ const ConstString &name);
+
+ void ForEachEnumerator(
+ lldb::opaque_compiler_type_t type,
+ std::function<bool(const CompilerType &integer_type,
+ const ConstString &name,
+ const llvm::APSInt &value)> const &callback) override;
+
+ uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx,
+ std::string &name, uint64_t *bit_offset_ptr,
+ uint32_t *bitfield_bit_size_ptr,
+ bool *is_bitfield_ptr) override;
+
+ uint32_t GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) override;
+
+ uint32_t GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type,
+ size_t idx,
+ uint32_t *bit_offset_ptr) override;
+
+ CompilerType GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type,
+ size_t idx,
+ uint32_t *bit_offset_ptr) override;
+
+ static uint32_t GetNumPointeeChildren(clang::QualType type);
+
+ CompilerType GetChildCompilerTypeAtIndex(
+ lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx,
+ bool transparent_pointers, bool omit_empty_base_classes,
+ bool ignore_array_bounds, std::string &child_name,
+ uint32_t &child_byte_size, int32_t &child_byte_offset,
+ uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
+ bool &child_is_base_class, bool &child_is_deref_of_parent,
+ ValueObject *valobj, uint64_t &language_flags) override;
+
+ // Lookup a child given a name. This function will match base class names
+ // and member member names in "clang_type" only, not descendants.
+ uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
const char *name,
- bool omit_empty_base_classes,
- std::vector<uint32_t>& child_indexes) override;
-
- size_t
- GetNumTemplateArguments (lldb::opaque_compiler_type_t type) override;
-
- CompilerType
- GetTemplateArgument (lldb::opaque_compiler_type_t type,
- size_t idx,
- lldb::TemplateArgumentKind &kind) override;
-
- CompilerType
- GetTypeForFormatters (void* type) override;
-
-#define LLDB_INVALID_DECL_LEVEL UINT32_MAX
- // LLDB_INVALID_DECL_LEVEL is returned by CountDeclLevels if
- // child_decl_ctx could not be found in decl_ctx.
- uint32_t
- CountDeclLevels (clang::DeclContext *frame_decl_ctx,
- clang::DeclContext *child_decl_ctx,
- ConstString *child_name = nullptr,
- CompilerType *child_type = nullptr);
-
- //----------------------------------------------------------------------
- // Modifying RecordType
- //----------------------------------------------------------------------
- static clang::FieldDecl *
- AddFieldToRecordType (const CompilerType& type,
- const char *name,
- const CompilerType &field_type,
- lldb::AccessType access,
- uint32_t bitfield_bit_size);
-
- static void
- BuildIndirectFields (const CompilerType& type);
-
- static void
- SetIsPacked (const CompilerType& type);
-
- static clang::VarDecl *
- AddVariableToRecordType (const CompilerType& type,
- const char *name,
- const CompilerType &var_type,
- lldb::AccessType access);
-
- clang::CXXMethodDecl *
- AddMethodToCXXRecordType (lldb::opaque_compiler_type_t type,
- const char *name,
- const CompilerType &method_type,
- lldb::AccessType access,
- bool is_virtual,
- bool is_static,
- bool is_inline,
- bool is_explicit,
- bool is_attr_used,
- bool is_artificial);
-
- // C++ Base Classes
- clang::CXXBaseSpecifier *
- CreateBaseClassSpecifier (lldb::opaque_compiler_type_t type,
- lldb::AccessType access,
- bool is_virtual,
- bool base_of_class);
-
- static void
- DeleteBaseClassSpecifiers (clang::CXXBaseSpecifier **base_classes,
- unsigned num_base_classes);
-
- bool
- SetBaseClassesForClassType (lldb::opaque_compiler_type_t type,
- clang::CXXBaseSpecifier const * const *base_classes,
- unsigned num_base_classes);
-
- static bool
- SetObjCSuperClass (const CompilerType& type,
- const CompilerType &superclass_compiler_type);
-
- static bool
- AddObjCClassProperty (const CompilerType& type,
- const char *property_name,
- const CompilerType &property_compiler_type,
- clang::ObjCIvarDecl *ivar_decl,
- const char *property_setter_name,
- const char *property_getter_name,
- uint32_t property_attributes,
- ClangASTMetadata *metadata);
-
- static clang::ObjCMethodDecl *
- AddMethodToObjCObjectType (const CompilerType& type,
- const char *name, // the full symbol name as seen in the symbol table (lldb::opaque_compiler_type_t type, "-[NString stringWithCString:]")
- const CompilerType &method_compiler_type,
- lldb::AccessType access,
- bool is_artificial,
- bool is_variadic);
-
- static bool
- SetHasExternalStorage (lldb::opaque_compiler_type_t type, bool has_extern);
-
- static bool
- GetHasExternalStorage (const CompilerType &type);
- //------------------------------------------------------------------
- // Tag Declarations
- //------------------------------------------------------------------
- static bool
- StartTagDeclarationDefinition (const CompilerType &type);
-
- static bool
- CompleteTagDeclarationDefinition (const CompilerType &type);
-
- //----------------------------------------------------------------------
- // Modifying Enumeration types
- //----------------------------------------------------------------------
- bool
- AddEnumerationValueToEnumerationType (lldb::opaque_compiler_type_t type,
- const CompilerType &enumerator_qual_type,
- const Declaration &decl,
- const char *name,
- int64_t enum_value,
- uint32_t enum_value_bit_size);
-
- CompilerType
- GetEnumerationIntegerType (lldb::opaque_compiler_type_t type);
-
- //------------------------------------------------------------------
- // Pointers & References
- //------------------------------------------------------------------
-
- // Call this function using the class type when you want to make a
- // member pointer type to pointee_type.
- static CompilerType
- CreateMemberPointerType (const CompilerType& type, const CompilerType &pointee_type);
-
- // Converts "s" to a floating point value and place resulting floating
- // point bytes in the "dst" buffer.
- size_t
- ConvertStringToFloatValue (lldb::opaque_compiler_type_t type,
- const char *s,
- uint8_t *dst,
- size_t dst_size) override;
-
- //----------------------------------------------------------------------
- // Dumping types
- //----------------------------------------------------------------------
- void
- DumpValue (lldb::opaque_compiler_type_t type,
- ExecutionContext *exe_ctx,
- Stream *s,
- lldb::Format format,
- const DataExtractor &data,
- lldb::offset_t data_offset,
- size_t data_byte_size,
- uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset,
- bool show_types,
- bool show_summary,
- bool verbose,
- uint32_t depth) override;
-
- bool
- DumpTypeValue (lldb::opaque_compiler_type_t type,
- Stream *s,
- lldb::Format format,
- const DataExtractor &data,
- lldb::offset_t data_offset,
- size_t data_byte_size,
- uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset,
- ExecutionContextScope *exe_scope) override;
-
- void
- DumpSummary (lldb::opaque_compiler_type_t type,
- ExecutionContext *exe_ctx,
- Stream *s,
- const DataExtractor &data,
- lldb::offset_t data_offset,
- size_t data_byte_size) override;
-
- void
- DumpTypeDescription (lldb::opaque_compiler_type_t type) override; // Dump to stdout
-
- void
- DumpTypeDescription (lldb::opaque_compiler_type_t type, Stream *s) override;
-
- static void
- DumpTypeName (const CompilerType &type);
-
- static clang::EnumDecl *
- GetAsEnumDecl (const CompilerType& type);
-
- static clang::RecordDecl *
- GetAsRecordDecl (const CompilerType& type);
-
- static clang::TagDecl *
- GetAsTagDecl (const CompilerType& type);
-
- clang::CXXRecordDecl *
- GetAsCXXRecordDecl (lldb::opaque_compiler_type_t type);
-
- static clang::ObjCInterfaceDecl *
- GetAsObjCInterfaceDecl (const CompilerType& type);
-
- clang::ClassTemplateDecl *
- ParseClassTemplateDecl (clang::DeclContext *decl_ctx,
- lldb::AccessType access_type,
- const char *parent_name,
- int tag_decl_kind,
- const ClangASTContext::TemplateParameterInfos &template_param_infos);
-
- clang::BlockDecl *
- CreateBlockDeclaration (clang::DeclContext *ctx);
-
- clang::UsingDirectiveDecl *
- CreateUsingDirectiveDeclaration (clang::DeclContext *decl_ctx, clang::NamespaceDecl *ns_decl);
-
- clang::UsingDecl *
- CreateUsingDeclaration (clang::DeclContext *current_decl_ctx, clang::NamedDecl *target);
-
- clang::VarDecl *
- CreateVariableDeclaration (clang::DeclContext *decl_context, const char *name, clang::QualType type);
-
- static lldb::opaque_compiler_type_t
- GetOpaqueCompilerType(clang::ASTContext *ast, lldb::BasicType basic_type);
-
- static clang::QualType
- GetQualType(lldb::opaque_compiler_type_t type)
- {
- if (type)
- return clang::QualType::getFromOpaquePtr(type);
- return clang::QualType();
- }
+ bool omit_empty_base_classes) override;
+
+ // Lookup a child member given a name. This function will match member names
+ // only and will descend into "clang_type" children in search for the first
+ // member in this class, or any base class that matches "name".
+ // TODO: Return all matches for a given name by returning a
+ // vector<vector<uint32_t>>
+ // so we catch all names that match a given child name, not just the first.
+ size_t
+ GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type,
+ const char *name, bool omit_empty_base_classes,
+ std::vector<uint32_t> &child_indexes) override;
+
+ size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetTemplateArgument(lldb::opaque_compiler_type_t type,
+ size_t idx,
+ lldb::TemplateArgumentKind &kind) override;
+
+ CompilerType GetTypeForFormatters(void *type) override;
+
+#define LLDB_INVALID_DECL_LEVEL UINT32_MAX
+ // LLDB_INVALID_DECL_LEVEL is returned by CountDeclLevels if
+ // child_decl_ctx could not be found in decl_ctx.
+ uint32_t CountDeclLevels(clang::DeclContext *frame_decl_ctx,
+ clang::DeclContext *child_decl_ctx,
+ ConstString *child_name = nullptr,
+ CompilerType *child_type = nullptr);
+
+ //----------------------------------------------------------------------
+ // Modifying RecordType
+ //----------------------------------------------------------------------
+ static clang::FieldDecl *AddFieldToRecordType(const CompilerType &type,
+ const char *name,
+ const CompilerType &field_type,
+ lldb::AccessType access,
+ uint32_t bitfield_bit_size);
+
+ static void BuildIndirectFields(const CompilerType &type);
+
+ static void SetIsPacked(const CompilerType &type);
+
+ static clang::VarDecl *AddVariableToRecordType(const CompilerType &type,
+ const char *name,
+ const CompilerType &var_type,
+ lldb::AccessType access);
+
+ clang::CXXMethodDecl *
+ AddMethodToCXXRecordType(lldb::opaque_compiler_type_t type, const char *name,
+ const CompilerType &method_type,
+ lldb::AccessType access, bool is_virtual,
+ bool is_static, bool is_inline, bool is_explicit,
+ bool is_attr_used, bool is_artificial);
+
+ // C++ Base Classes
+ clang::CXXBaseSpecifier *
+ CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type,
+ lldb::AccessType access, bool is_virtual,
+ bool base_of_class);
+
+ static void DeleteBaseClassSpecifiers(clang::CXXBaseSpecifier **base_classes,
+ unsigned num_base_classes);
+
+ bool
+ SetBaseClassesForClassType(lldb::opaque_compiler_type_t type,
+ clang::CXXBaseSpecifier const *const *base_classes,
+ unsigned num_base_classes);
+
+ static bool SetObjCSuperClass(const CompilerType &type,
+ const CompilerType &superclass_compiler_type);
+
+ static bool AddObjCClassProperty(const CompilerType &type,
+ const char *property_name,
+ const CompilerType &property_compiler_type,
+ clang::ObjCIvarDecl *ivar_decl,
+ const char *property_setter_name,
+ const char *property_getter_name,
+ uint32_t property_attributes,
+ ClangASTMetadata *metadata);
+
+ static clang::ObjCMethodDecl *AddMethodToObjCObjectType(
+ const CompilerType &type,
+ const char *name, // the full symbol name as seen in the symbol table
+ // (lldb::opaque_compiler_type_t type, "-[NString
+ // stringWithCString:]")
+ const CompilerType &method_compiler_type, lldb::AccessType access,
+ bool is_artificial, bool is_variadic);
+
+ static bool SetHasExternalStorage(lldb::opaque_compiler_type_t type,
+ bool has_extern);
+
+ static bool GetHasExternalStorage(const CompilerType &type);
+ //------------------------------------------------------------------
+ // Tag Declarations
+ //------------------------------------------------------------------
+ static bool StartTagDeclarationDefinition(const CompilerType &type);
+
+ static bool CompleteTagDeclarationDefinition(const CompilerType &type);
+
+ //----------------------------------------------------------------------
+ // Modifying Enumeration types
+ //----------------------------------------------------------------------
+ bool AddEnumerationValueToEnumerationType(
+ lldb::opaque_compiler_type_t type,
+ const CompilerType &enumerator_qual_type, const Declaration &decl,
+ const char *name, int64_t enum_value, uint32_t enum_value_bit_size);
+
+ CompilerType GetEnumerationIntegerType(lldb::opaque_compiler_type_t type);
+
+ //------------------------------------------------------------------
+ // Pointers & References
+ //------------------------------------------------------------------
+
+ // Call this function using the class type when you want to make a
+ // member pointer type to pointee_type.
+ static CompilerType CreateMemberPointerType(const CompilerType &type,
+ const CompilerType &pointee_type);
+
+ // Converts "s" to a floating point value and place resulting floating
+ // point bytes in the "dst" buffer.
+ size_t ConvertStringToFloatValue(lldb::opaque_compiler_type_t type,
+ const char *s, uint8_t *dst,
+ size_t dst_size) override;
+
+ //----------------------------------------------------------------------
+ // Dumping types
+ //----------------------------------------------------------------------
+ void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
+ Stream *s, lldb::Format format, const DataExtractor &data,
+ lldb::offset_t data_offset, size_t data_byte_size,
+ uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
+ bool show_types, bool show_summary, bool verbose,
+ uint32_t depth) override;
+
+ bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s,
+ lldb::Format format, const DataExtractor &data,
+ lldb::offset_t data_offset, size_t data_byte_size,
+ uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
+ ExecutionContextScope *exe_scope) override;
+
+ void DumpSummary(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
+ Stream *s, const DataExtractor &data,
+ lldb::offset_t data_offset, size_t data_byte_size) override;
+
+ void DumpTypeDescription(
+ lldb::opaque_compiler_type_t type) override; // Dump to stdout
+
+ void DumpTypeDescription(lldb::opaque_compiler_type_t type,
+ Stream *s) override;
+
+ static void DumpTypeName(const CompilerType &type);
+
+ static clang::EnumDecl *GetAsEnumDecl(const CompilerType &type);
+
+ static clang::RecordDecl *GetAsRecordDecl(const CompilerType &type);
+
+ static clang::TagDecl *GetAsTagDecl(const CompilerType &type);
+
+ clang::CXXRecordDecl *GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type);
+
+ static clang::ObjCInterfaceDecl *
+ GetAsObjCInterfaceDecl(const CompilerType &type);
+
+ clang::ClassTemplateDecl *ParseClassTemplateDecl(
+ clang::DeclContext *decl_ctx, lldb::AccessType access_type,
+ const char *parent_name, int tag_decl_kind,
+ const ClangASTContext::TemplateParameterInfos &template_param_infos);
+
+ clang::BlockDecl *CreateBlockDeclaration(clang::DeclContext *ctx);
+
+ clang::UsingDirectiveDecl *
+ CreateUsingDirectiveDeclaration(clang::DeclContext *decl_ctx,
+ clang::NamespaceDecl *ns_decl);
+
+ clang::UsingDecl *CreateUsingDeclaration(clang::DeclContext *current_decl_ctx,
+ clang::NamedDecl *target);
+
+ clang::VarDecl *CreateVariableDeclaration(clang::DeclContext *decl_context,
+ const char *name,
+ clang::QualType type);
+
+ static lldb::opaque_compiler_type_t
+ GetOpaqueCompilerType(clang::ASTContext *ast, lldb::BasicType basic_type);
- static clang::QualType
- GetCanonicalQualType(lldb::opaque_compiler_type_t type)
- {
- if (type)
- return clang::QualType::getFromOpaquePtr(type).getCanonicalType();
- return clang::QualType();
- }
+ static clang::QualType GetQualType(lldb::opaque_compiler_type_t type) {
+ if (type)
+ return clang::QualType::getFromOpaquePtr(type);
+ return clang::QualType();
+ }
+
+ static clang::QualType
+ GetCanonicalQualType(lldb::opaque_compiler_type_t type) {
+ if (type)
+ return clang::QualType::getFromOpaquePtr(type).getCanonicalType();
+ return clang::QualType();
+ }
+
+ clang::DeclarationName
+ GetDeclarationName(const char *name, const CompilerType &function_clang_type);
protected:
- //------------------------------------------------------------------
- // Classes that inherit from ClangASTContext can see and modify these
- //------------------------------------------------------------------
- // clang-format off
+ //------------------------------------------------------------------
+ // Classes that inherit from ClangASTContext can see and modify these
+ //------------------------------------------------------------------
+ // clang-format off
std::string m_target_triple;
std::unique_ptr<clang::ASTContext> m_ast_ap;
std::unique_ptr<clang::LangOptions> m_language_options_ap;
@@ -1216,43 +994,46 @@ protected:
uint32_t m_pointer_byte_size;
bool m_ast_owned;
bool m_can_evaluate_expressions;
- // clang-format on
+ // clang-format on
private:
- //------------------------------------------------------------------
- // For ClangASTContext only
- //------------------------------------------------------------------
- ClangASTContext(const ClangASTContext&);
- const ClangASTContext& operator=(const ClangASTContext&);
+ //------------------------------------------------------------------
+ // For ClangASTContext only
+ //------------------------------------------------------------------
+ ClangASTContext(const ClangASTContext &);
+ const ClangASTContext &operator=(const ClangASTContext &);
};
-class ClangASTContextForExpressions : public ClangASTContext
-{
+class ClangASTContextForExpressions : public ClangASTContext {
public:
- ClangASTContextForExpressions (Target &target);
-
- ~ClangASTContextForExpressions() override = default;
-
- UserExpression *
- GetUserExpression (const char *expr,
- const char *expr_prefix,
- lldb::LanguageType language,
- Expression::ResultType desired_type,
- const EvaluateExpressionOptions &options) override;
-
- FunctionCaller *
- GetFunctionCaller (const CompilerType &return_type,
- const Address& function_address,
- const ValueList &arg_value_list,
- const char *name) override;
-
- UtilityFunction *
- GetUtilityFunction(const char *text, const char *name) override;
-
- PersistentExpressionState *
- GetPersistentExpressionState() override;
+ ClangASTContextForExpressions(Target &target);
+
+ ~ClangASTContextForExpressions() override = default;
+
+ UserExpression *
+ GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix,
+ lldb::LanguageType language,
+ Expression::ResultType desired_type,
+ const EvaluateExpressionOptions &options) override;
+
+ FunctionCaller *GetFunctionCaller(const CompilerType &return_type,
+ const Address &function_address,
+ const ValueList &arg_value_list,
+ const char *name) override;
+
+ UtilityFunction *GetUtilityFunction(const char *text,
+ const char *name) override;
+
+ PersistentExpressionState *GetPersistentExpressionState() override;
+
private:
- lldb::TargetWP m_target_wp;
- lldb::ClangPersistentVariablesUP m_persistent_variables; ///< These are the persistent variables associated with this process for the expression parser.
+ lldb::TargetWP m_target_wp;
+ lldb::ClangPersistentVariablesUP m_persistent_variables; ///< These are the
+ ///persistent
+ ///variables
+ ///associated with
+ ///this process for
+ ///the expression
+ ///parser.
};
} // namespace lldb_private
diff --git a/include/lldb/Symbol/ClangASTImporter.h b/include/lldb/Symbol/ClangASTImporter.h
index 0ea7308d9541..6823ad748282 100644
--- a/include/lldb/Symbol/ClangASTImporter.h
+++ b/include/lldb/Symbol/ClangASTImporter.h
@@ -26,399 +26,325 @@
#include "clang/Basic/FileSystemOptions.h"
// Project includes
-#include "lldb/lldb-types.h"
#include "lldb/Symbol/CompilerDeclContext.h"
+#include "lldb/lldb-types.h"
#include "llvm/ADT/DenseMap.h"
namespace lldb_private {
-
-class ClangASTMetrics
-{
+
+class ClangASTMetrics {
public:
- static void DumpCounters (Log *log);
- static void ClearLocalCounters ()
- {
- local_counters = { 0, 0, 0, 0, 0, 0 };
- }
-
- static void RegisterVisibleQuery ()
- {
- ++global_counters.m_visible_query_count;
- ++local_counters.m_visible_query_count;
- }
-
- static void RegisterLexicalQuery ()
- {
- ++global_counters.m_lexical_query_count;
- ++local_counters.m_lexical_query_count;
- }
-
- static void RegisterLLDBImport ()
- {
- ++global_counters.m_lldb_import_count;
- ++local_counters.m_lldb_import_count;
- }
-
- static void RegisterClangImport ()
- {
- ++global_counters.m_clang_import_count;
- ++local_counters.m_clang_import_count;
- }
-
- static void RegisterDeclCompletion ()
- {
- ++global_counters.m_decls_completed_count;
- ++local_counters.m_decls_completed_count;
- }
-
- static void RegisterRecordLayout ()
- {
- ++global_counters.m_record_layout_count;
- ++local_counters.m_record_layout_count;
- }
-
+ static void DumpCounters(Log *log);
+ static void ClearLocalCounters() { local_counters = {0, 0, 0, 0, 0, 0}; }
+
+ static void RegisterVisibleQuery() {
+ ++global_counters.m_visible_query_count;
+ ++local_counters.m_visible_query_count;
+ }
+
+ static void RegisterLexicalQuery() {
+ ++global_counters.m_lexical_query_count;
+ ++local_counters.m_lexical_query_count;
+ }
+
+ static void RegisterLLDBImport() {
+ ++global_counters.m_lldb_import_count;
+ ++local_counters.m_lldb_import_count;
+ }
+
+ static void RegisterClangImport() {
+ ++global_counters.m_clang_import_count;
+ ++local_counters.m_clang_import_count;
+ }
+
+ static void RegisterDeclCompletion() {
+ ++global_counters.m_decls_completed_count;
+ ++local_counters.m_decls_completed_count;
+ }
+
+ static void RegisterRecordLayout() {
+ ++global_counters.m_record_layout_count;
+ ++local_counters.m_record_layout_count;
+ }
+
private:
- struct Counters
- {
- uint64_t m_visible_query_count;
- uint64_t m_lexical_query_count;
- uint64_t m_lldb_import_count;
- uint64_t m_clang_import_count;
- uint64_t m_decls_completed_count;
- uint64_t m_record_layout_count;
- };
-
- static Counters global_counters;
- static Counters local_counters;
-
- static void DumpCounters (Log *log, Counters &counters);
+ struct Counters {
+ uint64_t m_visible_query_count;
+ uint64_t m_lexical_query_count;
+ uint64_t m_lldb_import_count;
+ uint64_t m_clang_import_count;
+ uint64_t m_decls_completed_count;
+ uint64_t m_record_layout_count;
+ };
+
+ static Counters global_counters;
+ static Counters local_counters;
+
+ static void DumpCounters(Log *log, Counters &counters);
};
-class ClangASTImporter
-{
+class ClangASTImporter {
public:
- struct LayoutInfo
- {
- LayoutInfo() : bit_size(0), alignment(0), field_offsets(), base_offsets(), vbase_offsets() {}
- uint64_t bit_size;
- uint64_t alignment;
- llvm::DenseMap<const clang::FieldDecl *, uint64_t> field_offsets;
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> base_offsets;
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> vbase_offsets;
- };
-
- ClangASTImporter () :
- m_file_manager(clang::FileSystemOptions())
- {
+ struct LayoutInfo {
+ LayoutInfo()
+ : bit_size(0), alignment(0), field_offsets(), base_offsets(),
+ vbase_offsets() {}
+ uint64_t bit_size;
+ uint64_t alignment;
+ llvm::DenseMap<const clang::FieldDecl *, uint64_t> field_offsets;
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> base_offsets;
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
+ vbase_offsets;
+ };
+
+ ClangASTImporter() : m_file_manager(clang::FileSystemOptions()) {}
+
+ clang::QualType CopyType(clang::ASTContext *dst_ctx,
+ clang::ASTContext *src_ctx, clang::QualType type);
+
+ lldb::opaque_compiler_type_t CopyType(clang::ASTContext *dst_ctx,
+ clang::ASTContext *src_ctx,
+ lldb::opaque_compiler_type_t type);
+
+ CompilerType CopyType(ClangASTContext &dst, const CompilerType &src_type);
+
+ clang::Decl *CopyDecl(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx,
+ clang::Decl *decl);
+
+ lldb::opaque_compiler_type_t DeportType(clang::ASTContext *dst_ctx,
+ clang::ASTContext *src_ctx,
+ lldb::opaque_compiler_type_t type);
+
+ clang::Decl *DeportDecl(clang::ASTContext *dst_ctx,
+ clang::ASTContext *src_ctx, clang::Decl *decl);
+
+ void InsertRecordDecl(clang::RecordDecl *decl, const LayoutInfo &layout);
+
+ bool LayoutRecordType(
+ const clang::RecordDecl *record_decl, uint64_t &bit_size,
+ uint64_t &alignment,
+ llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
+ &base_offsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
+ &vbase_offsets);
+
+ bool CanImport(const CompilerType &type);
+
+ bool Import(const CompilerType &type);
+
+ bool CompleteType(const CompilerType &compiler_type);
+
+ void CompleteDecl(clang::Decl *decl);
+
+ bool CompleteTagDecl(clang::TagDecl *decl);
+
+ bool CompleteTagDeclWithOrigin(clang::TagDecl *decl, clang::TagDecl *origin);
+
+ bool CompleteObjCInterfaceDecl(clang::ObjCInterfaceDecl *interface_decl);
+
+ bool CompleteAndFetchChildren(clang::QualType type);
+
+ bool RequireCompleteType(clang::QualType type);
+
+ bool ResolveDeclOrigin(const clang::Decl *decl, clang::Decl **original_decl,
+ clang::ASTContext **original_ctx) {
+ DeclOrigin origin = GetDeclOrigin(decl);
+
+ if (original_decl)
+ *original_decl = origin.decl;
+
+ if (original_ctx)
+ *original_ctx = origin.ctx;
+
+ return origin.Valid();
+ }
+
+ void SetDeclOrigin(const clang::Decl *decl, clang::Decl *original_decl);
+
+ ClangASTMetadata *GetDeclMetadata(const clang::Decl *decl);
+
+ //
+ // Namespace maps
+ //
+
+ typedef std::vector<std::pair<lldb::ModuleSP, CompilerDeclContext>>
+ NamespaceMap;
+ typedef std::shared_ptr<NamespaceMap> NamespaceMapSP;
+
+ void RegisterNamespaceMap(const clang::NamespaceDecl *decl,
+ NamespaceMapSP &namespace_map);
+
+ NamespaceMapSP GetNamespaceMap(const clang::NamespaceDecl *decl);
+
+ void BuildNamespaceMap(const clang::NamespaceDecl *decl);
+
+ //
+ // Completers for maps
+ //
+
+ class MapCompleter {
+ public:
+ virtual ~MapCompleter();
+
+ virtual void CompleteNamespaceMap(NamespaceMapSP &namespace_map,
+ const ConstString &name,
+ NamespaceMapSP &parent_map) const = 0;
+ };
+
+ void InstallMapCompleter(clang::ASTContext *dst_ctx,
+ MapCompleter &completer) {
+ ASTContextMetadataSP context_md;
+ ContextMetadataMap::iterator context_md_iter = m_metadata_map.find(dst_ctx);
+
+ if (context_md_iter == m_metadata_map.end()) {
+ context_md = ASTContextMetadataSP(new ASTContextMetadata(dst_ctx));
+ m_metadata_map[dst_ctx] = context_md;
+ } else {
+ context_md = context_md_iter->second;
}
-
- clang::QualType
- CopyType (clang::ASTContext *dst_ctx,
- clang::ASTContext *src_ctx,
- clang::QualType type);
-
- lldb::opaque_compiler_type_t
- CopyType (clang::ASTContext *dst_ctx,
- clang::ASTContext *src_ctx,
- lldb::opaque_compiler_type_t type);
-
- CompilerType
- CopyType (ClangASTContext &dst,
- const CompilerType &src_type);
-
- clang::Decl *
- CopyDecl (clang::ASTContext *dst_ctx,
- clang::ASTContext *src_ctx,
- clang::Decl *decl);
-
- lldb::opaque_compiler_type_t
- DeportType (clang::ASTContext *dst_ctx,
- clang::ASTContext *src_ctx,
- lldb::opaque_compiler_type_t type);
-
- clang::Decl *
- DeportDecl (clang::ASTContext *dst_ctx,
- clang::ASTContext *src_ctx,
- clang::Decl *decl);
- void
- InsertRecordDecl(clang::RecordDecl *decl, const LayoutInfo &layout);
+ context_md->m_map_completer = &completer;
+ }
- bool
- LayoutRecordType(const clang::RecordDecl *record_decl, uint64_t &bit_size, uint64_t &alignment,
- llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets);
+ void ForgetDestination(clang::ASTContext *dst_ctx);
+ void ForgetSource(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx);
- bool
- CanImport(const CompilerType &type);
+private:
+ struct DeclOrigin {
+ DeclOrigin() : ctx(nullptr), decl(nullptr) {}
- bool
- Import(const CompilerType &type);
+ DeclOrigin(clang::ASTContext *_ctx, clang::Decl *_decl)
+ : ctx(_ctx), decl(_decl) {}
- bool
- CompleteType(const CompilerType &compiler_type);
+ DeclOrigin(const DeclOrigin &rhs) {
+ ctx = rhs.ctx;
+ decl = rhs.decl;
+ }
- void
- CompleteDecl(clang::Decl *decl);
-
- bool
- CompleteTagDecl (clang::TagDecl *decl);
-
- bool
- CompleteTagDeclWithOrigin (clang::TagDecl *decl, clang::TagDecl *origin);
-
- bool
- CompleteObjCInterfaceDecl (clang::ObjCInterfaceDecl *interface_decl);
-
- bool
- CompleteAndFetchChildren (clang::QualType type);
-
- bool
- RequireCompleteType (clang::QualType type);
-
- bool
- ResolveDeclOrigin (const clang::Decl *decl, clang::Decl **original_decl, clang::ASTContext **original_ctx)
- {
- DeclOrigin origin = GetDeclOrigin(decl);
-
- if (original_decl)
- *original_decl = origin.decl;
-
- if (original_ctx)
- *original_ctx = origin.ctx;
-
- return origin.Valid();
+ void operator=(const DeclOrigin &rhs) {
+ ctx = rhs.ctx;
+ decl = rhs.decl;
}
-
- void
- SetDeclOrigin (const clang::Decl *decl, clang::Decl *original_decl);
-
- ClangASTMetadata *
- GetDeclMetadata (const clang::Decl *decl);
-
- //
- // Namespace maps
- //
-
- typedef std::vector < std::pair<lldb::ModuleSP, CompilerDeclContext> > NamespaceMap;
- typedef std::shared_ptr<NamespaceMap> NamespaceMapSP;
-
- void RegisterNamespaceMap (const clang::NamespaceDecl *decl,
- NamespaceMapSP &namespace_map);
-
- NamespaceMapSP GetNamespaceMap (const clang::NamespaceDecl *decl);
-
- void BuildNamespaceMap (const clang::NamespaceDecl *decl);
-
+
+ bool Valid() { return (ctx != nullptr || decl != nullptr); }
+
+ clang::ASTContext *ctx;
+ clang::Decl *decl;
+ };
+
+ typedef std::map<const clang::Decl *, DeclOrigin> OriginMap;
+
+ class Minion : public clang::ASTImporter {
+ public:
+ Minion(ClangASTImporter &master, clang::ASTContext *target_ctx,
+ clang::ASTContext *source_ctx)
+ : clang::ASTImporter(*target_ctx, master.m_file_manager, *source_ctx,
+ master.m_file_manager, true /*minimal*/),
+ m_decls_to_deport(nullptr), m_decls_already_deported(nullptr),
+ m_master(master), m_source_ctx(source_ctx) {}
+
+ // A call to "InitDeportWorkQueues" puts the minion into deport mode.
+ // In deport mode, every copied Decl that could require completion is
+ // recorded and placed into the decls_to_deport set.
//
- // Completers for maps
+ // A call to "ExecuteDeportWorkQueues" completes all the Decls that
+ // are in decls_to_deport, adding any Decls it sees along the way that
+ // it hasn't already deported. It proceeds until decls_to_deport is
+ // empty.
//
-
- class MapCompleter
- {
- public:
- virtual ~MapCompleter ();
-
- virtual void CompleteNamespaceMap (NamespaceMapSP &namespace_map,
- const ConstString &name,
- NamespaceMapSP &parent_map) const = 0;
- };
-
- void InstallMapCompleter (clang::ASTContext *dst_ctx, MapCompleter &completer)
- {
- ASTContextMetadataSP context_md;
- ContextMetadataMap::iterator context_md_iter = m_metadata_map.find(dst_ctx);
-
- if (context_md_iter == m_metadata_map.end())
- {
- context_md = ASTContextMetadataSP(new ASTContextMetadata(dst_ctx));
- m_metadata_map[dst_ctx] = context_md;
- }
- else
- {
- context_md = context_md_iter->second;
- }
-
- context_md->m_map_completer = &completer;
- }
-
- void ForgetDestination (clang::ASTContext *dst_ctx);
- void ForgetSource (clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx);
+ // These calls must be paired. Leaving a minion in deport mode or
+ // trying to start deport minion with a new pair of queues will result
+ // in an assertion failure.
-private:
- struct DeclOrigin
- {
- DeclOrigin () :
- ctx(nullptr),
- decl(nullptr)
- {
- }
-
- DeclOrigin (clang::ASTContext *_ctx,
- clang::Decl *_decl) :
- ctx(_ctx),
- decl(_decl)
- {
- }
-
- DeclOrigin (const DeclOrigin &rhs)
- {
- ctx = rhs.ctx;
- decl = rhs.decl;
- }
-
- void operator= (const DeclOrigin &rhs)
- {
- ctx = rhs.ctx;
- decl = rhs.decl;
- }
-
- bool
- Valid ()
- {
- return (ctx != nullptr || decl != nullptr);
- }
-
- clang::ASTContext *ctx;
- clang::Decl *decl;
- };
-
- typedef std::map<const clang::Decl *, DeclOrigin> OriginMap;
-
- class Minion : public clang::ASTImporter
- {
- public:
- Minion (ClangASTImporter &master,
- clang::ASTContext *target_ctx,
- clang::ASTContext *source_ctx) :
- clang::ASTImporter(*target_ctx,
- master.m_file_manager,
- *source_ctx,
- master.m_file_manager,
- true /*minimal*/),
- m_decls_to_deport(nullptr),
- m_decls_already_deported(nullptr),
- m_master(master),
- m_source_ctx(source_ctx)
- {
- }
-
- // A call to "InitDeportWorkQueues" puts the minion into deport mode.
- // In deport mode, every copied Decl that could require completion is
- // recorded and placed into the decls_to_deport set.
- //
- // A call to "ExecuteDeportWorkQueues" completes all the Decls that
- // are in decls_to_deport, adding any Decls it sees along the way that
- // it hasn't already deported. It proceeds until decls_to_deport is
- // empty.
- //
- // These calls must be paired. Leaving a minion in deport mode or
- // trying to start deport minion with a new pair of queues will result
- // in an assertion failure.
-
- void InitDeportWorkQueues (std::set<clang::NamedDecl *> *decls_to_deport,
- std::set<clang::NamedDecl *> *decls_already_deported);
- void ExecuteDeportWorkQueues ();
-
- void ImportDefinitionTo (clang::Decl *to, clang::Decl *from);
-
- clang::Decl *Imported(clang::Decl *from, clang::Decl *to) override;
-
- clang::Decl *GetOriginalDecl(clang::Decl *To) override;
-
- std::set<clang::NamedDecl *> *m_decls_to_deport;
- std::set<clang::NamedDecl *> *m_decls_already_deported;
- ClangASTImporter &m_master;
- clang::ASTContext *m_source_ctx;
- };
-
- typedef std::shared_ptr<Minion> MinionSP;
- typedef std::map<clang::ASTContext *, MinionSP> MinionMap;
- typedef std::map<const clang::NamespaceDecl *, NamespaceMapSP> NamespaceMetaMap;
-
- struct ASTContextMetadata
- {
- ASTContextMetadata(clang::ASTContext *dst_ctx) :
- m_dst_ctx (dst_ctx),
- m_minions (),
- m_origins (),
- m_namespace_maps (),
- m_map_completer (nullptr)
- {
- }
-
- clang::ASTContext *m_dst_ctx;
- MinionMap m_minions;
- OriginMap m_origins;
-
- NamespaceMetaMap m_namespace_maps;
- MapCompleter *m_map_completer;
- };
-
- typedef std::shared_ptr<ASTContextMetadata> ASTContextMetadataSP;
- typedef std::map<const clang::ASTContext *, ASTContextMetadataSP> ContextMetadataMap;
-
- ContextMetadataMap m_metadata_map;
-
- ASTContextMetadataSP
- GetContextMetadata (clang::ASTContext *dst_ctx)
- {
- ContextMetadataMap::iterator context_md_iter = m_metadata_map.find(dst_ctx);
-
- if (context_md_iter == m_metadata_map.end())
- {
- ASTContextMetadataSP context_md = ASTContextMetadataSP(new ASTContextMetadata(dst_ctx));
- m_metadata_map[dst_ctx] = context_md;
- return context_md;
- }
- else
- {
- return context_md_iter->second;
- }
- }
-
- ASTContextMetadataSP
- MaybeGetContextMetadata (clang::ASTContext *dst_ctx)
- {
- ContextMetadataMap::iterator context_md_iter = m_metadata_map.find(dst_ctx);
-
- if (context_md_iter != m_metadata_map.end())
- return context_md_iter->second;
- else
- return ASTContextMetadataSP();
+ void
+ InitDeportWorkQueues(std::set<clang::NamedDecl *> *decls_to_deport,
+ std::set<clang::NamedDecl *> *decls_already_deported);
+ void ExecuteDeportWorkQueues();
+
+ void ImportDefinitionTo(clang::Decl *to, clang::Decl *from);
+
+ clang::Decl *Imported(clang::Decl *from, clang::Decl *to) override;
+
+ clang::Decl *GetOriginalDecl(clang::Decl *To) override;
+
+ std::set<clang::NamedDecl *> *m_decls_to_deport;
+ std::set<clang::NamedDecl *> *m_decls_already_deported;
+ ClangASTImporter &m_master;
+ clang::ASTContext *m_source_ctx;
+ };
+
+ typedef std::shared_ptr<Minion> MinionSP;
+ typedef std::map<clang::ASTContext *, MinionSP> MinionMap;
+ typedef std::map<const clang::NamespaceDecl *, NamespaceMapSP>
+ NamespaceMetaMap;
+
+ struct ASTContextMetadata {
+ ASTContextMetadata(clang::ASTContext *dst_ctx)
+ : m_dst_ctx(dst_ctx), m_minions(), m_origins(), m_namespace_maps(),
+ m_map_completer(nullptr) {}
+
+ clang::ASTContext *m_dst_ctx;
+ MinionMap m_minions;
+ OriginMap m_origins;
+
+ NamespaceMetaMap m_namespace_maps;
+ MapCompleter *m_map_completer;
+ };
+
+ typedef std::shared_ptr<ASTContextMetadata> ASTContextMetadataSP;
+ typedef std::map<const clang::ASTContext *, ASTContextMetadataSP>
+ ContextMetadataMap;
+
+ ContextMetadataMap m_metadata_map;
+
+ ASTContextMetadataSP GetContextMetadata(clang::ASTContext *dst_ctx) {
+ ContextMetadataMap::iterator context_md_iter = m_metadata_map.find(dst_ctx);
+
+ if (context_md_iter == m_metadata_map.end()) {
+ ASTContextMetadataSP context_md =
+ ASTContextMetadataSP(new ASTContextMetadata(dst_ctx));
+ m_metadata_map[dst_ctx] = context_md;
+ return context_md;
+ } else {
+ return context_md_iter->second;
}
-
- MinionSP
- GetMinion (clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx)
- {
- ASTContextMetadataSP context_md = GetContextMetadata(dst_ctx);
-
- MinionMap &minions = context_md->m_minions;
- MinionMap::iterator minion_iter = minions.find(src_ctx);
-
- if (minion_iter == minions.end())
- {
- MinionSP minion = MinionSP(new Minion(*this, dst_ctx, src_ctx));
- minions[src_ctx] = minion;
- return minion;
- }
- else
- {
- return minion_iter->second;
- }
+ }
+
+ ASTContextMetadataSP MaybeGetContextMetadata(clang::ASTContext *dst_ctx) {
+ ContextMetadataMap::iterator context_md_iter = m_metadata_map.find(dst_ctx);
+
+ if (context_md_iter != m_metadata_map.end())
+ return context_md_iter->second;
+ else
+ return ASTContextMetadataSP();
+ }
+
+ MinionSP GetMinion(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx) {
+ ASTContextMetadataSP context_md = GetContextMetadata(dst_ctx);
+
+ MinionMap &minions = context_md->m_minions;
+ MinionMap::iterator minion_iter = minions.find(src_ctx);
+
+ if (minion_iter == minions.end()) {
+ MinionSP minion = MinionSP(new Minion(*this, dst_ctx, src_ctx));
+ minions[src_ctx] = minion;
+ return minion;
+ } else {
+ return minion_iter->second;
}
-
- DeclOrigin
- GetDeclOrigin (const clang::Decl *decl);
-
- clang::FileManager m_file_manager;
- typedef llvm::DenseMap<const clang::RecordDecl *, LayoutInfo> RecordDeclToLayoutMap;
-
- RecordDeclToLayoutMap m_record_decl_to_layout_map;
+ }
+
+ DeclOrigin GetDeclOrigin(const clang::Decl *decl);
+
+ clang::FileManager m_file_manager;
+ typedef llvm::DenseMap<const clang::RecordDecl *, LayoutInfo>
+ RecordDeclToLayoutMap;
+
+ RecordDeclToLayoutMap m_record_decl_to_layout_map;
};
-
+
} // namespace lldb_private
#endif // liblldb_ClangASTImporter_h_
diff --git a/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h b/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h
index 5a00aa0072ab..61bbc122dd5f 100644
--- a/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h
+++ b/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h
@@ -15,139 +15,131 @@
// C++ Includes
// Other libraries and framework includes
-#include "llvm/ADT/DenseMap.h"
#include "clang/AST/CharUnits.h"
+#include "llvm/ADT/DenseMap.h"
// Project includes
-#include "lldb/lldb-enumerations.h"
#include "lldb/Core/ClangForward.h"
-#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
+#include "lldb/Symbol/CompilerType.h"
+#include "lldb/lldb-enumerations.h"
namespace lldb_private {
-class ClangExternalASTSourceCallbacks : public ClangExternalASTSourceCommon
-{
+class ClangExternalASTSourceCallbacks : public ClangExternalASTSourceCommon {
public:
- typedef void (*CompleteTagDeclCallback)(void *baton, clang::TagDecl *);
- typedef void (*CompleteObjCInterfaceDeclCallback)(void *baton, clang::ObjCInterfaceDecl *);
- typedef void (*FindExternalVisibleDeclsByNameCallback)(void *baton, const clang::DeclContext *DC, clang::DeclarationName Name, llvm::SmallVectorImpl <clang::NamedDecl *> *results);
- typedef bool (*LayoutRecordTypeCallback)(
- void *baton, const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
- llvm::DenseMap<const clang::FieldDecl *, uint64_t> &FieldOffsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &BaseOffsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &VirtualBaseOffsets);
-
- ClangExternalASTSourceCallbacks (CompleteTagDeclCallback tag_decl_callback,
- CompleteObjCInterfaceDeclCallback objc_decl_callback,
- FindExternalVisibleDeclsByNameCallback find_by_name_callback,
- LayoutRecordTypeCallback layout_record_type_callback,
- void *callback_baton) :
- m_callback_tag_decl (tag_decl_callback),
- m_callback_objc_decl (objc_decl_callback),
- m_callback_find_by_name (find_by_name_callback),
- m_callback_layout_record_type (layout_record_type_callback),
- m_callback_baton (callback_baton)
- {
- }
-
- //------------------------------------------------------------------
- // clang::ExternalASTSource
- //------------------------------------------------------------------
-
- clang::Decl *
- GetExternalDecl(uint32_t ID) override
- {
- // This method only needs to be implemented if the AST source ever
- // passes back decl sets as VisibleDeclaration objects.
- return nullptr;
- }
-
- clang::Stmt *
- GetExternalDeclStmt(uint64_t Offset) override
- {
- // This operation is meant to be used via a LazyOffsetPtr. It only
- // needs to be implemented if the AST source uses methods like
- // FunctionDecl::setLazyBody when building decls.
- return nullptr;
- }
-
- clang::Selector
- GetExternalSelector(uint32_t ID) override
- {
- // This operation only needs to be implemented if the AST source
- // returns non-zero for GetNumKnownSelectors().
- return clang::Selector();
- }
-
- uint32_t
- GetNumExternalSelectors() override
- {
- return 0;
- }
-
- clang::CXXBaseSpecifier *
- GetExternalCXXBaseSpecifiers(uint64_t Offset) override
- {
- return nullptr;
- }
-
- virtual void
- MaterializeVisibleDecls (const clang::DeclContext *decl_ctx)
- {
- }
-
- void
- FindExternalLexicalDecls(const clang::DeclContext *DC,
- llvm::function_ref<bool(clang::Decl::Kind)> IsKindWeWant,
- llvm::SmallVectorImpl<clang::Decl *> &Result) override;
-
- bool FindExternalVisibleDeclsByName(const clang::DeclContext *decl_ctx, clang::DeclarationName decl_name) override;
-
- void CompleteType(clang::TagDecl *tag_decl) override;
-
- void CompleteType(clang::ObjCInterfaceDecl *objc_decl) override;
-
- bool layoutRecordType(const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
- llvm::DenseMap<const clang::FieldDecl *, uint64_t> &FieldOffsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &BaseOffsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &VirtualBaseOffsets) override;
-
- void
- SetExternalSourceCallbacks (CompleteTagDeclCallback tag_decl_callback,
- CompleteObjCInterfaceDeclCallback objc_decl_callback,
- FindExternalVisibleDeclsByNameCallback find_by_name_callback,
- LayoutRecordTypeCallback layout_record_type_callback,
- void *callback_baton)
- {
- m_callback_tag_decl = tag_decl_callback;
- m_callback_objc_decl = objc_decl_callback;
- m_callback_find_by_name = find_by_name_callback;
- m_callback_layout_record_type = layout_record_type_callback;
- m_callback_baton = callback_baton;
- }
-
- void
- RemoveExternalSourceCallbacks (void *callback_baton)
- {
- if (callback_baton == m_callback_baton)
- {
- m_callback_tag_decl = nullptr;
- m_callback_objc_decl = nullptr;
- m_callback_find_by_name = nullptr;
- m_callback_layout_record_type = nullptr;
- }
+ typedef void (*CompleteTagDeclCallback)(void *baton, clang::TagDecl *);
+ typedef void (*CompleteObjCInterfaceDeclCallback)(void *baton,
+ clang::ObjCInterfaceDecl *);
+ typedef void (*FindExternalVisibleDeclsByNameCallback)(
+ void *baton, const clang::DeclContext *DC, clang::DeclarationName Name,
+ llvm::SmallVectorImpl<clang::NamedDecl *> *results);
+ typedef bool (*LayoutRecordTypeCallback)(
+ void *baton, const clang::RecordDecl *Record, uint64_t &Size,
+ uint64_t &Alignment,
+ llvm::DenseMap<const clang::FieldDecl *, uint64_t> &FieldOffsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
+ &BaseOffsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
+ &VirtualBaseOffsets);
+
+ ClangExternalASTSourceCallbacks(
+ CompleteTagDeclCallback tag_decl_callback,
+ CompleteObjCInterfaceDeclCallback objc_decl_callback,
+ FindExternalVisibleDeclsByNameCallback find_by_name_callback,
+ LayoutRecordTypeCallback layout_record_type_callback,
+ void *callback_baton)
+ : m_callback_tag_decl(tag_decl_callback),
+ m_callback_objc_decl(objc_decl_callback),
+ m_callback_find_by_name(find_by_name_callback),
+ m_callback_layout_record_type(layout_record_type_callback),
+ m_callback_baton(callback_baton) {}
+
+ //------------------------------------------------------------------
+ // clang::ExternalASTSource
+ //------------------------------------------------------------------
+
+ clang::Decl *GetExternalDecl(uint32_t ID) override {
+ // This method only needs to be implemented if the AST source ever
+ // passes back decl sets as VisibleDeclaration objects.
+ return nullptr;
+ }
+
+ clang::Stmt *GetExternalDeclStmt(uint64_t Offset) override {
+ // This operation is meant to be used via a LazyOffsetPtr. It only
+ // needs to be implemented if the AST source uses methods like
+ // FunctionDecl::setLazyBody when building decls.
+ return nullptr;
+ }
+
+ clang::Selector GetExternalSelector(uint32_t ID) override {
+ // This operation only needs to be implemented if the AST source
+ // returns non-zero for GetNumKnownSelectors().
+ return clang::Selector();
+ }
+
+ uint32_t GetNumExternalSelectors() override { return 0; }
+
+ clang::CXXBaseSpecifier *
+ GetExternalCXXBaseSpecifiers(uint64_t Offset) override {
+ return nullptr;
+ }
+
+ virtual void MaterializeVisibleDecls(const clang::DeclContext *decl_ctx) {}
+
+ void FindExternalLexicalDecls(
+ const clang::DeclContext *DC,
+ llvm::function_ref<bool(clang::Decl::Kind)> IsKindWeWant,
+ llvm::SmallVectorImpl<clang::Decl *> &Result) override;
+
+ bool
+ FindExternalVisibleDeclsByName(const clang::DeclContext *decl_ctx,
+ clang::DeclarationName decl_name) override;
+
+ void CompleteType(clang::TagDecl *tag_decl) override;
+
+ void CompleteType(clang::ObjCInterfaceDecl *objc_decl) override;
+
+ bool layoutRecordType(
+ const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
+ llvm::DenseMap<const clang::FieldDecl *, uint64_t> &FieldOffsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
+ &BaseOffsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
+ &VirtualBaseOffsets) override;
+
+ void SetExternalSourceCallbacks(
+ CompleteTagDeclCallback tag_decl_callback,
+ CompleteObjCInterfaceDeclCallback objc_decl_callback,
+ FindExternalVisibleDeclsByNameCallback find_by_name_callback,
+ LayoutRecordTypeCallback layout_record_type_callback,
+ void *callback_baton) {
+ m_callback_tag_decl = tag_decl_callback;
+ m_callback_objc_decl = objc_decl_callback;
+ m_callback_find_by_name = find_by_name_callback;
+ m_callback_layout_record_type = layout_record_type_callback;
+ m_callback_baton = callback_baton;
+ }
+
+ void RemoveExternalSourceCallbacks(void *callback_baton) {
+ if (callback_baton == m_callback_baton) {
+ m_callback_tag_decl = nullptr;
+ m_callback_objc_decl = nullptr;
+ m_callback_find_by_name = nullptr;
+ m_callback_layout_record_type = nullptr;
}
+ }
protected:
- //------------------------------------------------------------------
- // Classes that inherit from ClangExternalASTSourceCallbacks can see and modify these
- //------------------------------------------------------------------
- CompleteTagDeclCallback m_callback_tag_decl;
- CompleteObjCInterfaceDeclCallback m_callback_objc_decl;
- FindExternalVisibleDeclsByNameCallback m_callback_find_by_name;
- LayoutRecordTypeCallback m_callback_layout_record_type;
- void * m_callback_baton;
+ //------------------------------------------------------------------
+ // Classes that inherit from ClangExternalASTSourceCallbacks can see and
+ // modify these
+ //------------------------------------------------------------------
+ CompleteTagDeclCallback m_callback_tag_decl;
+ CompleteObjCInterfaceDeclCallback m_callback_objc_decl;
+ FindExternalVisibleDeclsByNameCallback m_callback_find_by_name;
+ LayoutRecordTypeCallback m_callback_layout_record_type;
+ void *m_callback_baton;
};
} // namespace lldb_private
diff --git a/include/lldb/Symbol/ClangExternalASTSourceCommon.h b/include/lldb/Symbol/ClangExternalASTSourceCommon.h
index 711be42c15fb..3e700ba2439c 100644
--- a/include/lldb/Symbol/ClangExternalASTSourceCommon.h
+++ b/include/lldb/Symbol/ClangExternalASTSourceCommon.h
@@ -10,7 +10,7 @@
#ifndef liblldb_ClangExternalASTSourceCommon_h
#define liblldb_ClangExternalASTSourceCommon_h
-// Clang headers like to use NDEBUG inside of them to enable/disable debug
+// Clang headers like to use NDEBUG inside of them to enable/disable debug
// related features using "#ifndef NDEBUG" preprocessor blocks to do one thing
// or another. This is bad because it means that if clang was built in release
// mode, it assumes that you are building in release mode which is not always
@@ -40,150 +40,107 @@
#include "clang/AST/ExternalASTSource.h"
// Project includes
+#include "lldb/Core/dwarf.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-enumerations.h"
-#include "lldb/Core/dwarf.h"
namespace lldb_private {
-class ClangASTMetadata
-{
+class ClangASTMetadata {
public:
- ClangASTMetadata () :
- m_user_id(0),
- m_union_is_user_id(false),
- m_union_is_isa_ptr(false),
- m_has_object_ptr(false),
- m_is_self (false),
- m_is_dynamic_cxx (true)
- {
- }
-
- bool
- GetIsDynamicCXXType () const
- {
- return m_is_dynamic_cxx;
- }
-
- void
- SetIsDynamicCXXType (bool b)
- {
- m_is_dynamic_cxx = b;
+ ClangASTMetadata()
+ : m_user_id(0), m_union_is_user_id(false), m_union_is_isa_ptr(false),
+ m_has_object_ptr(false), m_is_self(false), m_is_dynamic_cxx(true) {}
+
+ bool GetIsDynamicCXXType() const { return m_is_dynamic_cxx; }
+
+ void SetIsDynamicCXXType(bool b) { m_is_dynamic_cxx = b; }
+
+ void SetUserID(lldb::user_id_t user_id) {
+ m_user_id = user_id;
+ m_union_is_user_id = true;
+ m_union_is_isa_ptr = false;
+ }
+
+ lldb::user_id_t GetUserID() const {
+ if (m_union_is_user_id)
+ return m_user_id;
+ else
+ return LLDB_INVALID_UID;
+ }
+
+ void SetISAPtr(uint64_t isa_ptr) {
+ m_isa_ptr = isa_ptr;
+ m_union_is_user_id = false;
+ m_union_is_isa_ptr = true;
+ }
+
+ uint64_t GetISAPtr() const {
+ if (m_union_is_isa_ptr)
+ return m_isa_ptr;
+ else
+ return 0;
+ }
+
+ void SetObjectPtrName(const char *name) {
+ m_has_object_ptr = true;
+ if (strcmp(name, "self") == 0)
+ m_is_self = true;
+ else if (strcmp(name, "this") == 0)
+ m_is_self = false;
+ else
+ m_has_object_ptr = false;
+ }
+
+ lldb::LanguageType GetObjectPtrLanguage() const {
+ if (m_has_object_ptr) {
+ if (m_is_self)
+ return lldb::eLanguageTypeObjC;
+ else
+ return lldb::eLanguageTypeC_plus_plus;
}
+ return lldb::eLanguageTypeUnknown;
+ }
- void
- SetUserID (lldb::user_id_t user_id)
- {
- m_user_id = user_id;
- m_union_is_user_id = true;
- m_union_is_isa_ptr = false;
- }
+ const char *GetObjectPtrName() const {
+ if (m_has_object_ptr) {
+ if (m_is_self)
+ return "self";
+ else
+ return "this";
+ } else
+ return nullptr;
+ }
- lldb::user_id_t
- GetUserID () const
- {
- if (m_union_is_user_id)
- return m_user_id;
- else
- return LLDB_INVALID_UID;
- }
+ bool HasObjectPtr() const { return m_has_object_ptr; }
- void
- SetISAPtr (uint64_t isa_ptr)
- {
- m_isa_ptr = isa_ptr;
- m_union_is_user_id = false;
- m_union_is_isa_ptr = true;
- }
-
- uint64_t
- GetISAPtr () const
- {
- if (m_union_is_isa_ptr)
- return m_isa_ptr;
- else
- return 0;
- }
-
- void
- SetObjectPtrName(const char *name)
- {
- m_has_object_ptr = true;
- if (strcmp (name, "self") == 0)
- m_is_self = true;
- else if (strcmp (name, "this") == 0)
- m_is_self = false;
- else
- m_has_object_ptr = false;
- }
-
- lldb::LanguageType
- GetObjectPtrLanguage () const
- {
- if (m_has_object_ptr)
- {
- if (m_is_self)
- return lldb::eLanguageTypeObjC;
- else
- return lldb::eLanguageTypeC_plus_plus;
- }
- return lldb::eLanguageTypeUnknown;
- }
+ void Dump(Stream *s);
- const char *
- GetObjectPtrName() const
- {
- if (m_has_object_ptr)
- {
- if (m_is_self)
- return "self";
- else
- return "this";
- }
- else
- return nullptr;
- }
-
- bool
- HasObjectPtr() const
- {
- return m_has_object_ptr;
- }
-
- void
- Dump (Stream *s);
-
private:
- union
- {
- lldb::user_id_t m_user_id;
- uint64_t m_isa_ptr;
- };
-
- bool m_union_is_user_id : 1,
- m_union_is_isa_ptr : 1,
- m_has_object_ptr : 1,
- m_is_self : 1,
- m_is_dynamic_cxx : 1;
+ union {
+ lldb::user_id_t m_user_id;
+ uint64_t m_isa_ptr;
+ };
+
+ bool m_union_is_user_id : 1, m_union_is_isa_ptr : 1, m_has_object_ptr : 1,
+ m_is_self : 1, m_is_dynamic_cxx : 1;
};
-class ClangExternalASTSourceCommon : public clang::ExternalASTSource
-{
+class ClangExternalASTSourceCommon : public clang::ExternalASTSource {
public:
- ClangExternalASTSourceCommon();
- ~ClangExternalASTSourceCommon() override;
-
- ClangASTMetadata *GetMetadata(const void *object);
- void SetMetadata(const void *object, ClangASTMetadata &metadata);
- bool HasMetadata(const void *object);
-
- static ClangExternalASTSourceCommon *
- Lookup(clang::ExternalASTSource *source);
-
-private:
- typedef llvm::DenseMap<const void *, ClangASTMetadata> MetadataMap;
-
- MetadataMap m_metadata;
+ ClangExternalASTSourceCommon();
+ ~ClangExternalASTSourceCommon() override;
+
+ ClangASTMetadata *GetMetadata(const void *object);
+ void SetMetadata(const void *object, ClangASTMetadata &metadata);
+ bool HasMetadata(const void *object);
+
+ static ClangExternalASTSourceCommon *Lookup(clang::ExternalASTSource *source);
+
+private:
+ typedef llvm::DenseMap<const void *, ClangASTMetadata> MetadataMap;
+
+ MetadataMap m_metadata;
};
} // namespace lldb_private
diff --git a/include/lldb/Symbol/ClangUtil.h b/include/lldb/Symbol/ClangUtil.h
index ee9ff5678d79..cb380221152a 100644
--- a/include/lldb/Symbol/ClangUtil.h
+++ b/include/lldb/Symbol/ClangUtil.h
@@ -16,21 +16,15 @@
#include "lldb/Symbol/CompilerType.h"
-namespace lldb_private
-{
-struct ClangUtil
-{
- static bool
- IsClangType(const CompilerType &ct);
+namespace lldb_private {
+struct ClangUtil {
+ static bool IsClangType(const CompilerType &ct);
- static clang::QualType
- GetQualType(const CompilerType &ct);
+ static clang::QualType GetQualType(const CompilerType &ct);
- static clang::QualType
- GetCanonicalQualType(const CompilerType &ct);
+ static clang::QualType GetCanonicalQualType(const CompilerType &ct);
- static CompilerType
- RemoveFastQualifiers(const CompilerType &ct);
+ static CompilerType RemoveFastQualifiers(const CompilerType &ct);
};
}
diff --git a/include/lldb/Symbol/CompactUnwindInfo.h b/include/lldb/Symbol/CompactUnwindInfo.h
index 6bf65a223471..133a886812b3 100644
--- a/include/lldb/Symbol/CompactUnwindInfo.h
+++ b/include/lldb/Symbol/CompactUnwindInfo.h
@@ -21,141 +21,156 @@
namespace lldb_private {
-// Compact Unwind info is an unwind format used on Darwin. The unwind instructions
-// for typical compiler-generated functions can be expressed in a 32-bit encoding.
-// The format includes a two-level index so the unwind information for a function
+// Compact Unwind info is an unwind format used on Darwin. The unwind
+// instructions
+// for typical compiler-generated functions can be expressed in a 32-bit
+// encoding.
+// The format includes a two-level index so the unwind information for a
+// function
// can be found by two binary searches in the section. It can represent both
// stack frames that use a frame-pointer register and frameless functions, on
-// i386/x86_64 for instance. When a function is too complex to be represented in
+// i386/x86_64 for instance. When a function is too complex to be represented
+// in
// the compact unwind format, it calls out to eh_frame unwind instructions.
-// On Mac OS X / iOS, a function will have either a compact unwind representation
-// or an eh_frame representation. If lldb is going to benefit from the compiler's
-// description about saved register locations, it must be able to read both
+// On Mac OS X / iOS, a function will have either a compact unwind
+// representation
+// or an eh_frame representation. If lldb is going to benefit from the
+// compiler's
+// description about saved register locations, it must be able to read both
// sources of information.
-class CompactUnwindInfo
-{
+class CompactUnwindInfo {
public:
+ CompactUnwindInfo(ObjectFile &objfile, lldb::SectionSP &section);
- CompactUnwindInfo (ObjectFile& objfile,
- lldb::SectionSP& section);
+ ~CompactUnwindInfo();
- ~CompactUnwindInfo();
+ bool GetUnwindPlan(Target &target, Address addr, UnwindPlan &unwind_plan);
- bool
- GetUnwindPlan (Target &target, Address addr, UnwindPlan& unwind_plan);
-
- bool
- IsValid (const lldb::ProcessSP &process_sp);
+ bool IsValid(const lldb::ProcessSP &process_sp);
private:
-
-
- // The top level index entries of the compact unwind info
- // (internal representation of struct unwind_info_section_header_index_entry)
- // There are relatively few of these (one per 500/1000 functions, depending on format) so
- // creating them on first scan will not be too costly.
- struct UnwindIndex
- {
- uint32_t function_offset; // The offset of the first function covered by this index
- uint32_t second_level; // The offset (inside unwind_info sect) to the second level page for this index
- // (either UNWIND_SECOND_LEVEL_REGULAR or UNWIND_SECOND_LEVEL_COMPRESSED)
- uint32_t lsda_array_start;// The offset (inside unwind_info sect) LSDA array for this index
- uint32_t lsda_array_end; // The offset to the LSDA array for the NEXT index
- bool sentinal_entry; // There is an empty index at the end which provides the upper bound of
- // function addresses that are described
-
- UnwindIndex() :
- function_offset (0),
- second_level (0),
- lsda_array_start(0),
- lsda_array_end(0),
- sentinal_entry (false)
- { }
-
- bool
- operator< (const CompactUnwindInfo::UnwindIndex& rhs) const
- {
- return function_offset < rhs.function_offset;
- }
-
- bool
- operator== (const CompactUnwindInfo::UnwindIndex& rhs) const
- {
- return function_offset == rhs.function_offset;
- }
-
- };
-
- // An internal object used to store the information we retrieve about a function --
- // the encoding bits and possibly the LSDA/personality function.
- struct FunctionInfo
- {
- uint32_t encoding; // compact encoding 32-bit value for this function
- Address lsda_address; // the address of the LSDA data for this function
- Address personality_ptr_address; // the address where the personality routine addr can be found
-
- uint32_t valid_range_offset_start; // first offset that this encoding is valid for (start of the function)
- uint32_t valid_range_offset_end; // the offset of the start of the next function
- FunctionInfo () : encoding(0), lsda_address(), personality_ptr_address(), valid_range_offset_start(0), valid_range_offset_end(0) { }
- };
-
- struct UnwindHeader
- {
- uint32_t version;
- uint32_t common_encodings_array_offset;
- uint32_t common_encodings_array_count;
- uint32_t personality_array_offset;
- uint32_t personality_array_count;
-
- UnwindHeader () : common_encodings_array_offset (0), common_encodings_array_count (0), personality_array_offset (0), personality_array_count (0) { }
- };
-
- void
- ScanIndex(const lldb::ProcessSP &process_sp);
-
- bool
- GetCompactUnwindInfoForFunction (Target &target, Address address, FunctionInfo &unwind_info);
-
- lldb::offset_t
- BinarySearchRegularSecondPage (uint32_t entry_page_offset, uint32_t entry_count, uint32_t function_offset, uint32_t *entry_func_start_offset, uint32_t *entry_func_end_offset);
-
+ // The top level index entries of the compact unwind info
+ // (internal representation of struct
+ // unwind_info_section_header_index_entry)
+ // There are relatively few of these (one per 500/1000 functions, depending on
+ // format) so
+ // creating them on first scan will not be too costly.
+ struct UnwindIndex {
+ uint32_t function_offset; // The offset of the first function covered by
+ // this index
+ uint32_t second_level; // The offset (inside unwind_info sect) to the second
+ // level page for this index
+ // (either UNWIND_SECOND_LEVEL_REGULAR or UNWIND_SECOND_LEVEL_COMPRESSED)
+ uint32_t lsda_array_start; // The offset (inside unwind_info sect) LSDA
+ // array for this index
+ uint32_t lsda_array_end; // The offset to the LSDA array for the NEXT index
+ bool sentinal_entry; // There is an empty index at the end which provides
+ // the upper bound of
+ // function addresses that are described
+
+ UnwindIndex()
+ : function_offset(0), second_level(0), lsda_array_start(0),
+ lsda_array_end(0), sentinal_entry(false) {}
+
+ bool operator<(const CompactUnwindInfo::UnwindIndex &rhs) const {
+ return function_offset < rhs.function_offset;
+ }
+
+ bool operator==(const CompactUnwindInfo::UnwindIndex &rhs) const {
+ return function_offset == rhs.function_offset;
+ }
+ };
+
+ // An internal object used to store the information we retrieve about a
+ // function --
+ // the encoding bits and possibly the LSDA/personality function.
+ struct FunctionInfo {
+ uint32_t encoding; // compact encoding 32-bit value for this function
+ Address lsda_address; // the address of the LSDA data for this function
+ Address personality_ptr_address; // the address where the personality
+ // routine addr can be found
+
+ uint32_t valid_range_offset_start; // first offset that this encoding is
+ // valid for (start of the function)
uint32_t
- BinarySearchCompressedSecondPage (uint32_t entry_page_offset, uint32_t entry_count, uint32_t function_offset_to_find, uint32_t function_offset_base, uint32_t *entry_func_start_offset, uint32_t *entry_func_end_offset);
-
- uint32_t
- GetLSDAForFunctionOffset (uint32_t lsda_offset, uint32_t lsda_count, uint32_t function_offset);
-
- bool
- CreateUnwindPlan_x86_64 (Target &target, FunctionInfo &function_info, UnwindPlan &unwind_plan, Address pc_or_function_start);
-
- bool
- CreateUnwindPlan_i386 (Target &target, FunctionInfo &function_info, UnwindPlan &unwind_plan, Address pc_or_function_start);
-
- bool
- CreateUnwindPlan_arm64 (Target &target, FunctionInfo &function_info, UnwindPlan &unwind_plan, Address pc_or_function_start);
-
- bool
- CreateUnwindPlan_armv7 (Target &target, FunctionInfo &function_info, UnwindPlan &unwind_plan, Address pc_or_function_start);
-
- ObjectFile &m_objfile;
- lldb::SectionSP m_section_sp;
- lldb::DataBufferSP m_section_contents_if_encrypted; // if the binary is encrypted, read the sect contents
- // out of live memory and cache them here
- std::mutex m_mutex;
- std::vector<UnwindIndex> m_indexes;
-
- LazyBool m_indexes_computed; // eLazyBoolYes once we've tried to parse the unwind info
- // eLazyBoolNo means we cannot parse the unwind info & should not retry
- // eLazyBoolCalculate means we haven't tried to parse it yet
-
- DataExtractor m_unwindinfo_data;
- bool m_unwindinfo_data_computed; // true once we've mapped in the unwindinfo data
-
- UnwindHeader m_unwind_header;
+ valid_range_offset_end; // the offset of the start of the next function
+ FunctionInfo()
+ : encoding(0), lsda_address(), personality_ptr_address(),
+ valid_range_offset_start(0), valid_range_offset_end(0) {}
+ };
+
+ struct UnwindHeader {
+ uint32_t version;
+ uint32_t common_encodings_array_offset;
+ uint32_t common_encodings_array_count;
+ uint32_t personality_array_offset;
+ uint32_t personality_array_count;
+
+ UnwindHeader()
+ : common_encodings_array_offset(0), common_encodings_array_count(0),
+ personality_array_offset(0), personality_array_count(0) {}
+ };
+
+ void ScanIndex(const lldb::ProcessSP &process_sp);
+
+ bool GetCompactUnwindInfoForFunction(Target &target, Address address,
+ FunctionInfo &unwind_info);
+
+ lldb::offset_t
+ BinarySearchRegularSecondPage(uint32_t entry_page_offset,
+ uint32_t entry_count, uint32_t function_offset,
+ uint32_t *entry_func_start_offset,
+ uint32_t *entry_func_end_offset);
+
+ uint32_t BinarySearchCompressedSecondPage(uint32_t entry_page_offset,
+ uint32_t entry_count,
+ uint32_t function_offset_to_find,
+ uint32_t function_offset_base,
+ uint32_t *entry_func_start_offset,
+ uint32_t *entry_func_end_offset);
+
+ uint32_t GetLSDAForFunctionOffset(uint32_t lsda_offset, uint32_t lsda_count,
+ uint32_t function_offset);
+
+ bool CreateUnwindPlan_x86_64(Target &target, FunctionInfo &function_info,
+ UnwindPlan &unwind_plan,
+ Address pc_or_function_start);
+
+ bool CreateUnwindPlan_i386(Target &target, FunctionInfo &function_info,
+ UnwindPlan &unwind_plan,
+ Address pc_or_function_start);
+
+ bool CreateUnwindPlan_arm64(Target &target, FunctionInfo &function_info,
+ UnwindPlan &unwind_plan,
+ Address pc_or_function_start);
+
+ bool CreateUnwindPlan_armv7(Target &target, FunctionInfo &function_info,
+ UnwindPlan &unwind_plan,
+ Address pc_or_function_start);
+
+ ObjectFile &m_objfile;
+ lldb::SectionSP m_section_sp;
+ lldb::DataBufferSP m_section_contents_if_encrypted; // if the binary is
+ // encrypted, read the
+ // sect contents
+ // out of live memory and cache them here
+ std::mutex m_mutex;
+ std::vector<UnwindIndex> m_indexes;
+
+ LazyBool m_indexes_computed; // eLazyBoolYes once we've tried to parse the
+ // unwind info
+ // eLazyBoolNo means we cannot parse the unwind info & should not retry
+ // eLazyBoolCalculate means we haven't tried to parse it yet
+
+ DataExtractor m_unwindinfo_data;
+ bool m_unwindinfo_data_computed; // true once we've mapped in the unwindinfo
+ // data
+
+ UnwindHeader m_unwind_header;
};
} // namespace lldb_private
-#endif // liblldb_CompactUnwindInfo_h_
+#endif // liblldb_CompactUnwindInfo_h_
diff --git a/include/lldb/Symbol/CompileUnit.h b/include/lldb/Symbol/CompileUnit.h
index 2f596f89ec5f..8465f3bb5777 100644
--- a/include/lldb/Symbol/CompileUnit.h
+++ b/include/lldb/Symbol/CompileUnit.h
@@ -10,13 +10,13 @@
#ifndef liblldb_CompUnit_h_
#define liblldb_CompUnit_h_
-#include "lldb/lldb-enumerations.h"
-#include "lldb/Symbol/DebugMacros.h"
-#include "lldb/Symbol/Function.h"
#include "lldb/Core/FileSpecList.h"
#include "lldb/Core/ModuleChild.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/UserID.h"
+#include "lldb/Symbol/DebugMacros.h"
+#include "lldb/Symbol/Function.h"
+#include "lldb/lldb-enumerations.h"
namespace lldb_private {
//----------------------------------------------------------------------
@@ -32,445 +32,433 @@ namespace lldb_private {
/// variables, support file list (include files and inlined source
/// files), and a line table.
//----------------------------------------------------------------------
-class CompileUnit :
- public std::enable_shared_from_this<CompileUnit>,
- public ModuleChild,
- public FileSpec,
- public UserID,
- public SymbolContextScope
-{
+class CompileUnit : public std::enable_shared_from_this<CompileUnit>,
+ public ModuleChild,
+ public FileSpec,
+ public UserID,
+ public SymbolContextScope {
public:
- //------------------------------------------------------------------
- /// Construct with a module, path, UID and language.
- ///
- /// Initialize the compile unit given the owning \a module, a path
- /// to convert into a FileSpec, the SymbolFile plug-in supplied
- /// \a uid, and the source language type.
- ///
- /// @param[in] module
- /// The parent module that owns this compile unit. This value
- /// must be a valid pointer value.
- ///
- /// @param[in] user_data
- /// User data where the SymbolFile parser can store data.
- ///
- /// @param[in] pathname
- /// The path to the source file for this compile unit.
- ///
- /// @param[in] uid
- /// The user ID of the compile unit. This value is supplied by
- /// the SymbolFile plug-in and should be a value that allows
- /// the SymbolFile plug-in to easily locate and parse additional
- /// information for the compile unit.
- ///
- /// @param[in] language
- /// A language enumeration type that describes the main language
- /// of this compile unit.
- ///
- /// @param[in] is_optimized
- /// A value that can initialized with eLazyBoolYes, eLazyBoolNo
- /// or eLazyBoolCalculate. If set to eLazyBoolCalculate, then
- /// an extra call into SymbolVendor will be made to calculate if
- /// the compile unit is optimized will be made when
- /// CompileUnit::GetIsOptimized() is called.
- ///
- /// @see lldb::LanguageType
- //------------------------------------------------------------------
- CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const char *pathname, lldb::user_id_t uid,
- lldb::LanguageType language, lldb_private::LazyBool is_optimized);
-
- //------------------------------------------------------------------
- /// Construct with a module, file spec, UID and language.
- ///
- /// Initialize the compile unit given the owning \a module, a path
- /// to convert into a FileSpec, the SymbolFile plug-in supplied
- /// \a uid, and the source language type.
- ///
- /// @param[in] module
- /// The parent module that owns this compile unit. This value
- /// must be a valid pointer value.
- ///
- /// @param[in] user_data
- /// User data where the SymbolFile parser can store data.
- ///
- /// @param[in] file_spec
- /// The file specification for the source file of this compile
- /// unit.
- ///
- /// @param[in] uid
- /// The user ID of the compile unit. This value is supplied by
- /// the SymbolFile plug-in and should be a value that allows
- /// the plug-in to easily locate and parse
- /// additional information for the compile unit.
- ///
- /// @param[in] language
- /// A language enumeration type that describes the main language
- /// of this compile unit.
- ///
- /// @param[in] is_optimized
- /// A value that can initialized with eLazyBoolYes, eLazyBoolNo
- /// or eLazyBoolCalculate. If set to eLazyBoolCalculate, then
- /// an extra call into SymbolVendor will be made to calculate if
- /// the compile unit is optimized will be made when
- /// CompileUnit::GetIsOptimized() is called.
- ///
- /// @see lldb::LanguageType
- //------------------------------------------------------------------
- CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const FileSpec &file_spec, lldb::user_id_t uid,
- lldb::LanguageType language, lldb_private::LazyBool is_optimized);
-
- //------------------------------------------------------------------
- /// Destructor
- //------------------------------------------------------------------
- ~CompileUnit() override;
-
- //------------------------------------------------------------------
- /// Add a function to this compile unit.
- ///
- /// Typically called by the SymbolFile plug-ins as they partially
- /// parse the debug information.
- ///
- /// @param[in] function_sp
- /// A shared pointer to the Function object.
- //------------------------------------------------------------------
- void
- AddFunction(lldb::FunctionSP& function_sp);
-
- //------------------------------------------------------------------
- /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
- ///
- /// @see SymbolContextScope
- //------------------------------------------------------------------
- void
- CalculateSymbolContext(SymbolContext* sc) override;
-
- lldb::ModuleSP
- CalculateSymbolContextModule() override;
-
- CompileUnit *
- CalculateSymbolContextCompileUnit() override;
-
- //------------------------------------------------------------------
- /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
- ///
- /// @see SymbolContextScope
- //------------------------------------------------------------------
- void
- DumpSymbolContext(Stream *s) override;
-
- lldb::LanguageType
- GetLanguage();
-
- void
- SetLanguage(lldb::LanguageType language)
- {
- m_flags.Set(flagsParsedLanguage);
- m_language = language;
- }
-
- void
- GetDescription(Stream *s, lldb::DescriptionLevel level) const;
-
- //------------------------------------------------------------------
- /// Get a shared pointer to a function in this compile unit by
- /// index.
- ///
- /// Typically called when iterating though all functions in a
- /// compile unit after all functions have been parsed. This provides
- /// raw access to the function shared pointer list and will not
- /// cause the SymbolFile plug-in to parse any unparsed functions.
- ///
- /// @param[in] idx
- /// An index into the function list.
- ///
- /// @return
- /// A shared pointer to a function that might contain a NULL
- /// Function class pointer.
- //------------------------------------------------------------------
- lldb::FunctionSP
- GetFunctionAtIndex (size_t idx);
-
- //------------------------------------------------------------------
- /// Dump the compile unit contents to the stream \a s.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- ///
- /// @param[in] show_context
- /// If \b true, variables will dump their symbol context
- /// information.
- //------------------------------------------------------------------
- void
- Dump (Stream *s, bool show_context) const;
-
- //------------------------------------------------------------------
- /// Find the line entry by line and optional inlined file spec.
- ///
- /// Finds the first line entry that has an index greater than
- /// \a start_idx that matches \a line. If \a file_spec_ptr
- /// is NULL, then the search matches line entries whose file matches
- /// the file for the compile unit. If \a file_spec_ptr is
- /// not NULL, line entries must match the specified file spec (for
- /// inlined line table entries).
- ///
- /// Multiple calls to this function can find all entries that match
- /// a given file and line by starting with \a start_idx equal to zero,
- /// and calling this function back with the return value + 1.
- ///
- /// @param[in] start_idx
- /// The zero based index at which to start looking for matches.
- ///
- /// @param[in] line
- /// The line number to search for.
- ///
- /// @param[in] file_spec_ptr
- /// If non-NULL search for entries that match this file spec,
- /// else if NULL, search for line entries that match the compile
- /// unit file.
- ///
- /// @param[in] exact
- /// If \btrue match only if there is a line table entry for this line number.
- /// If \bfalse, find the line table entry equal to or after this line number.
- ///
- /// @param[out] line_entry
- /// If non-NULL, a copy of the line entry that was found.
- ///
- /// @return
- /// The zero based index of a matching line entry, or UINT32_MAX
- /// if no matching line entry is found.
- //------------------------------------------------------------------
- uint32_t
- FindLineEntry (uint32_t start_idx,
- uint32_t line,
- const FileSpec* file_spec_ptr,
- bool exact,
- LineEntry *line_entry);
-
- //------------------------------------------------------------------
- /// Get the line table for the compile unit.
- ///
- /// Called by clients and the SymbolFile plug-in. The SymbolFile
- /// plug-ins use this function to determine if the line table has
- /// be parsed yet. Clients use this function to get the line table
- /// from a compile unit.
- ///
- /// @return
- /// The line table object pointer, or NULL if this line table
- /// hasn't been parsed yet.
- //------------------------------------------------------------------
- LineTable*
- GetLineTable ();
-
- DebugMacros*
- GetDebugMacros ();
-
- //------------------------------------------------------------------
- /// Get the compile unit's support file list.
- ///
- /// The support file list is used by the line table, and any objects
- /// that have valid Declaration objects.
- ///
- /// @return
- /// A support file list object.
- //------------------------------------------------------------------
- FileSpecList&
- GetSupportFiles ();
-
- //------------------------------------------------------------------
- /// Get the compile unit's imported module list.
- ///
- /// This reports all the imports that the compile unit made,
- /// including the current module.
- ///
- /// @return
- /// A list of imported module names.
- //------------------------------------------------------------------
- const std::vector<ConstString> &
- GetImportedModules ();
-
- //------------------------------------------------------------------
- /// Get the SymbolFile plug-in user data.
- ///
- /// SymbolFile plug-ins can store user data to internal state or
- /// objects to quickly allow them to parse more information for a
- /// given object.
- ///
- /// @return
- /// The user data stored with the CompileUnit when it was
- /// constructed.
- //------------------------------------------------------------------
- void *
- GetUserData () const;
-
- //------------------------------------------------------------------
- /// Get the variable list for a compile unit.
- ///
- /// Called by clients to get the variable list for a compile unit.
- /// The variable list will contain all global and static variables
- /// that were defined at the compile unit level.
- ///
- /// @param[in] can_create
- /// If \b true, the variable list will be parsed on demand. If
- /// \b false, the current variable list will be returned even
- /// if it contains a NULL VariableList object (typically
- /// called by dumping routines that want to display only what
- /// has currently been parsed).
- ///
- /// @return
- /// A shared pointer to a variable list, that can contain NULL
- /// VariableList pointer if there are no global or static
- /// variables.
- //------------------------------------------------------------------
- lldb::VariableListSP
- GetVariableList (bool can_create);
-
- //------------------------------------------------------------------
- /// Finds a function by user ID.
- ///
- /// Typically used by SymbolFile plug-ins when partially parsing
- /// the debug information to see if the function has been parsed
- /// yet.
- ///
- /// @param[in] uid
- /// The user ID of the function to find. This value is supplied
- /// by the SymbolFile plug-in and should be a value that
- /// allows the plug-in to easily locate and parse additional
- /// information in the function.
- ///
- /// @return
- /// A shared pointer to the function object that might contain
- /// a NULL Function pointer.
- //------------------------------------------------------------------
- lldb::FunctionSP
- FindFunctionByUID (lldb::user_id_t uid);
-
- //------------------------------------------------------------------
- /// Set the line table for the compile unit.
- ///
- /// Called by the SymbolFile plug-in when if first parses the line
- /// table and hands ownership of the line table to this object. The
- /// compile unit owns the line table object and will delete the
- /// object when it is deleted.
- ///
- /// @param[in] line_table
- /// A line table object pointer that this object now owns.
- //------------------------------------------------------------------
- void
- SetLineTable(LineTable* line_table);
-
- void
- SetDebugMacros(const DebugMacrosSP &debug_macros);
-
- //------------------------------------------------------------------
- /// Set accessor for the variable list.
- ///
- /// Called by the SymbolFile plug-ins after they have parsed the
- /// variable lists and are ready to hand ownership of the list over
- /// to this object.
- ///
- /// @param[in] variable_list_sp
- /// A shared pointer to a VariableList.
- //------------------------------------------------------------------
- void
- SetVariableList (lldb::VariableListSP& variable_list_sp);
-
- //------------------------------------------------------------------
- /// Resolve symbol contexts by file and line.
- ///
- /// Given a file in \a file_spec, and a line number, find all
- /// instances and append them to the supplied symbol context list
- /// \a sc_list.
- ///
- /// @param[in] file_spec
- /// A file specification. If \a file_spec contains no directory
- /// information, only the basename will be used when matching
- /// contexts. If the directory in \a file_spec is valid, a
- /// complete file specification match will be performed.
- ///
- /// @param[in] line
- /// The line number to match against the compile unit's line
- /// tables.
- ///
- /// @param[in] check_inlines
- /// If \b true this function will also match any inline
- /// file and line matches. If \b false, the compile unit's
- /// file specification must match \a file_spec for any matches
- /// to be returned.
- ///
- /// @param[in] exact
- /// If true, only resolve the context if \a line exists in the line table.
- /// If false, resolve the context to the closest line greater than \a line
- /// in the line table.
- ///
- /// @param[in] resolve_scope
- /// For each matching line entry, this bitfield indicates what
- /// values within each SymbolContext that gets added to \a
- /// sc_list will be resolved. See the SymbolContext::Scope
- /// enumeration for a list of all available bits that can be
- /// resolved. Only SymbolContext entries that can be resolved
- /// using a LineEntry base address will be able to be resolved.
- ///
- /// @param[out] sc_list
- /// A SymbolContext list class that will get any matching
- /// entries appended to.
- ///
- /// @return
- /// The number of new matches that were added to \a sc_list.
- ///
- /// @see enum SymbolContext::Scope
- //------------------------------------------------------------------
- uint32_t
- ResolveSymbolContext (const FileSpec& file_spec,
- uint32_t line,
- bool check_inlines,
- bool exact,
- uint32_t resolve_scope,
- SymbolContextList &sc_list);
-
-
- //------------------------------------------------------------------
- /// Get whether compiler optimizations were enabled for this compile unit
- ///
- /// "optimized" means that the debug experience may be difficult
- /// for the user to understand. Variables may not be available when
- /// the developer would expect them, stepping through the source lines
- /// in the function may appear strange, etc.
- ///
- /// @return
- /// Returns 'true' if this compile unit was compiled with
- /// optimization. 'false' indicates that either the optimization
- /// is unknown, or this compile unit was built without optimization.
- //------------------------------------------------------------------
- bool
- GetIsOptimized ();
+ //------------------------------------------------------------------
+ /// Construct with a module, path, UID and language.
+ ///
+ /// Initialize the compile unit given the owning \a module, a path
+ /// to convert into a FileSpec, the SymbolFile plug-in supplied
+ /// \a uid, and the source language type.
+ ///
+ /// @param[in] module
+ /// The parent module that owns this compile unit. This value
+ /// must be a valid pointer value.
+ ///
+ /// @param[in] user_data
+ /// User data where the SymbolFile parser can store data.
+ ///
+ /// @param[in] pathname
+ /// The path to the source file for this compile unit.
+ ///
+ /// @param[in] uid
+ /// The user ID of the compile unit. This value is supplied by
+ /// the SymbolFile plug-in and should be a value that allows
+ /// the SymbolFile plug-in to easily locate and parse additional
+ /// information for the compile unit.
+ ///
+ /// @param[in] language
+ /// A language enumeration type that describes the main language
+ /// of this compile unit.
+ ///
+ /// @param[in] is_optimized
+ /// A value that can initialized with eLazyBoolYes, eLazyBoolNo
+ /// or eLazyBoolCalculate. If set to eLazyBoolCalculate, then
+ /// an extra call into SymbolVendor will be made to calculate if
+ /// the compile unit is optimized will be made when
+ /// CompileUnit::GetIsOptimized() is called.
+ ///
+ /// @see lldb::LanguageType
+ //------------------------------------------------------------------
+ CompileUnit(const lldb::ModuleSP &module_sp, void *user_data,
+ const char *pathname, lldb::user_id_t uid,
+ lldb::LanguageType language, lldb_private::LazyBool is_optimized);
+
+ //------------------------------------------------------------------
+ /// Construct with a module, file spec, UID and language.
+ ///
+ /// Initialize the compile unit given the owning \a module, a path
+ /// to convert into a FileSpec, the SymbolFile plug-in supplied
+ /// \a uid, and the source language type.
+ ///
+ /// @param[in] module
+ /// The parent module that owns this compile unit. This value
+ /// must be a valid pointer value.
+ ///
+ /// @param[in] user_data
+ /// User data where the SymbolFile parser can store data.
+ ///
+ /// @param[in] file_spec
+ /// The file specification for the source file of this compile
+ /// unit.
+ ///
+ /// @param[in] uid
+ /// The user ID of the compile unit. This value is supplied by
+ /// the SymbolFile plug-in and should be a value that allows
+ /// the plug-in to easily locate and parse
+ /// additional information for the compile unit.
+ ///
+ /// @param[in] language
+ /// A language enumeration type that describes the main language
+ /// of this compile unit.
+ ///
+ /// @param[in] is_optimized
+ /// A value that can initialized with eLazyBoolYes, eLazyBoolNo
+ /// or eLazyBoolCalculate. If set to eLazyBoolCalculate, then
+ /// an extra call into SymbolVendor will be made to calculate if
+ /// the compile unit is optimized will be made when
+ /// CompileUnit::GetIsOptimized() is called.
+ ///
+ /// @see lldb::LanguageType
+ //------------------------------------------------------------------
+ CompileUnit(const lldb::ModuleSP &module_sp, void *user_data,
+ const FileSpec &file_spec, lldb::user_id_t uid,
+ lldb::LanguageType language, lldb_private::LazyBool is_optimized);
+
+ //------------------------------------------------------------------
+ /// Destructor
+ //------------------------------------------------------------------
+ ~CompileUnit() override;
+
+ //------------------------------------------------------------------
+ /// Add a function to this compile unit.
+ ///
+ /// Typically called by the SymbolFile plug-ins as they partially
+ /// parse the debug information.
+ ///
+ /// @param[in] function_sp
+ /// A shared pointer to the Function object.
+ //------------------------------------------------------------------
+ void AddFunction(lldb::FunctionSP &function_sp);
+
+ //------------------------------------------------------------------
+ /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
+ ///
+ /// @see SymbolContextScope
+ //------------------------------------------------------------------
+ void CalculateSymbolContext(SymbolContext *sc) override;
+
+ lldb::ModuleSP CalculateSymbolContextModule() override;
+
+ CompileUnit *CalculateSymbolContextCompileUnit() override;
+
+ //------------------------------------------------------------------
+ /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
+ ///
+ /// @see SymbolContextScope
+ //------------------------------------------------------------------
+ void DumpSymbolContext(Stream *s) override;
+
+ lldb::LanguageType GetLanguage();
+
+ void SetLanguage(lldb::LanguageType language) {
+ m_flags.Set(flagsParsedLanguage);
+ m_language = language;
+ }
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) const;
+
+ //------------------------------------------------------------------
+ /// Get a shared pointer to a function in this compile unit by
+ /// index.
+ ///
+ /// Typically called when iterating though all functions in a
+ /// compile unit after all functions have been parsed. This provides
+ /// raw access to the function shared pointer list and will not
+ /// cause the SymbolFile plug-in to parse any unparsed functions.
+ ///
+ /// @param[in] idx
+ /// An index into the function list.
+ ///
+ /// @return
+ /// A shared pointer to a function that might contain a NULL
+ /// Function class pointer.
+ //------------------------------------------------------------------
+ lldb::FunctionSP GetFunctionAtIndex(size_t idx);
+
+ //------------------------------------------------------------------
+ /// Dump the compile unit contents to the stream \a s.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ ///
+ /// @param[in] show_context
+ /// If \b true, variables will dump their symbol context
+ /// information.
+ //------------------------------------------------------------------
+ void Dump(Stream *s, bool show_context) const;
+
+ //------------------------------------------------------------------
+ /// Find the line entry by line and optional inlined file spec.
+ ///
+ /// Finds the first line entry that has an index greater than
+ /// \a start_idx that matches \a line. If \a file_spec_ptr
+ /// is NULL, then the search matches line entries whose file matches
+ /// the file for the compile unit. If \a file_spec_ptr is
+ /// not NULL, line entries must match the specified file spec (for
+ /// inlined line table entries).
+ ///
+ /// Multiple calls to this function can find all entries that match
+ /// a given file and line by starting with \a start_idx equal to zero,
+ /// and calling this function back with the return value + 1.
+ ///
+ /// @param[in] start_idx
+ /// The zero based index at which to start looking for matches.
+ ///
+ /// @param[in] line
+ /// The line number to search for.
+ ///
+ /// @param[in] file_spec_ptr
+ /// If non-NULL search for entries that match this file spec,
+ /// else if NULL, search for line entries that match the compile
+ /// unit file.
+ ///
+ /// @param[in] exact
+ /// If \btrue match only if there is a line table entry for this line
+ /// number.
+ /// If \bfalse, find the line table entry equal to or after this line
+ /// number.
+ ///
+ /// @param[out] line_entry
+ /// If non-NULL, a copy of the line entry that was found.
+ ///
+ /// @return
+ /// The zero based index of a matching line entry, or UINT32_MAX
+ /// if no matching line entry is found.
+ //------------------------------------------------------------------
+ uint32_t FindLineEntry(uint32_t start_idx, uint32_t line,
+ const FileSpec *file_spec_ptr, bool exact,
+ LineEntry *line_entry);
+
+ //------------------------------------------------------------------
+ /// Get the line table for the compile unit.
+ ///
+ /// Called by clients and the SymbolFile plug-in. The SymbolFile
+ /// plug-ins use this function to determine if the line table has
+ /// be parsed yet. Clients use this function to get the line table
+ /// from a compile unit.
+ ///
+ /// @return
+ /// The line table object pointer, or NULL if this line table
+ /// hasn't been parsed yet.
+ //------------------------------------------------------------------
+ LineTable *GetLineTable();
+
+ DebugMacros *GetDebugMacros();
+
+ //------------------------------------------------------------------
+ /// Get the compile unit's support file list.
+ ///
+ /// The support file list is used by the line table, and any objects
+ /// that have valid Declaration objects.
+ ///
+ /// @return
+ /// A support file list object.
+ //------------------------------------------------------------------
+ FileSpecList &GetSupportFiles();
+
+ //------------------------------------------------------------------
+ /// Get the compile unit's imported module list.
+ ///
+ /// This reports all the imports that the compile unit made,
+ /// including the current module.
+ ///
+ /// @return
+ /// A list of imported module names.
+ //------------------------------------------------------------------
+ const std::vector<ConstString> &GetImportedModules();
+
+ //------------------------------------------------------------------
+ /// Get the SymbolFile plug-in user data.
+ ///
+ /// SymbolFile plug-ins can store user data to internal state or
+ /// objects to quickly allow them to parse more information for a
+ /// given object.
+ ///
+ /// @return
+ /// The user data stored with the CompileUnit when it was
+ /// constructed.
+ //------------------------------------------------------------------
+ void *GetUserData() const;
+
+ //------------------------------------------------------------------
+ /// Get the variable list for a compile unit.
+ ///
+ /// Called by clients to get the variable list for a compile unit.
+ /// The variable list will contain all global and static variables
+ /// that were defined at the compile unit level.
+ ///
+ /// @param[in] can_create
+ /// If \b true, the variable list will be parsed on demand. If
+ /// \b false, the current variable list will be returned even
+ /// if it contains a NULL VariableList object (typically
+ /// called by dumping routines that want to display only what
+ /// has currently been parsed).
+ ///
+ /// @return
+ /// A shared pointer to a variable list, that can contain NULL
+ /// VariableList pointer if there are no global or static
+ /// variables.
+ //------------------------------------------------------------------
+ lldb::VariableListSP GetVariableList(bool can_create);
+
+ //------------------------------------------------------------------
+ /// Finds a function by user ID.
+ ///
+ /// Typically used by SymbolFile plug-ins when partially parsing
+ /// the debug information to see if the function has been parsed
+ /// yet.
+ ///
+ /// @param[in] uid
+ /// The user ID of the function to find. This value is supplied
+ /// by the SymbolFile plug-in and should be a value that
+ /// allows the plug-in to easily locate and parse additional
+ /// information in the function.
+ ///
+ /// @return
+ /// A shared pointer to the function object that might contain
+ /// a NULL Function pointer.
+ //------------------------------------------------------------------
+ lldb::FunctionSP FindFunctionByUID(lldb::user_id_t uid);
+
+ //------------------------------------------------------------------
+ /// Set the line table for the compile unit.
+ ///
+ /// Called by the SymbolFile plug-in when if first parses the line
+ /// table and hands ownership of the line table to this object. The
+ /// compile unit owns the line table object and will delete the
+ /// object when it is deleted.
+ ///
+ /// @param[in] line_table
+ /// A line table object pointer that this object now owns.
+ //------------------------------------------------------------------
+ void SetLineTable(LineTable *line_table);
+
+ void SetDebugMacros(const DebugMacrosSP &debug_macros);
+
+ //------------------------------------------------------------------
+ /// Set accessor for the variable list.
+ ///
+ /// Called by the SymbolFile plug-ins after they have parsed the
+ /// variable lists and are ready to hand ownership of the list over
+ /// to this object.
+ ///
+ /// @param[in] variable_list_sp
+ /// A shared pointer to a VariableList.
+ //------------------------------------------------------------------
+ void SetVariableList(lldb::VariableListSP &variable_list_sp);
+
+ //------------------------------------------------------------------
+ /// Resolve symbol contexts by file and line.
+ ///
+ /// Given a file in \a file_spec, and a line number, find all
+ /// instances and append them to the supplied symbol context list
+ /// \a sc_list.
+ ///
+ /// @param[in] file_spec
+ /// A file specification. If \a file_spec contains no directory
+ /// information, only the basename will be used when matching
+ /// contexts. If the directory in \a file_spec is valid, a
+ /// complete file specification match will be performed.
+ ///
+ /// @param[in] line
+ /// The line number to match against the compile unit's line
+ /// tables.
+ ///
+ /// @param[in] check_inlines
+ /// If \b true this function will also match any inline
+ /// file and line matches. If \b false, the compile unit's
+ /// file specification must match \a file_spec for any matches
+ /// to be returned.
+ ///
+ /// @param[in] exact
+ /// If true, only resolve the context if \a line exists in the line table.
+ /// If false, resolve the context to the closest line greater than \a line
+ /// in the line table.
+ ///
+ /// @param[in] resolve_scope
+ /// For each matching line entry, this bitfield indicates what
+ /// values within each SymbolContext that gets added to \a
+ /// sc_list will be resolved. See the SymbolContext::Scope
+ /// enumeration for a list of all available bits that can be
+ /// resolved. Only SymbolContext entries that can be resolved
+ /// using a LineEntry base address will be able to be resolved.
+ ///
+ /// @param[out] sc_list
+ /// A SymbolContext list class that will get any matching
+ /// entries appended to.
+ ///
+ /// @return
+ /// The number of new matches that were added to \a sc_list.
+ ///
+ /// @see enum SymbolContext::Scope
+ //------------------------------------------------------------------
+ uint32_t ResolveSymbolContext(const FileSpec &file_spec, uint32_t line,
+ bool check_inlines, bool exact,
+ uint32_t resolve_scope,
+ SymbolContextList &sc_list);
+
+ //------------------------------------------------------------------
+ /// Get whether compiler optimizations were enabled for this compile unit
+ ///
+ /// "optimized" means that the debug experience may be difficult
+ /// for the user to understand. Variables may not be available when
+ /// the developer would expect them, stepping through the source lines
+ /// in the function may appear strange, etc.
+ ///
+ /// @return
+ /// Returns 'true' if this compile unit was compiled with
+ /// optimization. 'false' indicates that either the optimization
+ /// is unknown, or this compile unit was built without optimization.
+ //------------------------------------------------------------------
+ bool GetIsOptimized();
protected:
- void *m_user_data; ///< User data for the SymbolFile parser to store information into.
- lldb::LanguageType m_language; ///< The programming language enumeration value.
- Flags m_flags; ///< Compile unit flags that help with partial parsing.
- std::vector<lldb::FunctionSP> m_functions; ///< The sparsely populated list of shared pointers to functions
- ///< that gets populated as functions get partially parsed.
- std::vector<ConstString> m_imported_modules; ///< All modules, including the current module, imported by this
- ///< compile unit.
- FileSpecList m_support_files; ///< Files associated with this compile unit's line table and declarations.
- std::unique_ptr<LineTable> m_line_table_ap; ///< Line table that will get parsed on demand.
- DebugMacrosSP m_debug_macros_sp; ///< Debug macros that will get parsed on demand.
- lldb::VariableListSP m_variables; ///< Global and static variable list that will get parsed on demand.
- lldb_private::LazyBool m_is_optimized; /// eLazyBoolYes if this compile unit was compiled with optimization.
+ void *m_user_data; ///< User data for the SymbolFile parser to store
+ ///information into.
+ lldb::LanguageType
+ m_language; ///< The programming language enumeration value.
+ Flags m_flags; ///< Compile unit flags that help with partial parsing.
+ std::vector<lldb::FunctionSP> m_functions; ///< The sparsely populated list of
+ ///shared pointers to functions
+ ///< that gets populated as functions get partially parsed.
+ std::vector<ConstString> m_imported_modules; ///< All modules, including the
+ ///current module, imported by
+ ///this
+ ///< compile unit.
+ FileSpecList m_support_files; ///< Files associated with this compile unit's
+ ///line table and declarations.
+ std::unique_ptr<LineTable>
+ m_line_table_ap; ///< Line table that will get parsed on demand.
+ DebugMacrosSP
+ m_debug_macros_sp; ///< Debug macros that will get parsed on demand.
+ lldb::VariableListSP m_variables; ///< Global and static variable list that
+ ///will get parsed on demand.
+ lldb_private::LazyBool m_is_optimized; /// eLazyBoolYes if this compile unit
+ /// was compiled with optimization.
private:
- enum
- {
- flagsParsedAllFunctions = (1u << 0), ///< Have we already parsed all our functions
- flagsParsedVariables = (1u << 1), ///< Have we already parsed globals and statics?
- flagsParsedSupportFiles = (1u << 2), ///< Have we already parsed the support files for this compile unit?
- flagsParsedLineTable = (1u << 3), ///< Have we parsed the line table already?
- flagsParsedLanguage = (1u << 4), ///< Have we parsed the language already?
- flagsParsedImportedModules = (1u << 5), ///< Have we parsed the imported modules already?
- flagsParsedDebugMacros = (1u << 6) ///< Have we parsed the debug macros already?
- };
-
- DISALLOW_COPY_AND_ASSIGN (CompileUnit);
+ enum {
+ flagsParsedAllFunctions =
+ (1u << 0), ///< Have we already parsed all our functions
+ flagsParsedVariables =
+ (1u << 1), ///< Have we already parsed globals and statics?
+ flagsParsedSupportFiles = (1u << 2), ///< Have we already parsed the support
+ ///files for this compile unit?
+ flagsParsedLineTable =
+ (1u << 3), ///< Have we parsed the line table already?
+ flagsParsedLanguage = (1u << 4), ///< Have we parsed the language already?
+ flagsParsedImportedModules =
+ (1u << 5), ///< Have we parsed the imported modules already?
+ flagsParsedDebugMacros =
+ (1u << 6) ///< Have we parsed the debug macros already?
+ };
+
+ DISALLOW_COPY_AND_ASSIGN(CompileUnit);
};
} // namespace lldb_private
diff --git a/include/lldb/Symbol/CompilerDecl.h b/include/lldb/Symbol/CompilerDecl.h
index 19654ab165bb..a612fb689c81 100644
--- a/include/lldb/Symbol/CompilerDecl.h
+++ b/include/lldb/Symbol/CompilerDecl.h
@@ -10,120 +10,85 @@
#ifndef liblldb_CompilerDecl_h_
#define liblldb_CompilerDecl_h_
-#include "lldb/lldb-private.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Symbol/CompilerType.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class CompilerDecl
-{
+class CompilerDecl {
public:
- //----------------------------------------------------------------------
- // Constructors and Destructors
- //----------------------------------------------------------------------
- CompilerDecl () :
- m_type_system (nullptr),
- m_opaque_decl (nullptr)
- {
- }
-
- CompilerDecl (TypeSystem *type_system, void *decl) :
- m_type_system (type_system),
- m_opaque_decl (decl)
- {
- }
-
- ~CompilerDecl ()
- {
- }
-
- //----------------------------------------------------------------------
- // Tests
- //----------------------------------------------------------------------
-
- explicit operator bool () const
- {
- return IsValid ();
- }
-
- bool
- operator < (const CompilerDecl &rhs) const
- {
- if (m_type_system == rhs.m_type_system)
- return m_opaque_decl < rhs.m_opaque_decl;
- return m_type_system < rhs.m_type_system;
- }
-
- bool
- IsValid () const
- {
- return m_type_system != nullptr && m_opaque_decl != nullptr;
- }
-
- bool
- IsClang () const;
-
- //----------------------------------------------------------------------
- // Accessors
- //----------------------------------------------------------------------
-
- TypeSystem *
- GetTypeSystem() const
- {
- return m_type_system;
- }
-
- void *
- GetOpaqueDecl() const
- {
- return m_opaque_decl;
- }
-
- void
- SetDecl (TypeSystem* type_system, void* decl)
- {
- m_type_system = type_system;
- m_opaque_decl = decl;
- }
-
- void
- Clear()
- {
- m_type_system = nullptr;
- m_opaque_decl = nullptr;
- }
-
- ConstString
- GetName () const;
-
- ConstString
- GetMangledName () const;
-
- CompilerDeclContext
- GetDeclContext() const;
-
- // If this decl represents a function, return the return type
- CompilerType
- GetFunctionReturnType() const;
-
- // If this decl represents a function, return the number of arguments for the function
- size_t
- GetNumFunctionArguments() const;
-
- // If this decl represents a function, return the argument type given a zero based argument index
- CompilerType
- GetFunctionArgumentType (size_t arg_idx) const;
+ //----------------------------------------------------------------------
+ // Constructors and Destructors
+ //----------------------------------------------------------------------
+ CompilerDecl() : m_type_system(nullptr), m_opaque_decl(nullptr) {}
+
+ CompilerDecl(TypeSystem *type_system, void *decl)
+ : m_type_system(type_system), m_opaque_decl(decl) {}
+
+ ~CompilerDecl() {}
+
+ //----------------------------------------------------------------------
+ // Tests
+ //----------------------------------------------------------------------
+
+ explicit operator bool() const { return IsValid(); }
+
+ bool operator<(const CompilerDecl &rhs) const {
+ if (m_type_system == rhs.m_type_system)
+ return m_opaque_decl < rhs.m_opaque_decl;
+ return m_type_system < rhs.m_type_system;
+ }
+
+ bool IsValid() const {
+ return m_type_system != nullptr && m_opaque_decl != nullptr;
+ }
+
+ bool IsClang() const;
+
+ //----------------------------------------------------------------------
+ // Accessors
+ //----------------------------------------------------------------------
+
+ TypeSystem *GetTypeSystem() const { return m_type_system; }
+
+ void *GetOpaqueDecl() const { return m_opaque_decl; }
+
+ void SetDecl(TypeSystem *type_system, void *decl) {
+ m_type_system = type_system;
+ m_opaque_decl = decl;
+ }
+
+ void Clear() {
+ m_type_system = nullptr;
+ m_opaque_decl = nullptr;
+ }
+
+ ConstString GetName() const;
+
+ ConstString GetMangledName() const;
+
+ CompilerDeclContext GetDeclContext() const;
+
+ // If this decl represents a function, return the return type
+ CompilerType GetFunctionReturnType() const;
+
+ // If this decl represents a function, return the number of arguments for the
+ // function
+ size_t GetNumFunctionArguments() const;
+
+ // If this decl represents a function, return the argument type given a zero
+ // based argument index
+ CompilerType GetFunctionArgumentType(size_t arg_idx) const;
private:
- TypeSystem *m_type_system;
- void *m_opaque_decl;
+ TypeSystem *m_type_system;
+ void *m_opaque_decl;
};
-
-bool operator == (const CompilerDecl &lhs, const CompilerDecl &rhs);
-bool operator != (const CompilerDecl &lhs, const CompilerDecl &rhs);
-
+bool operator==(const CompilerDecl &lhs, const CompilerDecl &rhs);
+bool operator!=(const CompilerDecl &lhs, const CompilerDecl &rhs);
+
} // namespace lldb_private
#endif // #ifndef liblldb_CompilerDecl_h_
diff --git a/include/lldb/Symbol/CompilerDeclContext.h b/include/lldb/Symbol/CompilerDeclContext.h
index 7432adac6133..e4f3e7459aa7 100644
--- a/include/lldb/Symbol/CompilerDeclContext.h
+++ b/include/lldb/Symbol/CompilerDeclContext.h
@@ -12,138 +12,102 @@
#include <vector>
-#include "lldb/lldb-private.h"
#include "lldb/Core/ConstString.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class CompilerDeclContext
-{
+class CompilerDeclContext {
public:
- //----------------------------------------------------------------------
- // Constructors and Destructors
- //----------------------------------------------------------------------
- CompilerDeclContext () :
- m_type_system (nullptr),
- m_opaque_decl_ctx (nullptr)
- {
- }
-
- CompilerDeclContext (TypeSystem *type_system, void *decl_ctx) :
- m_type_system (type_system),
- m_opaque_decl_ctx (decl_ctx)
- {
- }
-
- ~CompilerDeclContext()
- {
- }
-
- //----------------------------------------------------------------------
- // Tests
- //----------------------------------------------------------------------
-
- explicit operator bool () const
- {
- return IsValid ();
- }
-
- bool
- operator < (const CompilerDeclContext &rhs) const
- {
- if (m_type_system == rhs.m_type_system)
- return m_opaque_decl_ctx < rhs.m_opaque_decl_ctx;
- return m_type_system < rhs.m_type_system;
- }
-
- bool
- IsValid () const
- {
- return m_type_system != nullptr && m_opaque_decl_ctx != nullptr;
- }
-
- bool
- IsClang () const;
-
- std::vector<CompilerDecl>
- FindDeclByName (ConstString name, const bool ignore_using_decls);
-
- //----------------------------------------------------------------------
- /// Checks if this decl context represents a method of a class.
- ///
- /// @param[out] language_ptr
- /// If non NULL and \b true is returned from this function,
- /// this will indicate if the language that respresents the method.
- ///
- /// @param[out] is_instance_method_ptr
- /// If non NULL and \b true is returned from this function,
- /// this will indicate if the method is an instance function (true)
- /// or a class method (false indicating the function is static, or
- /// doesn't require an instance of the class to be called).
- ///
- /// @param[out] language_object_name_ptr
- /// If non NULL and \b true is returned from this function,
- /// this will indicate if implicit object name for the language
- /// like "this" for C++, and "self" for Objective C.
- ///
- /// @return
- /// Returns true if this is a decl context that represents a method
- /// in a struct, union or class.
- //----------------------------------------------------------------------
- bool
- IsClassMethod (lldb::LanguageType *language_ptr,
- bool *is_instance_method_ptr,
- ConstString *language_object_name_ptr);
-
- //----------------------------------------------------------------------
- // Accessors
- //----------------------------------------------------------------------
-
- TypeSystem *
- GetTypeSystem() const
- {
- return m_type_system;
- }
-
- void *
- GetOpaqueDeclContext() const
- {
- return m_opaque_decl_ctx;
- }
-
- void
- SetDeclContext (TypeSystem* type_system, void* decl_ctx)
- {
- m_type_system = type_system;
- m_opaque_decl_ctx = decl_ctx;
- }
-
- void
- Clear()
- {
- m_type_system = nullptr;
- m_opaque_decl_ctx = nullptr;
- }
-
- ConstString
- GetName () const;
-
- ConstString
- GetScopeQualifiedName() const;
-
- bool
- IsStructUnionOrClass () const;
+ //----------------------------------------------------------------------
+ // Constructors and Destructors
+ //----------------------------------------------------------------------
+ CompilerDeclContext() : m_type_system(nullptr), m_opaque_decl_ctx(nullptr) {}
+
+ CompilerDeclContext(TypeSystem *type_system, void *decl_ctx)
+ : m_type_system(type_system), m_opaque_decl_ctx(decl_ctx) {}
+
+ ~CompilerDeclContext() {}
+
+ //----------------------------------------------------------------------
+ // Tests
+ //----------------------------------------------------------------------
+
+ explicit operator bool() const { return IsValid(); }
+
+ bool operator<(const CompilerDeclContext &rhs) const {
+ if (m_type_system == rhs.m_type_system)
+ return m_opaque_decl_ctx < rhs.m_opaque_decl_ctx;
+ return m_type_system < rhs.m_type_system;
+ }
+
+ bool IsValid() const {
+ return m_type_system != nullptr && m_opaque_decl_ctx != nullptr;
+ }
+
+ bool IsClang() const;
+
+ std::vector<CompilerDecl> FindDeclByName(ConstString name,
+ const bool ignore_using_decls);
+
+ //----------------------------------------------------------------------
+ /// Checks if this decl context represents a method of a class.
+ ///
+ /// @param[out] language_ptr
+ /// If non NULL and \b true is returned from this function,
+ /// this will indicate if the language that respresents the method.
+ ///
+ /// @param[out] is_instance_method_ptr
+ /// If non NULL and \b true is returned from this function,
+ /// this will indicate if the method is an instance function (true)
+ /// or a class method (false indicating the function is static, or
+ /// doesn't require an instance of the class to be called).
+ ///
+ /// @param[out] language_object_name_ptr
+ /// If non NULL and \b true is returned from this function,
+ /// this will indicate if implicit object name for the language
+ /// like "this" for C++, and "self" for Objective C.
+ ///
+ /// @return
+ /// Returns true if this is a decl context that represents a method
+ /// in a struct, union or class.
+ //----------------------------------------------------------------------
+ bool IsClassMethod(lldb::LanguageType *language_ptr,
+ bool *is_instance_method_ptr,
+ ConstString *language_object_name_ptr);
+
+ //----------------------------------------------------------------------
+ // Accessors
+ //----------------------------------------------------------------------
+
+ TypeSystem *GetTypeSystem() const { return m_type_system; }
+
+ void *GetOpaqueDeclContext() const { return m_opaque_decl_ctx; }
+
+ void SetDeclContext(TypeSystem *type_system, void *decl_ctx) {
+ m_type_system = type_system;
+ m_opaque_decl_ctx = decl_ctx;
+ }
+
+ void Clear() {
+ m_type_system = nullptr;
+ m_opaque_decl_ctx = nullptr;
+ }
+
+ ConstString GetName() const;
+
+ ConstString GetScopeQualifiedName() const;
+
+ bool IsStructUnionOrClass() const;
private:
- TypeSystem *m_type_system;
- void *m_opaque_decl_ctx;
-
+ TypeSystem *m_type_system;
+ void *m_opaque_decl_ctx;
};
-
-bool operator == (const CompilerDeclContext &lhs, const CompilerDeclContext &rhs);
-bool operator != (const CompilerDeclContext &lhs, const CompilerDeclContext &rhs);
-
+bool operator==(const CompilerDeclContext &lhs, const CompilerDeclContext &rhs);
+bool operator!=(const CompilerDeclContext &lhs, const CompilerDeclContext &rhs);
+
} // namespace lldb_private
#endif // #ifndef liblldb_CompilerDeclContext_h_
diff --git a/include/lldb/Symbol/CompilerType.h b/include/lldb/Symbol/CompilerType.h
index 36f6ef3ba6eb..68221609c0cb 100644
--- a/include/lldb/Symbol/CompilerType.h
+++ b/include/lldb/Symbol/CompilerType.h
@@ -18,562 +18,414 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/ClangForward.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
-// A class that can carry around a clang ASTContext and a opaque clang
+// A class that can carry around a clang ASTContext and a opaque clang
// QualType. A clang::QualType can be easily reconstructed from an
-// opaque clang type and often the ASTContext is needed when doing
+// opaque clang type and often the ASTContext is needed when doing
// various type related tasks, so this class allows both items to travel
// in a single very lightweight class that can be used. There are many
// static equivalents of the member functions that allow the ASTContext
// and the opaque clang QualType to be specified for ease of use and
// to avoid code duplication.
//----------------------------------------------------------------------
-class CompilerType
-{
+class CompilerType {
public:
- //----------------------------------------------------------------------
- // Constructors and Destructors
- //----------------------------------------------------------------------
- CompilerType (TypeSystem *type_system, lldb::opaque_compiler_type_t type);
- CompilerType (clang::ASTContext *ast_context, clang::QualType qual_type);
-
- CompilerType (const CompilerType &rhs) :
- m_type (rhs.m_type),
- m_type_system (rhs.m_type_system)
- {
- }
-
- CompilerType () :
- m_type (nullptr),
- m_type_system (nullptr)
- {
- }
-
- ~CompilerType();
-
- //----------------------------------------------------------------------
- // Operators
- //----------------------------------------------------------------------
-
- const CompilerType &
- operator= (const CompilerType &rhs)
- {
- m_type = rhs.m_type;
- m_type_system = rhs.m_type_system;
- return *this;
- }
-
- //----------------------------------------------------------------------
- // Tests
- //----------------------------------------------------------------------
-
- explicit operator bool () const
- {
- return m_type != nullptr && m_type_system != nullptr;
- }
-
- bool
- operator < (const CompilerType &rhs) const
- {
- if (m_type_system == rhs.m_type_system)
- return m_type < rhs.m_type;
- return m_type_system < rhs.m_type_system;
- }
-
- bool
- IsValid () const
- {
- return m_type != nullptr && m_type_system != nullptr;
- }
-
- bool
- IsArrayType (CompilerType *element_type,
- uint64_t *size,
- bool *is_incomplete) const;
-
- bool
- IsVectorType (CompilerType *element_type,
- uint64_t *size) const;
-
- bool
- IsArrayOfScalarType () const;
-
- bool
- IsAggregateType () const;
-
- bool
- IsAnonymousType () const;
-
- bool
- IsBeingDefined () const;
-
- bool
- IsCharType () const;
-
- bool
- IsCompleteType () const;
-
- bool
- IsConst() const;
-
- bool
- IsCStringType (uint32_t &length) const;
-
- bool
- IsDefined() const;
-
- bool
- IsFloatingPointType (uint32_t &count, bool &is_complex) const;
-
- bool
- IsFunctionType(bool *is_variadic_ptr = nullptr) const;
-
- uint32_t
- IsHomogeneousAggregate (CompilerType* base_type_ptr) const;
-
- size_t
- GetNumberOfFunctionArguments () const;
-
- CompilerType
- GetFunctionArgumentAtIndex (const size_t index) const;
-
- bool
- IsVariadicFunctionType () const;
-
- bool
- IsFunctionPointerType () const;
-
- bool
- IsBlockPointerType (CompilerType *function_pointer_type_ptr) const;
-
- bool
- IsIntegerType (bool &is_signed) const;
-
- bool
- IsEnumerationType (bool &is_signed) const;
-
- bool
- IsIntegerOrEnumerationType (bool &is_signed) const;
-
- bool
- IsPolymorphicClass () const;
-
- bool
- IsPossibleCPlusPlusDynamicType(CompilerType *target_type = nullptr) const
- {
- return IsPossibleDynamicType (target_type, true, false);
- }
-
- bool
- IsPossibleDynamicType(CompilerType *target_type, // Can pass nullptr
- bool check_cplusplus,
- bool check_objc) const;
-
- bool
- IsPointerToScalarType () const;
-
- bool
- IsRuntimeGeneratedType () const;
-
- bool
- IsPointerType(CompilerType *pointee_type = nullptr) const;
-
- bool
- IsPointerOrReferenceType(CompilerType *pointee_type = nullptr) const;
-
- bool
- IsReferenceType(CompilerType *pointee_type = nullptr, bool* is_rvalue = nullptr) const;
-
- bool
- ShouldTreatScalarValueAsAddress () const;
-
- bool
- IsScalarType () const;
-
- bool
- IsTypedefType () const;
-
- bool
- IsVoidType () const;
-
- //----------------------------------------------------------------------
- // Type Completion
- //----------------------------------------------------------------------
-
- bool
- GetCompleteType () const;
-
- //----------------------------------------------------------------------
- // AST related queries
- //----------------------------------------------------------------------
-
- size_t
- GetPointerByteSize () const;
-
- //----------------------------------------------------------------------
- // Accessors
- //----------------------------------------------------------------------
-
- TypeSystem *
- GetTypeSystem() const
- {
- return m_type_system;
- }
-
- ConstString
- GetConstQualifiedTypeName () const;
-
- ConstString
- GetConstTypeName () const;
-
- ConstString
- GetTypeName () const;
-
- ConstString
- GetDisplayTypeName () const;
-
- uint32_t
- GetTypeInfo(CompilerType *pointee_or_element_compiler_type = nullptr) const;
-
- lldb::LanguageType
- GetMinimumLanguage ();
-
- lldb::opaque_compiler_type_t
- GetOpaqueQualType() const
- {
- return m_type;
- }
-
- lldb::TypeClass
- GetTypeClass () const;
-
- void
- SetCompilerType (TypeSystem* type_system, lldb::opaque_compiler_type_t type);
-
- void
- SetCompilerType (clang::ASTContext *ast, clang::QualType qual_type);
-
- unsigned
- GetTypeQualifiers() const;
-
- //----------------------------------------------------------------------
- // Creating related types
- //----------------------------------------------------------------------
-
- CompilerType
- GetArrayElementType(uint64_t *stride = nullptr) const;
-
- CompilerType
- GetCanonicalType () const;
-
- CompilerType
- GetFullyUnqualifiedType () const;
-
- // Returns -1 if this isn't a function of if the function doesn't have a prototype
- // Returns a value >= 0 if there is a prototype.
- int
- GetFunctionArgumentCount () const;
-
- CompilerType
- GetFunctionArgumentTypeAtIndex (size_t idx) const;
-
- CompilerType
- GetFunctionReturnType () const;
-
- size_t
- GetNumMemberFunctions () const;
-
- TypeMemberFunctionImpl
- GetMemberFunctionAtIndex (size_t idx);
-
- //----------------------------------------------------------------------
- // If this type is a reference to a type (L value or R value reference),
- // return a new type with the reference removed, else return the current
- // type itself.
- //----------------------------------------------------------------------
- CompilerType
- GetNonReferenceType () const;
-
- //----------------------------------------------------------------------
- // If this type is a pointer type, return the type that the pointer
- // points to, else return an invalid type.
- //----------------------------------------------------------------------
- CompilerType
- GetPointeeType () const;
-
- //----------------------------------------------------------------------
- // Return a new CompilerType that is a pointer to this type
- //----------------------------------------------------------------------
- CompilerType
- GetPointerType () const;
-
- //----------------------------------------------------------------------
- // Return a new CompilerType that is a L value reference to this type if
- // this type is valid and the type system supports L value references,
- // else return an invalid type.
- //----------------------------------------------------------------------
- CompilerType
- GetLValueReferenceType () const;
-
- //----------------------------------------------------------------------
- // Return a new CompilerType that is a R value reference to this type if
- // this type is valid and the type system supports R value references,
- // else return an invalid type.
- //----------------------------------------------------------------------
- CompilerType
- GetRValueReferenceType () const;
-
- //----------------------------------------------------------------------
- // Return a new CompilerType adds a const modifier to this type if
- // this type is valid and the type system supports const modifiers,
- // else return an invalid type.
- //----------------------------------------------------------------------
- CompilerType
- AddConstModifier () const;
-
- //----------------------------------------------------------------------
- // Return a new CompilerType adds a volatile modifier to this type if
- // this type is valid and the type system supports volatile modifiers,
- // else return an invalid type.
- //----------------------------------------------------------------------
- CompilerType
- AddVolatileModifier () const;
-
- //----------------------------------------------------------------------
- // Return a new CompilerType adds a restrict modifier to this type if
- // this type is valid and the type system supports restrict modifiers,
- // else return an invalid type.
- //----------------------------------------------------------------------
- CompilerType
- AddRestrictModifier () const;
-
- //----------------------------------------------------------------------
- // Create a typedef to this type using "name" as the name of the typedef
- // this type is valid and the type system supports typedefs, else return
- // an invalid type.
- //----------------------------------------------------------------------
- CompilerType
- CreateTypedef (const char *name, const CompilerDeclContext &decl_ctx) const;
-
- // If the current object represents a typedef type, get the underlying type
- CompilerType
- GetTypedefedType () const;
-
- //----------------------------------------------------------------------
- // Create related types using the current type's AST
- //----------------------------------------------------------------------
- CompilerType
- GetBasicTypeFromAST (lldb::BasicType basic_type) const;
-
- //----------------------------------------------------------------------
- // Exploring the type
- //----------------------------------------------------------------------
-
- uint64_t
- GetByteSize (ExecutionContextScope *exe_scope) const;
-
- uint64_t
- GetBitSize (ExecutionContextScope *exe_scope) const;
-
- lldb::Encoding
- GetEncoding (uint64_t &count) const;
-
- lldb::Format
- GetFormat () const;
-
- size_t
- GetTypeBitAlign () const;
-
- uint32_t
- GetNumChildren (bool omit_empty_base_classes) const;
-
- lldb::BasicType
- GetBasicTypeEnumeration () const;
-
- static lldb::BasicType
- GetBasicTypeEnumeration (const ConstString &name);
-
- //----------------------------------------------------------------------
- // If this type is an enumeration, iterate through all of its enumerators
- // using a callback. If the callback returns true, keep iterating, else
- // abort the iteration.
- //----------------------------------------------------------------------
- void
- ForEachEnumerator (std::function <bool (const CompilerType &integer_type,
- const ConstString &name,
- const llvm::APSInt &value)> const &callback) const;
-
- uint32_t
- GetNumFields () const;
-
- CompilerType
- GetFieldAtIndex (size_t idx,
- std::string& name,
- uint64_t *bit_offset_ptr,
- uint32_t *bitfield_bit_size_ptr,
- bool *is_bitfield_ptr) const;
-
- uint32_t
- GetNumDirectBaseClasses () const;
-
- uint32_t
- GetNumVirtualBaseClasses () const;
-
- CompilerType
- GetDirectBaseClassAtIndex (size_t idx,
- uint32_t *bit_offset_ptr) const;
-
- CompilerType
- GetVirtualBaseClassAtIndex (size_t idx,
- uint32_t *bit_offset_ptr) const;
-
- uint32_t
- GetIndexOfFieldWithName(const char* name,
- CompilerType* field_compiler_type = nullptr,
- uint64_t *bit_offset_ptr = nullptr,
- uint32_t *bitfield_bit_size_ptr = nullptr,
- bool *is_bitfield_ptr = nullptr) const;
-
- CompilerType
- GetChildCompilerTypeAtIndex (ExecutionContext *exe_ctx,
- size_t idx,
- bool transparent_pointers,
- bool omit_empty_base_classes,
- bool ignore_array_bounds,
- std::string& child_name,
- uint32_t &child_byte_size,
- int32_t &child_byte_offset,
- uint32_t &child_bitfield_bit_size,
- uint32_t &child_bitfield_bit_offset,
- bool &child_is_base_class,
- bool &child_is_deref_of_parent,
- ValueObject *valobj,
- uint64_t &language_flags) const;
-
- // Lookup a child given a name. This function will match base class names
- // and member member names in "clang_type" only, not descendants.
- uint32_t
- GetIndexOfChildWithName (const char *name,
- bool omit_empty_base_classes) const;
-
- // Lookup a child member given a name. This function will match member names
- // only and will descend into "clang_type" children in search for the first
- // member in this class, or any base class that matches "name".
- // TODO: Return all matches for a given name by returning a vector<vector<uint32_t>>
- // so we catch all names that match a given child name, not just the first.
- size_t
- GetIndexOfChildMemberWithName (const char *name,
- bool omit_empty_base_classes,
- std::vector<uint32_t>& child_indexes) const;
-
- size_t
- GetNumTemplateArguments () const;
-
- CompilerType
- GetTemplateArgument (size_t idx,
- lldb::TemplateArgumentKind &kind) const;
-
- CompilerType
- GetTypeForFormatters () const;
-
- LazyBool
- ShouldPrintAsOneLiner (ValueObject* valobj) const;
-
- bool
- IsMeaninglessWithoutDynamicResolution () const;
-
- //------------------------------------------------------------------
- // Pointers & References
- //------------------------------------------------------------------
-
- // Converts "s" to a floating point value and place resulting floating
- // point bytes in the "dst" buffer.
- size_t
- ConvertStringToFloatValue (const char *s,
- uint8_t *dst,
- size_t dst_size) const;
-
- //----------------------------------------------------------------------
- // Dumping types
- //----------------------------------------------------------------------
- void
- DumpValue (ExecutionContext *exe_ctx,
- Stream *s,
- lldb::Format format,
- const DataExtractor &data,
- lldb::offset_t data_offset,
- size_t data_byte_size,
- uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset,
- bool show_types,
- bool show_summary,
- bool verbose,
- uint32_t depth);
-
- bool
- DumpTypeValue (Stream *s,
- lldb::Format format,
- const DataExtractor &data,
- lldb::offset_t data_offset,
- size_t data_byte_size,
- uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset,
- ExecutionContextScope *exe_scope);
-
- void
- DumpSummary (ExecutionContext *exe_ctx,
- Stream *s,
- const DataExtractor &data,
- lldb::offset_t data_offset,
- size_t data_byte_size);
-
- void
- DumpTypeDescription () const; // Dump to stdout
-
- void
- DumpTypeDescription (Stream *s) const;
-
- bool
- GetValueAsScalar (const DataExtractor &data,
- lldb::offset_t data_offset,
- size_t data_byte_size,
- Scalar &value) const;
-
- bool
- SetValueFromScalar (const Scalar &value,
- Stream &strm);
-
- bool
- ReadFromMemory (ExecutionContext *exe_ctx,
- lldb::addr_t addr,
- AddressType address_type,
- DataExtractor &data);
-
- bool
- WriteToMemory (ExecutionContext *exe_ctx,
- lldb::addr_t addr,
- AddressType address_type,
- StreamString &new_value);
-
- void
- Clear()
- {
- m_type = nullptr;
- m_type_system = nullptr;
- }
+ //----------------------------------------------------------------------
+ // Constructors and Destructors
+ //----------------------------------------------------------------------
+ CompilerType(TypeSystem *type_system, lldb::opaque_compiler_type_t type);
+ CompilerType(clang::ASTContext *ast_context, clang::QualType qual_type);
+
+ CompilerType(const CompilerType &rhs)
+ : m_type(rhs.m_type), m_type_system(rhs.m_type_system) {}
+
+ CompilerType() : m_type(nullptr), m_type_system(nullptr) {}
+
+ ~CompilerType();
+
+ //----------------------------------------------------------------------
+ // Operators
+ //----------------------------------------------------------------------
+
+ const CompilerType &operator=(const CompilerType &rhs) {
+ m_type = rhs.m_type;
+ m_type_system = rhs.m_type_system;
+ return *this;
+ }
+
+ //----------------------------------------------------------------------
+ // Tests
+ //----------------------------------------------------------------------
+
+ explicit operator bool() const {
+ return m_type != nullptr && m_type_system != nullptr;
+ }
+
+ bool operator<(const CompilerType &rhs) const {
+ if (m_type_system == rhs.m_type_system)
+ return m_type < rhs.m_type;
+ return m_type_system < rhs.m_type_system;
+ }
+
+ bool IsValid() const { return m_type != nullptr && m_type_system != nullptr; }
+
+ bool IsArrayType(CompilerType *element_type, uint64_t *size,
+ bool *is_incomplete) const;
+
+ bool IsVectorType(CompilerType *element_type, uint64_t *size) const;
+
+ bool IsArrayOfScalarType() const;
+
+ bool IsAggregateType() const;
+
+ bool IsAnonymousType() const;
+
+ bool IsBeingDefined() const;
+
+ bool IsCharType() const;
+
+ bool IsCompleteType() const;
+
+ bool IsConst() const;
+
+ bool IsCStringType(uint32_t &length) const;
+
+ bool IsDefined() const;
+
+ bool IsFloatingPointType(uint32_t &count, bool &is_complex) const;
+
+ bool IsFunctionType(bool *is_variadic_ptr = nullptr) const;
+
+ uint32_t IsHomogeneousAggregate(CompilerType *base_type_ptr) const;
+
+ size_t GetNumberOfFunctionArguments() const;
+
+ CompilerType GetFunctionArgumentAtIndex(const size_t index) const;
+
+ bool IsVariadicFunctionType() const;
+
+ bool IsFunctionPointerType() const;
+
+ bool IsBlockPointerType(CompilerType *function_pointer_type_ptr) const;
+
+ bool IsIntegerType(bool &is_signed) const;
+
+ bool IsEnumerationType(bool &is_signed) const;
+
+ bool IsIntegerOrEnumerationType(bool &is_signed) const;
+
+ bool IsPolymorphicClass() const;
+
+ bool
+ IsPossibleCPlusPlusDynamicType(CompilerType *target_type = nullptr) const {
+ return IsPossibleDynamicType(target_type, true, false);
+ }
+
+ bool IsPossibleDynamicType(CompilerType *target_type, // Can pass nullptr
+ bool check_cplusplus, bool check_objc) const;
+
+ bool IsPointerToScalarType() const;
+
+ bool IsRuntimeGeneratedType() const;
+
+ bool IsPointerType(CompilerType *pointee_type = nullptr) const;
+
+ bool IsPointerOrReferenceType(CompilerType *pointee_type = nullptr) const;
+
+ bool IsReferenceType(CompilerType *pointee_type = nullptr,
+ bool *is_rvalue = nullptr) const;
+
+ bool ShouldTreatScalarValueAsAddress() const;
+
+ bool IsScalarType() const;
+
+ bool IsTypedefType() const;
+
+ bool IsVoidType() const;
+
+ //----------------------------------------------------------------------
+ // Type Completion
+ //----------------------------------------------------------------------
+
+ bool GetCompleteType() const;
+
+ //----------------------------------------------------------------------
+ // AST related queries
+ //----------------------------------------------------------------------
+
+ size_t GetPointerByteSize() const;
+
+ //----------------------------------------------------------------------
+ // Accessors
+ //----------------------------------------------------------------------
+
+ TypeSystem *GetTypeSystem() const { return m_type_system; }
+
+ ConstString GetConstQualifiedTypeName() const;
+
+ ConstString GetConstTypeName() const;
+
+ ConstString GetTypeName() const;
+
+ ConstString GetDisplayTypeName() const;
+
+ uint32_t
+ GetTypeInfo(CompilerType *pointee_or_element_compiler_type = nullptr) const;
+
+ lldb::LanguageType GetMinimumLanguage();
+
+ lldb::opaque_compiler_type_t GetOpaqueQualType() const { return m_type; }
+
+ lldb::TypeClass GetTypeClass() const;
+
+ void SetCompilerType(TypeSystem *type_system,
+ lldb::opaque_compiler_type_t type);
+
+ void SetCompilerType(clang::ASTContext *ast, clang::QualType qual_type);
+
+ unsigned GetTypeQualifiers() const;
+
+ //----------------------------------------------------------------------
+ // Creating related types
+ //----------------------------------------------------------------------
+
+ CompilerType GetArrayElementType(uint64_t *stride = nullptr) const;
+
+ CompilerType GetArrayType(uint64_t size) const;
+
+ CompilerType GetCanonicalType() const;
+
+ CompilerType GetFullyUnqualifiedType() const;
+
+ // Returns -1 if this isn't a function of if the function doesn't have a
+ // prototype
+ // Returns a value >= 0 if there is a prototype.
+ int GetFunctionArgumentCount() const;
+
+ CompilerType GetFunctionArgumentTypeAtIndex(size_t idx) const;
+
+ CompilerType GetFunctionReturnType() const;
+
+ size_t GetNumMemberFunctions() const;
+
+ TypeMemberFunctionImpl GetMemberFunctionAtIndex(size_t idx);
+
+ //----------------------------------------------------------------------
+ // If this type is a reference to a type (L value or R value reference),
+ // return a new type with the reference removed, else return the current
+ // type itself.
+ //----------------------------------------------------------------------
+ CompilerType GetNonReferenceType() const;
+
+ //----------------------------------------------------------------------
+ // If this type is a pointer type, return the type that the pointer
+ // points to, else return an invalid type.
+ //----------------------------------------------------------------------
+ CompilerType GetPointeeType() const;
+
+ //----------------------------------------------------------------------
+ // Return a new CompilerType that is a pointer to this type
+ //----------------------------------------------------------------------
+ CompilerType GetPointerType() const;
+
+ //----------------------------------------------------------------------
+ // Return a new CompilerType that is a L value reference to this type if
+ // this type is valid and the type system supports L value references,
+ // else return an invalid type.
+ //----------------------------------------------------------------------
+ CompilerType GetLValueReferenceType() const;
+
+ //----------------------------------------------------------------------
+ // Return a new CompilerType that is a R value reference to this type if
+ // this type is valid and the type system supports R value references,
+ // else return an invalid type.
+ //----------------------------------------------------------------------
+ CompilerType GetRValueReferenceType() const;
+
+ //----------------------------------------------------------------------
+ // Return a new CompilerType adds a const modifier to this type if
+ // this type is valid and the type system supports const modifiers,
+ // else return an invalid type.
+ //----------------------------------------------------------------------
+ CompilerType AddConstModifier() const;
+
+ //----------------------------------------------------------------------
+ // Return a new CompilerType adds a volatile modifier to this type if
+ // this type is valid and the type system supports volatile modifiers,
+ // else return an invalid type.
+ //----------------------------------------------------------------------
+ CompilerType AddVolatileModifier() const;
+
+ //----------------------------------------------------------------------
+ // Return a new CompilerType adds a restrict modifier to this type if
+ // this type is valid and the type system supports restrict modifiers,
+ // else return an invalid type.
+ //----------------------------------------------------------------------
+ CompilerType AddRestrictModifier() const;
+
+ //----------------------------------------------------------------------
+ // Create a typedef to this type using "name" as the name of the typedef
+ // this type is valid and the type system supports typedefs, else return
+ // an invalid type.
+ //----------------------------------------------------------------------
+ CompilerType CreateTypedef(const char *name,
+ const CompilerDeclContext &decl_ctx) const;
+
+ // If the current object represents a typedef type, get the underlying type
+ CompilerType GetTypedefedType() const;
+
+ //----------------------------------------------------------------------
+ // Create related types using the current type's AST
+ //----------------------------------------------------------------------
+ CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) const;
+
+ //----------------------------------------------------------------------
+ // Exploring the type
+ //----------------------------------------------------------------------
+
+ uint64_t GetByteSize(ExecutionContextScope *exe_scope) const;
+
+ uint64_t GetBitSize(ExecutionContextScope *exe_scope) const;
+
+ lldb::Encoding GetEncoding(uint64_t &count) const;
+
+ lldb::Format GetFormat() const;
+
+ size_t GetTypeBitAlign() const;
+
+ uint32_t GetNumChildren(bool omit_empty_base_classes) const;
+
+ lldb::BasicType GetBasicTypeEnumeration() const;
+
+ static lldb::BasicType GetBasicTypeEnumeration(const ConstString &name);
+
+ //----------------------------------------------------------------------
+ // If this type is an enumeration, iterate through all of its enumerators
+ // using a callback. If the callback returns true, keep iterating, else
+ // abort the iteration.
+ //----------------------------------------------------------------------
+ void ForEachEnumerator(
+ std::function<bool(const CompilerType &integer_type,
+ const ConstString &name,
+ const llvm::APSInt &value)> const &callback) const;
+
+ uint32_t GetNumFields() const;
+
+ CompilerType GetFieldAtIndex(size_t idx, std::string &name,
+ uint64_t *bit_offset_ptr,
+ uint32_t *bitfield_bit_size_ptr,
+ bool *is_bitfield_ptr) const;
+
+ uint32_t GetNumDirectBaseClasses() const;
+
+ uint32_t GetNumVirtualBaseClasses() const;
+
+ CompilerType GetDirectBaseClassAtIndex(size_t idx,
+ uint32_t *bit_offset_ptr) const;
+
+ CompilerType GetVirtualBaseClassAtIndex(size_t idx,
+ uint32_t *bit_offset_ptr) const;
+
+ uint32_t GetIndexOfFieldWithName(const char *name,
+ CompilerType *field_compiler_type = nullptr,
+ uint64_t *bit_offset_ptr = nullptr,
+ uint32_t *bitfield_bit_size_ptr = nullptr,
+ bool *is_bitfield_ptr = nullptr) const;
+
+ CompilerType GetChildCompilerTypeAtIndex(
+ ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers,
+ bool omit_empty_base_classes, bool ignore_array_bounds,
+ std::string &child_name, uint32_t &child_byte_size,
+ int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size,
+ uint32_t &child_bitfield_bit_offset, bool &child_is_base_class,
+ bool &child_is_deref_of_parent, ValueObject *valobj,
+ uint64_t &language_flags) const;
+
+ // Lookup a child given a name. This function will match base class names
+ // and member member names in "clang_type" only, not descendants.
+ uint32_t GetIndexOfChildWithName(const char *name,
+ bool omit_empty_base_classes) const;
+
+ // Lookup a child member given a name. This function will match member names
+ // only and will descend into "clang_type" children in search for the first
+ // member in this class, or any base class that matches "name".
+ // TODO: Return all matches for a given name by returning a
+ // vector<vector<uint32_t>>
+ // so we catch all names that match a given child name, not just the first.
+ size_t
+ GetIndexOfChildMemberWithName(const char *name, bool omit_empty_base_classes,
+ std::vector<uint32_t> &child_indexes) const;
+
+ size_t GetNumTemplateArguments() const;
+
+ CompilerType GetTemplateArgument(size_t idx,
+ lldb::TemplateArgumentKind &kind) const;
+
+ CompilerType GetTypeForFormatters() const;
+
+ LazyBool ShouldPrintAsOneLiner(ValueObject *valobj) const;
+
+ bool IsMeaninglessWithoutDynamicResolution() const;
+
+ //------------------------------------------------------------------
+ // Pointers & References
+ //------------------------------------------------------------------
+
+ // Converts "s" to a floating point value and place resulting floating
+ // point bytes in the "dst" buffer.
+ size_t ConvertStringToFloatValue(const char *s, uint8_t *dst,
+ size_t dst_size) const;
+
+ //----------------------------------------------------------------------
+ // Dumping types
+ //----------------------------------------------------------------------
+ void DumpValue(ExecutionContext *exe_ctx, Stream *s, lldb::Format format,
+ const DataExtractor &data, lldb::offset_t data_offset,
+ size_t data_byte_size, uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset, bool show_types,
+ bool show_summary, bool verbose, uint32_t depth);
+
+ bool DumpTypeValue(Stream *s, lldb::Format format, const DataExtractor &data,
+ lldb::offset_t data_offset, size_t data_byte_size,
+ uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
+ ExecutionContextScope *exe_scope);
+
+ void DumpSummary(ExecutionContext *exe_ctx, Stream *s,
+ const DataExtractor &data, lldb::offset_t data_offset,
+ size_t data_byte_size);
+
+ void DumpTypeDescription() const; // Dump to stdout
+
+ void DumpTypeDescription(Stream *s) const;
+
+ bool GetValueAsScalar(const DataExtractor &data, lldb::offset_t data_offset,
+ size_t data_byte_size, Scalar &value) const;
+
+ bool SetValueFromScalar(const Scalar &value, Stream &strm);
+
+ bool ReadFromMemory(ExecutionContext *exe_ctx, lldb::addr_t addr,
+ AddressType address_type, DataExtractor &data);
+
+ bool WriteToMemory(ExecutionContext *exe_ctx, lldb::addr_t addr,
+ AddressType address_type, StreamString &new_value);
+
+ void Clear() {
+ m_type = nullptr;
+ m_type_system = nullptr;
+ }
private:
- lldb::opaque_compiler_type_t m_type;
- TypeSystem *m_type_system;
+ lldb::opaque_compiler_type_t m_type;
+ TypeSystem *m_type_system;
};
-
-bool operator == (const CompilerType &lhs, const CompilerType &rhs);
-bool operator != (const CompilerType &lhs, const CompilerType &rhs);
+
+bool operator==(const CompilerType &lhs, const CompilerType &rhs);
+bool operator!=(const CompilerType &lhs, const CompilerType &rhs);
} // namespace lldb_private
diff --git a/include/lldb/Symbol/DWARFCallFrameInfo.h b/include/lldb/Symbol/DWARFCallFrameInfo.h
index da7f87ced0a0..c221a36bd6c8 100644
--- a/include/lldb/Symbol/DWARFCallFrameInfo.h
+++ b/include/lldb/Symbol/DWARFCallFrameInfo.h
@@ -32,138 +32,125 @@ namespace lldb_private {
// eh_frame / debug_frame, and one to generate an UnwindPlan based
// on the FDE in the eh_frame / debug_frame section.
-class DWARFCallFrameInfo
-{
+class DWARFCallFrameInfo {
public:
-
- DWARFCallFrameInfo (ObjectFile& objfile,
- lldb::SectionSP& section,
- lldb::RegisterKind reg_kind,
- bool is_eh_frame);
-
- ~DWARFCallFrameInfo();
-
- // Locate an AddressRange that includes the provided Address in this
- // object's eh_frame/debug_info
- // Returns true if a range is found to cover that address.
- bool
- GetAddressRange (Address addr, AddressRange &range);
-
- // Return an UnwindPlan based on the call frame information encoded
- // in the FDE of this DWARFCallFrameInfo section.
- bool
- GetUnwindPlan (Address addr, UnwindPlan& unwind_plan);
-
- typedef RangeVector<lldb::addr_t, uint32_t> FunctionAddressAndSizeVector;
-
- //------------------------------------------------------------------
- // Build a vector of file address and size for all functions in this Module
- // based on the eh_frame FDE entries.
- //
- // The eh_frame information can be a useful source of file address and size of
- // the functions in a Module. Often a binary's non-exported symbols are stripped
- // before shipping so lldb won't know the start addr / size of many functions
- // in the Module. But the eh_frame can help to give the addresses of these
- // stripped symbols, at least.
- //
- // @param[out] function_info
- // A vector provided by the caller is filled out. May be empty if no FDEs/no eh_frame
- // is present in this Module.
-
- void
- GetFunctionAddressAndSizeVector (FunctionAddressAndSizeVector &function_info);
-
- void
- ForEachFDEEntries(const std::function<bool(lldb::addr_t, uint32_t, dw_offset_t)>& callback);
+ DWARFCallFrameInfo(ObjectFile &objfile, lldb::SectionSP &section,
+ lldb::RegisterKind reg_kind, bool is_eh_frame);
+
+ ~DWARFCallFrameInfo();
+
+ // Locate an AddressRange that includes the provided Address in this
+ // object's eh_frame/debug_info
+ // Returns true if a range is found to cover that address.
+ bool GetAddressRange(Address addr, AddressRange &range);
+
+ // Return an UnwindPlan based on the call frame information encoded
+ // in the FDE of this DWARFCallFrameInfo section.
+ bool GetUnwindPlan(Address addr, UnwindPlan &unwind_plan);
+
+ typedef RangeVector<lldb::addr_t, uint32_t> FunctionAddressAndSizeVector;
+
+ //------------------------------------------------------------------
+ // Build a vector of file address and size for all functions in this Module
+ // based on the eh_frame FDE entries.
+ //
+ // The eh_frame information can be a useful source of file address and size of
+ // the functions in a Module. Often a binary's non-exported symbols are
+ // stripped
+ // before shipping so lldb won't know the start addr / size of many functions
+ // in the Module. But the eh_frame can help to give the addresses of these
+ // stripped symbols, at least.
+ //
+ // @param[out] function_info
+ // A vector provided by the caller is filled out. May be empty if no
+ // FDEs/no eh_frame
+ // is present in this Module.
+
+ void
+ GetFunctionAddressAndSizeVector(FunctionAddressAndSizeVector &function_info);
+
+ void ForEachFDEEntries(
+ const std::function<bool(lldb::addr_t, uint32_t, dw_offset_t)> &callback);
private:
- enum
- {
- CFI_AUG_MAX_SIZE = 8,
- CFI_HEADER_SIZE = 8
- };
-
- struct CIE
- {
- dw_offset_t cie_offset;
- uint8_t version;
- char augmentation[CFI_AUG_MAX_SIZE]; // This is typically empty or very short.
- uint32_t code_align;
- int32_t data_align;
- uint32_t return_addr_reg_num;
- dw_offset_t inst_offset; // offset of CIE instructions in mCFIData
- uint32_t inst_length; // length of CIE instructions in mCFIData
- uint8_t ptr_encoding;
- uint8_t lsda_addr_encoding; // The encoding of the LSDA address in the FDE augmentation data
- lldb::addr_t personality_loc; // (file) address of the pointer to the personality routine
- lldb_private::UnwindPlan::Row initial_row;
-
- CIE(dw_offset_t offset) : cie_offset(offset), version (-1), code_align (0),
- data_align (0), return_addr_reg_num (LLDB_INVALID_REGNUM), inst_offset (0),
- inst_length (0), ptr_encoding (0),
- lsda_addr_encoding (DW_EH_PE_omit), personality_loc (LLDB_INVALID_ADDRESS),
- initial_row ()
- {
- }
- };
-
- typedef std::shared_ptr<CIE> CIESP;
-
- typedef std::map<dw_offset_t, CIESP> cie_map_t;
-
- // Start address (file address), size, offset of FDE location
- // used for finding an FDE for a given File address; the start address field is
- // an offset into an individual Module.
- typedef RangeDataVector<lldb::addr_t, uint32_t, dw_offset_t> FDEEntryMap;
-
- bool
- IsEHFrame() const;
-
- bool
- GetFDEEntryByFileAddress (lldb::addr_t file_offset, FDEEntryMap::Entry& fde_entry);
-
- void
- GetFDEIndex ();
-
- bool
- FDEToUnwindPlan (uint32_t offset, Address startaddr, UnwindPlan& unwind_plan);
-
- const CIE*
- GetCIE(dw_offset_t cie_offset);
-
- void
- GetCFIData();
-
- // Applies the specified DWARF opcode to the given row. This function handle the commands
- // operates only on a single row (these are the ones what can appear both in CIE and in FDE).
- // Returns true if the opcode is handled and false otherwise.
- bool
- HandleCommonDwarfOpcode(uint8_t primary_opcode,
- uint8_t extended_opcode,
- int32_t data_align,
- lldb::offset_t& offset,
- UnwindPlan::Row& row);
-
- ObjectFile& m_objfile;
- lldb::SectionSP m_section_sp;
- lldb::RegisterKind m_reg_kind;
- Flags m_flags;
- cie_map_t m_cie_map;
-
- DataExtractor m_cfi_data;
- bool m_cfi_data_initialized; // only copy the section into the DE once
-
- FDEEntryMap m_fde_index;
- bool m_fde_index_initialized; // only scan the section for FDEs once
- std::mutex m_fde_index_mutex; // and isolate the thread that does it
-
- bool m_is_eh_frame;
-
- CIESP
- ParseCIE (const uint32_t cie_offset);
-
+ enum { CFI_AUG_MAX_SIZE = 8, CFI_HEADER_SIZE = 8 };
+
+ struct CIE {
+ dw_offset_t cie_offset;
+ uint8_t version;
+ char augmentation[CFI_AUG_MAX_SIZE]; // This is typically empty or very
+ // short.
+ uint32_t code_align;
+ int32_t data_align;
+ uint32_t return_addr_reg_num;
+ dw_offset_t inst_offset; // offset of CIE instructions in mCFIData
+ uint32_t inst_length; // length of CIE instructions in mCFIData
+ uint8_t ptr_encoding;
+ uint8_t lsda_addr_encoding; // The encoding of the LSDA address in the FDE
+ // augmentation data
+ lldb::addr_t personality_loc; // (file) address of the pointer to the
+ // personality routine
+ lldb_private::UnwindPlan::Row initial_row;
+
+ CIE(dw_offset_t offset)
+ : cie_offset(offset), version(-1), code_align(0), data_align(0),
+ return_addr_reg_num(LLDB_INVALID_REGNUM), inst_offset(0),
+ inst_length(0), ptr_encoding(0), lsda_addr_encoding(DW_EH_PE_omit),
+ personality_loc(LLDB_INVALID_ADDRESS), initial_row() {}
+ };
+
+ typedef std::shared_ptr<CIE> CIESP;
+
+ typedef std::map<dw_offset_t, CIESP> cie_map_t;
+
+ // Start address (file address), size, offset of FDE location
+ // used for finding an FDE for a given File address; the start address field
+ // is
+ // an offset into an individual Module.
+ typedef RangeDataVector<lldb::addr_t, uint32_t, dw_offset_t> FDEEntryMap;
+
+ bool IsEHFrame() const;
+
+ bool GetFDEEntryByFileAddress(lldb::addr_t file_offset,
+ FDEEntryMap::Entry &fde_entry);
+
+ void GetFDEIndex();
+
+ bool FDEToUnwindPlan(uint32_t offset, Address startaddr,
+ UnwindPlan &unwind_plan);
+
+ const CIE *GetCIE(dw_offset_t cie_offset);
+
+ void GetCFIData();
+
+ // Applies the specified DWARF opcode to the given row. This function handle
+ // the commands
+ // operates only on a single row (these are the ones what can appear both in
+ // CIE and in FDE).
+ // Returns true if the opcode is handled and false otherwise.
+ bool HandleCommonDwarfOpcode(uint8_t primary_opcode, uint8_t extended_opcode,
+ int32_t data_align, lldb::offset_t &offset,
+ UnwindPlan::Row &row);
+
+ ObjectFile &m_objfile;
+ lldb::SectionSP m_section_sp;
+ lldb::RegisterKind m_reg_kind;
+ Flags m_flags;
+ cie_map_t m_cie_map;
+
+ DataExtractor m_cfi_data;
+ bool m_cfi_data_initialized; // only copy the section into the DE once
+
+ FDEEntryMap m_fde_index;
+ bool m_fde_index_initialized; // only scan the section for FDEs once
+ std::mutex m_fde_index_mutex; // and isolate the thread that does it
+
+ bool m_is_eh_frame;
+
+ CIESP
+ ParseCIE(const uint32_t cie_offset);
};
} // namespace lldb_private
-#endif // liblldb_DWARFCallFrameInfo_h_
+#endif // liblldb_DWARFCallFrameInfo_h_
diff --git a/include/lldb/Symbol/DebugMacros.h b/include/lldb/Symbol/DebugMacros.h
index 24bf03a8c3b1..4d4a3273db64 100644
--- a/include/lldb/Symbol/DebugMacros.h
+++ b/include/lldb/Symbol/DebugMacros.h
@@ -17,8 +17,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/ConstString.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -26,113 +26,75 @@ class CompileUnit;
class DebugMacros;
typedef std::shared_ptr<DebugMacros> DebugMacrosSP;
-class DebugMacroEntry
-{
+class DebugMacroEntry {
public:
- enum EntryType
- {
- INVALID,
- DEFINE,
- UNDEF,
- START_FILE,
- END_FILE,
- INDIRECT
- };
+ enum EntryType { INVALID, DEFINE, UNDEF, START_FILE, END_FILE, INDIRECT };
public:
- static DebugMacroEntry
- CreateDefineEntry(uint32_t line, const char *str);
+ static DebugMacroEntry CreateDefineEntry(uint32_t line, const char *str);
- static DebugMacroEntry
- CreateUndefEntry(uint32_t line, const char *str);
+ static DebugMacroEntry CreateUndefEntry(uint32_t line, const char *str);
- static DebugMacroEntry
- CreateStartFileEntry(uint32_t line, uint32_t debug_line_file_idx);
+ static DebugMacroEntry CreateStartFileEntry(uint32_t line,
+ uint32_t debug_line_file_idx);
- static DebugMacroEntry
- CreateEndFileEntry();
+ static DebugMacroEntry CreateEndFileEntry();
- static DebugMacroEntry
- CreateIndirectEntry(const DebugMacrosSP &debug_macros_sp);
+ static DebugMacroEntry
+ CreateIndirectEntry(const DebugMacrosSP &debug_macros_sp);
- DebugMacroEntry() : m_type(INVALID) { }
+ DebugMacroEntry() : m_type(INVALID) {}
- ~DebugMacroEntry() = default;
+ ~DebugMacroEntry() = default;
- EntryType
- GetType() const
- {
- return m_type;
- }
+ EntryType GetType() const { return m_type; }
- uint64_t
- GetLineNumber() const
- {
- return m_line;
- }
+ uint64_t GetLineNumber() const { return m_line; }
- ConstString
- GetMacroString() const
- {
- return m_str;
- }
+ ConstString GetMacroString() const { return m_str; }
- const FileSpec& GetFileSpec(CompileUnit *comp_unit) const;
+ const FileSpec &GetFileSpec(CompileUnit *comp_unit) const;
- DebugMacros *
- GetIndirectDebugMacros() const
- {
- return m_debug_macros_sp.get();
- }
+ DebugMacros *GetIndirectDebugMacros() const {
+ return m_debug_macros_sp.get();
+ }
private:
- DebugMacroEntry(EntryType type,
- uint32_t line,
- uint32_t debug_line_file_idx,
- const char *str);
-
- DebugMacroEntry(EntryType type,
- const DebugMacrosSP &debug_macros_sp);
-
- EntryType m_type:3;
- uint32_t m_line:29;
- uint32_t m_debug_line_file_idx;
- ConstString m_str;
- DebugMacrosSP m_debug_macros_sp;
+ DebugMacroEntry(EntryType type, uint32_t line, uint32_t debug_line_file_idx,
+ const char *str);
+
+ DebugMacroEntry(EntryType type, const DebugMacrosSP &debug_macros_sp);
+
+ EntryType m_type : 3;
+ uint32_t m_line : 29;
+ uint32_t m_debug_line_file_idx;
+ ConstString m_str;
+ DebugMacrosSP m_debug_macros_sp;
};
-class DebugMacros
-{
+class DebugMacros {
public:
- DebugMacros() = default;
-
- ~DebugMacros() = default;
-
- void
- AddMacroEntry(const DebugMacroEntry &entry)
- {
- m_macro_entries.push_back(entry);
- }
-
- size_t
- GetNumMacroEntries() const
- {
- return m_macro_entries.size();
- }
-
- DebugMacroEntry
- GetMacroEntryAtIndex(const size_t index) const
- {
- if (index < m_macro_entries.size())
- return m_macro_entries[index];
- else
- return DebugMacroEntry();
- }
+ DebugMacros() = default;
+
+ ~DebugMacros() = default;
+
+ void AddMacroEntry(const DebugMacroEntry &entry) {
+ m_macro_entries.push_back(entry);
+ }
+
+ size_t GetNumMacroEntries() const { return m_macro_entries.size(); }
+
+ DebugMacroEntry GetMacroEntryAtIndex(const size_t index) const {
+ if (index < m_macro_entries.size())
+ return m_macro_entries[index];
+ else
+ return DebugMacroEntry();
+ }
private:
- DISALLOW_COPY_AND_ASSIGN(DebugMacros);
+ DISALLOW_COPY_AND_ASSIGN(DebugMacros);
- std::vector<DebugMacroEntry> m_macro_entries;
+ std::vector<DebugMacroEntry> m_macro_entries;
};
} // namespace lldb_private
diff --git a/include/lldb/Symbol/DeclVendor.h b/include/lldb/Symbol/DeclVendor.h
index ffba71c9299f..5ee8b19b6ed0 100644
--- a/include/lldb/Symbol/DeclVendor.h
+++ b/include/lldb/Symbol/DeclVendor.h
@@ -15,59 +15,50 @@
#include <vector>
namespace lldb_private {
-
+
//----------------------------------------------------------------------
// The Decl vendor class is intended as a generic interface to search
// for named declarations that are not necessarily backed by a specific
// symbol file.
//----------------------------------------------------------------------
-class DeclVendor
-{
+class DeclVendor {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- DeclVendor()
- {
- }
-
- virtual
- ~DeclVendor()
- {
- }
-
- //------------------------------------------------------------------
- /// Look up the set of Decls that the DeclVendor currently knows about
- /// matching a given name.
- ///
- /// @param[in] name
- /// The name to look for.
- ///
- /// @param[in] append
- /// If true, FindDecls will clear "decls" when it starts.
- ///
- /// @param[in] max_matches
- /// The maximum number of Decls to return. UINT32_MAX means "as
- /// many as possible."
- ///
- /// @return
- /// The number of Decls added to decls; will not exceed
- /// max_matches.
- //------------------------------------------------------------------
- virtual uint32_t
- FindDecls (const ConstString &name,
- bool append,
- uint32_t max_matches,
- std::vector <clang::NamedDecl*> &decls) = 0;
-
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ DeclVendor() {}
+
+ virtual ~DeclVendor() {}
+
+ //------------------------------------------------------------------
+ /// Look up the set of Decls that the DeclVendor currently knows about
+ /// matching a given name.
+ ///
+ /// @param[in] name
+ /// The name to look for.
+ ///
+ /// @param[in] append
+ /// If true, FindDecls will clear "decls" when it starts.
+ ///
+ /// @param[in] max_matches
+ /// The maximum number of Decls to return. UINT32_MAX means "as
+ /// many as possible."
+ ///
+ /// @return
+ /// The number of Decls added to decls; will not exceed
+ /// max_matches.
+ //------------------------------------------------------------------
+ virtual uint32_t FindDecls(const ConstString &name, bool append,
+ uint32_t max_matches,
+ std::vector<clang::NamedDecl *> &decls) = 0;
+
private:
- //------------------------------------------------------------------
- // For DeclVendor only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (DeclVendor);
+ //------------------------------------------------------------------
+ // For DeclVendor only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(DeclVendor);
};
-
-
+
} // namespace lldb_private
#endif
diff --git a/include/lldb/Symbol/Declaration.h b/include/lldb/Symbol/Declaration.h
index 73dede556eae..1846e2fdca82 100644
--- a/include/lldb/Symbol/Declaration.h
+++ b/include/lldb/Symbol/Declaration.h
@@ -10,8 +10,8 @@
#ifndef liblldb_Declaration_h_
#define liblldb_Declaration_h_
-#include "lldb/lldb-private.h"
#include "lldb/Host/FileSpec.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -25,254 +25,216 @@ namespace lldb_private {
/// functions, types, variables, any many other debug core objects were
/// declared.
//----------------------------------------------------------------------
-class Declaration
-{
+class Declaration {
public:
- //------------------------------------------------------------------
- /// Default constructor.
- //------------------------------------------------------------------
- Declaration () :
- m_file (),
- m_line (0)
+ //------------------------------------------------------------------
+ /// Default constructor.
+ //------------------------------------------------------------------
+ Declaration()
+ : m_file(), m_line(0)
#ifdef LLDB_ENABLE_DECLARATION_COLUMNS
- ,m_column (0)
+ ,
+ m_column(0)
#endif
- {
- }
-
-
- //------------------------------------------------------------------
- /// Construct with file specification, and optional line and column.
- ///
- /// @param[in] file_spec
- /// The file specification that describes where this was
- /// declared.
- ///
- /// @param[in] line
- /// The line number that describes where this was declared. Set
- /// to zero if there is no line number information.
- ///
- /// @param[in] column
- /// The column number that describes where this was declared.
- /// Set to zero if there is no column number information.
- //------------------------------------------------------------------
- Declaration (const FileSpec& file_spec, uint32_t line = 0, uint32_t column = 0) :
- m_file (file_spec),
- m_line (line)
+ {
+ }
+
+ //------------------------------------------------------------------
+ /// Construct with file specification, and optional line and column.
+ ///
+ /// @param[in] file_spec
+ /// The file specification that describes where this was
+ /// declared.
+ ///
+ /// @param[in] line
+ /// The line number that describes where this was declared. Set
+ /// to zero if there is no line number information.
+ ///
+ /// @param[in] column
+ /// The column number that describes where this was declared.
+ /// Set to zero if there is no column number information.
+ //------------------------------------------------------------------
+ Declaration(const FileSpec &file_spec, uint32_t line = 0, uint32_t column = 0)
+ : m_file(file_spec), m_line(line)
#ifdef LLDB_ENABLE_DECLARATION_COLUMNS
- ,m_column (column)
+ ,
+ m_column(column)
#endif
- {
- }
-
- //------------------------------------------------------------------
- /// Construct with a reference to another Declaration object.
- //------------------------------------------------------------------
- Declaration (const Declaration& rhs) :
- m_file (rhs.m_file),
- m_line (rhs.m_line)
+ {
+ }
+
+ //------------------------------------------------------------------
+ /// Construct with a reference to another Declaration object.
+ //------------------------------------------------------------------
+ Declaration(const Declaration &rhs)
+ : m_file(rhs.m_file), m_line(rhs.m_line)
#ifdef LLDB_ENABLE_DECLARATION_COLUMNS
- ,m_column (rhs.m_column)
+ ,
+ m_column(rhs.m_column)
#endif
- {
-
- }
-
- //------------------------------------------------------------------
- /// Construct with a pointer to another Declaration object.
- //------------------------------------------------------------------
- Declaration(const Declaration* decl_ptr) :
- m_file(),
- m_line(0)
+ {
+ }
+
+ //------------------------------------------------------------------
+ /// Construct with a pointer to another Declaration object.
+ //------------------------------------------------------------------
+ Declaration(const Declaration *decl_ptr)
+ : m_file(), m_line(0)
#ifdef LLDB_ENABLE_DECLARATION_COLUMNS
- ,m_column(0)
+ ,
+ m_column(0)
#endif
- {
- if (decl_ptr)
- *this = *decl_ptr;
- }
-
- //------------------------------------------------------------------
- /// Clear the object's state.
- ///
- /// Sets the file specification to be empty, and the line and column
- /// to zero.
- //------------------------------------------------------------------
- void
- Clear ()
- {
- m_file.Clear();
- m_line= 0;
+ {
+ if (decl_ptr)
+ *this = *decl_ptr;
+ }
+
+ //------------------------------------------------------------------
+ /// Clear the object's state.
+ ///
+ /// Sets the file specification to be empty, and the line and column
+ /// to zero.
+ //------------------------------------------------------------------
+ void Clear() {
+ m_file.Clear();
+ m_line = 0;
#ifdef LLDB_ENABLE_DECLARATION_COLUMNS
- m_column = 0;
+ m_column = 0;
#endif
- }
-
- //------------------------------------------------------------------
- /// Compare two declaration objects.
- ///
- /// Compares the two file specifications from \a lhs and \a rhs. If
- /// the file specifications are equal, then continue to compare the
- /// line number and column numbers respectively.
- ///
- /// @param[in] lhs
- /// The Left Hand Side const Declaration object reference.
- ///
- /// @param[in] rhs
- /// The Right Hand Side const Declaration object reference.
- ///
- /// @return
- /// @li -1 if lhs < rhs
- /// @li 0 if lhs == rhs
- /// @li 1 if lhs > rhs
- //------------------------------------------------------------------
- static int
- Compare (const Declaration& lhs, const Declaration& rhs);
-
- //------------------------------------------------------------------
- /// Dump a description of this object to a Stream.
- ///
- /// Dump a description of the contents of this object to the
- /// supplied stream \a s.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- //------------------------------------------------------------------
- void
- Dump (Stream *s, bool show_fullpaths) const;
-
- bool
- DumpStopContext (Stream *s, bool show_fullpaths) const;
- //------------------------------------------------------------------
- /// Get accessor for the declaration column number.
- ///
- /// @return
- /// Non-zero indicates a valid column number, zero indicates no
- /// column information is available.
- //------------------------------------------------------------------
- uint32_t
- GetColumn () const
- {
+ }
+
+ //------------------------------------------------------------------
+ /// Compare two declaration objects.
+ ///
+ /// Compares the two file specifications from \a lhs and \a rhs. If
+ /// the file specifications are equal, then continue to compare the
+ /// line number and column numbers respectively.
+ ///
+ /// @param[in] lhs
+ /// The Left Hand Side const Declaration object reference.
+ ///
+ /// @param[in] rhs
+ /// The Right Hand Side const Declaration object reference.
+ ///
+ /// @return
+ /// @li -1 if lhs < rhs
+ /// @li 0 if lhs == rhs
+ /// @li 1 if lhs > rhs
+ //------------------------------------------------------------------
+ static int Compare(const Declaration &lhs, const Declaration &rhs);
+
+ //------------------------------------------------------------------
+ /// Dump a description of this object to a Stream.
+ ///
+ /// Dump a description of the contents of this object to the
+ /// supplied stream \a s.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ //------------------------------------------------------------------
+ void Dump(Stream *s, bool show_fullpaths) const;
+
+ bool DumpStopContext(Stream *s, bool show_fullpaths) const;
+ //------------------------------------------------------------------
+ /// Get accessor for the declaration column number.
+ ///
+ /// @return
+ /// Non-zero indicates a valid column number, zero indicates no
+ /// column information is available.
+ //------------------------------------------------------------------
+ uint32_t GetColumn() const {
#ifdef LLDB_ENABLE_DECLARATION_COLUMNS
- return m_column;
+ return m_column;
#else
- return 0;
+ return 0;
#endif
- }
-
- //------------------------------------------------------------------
- /// Get accessor for file specification.
- ///
- /// @return
- /// A reference to the file specification object.
- //------------------------------------------------------------------
- FileSpec&
- GetFile ()
- {
- return m_file;
- }
-
- //------------------------------------------------------------------
- /// Get const accessor for file specification.
- ///
- /// @return
- /// A const reference to the file specification object.
- //------------------------------------------------------------------
- const FileSpec&
- GetFile () const
- {
- return m_file;
- }
-
- //------------------------------------------------------------------
- /// Get accessor for the declaration line number.
- ///
- /// @return
- /// Non-zero indicates a valid line number, zero indicates no
- /// line information is available.
- //------------------------------------------------------------------
- uint32_t
- GetLine () const
- {
- return m_line;
- }
-
-
- bool
- IsValid() const
- {
- return m_file && m_line != 0;
- }
-
- //------------------------------------------------------------------
- /// Get the memory cost of this object.
- ///
- /// @return
- /// The number of bytes that this object occupies in memory.
- /// The returned value does not include the bytes for any
- /// shared string values.
- ///
- /// @see ConstString::StaticMemorySize ()
- //------------------------------------------------------------------
- size_t
- MemorySize () const;
-
- //------------------------------------------------------------------
- /// Set accessor for the declaration column number.
- ///
- /// @param[in] column
- /// Non-zero indicates a valid column number, zero indicates no
- /// column information is available.
- //------------------------------------------------------------------
- void
- SetColumn (uint32_t column)
- {
+ }
+
+ //------------------------------------------------------------------
+ /// Get accessor for file specification.
+ ///
+ /// @return
+ /// A reference to the file specification object.
+ //------------------------------------------------------------------
+ FileSpec &GetFile() { return m_file; }
+
+ //------------------------------------------------------------------
+ /// Get const accessor for file specification.
+ ///
+ /// @return
+ /// A const reference to the file specification object.
+ //------------------------------------------------------------------
+ const FileSpec &GetFile() const { return m_file; }
+
+ //------------------------------------------------------------------
+ /// Get accessor for the declaration line number.
+ ///
+ /// @return
+ /// Non-zero indicates a valid line number, zero indicates no
+ /// line information is available.
+ //------------------------------------------------------------------
+ uint32_t GetLine() const { return m_line; }
+
+ bool IsValid() const { return m_file && m_line != 0; }
+
+ //------------------------------------------------------------------
+ /// Get the memory cost of this object.
+ ///
+ /// @return
+ /// The number of bytes that this object occupies in memory.
+ /// The returned value does not include the bytes for any
+ /// shared string values.
+ ///
+ /// @see ConstString::StaticMemorySize ()
+ //------------------------------------------------------------------
+ size_t MemorySize() const;
+
+ //------------------------------------------------------------------
+ /// Set accessor for the declaration column number.
+ ///
+ /// @param[in] column
+ /// Non-zero indicates a valid column number, zero indicates no
+ /// column information is available.
+ //------------------------------------------------------------------
+ void SetColumn(uint32_t column) {
#ifdef LLDB_ENABLE_DECLARATION_COLUMNS
- m_column = col;
+ m_column = col;
#endif
- }
-
- //------------------------------------------------------------------
- /// Set accessor for the declaration file specification.
- ///
- /// @param[in] file_spec
- /// The new declaration file specification.
- //------------------------------------------------------------------
- void
- SetFile (const FileSpec& file_spec)
- {
- m_file = file_spec;
- }
+ }
+
+ //------------------------------------------------------------------
+ /// Set accessor for the declaration file specification.
+ ///
+ /// @param[in] file_spec
+ /// The new declaration file specification.
+ //------------------------------------------------------------------
+ void SetFile(const FileSpec &file_spec) { m_file = file_spec; }
+
+ //------------------------------------------------------------------
+ /// Set accessor for the declaration line number.
+ ///
+ /// @param[in] line
+ /// Non-zero indicates a valid line number, zero indicates no
+ /// line information is available.
+ //------------------------------------------------------------------
+ void SetLine(uint32_t line) { m_line = line; }
- //------------------------------------------------------------------
- /// Set accessor for the declaration line number.
- ///
- /// @param[in] line
- /// Non-zero indicates a valid line number, zero indicates no
- /// line information is available.
- //------------------------------------------------------------------
- void
- SetLine (uint32_t line)
- {
- m_line = line;
- }
protected:
- //------------------------------------------------------------------
- /// Member variables.
- //------------------------------------------------------------------
- FileSpec m_file; ///< The file specification that points to the
- ///< source file where the declaration occurred.
- uint32_t m_line; ///< Non-zero values indicates a valid line number,
- ///< zero indicates no line number information is available.
+ //------------------------------------------------------------------
+ /// Member variables.
+ //------------------------------------------------------------------
+ FileSpec m_file; ///< The file specification that points to the
+ ///< source file where the declaration occurred.
+ uint32_t m_line; ///< Non-zero values indicates a valid line number,
+ ///< zero indicates no line number information is available.
#ifdef LLDB_ENABLE_DECLARATION_COLUMNS
- uint32_t m_column; ///< Non-zero values indicates a valid column number,
- ///< zero indicates no column information is available.
+ uint32_t m_column; ///< Non-zero values indicates a valid column number,
+ ///< zero indicates no column information is available.
#endif
};
-bool
-operator == (const Declaration &lhs, const Declaration &rhs);
+bool operator==(const Declaration &lhs, const Declaration &rhs);
} // namespace lldb_private
-#endif // liblldb_Declaration_h_
+#endif // liblldb_Declaration_h_
diff --git a/include/lldb/Symbol/FuncUnwinders.h b/include/lldb/Symbol/FuncUnwinders.h
index 6d5991cc2b33..a5b9b801e033 100644
--- a/include/lldb/Symbol/FuncUnwinders.h
+++ b/include/lldb/Symbol/FuncUnwinders.h
@@ -5,157 +5,152 @@
#include <vector>
#include "lldb/Core/AddressRange.h"
-#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/AddressRange.h"
+#include "lldb/Core/ArchSpec.h"
namespace lldb_private {
class UnwindTable;
-class FuncUnwinders
-{
+class FuncUnwinders {
public:
- // FuncUnwinders objects are used to track UnwindPlans for a function
- // (named or not - really just an address range)
-
- // We'll record four different UnwindPlans for each address range:
- //
- // 1. Unwinding from a call site (a valid exception throw location)
- // This is often sourced from the eh_frame exception handling info
- // 2. Unwinding from a non-call site (any location in the function)
- // This is often done by analyzing the function prologue assembly
- // language instructions
- // 3. A fast unwind method for this function which only retrieves a
- // limited set of registers necessary to walk the stack
- // 4. An architectural default unwind plan when none of the above are
- // available for some reason.
+ // FuncUnwinders objects are used to track UnwindPlans for a function
+ // (named or not - really just an address range)
- // Additionally, FuncUnwinds object can be asked where the prologue
- // instructions are finished for migrating breakpoints past the
- // stack frame setup instructions when we don't have line table information.
+ // We'll record four different UnwindPlans for each address range:
+ //
+ // 1. Unwinding from a call site (a valid exception throw location)
+ // This is often sourced from the eh_frame exception handling info
+ // 2. Unwinding from a non-call site (any location in the function)
+ // This is often done by analyzing the function prologue assembly
+ // language instructions
+ // 3. A fast unwind method for this function which only retrieves a
+ // limited set of registers necessary to walk the stack
+ // 4. An architectural default unwind plan when none of the above are
+ // available for some reason.
- FuncUnwinders (lldb_private::UnwindTable& unwind_table, AddressRange range);
+ // Additionally, FuncUnwinds object can be asked where the prologue
+ // instructions are finished for migrating breakpoints past the
+ // stack frame setup instructions when we don't have line table information.
- ~FuncUnwinders ();
+ FuncUnwinders(lldb_private::UnwindTable &unwind_table, AddressRange range);
- // current_offset is the byte offset into the function.
- // 0 means no instructions have executed yet. -1 means the offset is unknown.
- // On architectures where the pc points to the next instruction that will execute, this
- // offset value will have already been decremented by 1 to stay within the bounds of the
- // correct function body.
- lldb::UnwindPlanSP
- GetUnwindPlanAtCallSite (Target &target, int current_offset);
+ ~FuncUnwinders();
- lldb::UnwindPlanSP
- GetUnwindPlanAtNonCallSite (Target& target, lldb_private::Thread& thread, int current_offset);
+ // current_offset is the byte offset into the function.
+ // 0 means no instructions have executed yet. -1 means the offset is unknown.
+ // On architectures where the pc points to the next instruction that will
+ // execute, this
+ // offset value will have already been decremented by 1 to stay within the
+ // bounds of the
+ // correct function body.
+ lldb::UnwindPlanSP GetUnwindPlanAtCallSite(Target &target,
+ int current_offset);
- lldb::UnwindPlanSP
- GetUnwindPlanFastUnwind (Target& target, lldb_private::Thread& thread);
+ lldb::UnwindPlanSP GetUnwindPlanAtNonCallSite(Target &target,
+ lldb_private::Thread &thread,
+ int current_offset);
- lldb::UnwindPlanSP
- GetUnwindPlanArchitectureDefault (lldb_private::Thread& thread);
+ lldb::UnwindPlanSP GetUnwindPlanFastUnwind(Target &target,
+ lldb_private::Thread &thread);
- lldb::UnwindPlanSP
- GetUnwindPlanArchitectureDefaultAtFunctionEntry (lldb_private::Thread& thread);
+ lldb::UnwindPlanSP
+ GetUnwindPlanArchitectureDefault(lldb_private::Thread &thread);
- Address&
- GetFirstNonPrologueInsn (Target& target);
+ lldb::UnwindPlanSP
+ GetUnwindPlanArchitectureDefaultAtFunctionEntry(lldb_private::Thread &thread);
- const Address&
- GetFunctionStartAddress () const;
+ Address &GetFirstNonPrologueInsn(Target &target);
- bool
- ContainsAddress (const Address& addr) const
- {
- return m_range.ContainsFileAddress (addr);
- }
+ const Address &GetFunctionStartAddress() const;
- // A function may have a Language Specific Data Area specified -- a block of data in
- // the object file which is used in the processing of an exception throw / catch.
- // If any of the UnwindPlans have the address of the LSDA region for this function,
- // this will return it.
- Address
- GetLSDAAddress (Target &target);
+ bool ContainsAddress(const Address &addr) const {
+ return m_range.ContainsFileAddress(addr);
+ }
- // A function may have a Personality Routine associated with it -- used in the
- // processing of throwing an exception. If any of the UnwindPlans have the
- // address of the personality routine, this will return it. Read the target-pointer
- // at this address to get the personality function address.
- Address
- GetPersonalityRoutinePtrAddress (Target &target);
+ // A function may have a Language Specific Data Area specified -- a block of
+ // data in
+ // the object file which is used in the processing of an exception throw /
+ // catch.
+ // If any of the UnwindPlans have the address of the LSDA region for this
+ // function,
+ // this will return it.
+ Address GetLSDAAddress(Target &target);
+ // A function may have a Personality Routine associated with it -- used in the
+ // processing of throwing an exception. If any of the UnwindPlans have the
+ // address of the personality routine, this will return it. Read the
+ // target-pointer
+ // at this address to get the personality function address.
+ Address GetPersonalityRoutinePtrAddress(Target &target);
+ // The following methods to retrieve specific unwind plans should rarely be
+ // used.
+ // Instead, clients should ask for the *behavior* they are looking for, using
+ // one
+ // of the above UnwindPlan retrieval methods.
- // The following methods to retrieve specific unwind plans should rarely be used.
- // Instead, clients should ask for the *behavior* they are looking for, using one
- // of the above UnwindPlan retrieval methods.
+ lldb::UnwindPlanSP GetAssemblyUnwindPlan(Target &target, Thread &thread,
+ int current_offset);
- lldb::UnwindPlanSP
- GetAssemblyUnwindPlan (Target &target, Thread &thread, int current_offset);
+ lldb::UnwindPlanSP GetEHFrameUnwindPlan(Target &target, int current_offset);
- lldb::UnwindPlanSP
- GetEHFrameUnwindPlan (Target &target, int current_offset);
+ lldb::UnwindPlanSP GetEHFrameAugmentedUnwindPlan(Target &target,
+ Thread &thread,
+ int current_offset);
- lldb::UnwindPlanSP
- GetEHFrameAugmentedUnwindPlan (Target &target, Thread &thread, int current_offset);
+ lldb::UnwindPlanSP GetCompactUnwindUnwindPlan(Target &target,
+ int current_offset);
- lldb::UnwindPlanSP
- GetCompactUnwindUnwindPlan (Target &target, int current_offset);
+ lldb::UnwindPlanSP GetArmUnwindUnwindPlan(Target &target, int current_offset);
- lldb::UnwindPlanSP
- GetArmUnwindUnwindPlan (Target &target, int current_offset);
+ lldb::UnwindPlanSP GetArchDefaultUnwindPlan(Thread &thread);
- lldb::UnwindPlanSP
- GetArchDefaultUnwindPlan (Thread &thread);
-
- lldb::UnwindPlanSP
- GetArchDefaultAtFuncEntryUnwindPlan (Thread &thread);
+ lldb::UnwindPlanSP GetArchDefaultAtFuncEntryUnwindPlan(Thread &thread);
private:
-
- lldb::UnwindAssemblySP
- GetUnwindAssemblyProfiler (Target& target);
-
- // Do a simplistic comparison for the register restore rule for getting
- // the caller's pc value on two UnwindPlans -- returns LazyBoolYes if
- // they have the same unwind rule for the pc, LazyBoolNo if they do not
- // have the same unwind rule for the pc, and LazyBoolCalculate if it was
- // unable to determine this for some reason.
- lldb_private::LazyBool
- CompareUnwindPlansForIdenticalInitialPCLocation (Thread& thread, const lldb::UnwindPlanSP &a, const lldb::UnwindPlanSP &b);
-
- UnwindTable& m_unwind_table;
- AddressRange m_range;
-
- std::recursive_mutex m_mutex;
-
- lldb::UnwindPlanSP m_unwind_plan_assembly_sp;
- lldb::UnwindPlanSP m_unwind_plan_eh_frame_sp;
- lldb::UnwindPlanSP m_unwind_plan_eh_frame_augmented_sp; // augmented by assembly inspection so it's valid everywhere
- std::vector<lldb::UnwindPlanSP> m_unwind_plan_compact_unwind;
- lldb::UnwindPlanSP m_unwind_plan_arm_unwind_sp;
- lldb::UnwindPlanSP m_unwind_plan_fast_sp;
- lldb::UnwindPlanSP m_unwind_plan_arch_default_sp;
- lldb::UnwindPlanSP m_unwind_plan_arch_default_at_func_entry_sp;
-
- // Fetching the UnwindPlans can be expensive - if we've already attempted
- // to get one & failed, don't try again.
- bool m_tried_unwind_plan_assembly:1,
- m_tried_unwind_plan_eh_frame:1,
- m_tried_unwind_plan_eh_frame_augmented:1,
- m_tried_unwind_plan_compact_unwind:1,
- m_tried_unwind_plan_arm_unwind:1,
- m_tried_unwind_fast:1,
- m_tried_unwind_arch_default:1,
- m_tried_unwind_arch_default_at_func_entry:1;
-
- Address m_first_non_prologue_insn;
-
- DISALLOW_COPY_AND_ASSIGN (FuncUnwinders);
+ lldb::UnwindAssemblySP GetUnwindAssemblyProfiler(Target &target);
+
+ // Do a simplistic comparison for the register restore rule for getting
+ // the caller's pc value on two UnwindPlans -- returns LazyBoolYes if
+ // they have the same unwind rule for the pc, LazyBoolNo if they do not
+ // have the same unwind rule for the pc, and LazyBoolCalculate if it was
+ // unable to determine this for some reason.
+ lldb_private::LazyBool CompareUnwindPlansForIdenticalInitialPCLocation(
+ Thread &thread, const lldb::UnwindPlanSP &a, const lldb::UnwindPlanSP &b);
+
+ UnwindTable &m_unwind_table;
+ AddressRange m_range;
+
+ std::recursive_mutex m_mutex;
+
+ lldb::UnwindPlanSP m_unwind_plan_assembly_sp;
+ lldb::UnwindPlanSP m_unwind_plan_eh_frame_sp;
+ lldb::UnwindPlanSP m_unwind_plan_eh_frame_augmented_sp; // augmented by
+ // assembly inspection
+ // so it's valid
+ // everywhere
+ std::vector<lldb::UnwindPlanSP> m_unwind_plan_compact_unwind;
+ lldb::UnwindPlanSP m_unwind_plan_arm_unwind_sp;
+ lldb::UnwindPlanSP m_unwind_plan_fast_sp;
+ lldb::UnwindPlanSP m_unwind_plan_arch_default_sp;
+ lldb::UnwindPlanSP m_unwind_plan_arch_default_at_func_entry_sp;
+
+ // Fetching the UnwindPlans can be expensive - if we've already attempted
+ // to get one & failed, don't try again.
+ bool m_tried_unwind_plan_assembly : 1, m_tried_unwind_plan_eh_frame : 1,
+ m_tried_unwind_plan_eh_frame_augmented : 1,
+ m_tried_unwind_plan_compact_unwind : 1,
+ m_tried_unwind_plan_arm_unwind : 1, m_tried_unwind_fast : 1,
+ m_tried_unwind_arch_default : 1,
+ m_tried_unwind_arch_default_at_func_entry : 1;
+
+ Address m_first_non_prologue_insn;
+
+ DISALLOW_COPY_AND_ASSIGN(FuncUnwinders);
}; // class FuncUnwinders
} // namespace lldb_private
-
-#endif //liblldb_FuncUnwinders_h
+#endif // liblldb_FuncUnwinders_h
diff --git a/include/lldb/Symbol/Function.h b/include/lldb/Symbol/Function.h
index 9892d620ce47..232d0790f492 100644
--- a/include/lldb/Symbol/Function.h
+++ b/include/lldb/Symbol/Function.h
@@ -11,11 +11,11 @@
#define liblldb_Function_h_
#include "lldb/Core/AddressRange.h"
-#include "lldb/Symbol/Block.h"
-#include "lldb/Symbol/Declaration.h"
-#include "lldb/Expression/DWARFExpression.h"
#include "lldb/Core/Mangled.h"
#include "lldb/Core/UserID.h"
+#include "lldb/Expression/DWARFExpression.h"
+#include "lldb/Symbol/Block.h"
+#include "lldb/Symbol/Declaration.h"
namespace lldb_private {
@@ -26,281 +26,268 @@ namespace lldb_private {
/// This provides generic function information that gets reused between
/// inline functions and function types.
//----------------------------------------------------------------------
-class FunctionInfo
-{
+class FunctionInfo {
public:
- //------------------------------------------------------------------
- /// Construct with the function method name and optional declaration
- /// information.
- ///
- /// @param[in] name
- /// A C string name for the method name for this function. This
- /// value should not be the mangled named, but the simple method
- /// name.
- ///
- /// @param[in] decl_ptr
- /// Optional declaration information that describes where the
- /// function was declared. This can be NULL.
- //------------------------------------------------------------------
- FunctionInfo (const char *name, const Declaration *decl_ptr);
-
- //------------------------------------------------------------------
- /// Construct with the function method name and optional declaration
- /// information.
- ///
- /// @param[in] name
- /// A name for the method name for this function. This value
- /// should not be the mangled named, but the simple method name.
- ///
- /// @param[in] decl_ptr
- /// Optional declaration information that describes where the
- /// function was declared. This can be NULL.
- //------------------------------------------------------------------
- FunctionInfo (const ConstString& name, const Declaration *decl_ptr);
-
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// The destructor is virtual since classes inherit from this class.
- //------------------------------------------------------------------
- virtual
- ~FunctionInfo ();
-
- //------------------------------------------------------------------
- /// Compare two function information objects.
- ///
- /// First compares the method names, and if equal, then compares
- /// the declaration information.
- ///
- /// @param[in] lhs
- /// The Left Hand Side const FunctionInfo object reference.
- ///
- /// @param[in] rhs
- /// The Right Hand Side const FunctionInfo object reference.
- ///
- /// @return
- /// @li -1 if lhs < rhs
- /// @li 0 if lhs == rhs
- /// @li 1 if lhs > rhs
- //------------------------------------------------------------------
- static int
- Compare (const FunctionInfo& lhs, const FunctionInfo& rhs);
-
- //------------------------------------------------------------------
- /// Dump a description of this object to a Stream.
- ///
- /// Dump a description of the contents of this object to the
- /// supplied stream \a s.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- //------------------------------------------------------------------
- void
- Dump (Stream *s, bool show_fullpaths) const;
-
- //------------------------------------------------------------------
- /// Get accessor for the declaration information.
- ///
- /// @return
- /// A reference to the declaration object.
- //------------------------------------------------------------------
- Declaration&
- GetDeclaration ();
-
- //------------------------------------------------------------------
- /// Get const accessor for the declaration information.
- ///
- /// @return
- /// A const reference to the declaration object.
- //------------------------------------------------------------------
- const Declaration&
- GetDeclaration () const;
-
- //------------------------------------------------------------------
- /// Get accessor for the method name.
- ///
- /// @return
- /// A const reference to the method name object.
- //------------------------------------------------------------------
- ConstString
- GetName () const;
-
- //------------------------------------------------------------------
- /// Get the memory cost of this object.
- ///
- /// @return
- /// The number of bytes that this object occupies in memory.
- /// The returned value does not include the bytes for any
- /// shared string values.
- ///
- /// @see ConstString::StaticMemorySize ()
- //------------------------------------------------------------------
- virtual size_t
- MemorySize () const;
+ //------------------------------------------------------------------
+ /// Construct with the function method name and optional declaration
+ /// information.
+ ///
+ /// @param[in] name
+ /// A C string name for the method name for this function. This
+ /// value should not be the mangled named, but the simple method
+ /// name.
+ ///
+ /// @param[in] decl_ptr
+ /// Optional declaration information that describes where the
+ /// function was declared. This can be NULL.
+ //------------------------------------------------------------------
+ FunctionInfo(const char *name, const Declaration *decl_ptr);
+
+ //------------------------------------------------------------------
+ /// Construct with the function method name and optional declaration
+ /// information.
+ ///
+ /// @param[in] name
+ /// A name for the method name for this function. This value
+ /// should not be the mangled named, but the simple method name.
+ ///
+ /// @param[in] decl_ptr
+ /// Optional declaration information that describes where the
+ /// function was declared. This can be NULL.
+ //------------------------------------------------------------------
+ FunctionInfo(const ConstString &name, const Declaration *decl_ptr);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ ///
+ /// The destructor is virtual since classes inherit from this class.
+ //------------------------------------------------------------------
+ virtual ~FunctionInfo();
+
+ //------------------------------------------------------------------
+ /// Compare two function information objects.
+ ///
+ /// First compares the method names, and if equal, then compares
+ /// the declaration information.
+ ///
+ /// @param[in] lhs
+ /// The Left Hand Side const FunctionInfo object reference.
+ ///
+ /// @param[in] rhs
+ /// The Right Hand Side const FunctionInfo object reference.
+ ///
+ /// @return
+ /// @li -1 if lhs < rhs
+ /// @li 0 if lhs == rhs
+ /// @li 1 if lhs > rhs
+ //------------------------------------------------------------------
+ static int Compare(const FunctionInfo &lhs, const FunctionInfo &rhs);
+
+ //------------------------------------------------------------------
+ /// Dump a description of this object to a Stream.
+ ///
+ /// Dump a description of the contents of this object to the
+ /// supplied stream \a s.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ //------------------------------------------------------------------
+ void Dump(Stream *s, bool show_fullpaths) const;
+
+ //------------------------------------------------------------------
+ /// Get accessor for the declaration information.
+ ///
+ /// @return
+ /// A reference to the declaration object.
+ //------------------------------------------------------------------
+ Declaration &GetDeclaration();
+
+ //------------------------------------------------------------------
+ /// Get const accessor for the declaration information.
+ ///
+ /// @return
+ /// A const reference to the declaration object.
+ //------------------------------------------------------------------
+ const Declaration &GetDeclaration() const;
+
+ //------------------------------------------------------------------
+ /// Get accessor for the method name.
+ ///
+ /// @return
+ /// A const reference to the method name object.
+ //------------------------------------------------------------------
+ ConstString GetName() const;
+
+ //------------------------------------------------------------------
+ /// Get the memory cost of this object.
+ ///
+ /// @return
+ /// The number of bytes that this object occupies in memory.
+ /// The returned value does not include the bytes for any
+ /// shared string values.
+ ///
+ /// @see ConstString::StaticMemorySize ()
+ //------------------------------------------------------------------
+ virtual size_t MemorySize() const;
protected:
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- ConstString m_name; ///< Function method name (not a mangled name).
- Declaration m_declaration; ///< Information describing where this function information was defined.
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ ConstString m_name; ///< Function method name (not a mangled name).
+ Declaration m_declaration; ///< Information describing where this function
+ ///information was defined.
};
//----------------------------------------------------------------------
/// @class InlineFunctionInfo Function.h "lldb/Symbol/Function.h"
/// @brief A class that describes information for an inlined function.
//----------------------------------------------------------------------
-class InlineFunctionInfo : public FunctionInfo
-{
+class InlineFunctionInfo : public FunctionInfo {
public:
- //------------------------------------------------------------------
- /// Construct with the function method name, mangled name, and
- /// optional declaration information.
- ///
- /// @param[in] name
- /// A C string name for the method name for this function. This
- /// value should not be the mangled named, but the simple method
- /// name.
- ///
- /// @param[in] mangled
- /// A C string name for the mangled name for this function. This
- /// value can be NULL if there is no mangled information.
- ///
- /// @param[in] decl_ptr
- /// Optional declaration information that describes where the
- /// function was declared. This can be NULL.
- ///
- /// @param[in] call_decl_ptr
- /// Optional calling location declaration information that
- /// describes from where this inlined function was called.
- //------------------------------------------------------------------
- InlineFunctionInfo(const char *name, const char *mangled, const Declaration *decl_ptr, const Declaration *call_decl_ptr);
-
- //------------------------------------------------------------------
- /// Construct with the function method name, mangled name, and
- /// optional declaration information.
- ///
- /// @param[in] name
- /// A name for the method name for this function. This value
- /// should not be the mangled named, but the simple method name.
- ///
- /// @param[in] mangled
- /// A name for the mangled name for this function. This value
- /// can be empty if there is no mangled information.
- ///
- /// @param[in] decl_ptr
- /// Optional declaration information that describes where the
- /// function was declared. This can be NULL.
- ///
- /// @param[in] call_decl_ptr
- /// Optional calling location declaration information that
- /// describes from where this inlined function was called.
- //------------------------------------------------------------------
- InlineFunctionInfo(const ConstString& name, const Mangled &mangled, const Declaration *decl_ptr, const Declaration *call_decl_ptr);
-
- //------------------------------------------------------------------
- /// Destructor.
- //------------------------------------------------------------------
- ~InlineFunctionInfo() override;
-
- //------------------------------------------------------------------
- /// Compare two inlined function information objects.
- ///
- /// First compares the FunctionInfo objects, and if equal,
- /// compares the mangled names.
- ///
- /// @param[in] lhs
- /// The Left Hand Side const InlineFunctionInfo object
- /// reference.
- ///
- /// @param[in] rhs
- /// The Right Hand Side const InlineFunctionInfo object
- /// reference.
- ///
- /// @return
- /// @li -1 if lhs < rhs
- /// @li 0 if lhs == rhs
- /// @li 1 if lhs > rhs
- //------------------------------------------------------------------
- int
- Compare(const InlineFunctionInfo& lhs, const InlineFunctionInfo& rhs);
-
- //------------------------------------------------------------------
- /// Dump a description of this object to a Stream.
- ///
- /// Dump a description of the contents of this object to the
- /// supplied stream \a s.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- //------------------------------------------------------------------
- void
- Dump(Stream *s, bool show_fullpaths) const;
-
- void
- DumpStopContext (Stream *s, lldb::LanguageType language) const;
-
- ConstString
- GetName (lldb::LanguageType language) const;
-
- ConstString
- GetDisplayName (lldb::LanguageType language) const;
-
- //------------------------------------------------------------------
- /// Get accessor for the call site declaration information.
- ///
- /// @return
- /// A reference to the declaration object.
- //------------------------------------------------------------------
- Declaration&
- GetCallSite ();
-
- //------------------------------------------------------------------
- /// Get const accessor for the call site declaration information.
- ///
- /// @return
- /// A const reference to the declaration object.
- //------------------------------------------------------------------
- const Declaration&
- GetCallSite () const;
-
- //------------------------------------------------------------------
- /// Get accessor for the mangled name object.
- ///
- /// @return
- /// A reference to the mangled name object.
- //------------------------------------------------------------------
- Mangled&
- GetMangled();
-
- //------------------------------------------------------------------
- /// Get const accessor for the mangled name object.
- ///
- /// @return
- /// A const reference to the mangled name object.
- //------------------------------------------------------------------
- const Mangled&
- GetMangled() const;
-
- //------------------------------------------------------------------
- /// Get the memory cost of this object.
- ///
- /// @return
- /// The number of bytes that this object occupies in memory.
- /// The returned value does not include the bytes for any
- /// shared string values.
- ///
- /// @see ConstString::StaticMemorySize ()
- //------------------------------------------------------------------
- size_t
- MemorySize() const override;
+ //------------------------------------------------------------------
+ /// Construct with the function method name, mangled name, and
+ /// optional declaration information.
+ ///
+ /// @param[in] name
+ /// A C string name for the method name for this function. This
+ /// value should not be the mangled named, but the simple method
+ /// name.
+ ///
+ /// @param[in] mangled
+ /// A C string name for the mangled name for this function. This
+ /// value can be NULL if there is no mangled information.
+ ///
+ /// @param[in] decl_ptr
+ /// Optional declaration information that describes where the
+ /// function was declared. This can be NULL.
+ ///
+ /// @param[in] call_decl_ptr
+ /// Optional calling location declaration information that
+ /// describes from where this inlined function was called.
+ //------------------------------------------------------------------
+ InlineFunctionInfo(const char *name, const char *mangled,
+ const Declaration *decl_ptr,
+ const Declaration *call_decl_ptr);
+
+ //------------------------------------------------------------------
+ /// Construct with the function method name, mangled name, and
+ /// optional declaration information.
+ ///
+ /// @param[in] name
+ /// A name for the method name for this function. This value
+ /// should not be the mangled named, but the simple method name.
+ ///
+ /// @param[in] mangled
+ /// A name for the mangled name for this function. This value
+ /// can be empty if there is no mangled information.
+ ///
+ /// @param[in] decl_ptr
+ /// Optional declaration information that describes where the
+ /// function was declared. This can be NULL.
+ ///
+ /// @param[in] call_decl_ptr
+ /// Optional calling location declaration information that
+ /// describes from where this inlined function was called.
+ //------------------------------------------------------------------
+ InlineFunctionInfo(const ConstString &name, const Mangled &mangled,
+ const Declaration *decl_ptr,
+ const Declaration *call_decl_ptr);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ //------------------------------------------------------------------
+ ~InlineFunctionInfo() override;
+
+ //------------------------------------------------------------------
+ /// Compare two inlined function information objects.
+ ///
+ /// First compares the FunctionInfo objects, and if equal,
+ /// compares the mangled names.
+ ///
+ /// @param[in] lhs
+ /// The Left Hand Side const InlineFunctionInfo object
+ /// reference.
+ ///
+ /// @param[in] rhs
+ /// The Right Hand Side const InlineFunctionInfo object
+ /// reference.
+ ///
+ /// @return
+ /// @li -1 if lhs < rhs
+ /// @li 0 if lhs == rhs
+ /// @li 1 if lhs > rhs
+ //------------------------------------------------------------------
+ int Compare(const InlineFunctionInfo &lhs, const InlineFunctionInfo &rhs);
+
+ //------------------------------------------------------------------
+ /// Dump a description of this object to a Stream.
+ ///
+ /// Dump a description of the contents of this object to the
+ /// supplied stream \a s.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ //------------------------------------------------------------------
+ void Dump(Stream *s, bool show_fullpaths) const;
+
+ void DumpStopContext(Stream *s, lldb::LanguageType language) const;
+
+ ConstString GetName(lldb::LanguageType language) const;
+
+ ConstString GetDisplayName(lldb::LanguageType language) const;
+
+ //------------------------------------------------------------------
+ /// Get accessor for the call site declaration information.
+ ///
+ /// @return
+ /// A reference to the declaration object.
+ //------------------------------------------------------------------
+ Declaration &GetCallSite();
+
+ //------------------------------------------------------------------
+ /// Get const accessor for the call site declaration information.
+ ///
+ /// @return
+ /// A const reference to the declaration object.
+ //------------------------------------------------------------------
+ const Declaration &GetCallSite() const;
+
+ //------------------------------------------------------------------
+ /// Get accessor for the mangled name object.
+ ///
+ /// @return
+ /// A reference to the mangled name object.
+ //------------------------------------------------------------------
+ Mangled &GetMangled();
+
+ //------------------------------------------------------------------
+ /// Get const accessor for the mangled name object.
+ ///
+ /// @return
+ /// A const reference to the mangled name object.
+ //------------------------------------------------------------------
+ const Mangled &GetMangled() const;
+
+ //------------------------------------------------------------------
+ /// Get the memory cost of this object.
+ ///
+ /// @return
+ /// The number of bytes that this object occupies in memory.
+ /// The returned value does not include the bytes for any
+ /// shared string values.
+ ///
+ /// @see ConstString::StaticMemorySize ()
+ //------------------------------------------------------------------
+ size_t MemorySize() const override;
private:
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- Mangled m_mangled; ///< Mangled inlined function name (can be empty if there is no mangled information).
- Declaration m_call_decl;
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ Mangled m_mangled; ///< Mangled inlined function name (can be empty if there
+ ///is no mangled information).
+ Declaration m_call_decl;
};
//----------------------------------------------------------------------
@@ -327,369 +314,321 @@ private:
/// The concrete information is the address range information and
/// specific locations for an instance of this function.
//----------------------------------------------------------------------
-class Function :
- public UserID,
- public SymbolContextScope
-{
+class Function : public UserID, public SymbolContextScope {
public:
- //------------------------------------------------------------------
- /// Construct with a compile unit, function UID, function type UID,
- /// optional mangled name, function type, and a section offset
- /// based address range.
- ///
- /// @param[in] comp_unit
- /// The compile unit to which this function belongs.
- ///
- /// @param[in] func_uid
- /// The UID for this function. This value is provided by the
- /// SymbolFile plug-in and can be any value that allows
- /// the plug-in to quickly find and parse more detailed
- /// information when and if more information is needed.
- ///
- /// @param[in] func_type_uid
- /// The type UID for the function Type to allow for lazy type
- /// parsing from the debug information.
- ///
- /// @param[in] mangled
- /// The optional mangled name for this function. If empty, there
- /// is no mangled information.
- ///
- /// @param[in] func_type
- /// The optional function type. If NULL, the function type will
- /// be parsed on demand when accessed using the
- /// Function::GetType() function by asking the SymbolFile
- /// plug-in to get the type for \a func_type_uid.
- ///
- /// @param[in] range
- /// The section offset based address for this function.
- //------------------------------------------------------------------
- Function (
- CompileUnit *comp_unit,
- lldb::user_id_t func_uid,
- lldb::user_id_t func_type_uid,
- const Mangled &mangled,
- Type * func_type,
- const AddressRange& range);
-
- //------------------------------------------------------------------
- /// Construct with a compile unit, function UID, function type UID,
- /// optional mangled name, function type, and a section offset
- /// based address range.
- ///
- /// @param[in] comp_unit
- /// The compile unit to which this function belongs.
- ///
- /// @param[in] func_uid
- /// The UID for this function. This value is provided by the
- /// SymbolFile plug-in and can be any value that allows
- /// the plug-in to quickly find and parse more detailed
- /// information when and if more information is needed.
- ///
- /// @param[in] func_type_uid
- /// The type UID for the function Type to allow for lazy type
- /// parsing from the debug information.
- ///
- /// @param[in] mangled
- /// The optional mangled name for this function. If empty, there
- /// is no mangled information.
- ///
- /// @param[in] func_type
- /// The optional function type. If NULL, the function type will
- /// be parsed on demand when accessed using the
- /// Function::GetType() function by asking the SymbolFile
- /// plug-in to get the type for \a func_type_uid.
- ///
- /// @param[in] range
- /// The section offset based address for this function.
- //------------------------------------------------------------------
- Function (
- CompileUnit *comp_unit,
- lldb::user_id_t func_uid,
- lldb::user_id_t func_type_uid,
- const char *mangled,
- Type * func_type,
- const AddressRange& range);
-
- //------------------------------------------------------------------
- /// Destructor.
- //------------------------------------------------------------------
- ~Function() override;
-
- //------------------------------------------------------------------
- /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
- ///
- /// @see SymbolContextScope
- //------------------------------------------------------------------
- void
- CalculateSymbolContext(SymbolContext* sc) override;
-
- lldb::ModuleSP
- CalculateSymbolContextModule() override;
-
- CompileUnit *
- CalculateSymbolContextCompileUnit() override;
-
- Function *
- CalculateSymbolContextFunction() override;
-
- const AddressRange &
- GetAddressRange()
- {
- return m_range;
- }
-
- lldb::LanguageType
- GetLanguage() const;
- //------------------------------------------------------------------
- /// Find the file and line number of the source location of the start
- /// of the function. This will use the declaration if present and fall
- /// back on the line table if that fails. So there may NOT be a line
- /// table entry for this source file/line combo.
- ///
- /// @param[out] source_file
- /// The source file.
- ///
- /// @param[out] line_no
- /// The line number.
- //------------------------------------------------------------------
- void
- GetStartLineSourceInfo (FileSpec &source_file, uint32_t &line_no);
-
- //------------------------------------------------------------------
- /// Find the file and line number of the source location of the end
- /// of the function.
- ///
- ///
- /// @param[out] source_file
- /// The source file.
- ///
- /// @param[out] line_no
- /// The line number.
- //------------------------------------------------------------------
- void
- GetEndLineSourceInfo (FileSpec &source_file, uint32_t &line_no);
-
- //------------------------------------------------------------------
- /// Get accessor for the block list.
- ///
- /// @return
- /// The block list object that describes all lexical blocks
- /// in the function.
- ///
- /// @see BlockList
- //------------------------------------------------------------------
- Block&
- GetBlock (bool can_create);
-
- //------------------------------------------------------------------
- /// Get accessor for the compile unit that owns this function.
- ///
- /// @return
- /// A compile unit object pointer.
- //------------------------------------------------------------------
- CompileUnit*
- GetCompileUnit();
-
- //------------------------------------------------------------------
- /// Get const accessor for the compile unit that owns this function.
- ///
- /// @return
- /// A const compile unit object pointer.
- //------------------------------------------------------------------
- const CompileUnit*
- GetCompileUnit() const;
-
- void
- GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target);
-
- //------------------------------------------------------------------
- /// Get accessor for the frame base location.
- ///
- /// @return
- /// A location expression that describes the function frame
- /// base.
- //------------------------------------------------------------------
- DWARFExpression &
- GetFrameBaseExpression()
- {
- return m_frame_base;
- }
-
- //------------------------------------------------------------------
- /// Get const accessor for the frame base location.
- ///
- /// @return
- /// A const compile unit object pointer.
- //------------------------------------------------------------------
- const DWARFExpression &
- GetFrameBaseExpression() const
- {
- return m_frame_base;
- }
-
- ConstString
- GetName() const;
-
- ConstString
- GetNameNoArguments () const;
-
- ConstString
- GetDisplayName () const;
-
- const Mangled &
- GetMangled() const
- {
- return m_mangled;
- }
-
- //------------------------------------------------------------------
- /// Get the DeclContext for this function, if available.
- ///
- /// @return
- /// The DeclContext, or NULL if none exists.
- //------------------------------------------------------------------
- CompilerDeclContext
- GetDeclContext();
-
- //------------------------------------------------------------------
- /// Get accessor for the type that describes the function
- /// return value type, and parameter types.
- ///
- /// @return
- /// A type object pointer.
- //------------------------------------------------------------------
- Type*
- GetType();
-
- //------------------------------------------------------------------
- /// Get const accessor for the type that describes the function
- /// return value type, and parameter types.
- ///
- /// @return
- /// A const type object pointer.
- //------------------------------------------------------------------
- const Type*
- GetType() const;
-
- CompilerType
- GetCompilerType ();
-
- //------------------------------------------------------------------
- /// Get the size of the prologue instructions for this function. The "prologue"
- /// instructions include any instructions given line number 0 immediately following
- /// the prologue end.
- ///
- /// @return
- /// The size of the prologue.
- //------------------------------------------------------------------
- uint32_t
- GetPrologueByteSize ();
-
- //------------------------------------------------------------------
- /// Dump a description of this object to a Stream.
- ///
- /// Dump a description of the contents of this object to the
- /// supplied stream \a s.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- ///
- /// @param[in] show_context
- /// If \b true, variables will dump their symbol context
- /// information.
- //------------------------------------------------------------------
- void
- Dump(Stream *s, bool show_context) const;
-
- //------------------------------------------------------------------
- /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
- ///
- /// @see SymbolContextScope
- //------------------------------------------------------------------
- void
- DumpSymbolContext(Stream *s) override;
-
- //------------------------------------------------------------------
- /// Get the memory cost of this object.
- ///
- /// @return
- /// The number of bytes that this object occupies in memory.
- /// The returned value does not include the bytes for any
- /// shared string values.
- ///
- /// @see ConstString::StaticMemorySize ()
- //------------------------------------------------------------------
- size_t
- MemorySize () const;
-
- //------------------------------------------------------------------
- /// Get whether compiler optimizations were enabled for this function
- ///
- /// The debug information may provide information about whether this
- /// function was compiled with optimization or not. In this case,
- /// "optimized" means that the debug experience may be difficult
- /// for the user to understand. Variables may not be available when
- /// the developer would expect them, stepping through the source lines
- /// in the function may appear strange, etc.
- ///
- /// @return
- /// Returns 'true' if this function was compiled with
- /// optimization. 'false' indicates that either the optimization
- /// is unknown, or this function was built without optimization.
- //------------------------------------------------------------------
- bool
- GetIsOptimized ();
-
- //------------------------------------------------------------------
- /// Get whether this function represents a 'top-level' function
- ///
- /// The concept of a top-level function is language-specific, mostly
- /// meant to represent the notion of scripting-style code that has
- /// global visibility of the variables/symbols/functions/...
- /// defined within the containing file/module
- ///
- /// If stopped in a top-level function, LLDB will expose global variables
- /// as-if locals in the 'frame variable' command
- ///
- /// @return
- /// Returns 'true' if this function is a top-level function,
- /// 'false' otherwise.
- //------------------------------------------------------------------
- bool
- IsTopLevelFunction ();
-
- lldb::DisassemblerSP
- GetInstructions (const ExecutionContext &exe_ctx,
- const char *flavor,
- bool prefer_file_cache);
-
- bool
- GetDisassembly (const ExecutionContext &exe_ctx,
- const char *flavor,
- bool prefer_file_cache,
- Stream &strm);
+ //------------------------------------------------------------------
+ /// Construct with a compile unit, function UID, function type UID,
+ /// optional mangled name, function type, and a section offset
+ /// based address range.
+ ///
+ /// @param[in] comp_unit
+ /// The compile unit to which this function belongs.
+ ///
+ /// @param[in] func_uid
+ /// The UID for this function. This value is provided by the
+ /// SymbolFile plug-in and can be any value that allows
+ /// the plug-in to quickly find and parse more detailed
+ /// information when and if more information is needed.
+ ///
+ /// @param[in] func_type_uid
+ /// The type UID for the function Type to allow for lazy type
+ /// parsing from the debug information.
+ ///
+ /// @param[in] mangled
+ /// The optional mangled name for this function. If empty, there
+ /// is no mangled information.
+ ///
+ /// @param[in] func_type
+ /// The optional function type. If NULL, the function type will
+ /// be parsed on demand when accessed using the
+ /// Function::GetType() function by asking the SymbolFile
+ /// plug-in to get the type for \a func_type_uid.
+ ///
+ /// @param[in] range
+ /// The section offset based address for this function.
+ //------------------------------------------------------------------
+ Function(CompileUnit *comp_unit, lldb::user_id_t func_uid,
+ lldb::user_id_t func_type_uid, const Mangled &mangled,
+ Type *func_type, const AddressRange &range);
+
+ //------------------------------------------------------------------
+ /// Construct with a compile unit, function UID, function type UID,
+ /// optional mangled name, function type, and a section offset
+ /// based address range.
+ ///
+ /// @param[in] comp_unit
+ /// The compile unit to which this function belongs.
+ ///
+ /// @param[in] func_uid
+ /// The UID for this function. This value is provided by the
+ /// SymbolFile plug-in and can be any value that allows
+ /// the plug-in to quickly find and parse more detailed
+ /// information when and if more information is needed.
+ ///
+ /// @param[in] func_type_uid
+ /// The type UID for the function Type to allow for lazy type
+ /// parsing from the debug information.
+ ///
+ /// @param[in] mangled
+ /// The optional mangled name for this function. If empty, there
+ /// is no mangled information.
+ ///
+ /// @param[in] func_type
+ /// The optional function type. If NULL, the function type will
+ /// be parsed on demand when accessed using the
+ /// Function::GetType() function by asking the SymbolFile
+ /// plug-in to get the type for \a func_type_uid.
+ ///
+ /// @param[in] range
+ /// The section offset based address for this function.
+ //------------------------------------------------------------------
+ Function(CompileUnit *comp_unit, lldb::user_id_t func_uid,
+ lldb::user_id_t func_type_uid, const char *mangled, Type *func_type,
+ const AddressRange &range);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ //------------------------------------------------------------------
+ ~Function() override;
+
+ //------------------------------------------------------------------
+ /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
+ ///
+ /// @see SymbolContextScope
+ //------------------------------------------------------------------
+ void CalculateSymbolContext(SymbolContext *sc) override;
+
+ lldb::ModuleSP CalculateSymbolContextModule() override;
+
+ CompileUnit *CalculateSymbolContextCompileUnit() override;
+
+ Function *CalculateSymbolContextFunction() override;
+
+ const AddressRange &GetAddressRange() { return m_range; }
+
+ lldb::LanguageType GetLanguage() const;
+ //------------------------------------------------------------------
+ /// Find the file and line number of the source location of the start
+ /// of the function. This will use the declaration if present and fall
+ /// back on the line table if that fails. So there may NOT be a line
+ /// table entry for this source file/line combo.
+ ///
+ /// @param[out] source_file
+ /// The source file.
+ ///
+ /// @param[out] line_no
+ /// The line number.
+ //------------------------------------------------------------------
+ void GetStartLineSourceInfo(FileSpec &source_file, uint32_t &line_no);
+
+ //------------------------------------------------------------------
+ /// Find the file and line number of the source location of the end
+ /// of the function.
+ ///
+ ///
+ /// @param[out] source_file
+ /// The source file.
+ ///
+ /// @param[out] line_no
+ /// The line number.
+ //------------------------------------------------------------------
+ void GetEndLineSourceInfo(FileSpec &source_file, uint32_t &line_no);
+
+ //------------------------------------------------------------------
+ /// Get accessor for the block list.
+ ///
+ /// @return
+ /// The block list object that describes all lexical blocks
+ /// in the function.
+ ///
+ /// @see BlockList
+ //------------------------------------------------------------------
+ Block &GetBlock(bool can_create);
+
+ //------------------------------------------------------------------
+ /// Get accessor for the compile unit that owns this function.
+ ///
+ /// @return
+ /// A compile unit object pointer.
+ //------------------------------------------------------------------
+ CompileUnit *GetCompileUnit();
+
+ //------------------------------------------------------------------
+ /// Get const accessor for the compile unit that owns this function.
+ ///
+ /// @return
+ /// A const compile unit object pointer.
+ //------------------------------------------------------------------
+ const CompileUnit *GetCompileUnit() const;
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target);
+
+ //------------------------------------------------------------------
+ /// Get accessor for the frame base location.
+ ///
+ /// @return
+ /// A location expression that describes the function frame
+ /// base.
+ //------------------------------------------------------------------
+ DWARFExpression &GetFrameBaseExpression() { return m_frame_base; }
+
+ //------------------------------------------------------------------
+ /// Get const accessor for the frame base location.
+ ///
+ /// @return
+ /// A const compile unit object pointer.
+ //------------------------------------------------------------------
+ const DWARFExpression &GetFrameBaseExpression() const { return m_frame_base; }
+
+ ConstString GetName() const;
+
+ ConstString GetNameNoArguments() const;
+
+ ConstString GetDisplayName() const;
+
+ const Mangled &GetMangled() const { return m_mangled; }
+
+ //------------------------------------------------------------------
+ /// Get the DeclContext for this function, if available.
+ ///
+ /// @return
+ /// The DeclContext, or NULL if none exists.
+ //------------------------------------------------------------------
+ CompilerDeclContext GetDeclContext();
+
+ //------------------------------------------------------------------
+ /// Get accessor for the type that describes the function
+ /// return value type, and parameter types.
+ ///
+ /// @return
+ /// A type object pointer.
+ //------------------------------------------------------------------
+ Type *GetType();
+
+ //------------------------------------------------------------------
+ /// Get const accessor for the type that describes the function
+ /// return value type, and parameter types.
+ ///
+ /// @return
+ /// A const type object pointer.
+ //------------------------------------------------------------------
+ const Type *GetType() const;
+
+ CompilerType GetCompilerType();
+
+ //------------------------------------------------------------------
+ /// Get the size of the prologue instructions for this function. The
+ /// "prologue"
+ /// instructions include any instructions given line number 0 immediately
+ /// following
+ /// the prologue end.
+ ///
+ /// @return
+ /// The size of the prologue.
+ //------------------------------------------------------------------
+ uint32_t GetPrologueByteSize();
+
+ //------------------------------------------------------------------
+ /// Dump a description of this object to a Stream.
+ ///
+ /// Dump a description of the contents of this object to the
+ /// supplied stream \a s.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ ///
+ /// @param[in] show_context
+ /// If \b true, variables will dump their symbol context
+ /// information.
+ //------------------------------------------------------------------
+ void Dump(Stream *s, bool show_context) const;
+
+ //------------------------------------------------------------------
+ /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
+ ///
+ /// @see SymbolContextScope
+ //------------------------------------------------------------------
+ void DumpSymbolContext(Stream *s) override;
+
+ //------------------------------------------------------------------
+ /// Get the memory cost of this object.
+ ///
+ /// @return
+ /// The number of bytes that this object occupies in memory.
+ /// The returned value does not include the bytes for any
+ /// shared string values.
+ ///
+ /// @see ConstString::StaticMemorySize ()
+ //------------------------------------------------------------------
+ size_t MemorySize() const;
+
+ //------------------------------------------------------------------
+ /// Get whether compiler optimizations were enabled for this function
+ ///
+ /// The debug information may provide information about whether this
+ /// function was compiled with optimization or not. In this case,
+ /// "optimized" means that the debug experience may be difficult
+ /// for the user to understand. Variables may not be available when
+ /// the developer would expect them, stepping through the source lines
+ /// in the function may appear strange, etc.
+ ///
+ /// @return
+ /// Returns 'true' if this function was compiled with
+ /// optimization. 'false' indicates that either the optimization
+ /// is unknown, or this function was built without optimization.
+ //------------------------------------------------------------------
+ bool GetIsOptimized();
+
+ //------------------------------------------------------------------
+ /// Get whether this function represents a 'top-level' function
+ ///
+ /// The concept of a top-level function is language-specific, mostly
+ /// meant to represent the notion of scripting-style code that has
+ /// global visibility of the variables/symbols/functions/...
+ /// defined within the containing file/module
+ ///
+ /// If stopped in a top-level function, LLDB will expose global variables
+ /// as-if locals in the 'frame variable' command
+ ///
+ /// @return
+ /// Returns 'true' if this function is a top-level function,
+ /// 'false' otherwise.
+ //------------------------------------------------------------------
+ bool IsTopLevelFunction();
+
+ lldb::DisassemblerSP GetInstructions(const ExecutionContext &exe_ctx,
+ const char *flavor,
+ bool prefer_file_cache);
+
+ bool GetDisassembly(const ExecutionContext &exe_ctx, const char *flavor,
+ bool prefer_file_cache, Stream &strm);
protected:
-
- enum
- {
- flagsCalculatedPrologueSize = (1 << 0) ///< Have we already tried to calculate the prologue size?
- };
-
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- CompileUnit *m_comp_unit; ///< The compile unit that owns this function.
- lldb::user_id_t m_type_uid; ///< The user ID of for the prototype Type for this function.
- Type * m_type; ///< The function prototype type for this function that include the function info (FunctionInfo), return type and parameters.
- Mangled m_mangled; ///< The mangled function name if any, if empty, there is no mangled information.
- Block m_block; ///< All lexical blocks contained in this function.
- AddressRange m_range; ///< The function address range that covers the widest range needed to contain all blocks
- DWARFExpression m_frame_base; ///< The frame base expression for variables that are relative to the frame pointer.
- Flags m_flags;
- uint32_t m_prologue_byte_size; ///< Compute the prologue size once and cache it
+ enum {
+ flagsCalculatedPrologueSize =
+ (1 << 0) ///< Have we already tried to calculate the prologue size?
+ };
+
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ CompileUnit *m_comp_unit; ///< The compile unit that owns this function.
+ lldb::user_id_t
+ m_type_uid; ///< The user ID of for the prototype Type for this function.
+ Type *m_type; ///< The function prototype type for this function that include
+ ///the function info (FunctionInfo), return type and parameters.
+ Mangled m_mangled; ///< The mangled function name if any, if empty, there is
+ ///no mangled information.
+ Block m_block; ///< All lexical blocks contained in this function.
+ AddressRange m_range; ///< The function address range that covers the widest
+ ///range needed to contain all blocks
+ DWARFExpression m_frame_base; ///< The frame base expression for variables
+ ///that are relative to the frame pointer.
+ Flags m_flags;
+ uint32_t
+ m_prologue_byte_size; ///< Compute the prologue size once and cache it
private:
- DISALLOW_COPY_AND_ASSIGN(Function);
+ DISALLOW_COPY_AND_ASSIGN(Function);
};
} // namespace lldb_private
diff --git a/include/lldb/Symbol/GoASTContext.h b/include/lldb/Symbol/GoASTContext.h
index ec0203bc3221..5530a35493dc 100644
--- a/include/lldb/Symbol/GoASTContext.h
+++ b/include/lldb/Symbol/GoASTContext.h
@@ -21,379 +21,408 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/ConstString.h"
-#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Symbol/TypeSystem.h"
-namespace lldb_private
-{
+namespace lldb_private {
class Declaration;
class GoType;
-class GoASTContext : public TypeSystem
-{
- public:
- GoASTContext();
- ~GoASTContext() override;
-
- //------------------------------------------------------------------
- // PluginInterface functions
- //------------------------------------------------------------------
- ConstString
- GetPluginName() override;
-
- uint32_t
- GetPluginVersion() override;
-
- static ConstString
- GetPluginNameStatic ();
-
- static lldb::TypeSystemSP
- CreateInstance (lldb::LanguageType language, Module *module, Target *target);
-
- static void
- EnumerateSupportedLanguages(std::set<lldb::LanguageType> &languages_for_types, std::set<lldb::LanguageType> &languages_for_expressions);
-
- static void
- Initialize ();
-
- static void
- Terminate ();
-
- DWARFASTParser *GetDWARFParser() override;
-
- void
- SetAddressByteSize(int byte_size)
- {
- m_pointer_byte_size = byte_size;
- }
-
- //------------------------------------------------------------------
- // llvm casting support
- //------------------------------------------------------------------
- static bool classof(const TypeSystem *ts)
- {
- return ts->getKind() == TypeSystem::eKindGo;
- }
+class GoASTContext : public TypeSystem {
+public:
+ GoASTContext();
+ ~GoASTContext() override;
- //----------------------------------------------------------------------
- // CompilerDecl functions
- //----------------------------------------------------------------------
- ConstString
- DeclGetName (void *opaque_decl) override
- {
- return ConstString();
- }
+ //------------------------------------------------------------------
+ // PluginInterface functions
+ //------------------------------------------------------------------
+ ConstString GetPluginName() override;
- //----------------------------------------------------------------------
- // CompilerDeclContext functions
- //----------------------------------------------------------------------
-
- bool
- DeclContextIsStructUnionOrClass(void *opaque_decl_ctx) override
- {
- return false;
- }
+ uint32_t GetPluginVersion() override;
- ConstString
- DeclContextGetName(void *opaque_decl_ctx) override
- {
- return ConstString();
- }
+ static ConstString GetPluginNameStatic();
- ConstString
- DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) override
- {
- return ConstString();
- }
+ static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language,
+ Module *module, Target *target);
- bool
- DeclContextIsClassMethod(void *opaque_decl_ctx, lldb::LanguageType *language_ptr, bool *is_instance_method_ptr,
- ConstString *language_object_name_ptr) override
- {
- return false;
- }
+ static void EnumerateSupportedLanguages(
+ std::set<lldb::LanguageType> &languages_for_types,
+ std::set<lldb::LanguageType> &languages_for_expressions);
- //----------------------------------------------------------------------
- // Creating Types
- //----------------------------------------------------------------------
+ static void Initialize();
- CompilerType CreateArrayType(const ConstString &name, const CompilerType &element_type, uint64_t length);
+ static void Terminate();
- CompilerType CreateBaseType(int go_kind, const ConstString &type_name_const_str, uint64_t byte_size);
+ DWARFASTParser *GetDWARFParser() override;
- // For interface, map, chan.
- CompilerType CreateTypedefType(int kind, const ConstString &name, CompilerType impl);
+ void SetAddressByteSize(int byte_size) { m_pointer_byte_size = byte_size; }
- CompilerType CreateVoidType(const ConstString &name);
- CompilerType CreateFunctionType(const lldb_private::ConstString &name, CompilerType *params, size_t params_count,
- bool is_variadic);
+ //------------------------------------------------------------------
+ // llvm casting support
+ //------------------------------------------------------------------
+ static bool classof(const TypeSystem *ts) {
+ return ts->getKind() == TypeSystem::eKindGo;
+ }
- CompilerType CreateStructType(int kind, const ConstString &name, uint32_t byte_size);
+ //----------------------------------------------------------------------
+ // CompilerDecl functions
+ //----------------------------------------------------------------------
+ ConstString DeclGetName(void *opaque_decl) override { return ConstString(); }
- void CompleteStructType(const CompilerType &type);
+ //----------------------------------------------------------------------
+ // CompilerDeclContext functions
+ //----------------------------------------------------------------------
- void AddFieldToStruct(const CompilerType &struct_type, const ConstString &name, const CompilerType &field_type,
- uint32_t byte_offset);
+ bool DeclContextIsStructUnionOrClass(void *opaque_decl_ctx) override {
+ return false;
+ }
- //----------------------------------------------------------------------
- // Tests
- //----------------------------------------------------------------------
+ ConstString DeclContextGetName(void *opaque_decl_ctx) override {
+ return ConstString();
+ }
- static bool IsGoString(const CompilerType &type);
- static bool IsGoSlice(const CompilerType &type);
- static bool IsGoInterface(const CompilerType &type);
- static bool IsDirectIface(uint8_t kind);
- static bool IsPointerKind(uint8_t kind);
+ ConstString DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) override {
+ return ConstString();
+ }
- bool IsArrayType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size, bool *is_incomplete) override;
+ bool
+ DeclContextIsClassMethod(void *opaque_decl_ctx,
+ lldb::LanguageType *language_ptr,
+ bool *is_instance_method_ptr,
+ ConstString *language_object_name_ptr) override {
+ return false;
+ }
- bool IsAggregateType(lldb::opaque_compiler_type_t type) override;
+ //----------------------------------------------------------------------
+ // Creating Types
+ //----------------------------------------------------------------------
- bool IsCharType(lldb::opaque_compiler_type_t type) override;
+ CompilerType CreateArrayType(const ConstString &name,
+ const CompilerType &element_type,
+ uint64_t length);
- bool IsCompleteType(lldb::opaque_compiler_type_t type) override;
+ CompilerType CreateBaseType(int go_kind,
+ const ConstString &type_name_const_str,
+ uint64_t byte_size);
- bool IsDefined(lldb::opaque_compiler_type_t type) override;
+ // For interface, map, chan.
+ CompilerType CreateTypedefType(int kind, const ConstString &name,
+ CompilerType impl);
- bool IsFloatingPointType(lldb::opaque_compiler_type_t type, uint32_t &count, bool &is_complex) override;
+ CompilerType CreateVoidType(const ConstString &name);
+ CompilerType CreateFunctionType(const lldb_private::ConstString &name,
+ CompilerType *params, size_t params_count,
+ bool is_variadic);
- bool IsFunctionType(lldb::opaque_compiler_type_t type, bool *is_variadic_ptr = nullptr) override;
+ CompilerType CreateStructType(int kind, const ConstString &name,
+ uint32_t byte_size);
- size_t GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) override;
+ void CompleteStructType(const CompilerType &type);
- CompilerType GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type, const size_t index) override;
+ void AddFieldToStruct(const CompilerType &struct_type,
+ const ConstString &name, const CompilerType &field_type,
+ uint32_t byte_offset);
- bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) override;
-
- bool IsBlockPointerType (lldb::opaque_compiler_type_t type, CompilerType *function_pointer_type_ptr) override;
+ //----------------------------------------------------------------------
+ // Tests
+ //----------------------------------------------------------------------
- bool IsIntegerType(lldb::opaque_compiler_type_t type, bool &is_signed) override;
+ static bool IsGoString(const CompilerType &type);
+ static bool IsGoSlice(const CompilerType &type);
+ static bool IsGoInterface(const CompilerType &type);
+ static bool IsDirectIface(uint8_t kind);
+ static bool IsPointerKind(uint8_t kind);
- bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
- CompilerType *target_type, // Can pass nullptr
- bool check_cplusplus, bool check_objc) override;
+ bool IsArrayType(lldb::opaque_compiler_type_t type,
+ CompilerType *element_type, uint64_t *size,
+ bool *is_incomplete) override;
- bool IsPointerType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type = nullptr) override;
+ bool IsAggregateType(lldb::opaque_compiler_type_t type) override;
- bool IsScalarType(lldb::opaque_compiler_type_t type) override;
+ bool IsCharType(lldb::opaque_compiler_type_t type) override;
- bool IsVoidType(lldb::opaque_compiler_type_t type) override;
+ bool IsCompleteType(lldb::opaque_compiler_type_t type) override;
- bool SupportsLanguage (lldb::LanguageType language) override;
+ bool IsDefined(lldb::opaque_compiler_type_t type) override;
- //----------------------------------------------------------------------
- // Type Completion
- //----------------------------------------------------------------------
+ bool IsFloatingPointType(lldb::opaque_compiler_type_t type, uint32_t &count,
+ bool &is_complex) override;
- bool GetCompleteType(lldb::opaque_compiler_type_t type) override;
+ bool IsFunctionType(lldb::opaque_compiler_type_t type,
+ bool *is_variadic_ptr = nullptr) override;
- //----------------------------------------------------------------------
- // AST related queries
- //----------------------------------------------------------------------
+ size_t
+ GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) override;
- uint32_t GetPointerByteSize() override;
+ CompilerType GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type,
+ const size_t index) override;
- //----------------------------------------------------------------------
- // Accessors
- //----------------------------------------------------------------------
+ bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) override;
- ConstString GetTypeName(lldb::opaque_compiler_type_t type) override;
+ bool IsBlockPointerType(lldb::opaque_compiler_type_t type,
+ CompilerType *function_pointer_type_ptr) override;
- uint32_t GetTypeInfo(lldb::opaque_compiler_type_t type,
- CompilerType *pointee_or_element_compiler_type = nullptr) override;
+ bool IsIntegerType(lldb::opaque_compiler_type_t type,
+ bool &is_signed) override;
- lldb::LanguageType GetMinimumLanguage(lldb::opaque_compiler_type_t type) override;
+ bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
+ CompilerType *target_type, // Can pass nullptr
+ bool check_cplusplus, bool check_objc) override;
- lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override;
+ bool IsPointerType(lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_type = nullptr) override;
- //----------------------------------------------------------------------
- // Creating related types
- //----------------------------------------------------------------------
+ bool IsScalarType(lldb::opaque_compiler_type_t type) override;
- CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type, uint64_t *stride = nullptr) override;
+ bool IsVoidType(lldb::opaque_compiler_type_t type) override;
- CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override;
+ bool SupportsLanguage(lldb::LanguageType language) override;
- // Returns -1 if this isn't a function of if the function doesn't have a prototype
- // Returns a value >= 0 if there is a prototype.
- int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override;
+ //----------------------------------------------------------------------
+ // Type Completion
+ //----------------------------------------------------------------------
- CompilerType GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type, size_t idx) override;
+ bool GetCompleteType(lldb::opaque_compiler_type_t type) override;
- CompilerType GetFunctionReturnType(lldb::opaque_compiler_type_t type) override;
+ //----------------------------------------------------------------------
+ // AST related queries
+ //----------------------------------------------------------------------
- size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) override;
+ uint32_t GetPointerByteSize() override;
- TypeMemberFunctionImpl GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type, size_t idx) override;
+ //----------------------------------------------------------------------
+ // Accessors
+ //----------------------------------------------------------------------
- CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) override;
+ ConstString GetTypeName(lldb::opaque_compiler_type_t type) override;
- CompilerType GetPointerType(lldb::opaque_compiler_type_t type) override;
+ uint32_t GetTypeInfo(
+ lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_or_element_compiler_type = nullptr) override;
- //----------------------------------------------------------------------
- // Exploring the type
- //----------------------------------------------------------------------
+ lldb::LanguageType
+ GetMinimumLanguage(lldb::opaque_compiler_type_t type) override;
- uint64_t GetBitSize(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override;
+ lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override;
- lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type, uint64_t &count) override;
+ //----------------------------------------------------------------------
+ // Creating related types
+ //----------------------------------------------------------------------
- lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override;
+ CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type,
+ uint64_t *stride = nullptr) override;
- uint32_t GetNumChildren(lldb::opaque_compiler_type_t type, bool omit_empty_base_classes) override;
+ CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override;
- lldb::BasicType GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) override;
+ // Returns -1 if this isn't a function of if the function doesn't have a
+ // prototype
+ // Returns a value >= 0 if there is a prototype.
+ int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override;
- CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size) override;
+ CompilerType GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type,
+ size_t idx) override;
- uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override;
+ CompilerType
+ GetFunctionReturnType(lldb::opaque_compiler_type_t type) override;
- CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx, std::string &name, uint64_t *bit_offset_ptr,
- uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) override;
+ size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) override;
- uint32_t
- GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) override
- {
- return 0;
- }
+ TypeMemberFunctionImpl
+ GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type,
+ size_t idx) override;
- uint32_t
- GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) override
- {
- return 0;
- }
+ CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) override;
- CompilerType
- GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) override
- {
- return CompilerType();
- }
+ CompilerType GetPointerType(lldb::opaque_compiler_type_t type) override;
- CompilerType
- GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) override
- {
- return CompilerType();
- }
+ //----------------------------------------------------------------------
+ // Exploring the type
+ //----------------------------------------------------------------------
- CompilerType GetChildCompilerTypeAtIndex(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx,
- bool transparent_pointers, bool omit_empty_base_classes,
- bool ignore_array_bounds, std::string &child_name,
- uint32_t &child_byte_size, int32_t &child_byte_offset,
- uint32_t &child_bitfield_bit_size,
- uint32_t &child_bitfield_bit_offset, bool &child_is_base_class,
- bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) override;
+ uint64_t GetBitSize(lldb::opaque_compiler_type_t type,
+ ExecutionContextScope *exe_scope) override;
- // Lookup a child given a name. This function will match base class names
- // and member member names in "clang_type" only, not descendants.
- uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, const char *name, bool omit_empty_base_classes) override;
+ lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type,
+ uint64_t &count) override;
- // Lookup a child member given a name. This function will match member names
- // only and will descend into "clang_type" children in search for the first
- // member in this class, or any base class that matches "name".
- // TODO: Return all matches for a given name by returning a vector<vector<uint32_t>>
- // so we catch all names that match a given child name, not just the first.
- size_t GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type, const char *name, bool omit_empty_base_classes,
- std::vector<uint32_t> &child_indexes) override;
+ lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override;
- size_t
- GetNumTemplateArguments(lldb::opaque_compiler_type_t type) override
- {
- return 0;
- }
+ uint32_t GetNumChildren(lldb::opaque_compiler_type_t type,
+ bool omit_empty_base_classes) override;
- CompilerType
- GetTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx, lldb::TemplateArgumentKind &kind) override
- {
- return CompilerType();
- }
+ lldb::BasicType
+ GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) override;
- //----------------------------------------------------------------------
- // Dumping types
- //----------------------------------------------------------------------
- void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, lldb::Format format,
- const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size,
- uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, bool show_types, bool show_summary,
- bool verbose, uint32_t depth) override;
+ CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding,
+ size_t bit_size) override;
- bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s, lldb::Format format, const DataExtractor &data,
- lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope) override;
+ uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override;
- void DumpTypeDescription(lldb::opaque_compiler_type_t type) override; // Dump to stdout
+ CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx,
+ std::string &name, uint64_t *bit_offset_ptr,
+ uint32_t *bitfield_bit_size_ptr,
+ bool *is_bitfield_ptr) override;
- void DumpTypeDescription(lldb::opaque_compiler_type_t type, Stream *s) override;
+ uint32_t GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) override {
+ return 0;
+ }
- //----------------------------------------------------------------------
- // TODO: These methods appear unused. Should they be removed?
- //----------------------------------------------------------------------
+ uint32_t
+ GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) override {
+ return 0;
+ }
- bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) override;
+ CompilerType GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type,
+ size_t idx,
+ uint32_t *bit_offset_ptr) override {
+ return CompilerType();
+ }
- void DumpSummary(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, const DataExtractor &data,
- lldb::offset_t data_offset, size_t data_byte_size) override;
+ CompilerType GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type,
+ size_t idx,
+ uint32_t *bit_offset_ptr) override {
+ return CompilerType();
+ }
- // Converts "s" to a floating point value and place resulting floating
- // point bytes in the "dst" buffer.
- size_t ConvertStringToFloatValue(lldb::opaque_compiler_type_t type, const char *s, uint8_t *dst, size_t dst_size) override;
+ CompilerType GetChildCompilerTypeAtIndex(
+ lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx,
+ bool transparent_pointers, bool omit_empty_base_classes,
+ bool ignore_array_bounds, std::string &child_name,
+ uint32_t &child_byte_size, int32_t &child_byte_offset,
+ uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
+ bool &child_is_base_class, bool &child_is_deref_of_parent,
+ ValueObject *valobj, uint64_t &language_flags) override;
- //----------------------------------------------------------------------
- // TODO: Determine if these methods should move to ClangASTContext.
- //----------------------------------------------------------------------
+ // Lookup a child given a name. This function will match base class names
+ // and member member names in "clang_type" only, not descendants.
+ uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
+ const char *name,
+ bool omit_empty_base_classes) override;
- bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type,
- CompilerType *pointee_type = nullptr) override;
+ // Lookup a child member given a name. This function will match member names
+ // only and will descend into "clang_type" children in search for the first
+ // member in this class, or any base class that matches "name".
+ // TODO: Return all matches for a given name by returning a
+ // vector<vector<uint32_t>>
+ // so we catch all names that match a given child name, not just the first.
+ size_t
+ GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type,
+ const char *name, bool omit_empty_base_classes,
+ std::vector<uint32_t> &child_indexes) override;
- unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override;
+ size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type) override {
+ return 0;
+ }
- bool IsCStringType(lldb::opaque_compiler_type_t type, uint32_t &length) override;
+ CompilerType GetTemplateArgument(lldb::opaque_compiler_type_t type,
+ size_t idx,
+ lldb::TemplateArgumentKind &kind) override {
+ return CompilerType();
+ }
- size_t GetTypeBitAlign(lldb::opaque_compiler_type_t type) override;
+ //----------------------------------------------------------------------
+ // Dumping types
+ //----------------------------------------------------------------------
+ void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
+ Stream *s, lldb::Format format, const DataExtractor &data,
+ lldb::offset_t data_offset, size_t data_byte_size,
+ uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
+ bool show_types, bool show_summary, bool verbose,
+ uint32_t depth) override;
- CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override;
+ bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s,
+ lldb::Format format, const DataExtractor &data,
+ lldb::offset_t data_offset, size_t data_byte_size,
+ uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
+ ExecutionContextScope *exe_scope) override;
- bool IsBeingDefined(lldb::opaque_compiler_type_t type) override;
+ void DumpTypeDescription(
+ lldb::opaque_compiler_type_t type) override; // Dump to stdout
- bool IsConst(lldb::opaque_compiler_type_t type) override;
+ void DumpTypeDescription(lldb::opaque_compiler_type_t type,
+ Stream *s) override;
- uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type, CompilerType *base_type_ptr) override;
+ //----------------------------------------------------------------------
+ // TODO: These methods appear unused. Should they be removed?
+ //----------------------------------------------------------------------
+
+ bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) override;
+
+ void DumpSummary(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
+ Stream *s, const DataExtractor &data,
+ lldb::offset_t data_offset, size_t data_byte_size) override;
+
+ // Converts "s" to a floating point value and place resulting floating
+ // point bytes in the "dst" buffer.
+ size_t ConvertStringToFloatValue(lldb::opaque_compiler_type_t type,
+ const char *s, uint8_t *dst,
+ size_t dst_size) override;
+
+ //----------------------------------------------------------------------
+ // TODO: Determine if these methods should move to ClangASTContext.
+ //----------------------------------------------------------------------
+
+ bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_type = nullptr) override;
+
+ unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override;
+
+ bool IsCStringType(lldb::opaque_compiler_type_t type,
+ uint32_t &length) override;
+
+ size_t GetTypeBitAlign(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override;
+
+ bool IsBeingDefined(lldb::opaque_compiler_type_t type) override;
+
+ bool IsConst(lldb::opaque_compiler_type_t type) override;
+
+ uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type,
+ CompilerType *base_type_ptr) override;
+
+ bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) override;
- bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) override;
+ bool IsTypedefType(lldb::opaque_compiler_type_t type) override;
+
+ // If the current object represents a typedef type, get the underlying type
+ CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) override;
- bool IsTypedefType(lldb::opaque_compiler_type_t type) override;
+ bool IsVectorType(lldb::opaque_compiler_type_t type,
+ CompilerType *element_type, uint64_t *size) override;
- // If the current object represents a typedef type, get the underlying type
- CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) override;
+ CompilerType
+ GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override;
- bool IsVectorType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size) override;
+ CompilerType GetNonReferenceType(lldb::opaque_compiler_type_t type) override;
- CompilerType GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override;
+ bool IsReferenceType(lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_type = nullptr,
+ bool *is_rvalue = nullptr) override;
- CompilerType GetNonReferenceType(lldb::opaque_compiler_type_t type) override;
+private:
+ typedef std::map<ConstString, std::unique_ptr<GoType>> TypeMap;
+ int m_pointer_byte_size;
+ int m_int_byte_size;
+ std::unique_ptr<TypeMap> m_types;
+ std::unique_ptr<DWARFASTParser> m_dwarf_ast_parser_ap;
- bool IsReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type = nullptr, bool *is_rvalue = nullptr) override;
-
- private:
- typedef std::map<ConstString, std::unique_ptr<GoType>> TypeMap;
- int m_pointer_byte_size;
- int m_int_byte_size;
- std::unique_ptr<TypeMap> m_types;
- std::unique_ptr<DWARFASTParser> m_dwarf_ast_parser_ap;
-
- GoASTContext(const GoASTContext &) = delete;
- const GoASTContext &operator=(const GoASTContext &) = delete;
+ GoASTContext(const GoASTContext &) = delete;
+ const GoASTContext &operator=(const GoASTContext &) = delete;
};
-class GoASTContextForExpr : public GoASTContext
-{
- public:
- GoASTContextForExpr(lldb::TargetSP target) : m_target_wp(target) {}
- UserExpression *GetUserExpression(const char *expr, const char *expr_prefix, lldb::LanguageType language,
- Expression::ResultType desired_type,
- const EvaluateExpressionOptions &options) override;
-
- private:
- lldb::TargetWP m_target_wp;
+class GoASTContextForExpr : public GoASTContext {
+public:
+ GoASTContextForExpr(lldb::TargetSP target) : m_target_wp(target) {}
+ UserExpression *
+ GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix,
+ lldb::LanguageType language,
+ Expression::ResultType desired_type,
+ const EvaluateExpressionOptions &options) override;
+
+private:
+ lldb::TargetWP m_target_wp;
};
}
#endif // liblldb_GoASTContext_h_
diff --git a/include/lldb/Symbol/JavaASTContext.h b/include/lldb/Symbol/JavaASTContext.h
index 7d5a37649f6f..6e97674847f4 100644
--- a/include/lldb/Symbol/JavaASTContext.h
+++ b/include/lldb/Symbol/JavaASTContext.h
@@ -21,365 +21,334 @@
#include "lldb/Core/ConstString.h"
#include "lldb/Symbol/TypeSystem.h"
-namespace lldb_private
-{
+namespace lldb_private {
-class JavaASTContext : public TypeSystem
-{
+class JavaASTContext : public TypeSystem {
public:
- class JavaType;
- typedef std::map<ConstString, std::unique_ptr<JavaType>> JavaTypeMap;
+ class JavaType;
+ typedef std::map<ConstString, std::unique_ptr<JavaType>> JavaTypeMap;
- JavaASTContext(const ArchSpec &arch);
- ~JavaASTContext() override;
+ JavaASTContext(const ArchSpec &arch);
+ ~JavaASTContext() override;
- //------------------------------------------------------------------
- // PluginInterface functions
- //------------------------------------------------------------------
- ConstString
- GetPluginName() override;
+ //------------------------------------------------------------------
+ // PluginInterface functions
+ //------------------------------------------------------------------
+ ConstString GetPluginName() override;
- uint32_t
- GetPluginVersion() override;
+ uint32_t GetPluginVersion() override;
- static ConstString
- GetPluginNameStatic();
+ static ConstString GetPluginNameStatic();
- static lldb::TypeSystemSP
- CreateInstance(lldb::LanguageType language, Module *module, Target *target);
+ static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language,
+ Module *module, Target *target);
- static void
- EnumerateSupportedLanguages(std::set<lldb::LanguageType> &languages_for_types,
- std::set<lldb::LanguageType> &languages_for_expressions);
+ static void EnumerateSupportedLanguages(
+ std::set<lldb::LanguageType> &languages_for_types,
+ std::set<lldb::LanguageType> &languages_for_expressions);
- static void
- Initialize();
+ static void Initialize();
- static void
- Terminate();
+ static void Terminate();
- DWARFASTParser *
- GetDWARFParser() override;
+ DWARFASTParser *GetDWARFParser() override;
- uint32_t
- GetPointerByteSize() override;
+ uint32_t GetPointerByteSize() override;
- //----------------------------------------------------------------------
- // CompilerDecl functions
- //----------------------------------------------------------------------
- ConstString
- DeclGetName(void *opaque_decl) override;
+ //----------------------------------------------------------------------
+ // CompilerDecl functions
+ //----------------------------------------------------------------------
+ ConstString DeclGetName(void *opaque_decl) override;
- //----------------------------------------------------------------------
- // CompilerDeclContext functions
- //----------------------------------------------------------------------
+ //----------------------------------------------------------------------
+ // CompilerDeclContext functions
+ //----------------------------------------------------------------------
- std::vector<CompilerDecl>
- DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name, const bool ignore_imported_decls) override;
+ std::vector<CompilerDecl>
+ DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name,
+ const bool ignore_imported_decls) override;
- bool
- DeclContextIsStructUnionOrClass(void *opaque_decl_ctx) override;
+ bool DeclContextIsStructUnionOrClass(void *opaque_decl_ctx) override;
- ConstString
- DeclContextGetName(void *opaque_decl_ctx) override;
+ ConstString DeclContextGetName(void *opaque_decl_ctx) override;
- bool
- DeclContextIsClassMethod(void *opaque_decl_ctx, lldb::LanguageType *language_ptr, bool *is_instance_method_ptr,
- ConstString *language_object_name_ptr) override;
+ bool DeclContextIsClassMethod(void *opaque_decl_ctx,
+ lldb::LanguageType *language_ptr,
+ bool *is_instance_method_ptr,
+ ConstString *language_object_name_ptr) override;
- //----------------------------------------------------------------------
- // Tests
- //----------------------------------------------------------------------
+ //----------------------------------------------------------------------
+ // Tests
+ //----------------------------------------------------------------------
- bool
- IsArrayType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size,
- bool *is_incomplete) override;
+ bool IsArrayType(lldb::opaque_compiler_type_t type,
+ CompilerType *element_type, uint64_t *size,
+ bool *is_incomplete) override;
- bool
- IsAggregateType(lldb::opaque_compiler_type_t type) override;
+ bool IsAggregateType(lldb::opaque_compiler_type_t type) override;
- bool
- IsCharType(lldb::opaque_compiler_type_t type) override;
+ bool IsCharType(lldb::opaque_compiler_type_t type) override;
- bool
- IsFloatingPointType(lldb::opaque_compiler_type_t type, uint32_t &count, bool &is_complex) override;
+ bool IsFloatingPointType(lldb::opaque_compiler_type_t type, uint32_t &count,
+ bool &is_complex) override;
- bool
- IsFunctionType(lldb::opaque_compiler_type_t type, bool *is_variadic_ptr = nullptr) override;
+ bool IsFunctionType(lldb::opaque_compiler_type_t type,
+ bool *is_variadic_ptr = nullptr) override;
- size_t
- GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) override;
+ size_t
+ GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) override;
- CompilerType
- GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type, const size_t index) override;
+ CompilerType GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type,
+ const size_t index) override;
- bool
- IsFunctionPointerType(lldb::opaque_compiler_type_t type) override;
-
- bool
- IsBlockPointerType (lldb::opaque_compiler_type_t type, CompilerType *function_pointer_type_ptr) override;
+ bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) override;
- bool
- IsIntegerType(lldb::opaque_compiler_type_t type, bool &is_signed) override;
+ bool IsBlockPointerType(lldb::opaque_compiler_type_t type,
+ CompilerType *function_pointer_type_ptr) override;
- bool
- IsPossibleDynamicType(lldb::opaque_compiler_type_t type, CompilerType *target_type, bool check_cplusplus,
- bool check_objc) override;
+ bool IsIntegerType(lldb::opaque_compiler_type_t type,
+ bool &is_signed) override;
- bool
- IsPointerType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type = nullptr) override;
+ bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
+ CompilerType *target_type, bool check_cplusplus,
+ bool check_objc) override;
- bool
- IsReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type = nullptr,
- bool *is_rvalue = nullptr) override;
+ bool IsPointerType(lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_type = nullptr) override;
- bool
- IsPointerOrReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type = nullptr) override;
+ bool IsReferenceType(lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_type = nullptr,
+ bool *is_rvalue = nullptr) override;
- bool
- IsScalarType(lldb::opaque_compiler_type_t type) override;
+ bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_type = nullptr) override;
- bool
- IsVoidType(lldb::opaque_compiler_type_t type) override;
+ bool IsScalarType(lldb::opaque_compiler_type_t type) override;
- bool
- IsCStringType(lldb::opaque_compiler_type_t type, uint32_t &length) override;
+ bool IsVoidType(lldb::opaque_compiler_type_t type) override;
- bool
- IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) override;
+ bool IsCStringType(lldb::opaque_compiler_type_t type,
+ uint32_t &length) override;
- bool
- IsTypedefType(lldb::opaque_compiler_type_t type) override;
+ bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) override;
- bool
- IsVectorType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size) override;
+ bool IsTypedefType(lldb::opaque_compiler_type_t type) override;
- bool
- IsPolymorphicClass(lldb::opaque_compiler_type_t type) override;
+ bool IsVectorType(lldb::opaque_compiler_type_t type,
+ CompilerType *element_type, uint64_t *size) override;
- bool
- IsCompleteType(lldb::opaque_compiler_type_t type) override;
+ bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) override;
- bool
- IsConst(lldb::opaque_compiler_type_t type) override;
+ bool IsCompleteType(lldb::opaque_compiler_type_t type) override;
- bool
- IsBeingDefined(lldb::opaque_compiler_type_t type) override;
+ bool IsConst(lldb::opaque_compiler_type_t type) override;
- bool
- IsDefined(lldb::opaque_compiler_type_t type) override;
+ bool IsBeingDefined(lldb::opaque_compiler_type_t type) override;
- uint32_t
- IsHomogeneousAggregate(lldb::opaque_compiler_type_t type, CompilerType *base_type_ptr) override;
+ bool IsDefined(lldb::opaque_compiler_type_t type) override;
- bool
- SupportsLanguage(lldb::LanguageType language) override;
+ uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type,
+ CompilerType *base_type_ptr) override;
- bool
- GetCompleteType(lldb::opaque_compiler_type_t type) override;
+ bool SupportsLanguage(lldb::LanguageType language) override;
- ConstString
- GetTypeName(lldb::opaque_compiler_type_t type) override;
+ bool GetCompleteType(lldb::opaque_compiler_type_t type) override;
- uint32_t
- GetTypeInfo(lldb::opaque_compiler_type_t type, CompilerType *pointee_or_element_compiler_type = nullptr) override;
+ ConstString GetTypeName(lldb::opaque_compiler_type_t type) override;
- lldb::TypeClass
- GetTypeClass(lldb::opaque_compiler_type_t type) override;
+ uint32_t GetTypeInfo(
+ lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_or_element_compiler_type = nullptr) override;
- lldb::LanguageType
- GetMinimumLanguage(lldb::opaque_compiler_type_t type) override;
+ lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override;
- CompilerType
- GetArrayElementType(lldb::opaque_compiler_type_t type, uint64_t *stride = nullptr) override;
+ lldb::LanguageType
+ GetMinimumLanguage(lldb::opaque_compiler_type_t type) override;
- CompilerType
- GetPointeeType(lldb::opaque_compiler_type_t type) override;
+ CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type,
+ uint64_t *stride = nullptr) override;
- CompilerType
- GetPointerType(lldb::opaque_compiler_type_t type) override;
+ CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) override;
- CompilerType
- GetCanonicalType(lldb::opaque_compiler_type_t type) override;
+ CompilerType GetPointerType(lldb::opaque_compiler_type_t type) override;
- CompilerType
- GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override;
+ CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override;
- CompilerType
- GetNonReferenceType(lldb::opaque_compiler_type_t type) override;
+ CompilerType
+ GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override;
- CompilerType
- GetTypedefedType(lldb::opaque_compiler_type_t type) override;
+ CompilerType GetNonReferenceType(lldb::opaque_compiler_type_t type) override;
- CompilerType
- GetBasicTypeFromAST(lldb::BasicType basic_type) override;
+ CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) override;
- CompilerType
- GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size) override;
+ CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override;
- size_t
- GetTypeBitAlign(lldb::opaque_compiler_type_t type) override;
+ CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding,
+ size_t bit_size) override;
- lldb::BasicType
- GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) override;
+ size_t GetTypeBitAlign(lldb::opaque_compiler_type_t type) override;
- uint64_t
- GetBitSize(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override;
+ lldb::BasicType
+ GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) override;
- lldb::Encoding
- GetEncoding(lldb::opaque_compiler_type_t type, uint64_t &count) override;
+ uint64_t GetBitSize(lldb::opaque_compiler_type_t type,
+ ExecutionContextScope *exe_scope) override;
- lldb::Format
- GetFormat(lldb::opaque_compiler_type_t type) override;
+ lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type,
+ uint64_t &count) override;
- unsigned
- GetTypeQualifiers(lldb::opaque_compiler_type_t type) override;
+ lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override;
- size_t
- GetNumTemplateArguments(lldb::opaque_compiler_type_t type) override;
+ unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override;
- CompilerType
- GetTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx, lldb::TemplateArgumentKind &kind) override;
+ size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type) override;
- int
- GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override;
+ CompilerType GetTemplateArgument(lldb::opaque_compiler_type_t type,
+ size_t idx,
+ lldb::TemplateArgumentKind &kind) override;
- CompilerType
- GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type, size_t idx) override;
+ int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override;
- CompilerType
- GetFunctionReturnType(lldb::opaque_compiler_type_t type) override;
+ CompilerType GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type,
+ size_t idx) override;
- size_t
- GetNumMemberFunctions(lldb::opaque_compiler_type_t type) override;
+ CompilerType
+ GetFunctionReturnType(lldb::opaque_compiler_type_t type) override;
- TypeMemberFunctionImpl
- GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type, size_t idx) override;
+ size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) override;
- uint32_t
- GetNumFields(lldb::opaque_compiler_type_t type) override;
+ TypeMemberFunctionImpl
+ GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type,
+ size_t idx) override;
- CompilerType
- GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx, std::string &name, uint64_t *bit_offset_ptr,
- uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) override;
+ uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override;
- uint32_t
- GetNumChildren(lldb::opaque_compiler_type_t type, bool omit_empty_base_classes) override;
+ CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx,
+ std::string &name, uint64_t *bit_offset_ptr,
+ uint32_t *bitfield_bit_size_ptr,
+ bool *is_bitfield_ptr) override;
- uint32_t
- GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) override;
+ uint32_t GetNumChildren(lldb::opaque_compiler_type_t type,
+ bool omit_empty_base_classes) override;
- uint32_t
- GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) override;
+ uint32_t GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) override;
- CompilerType
- GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) override;
+ uint32_t GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) override;
- CompilerType
- GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) override;
+ CompilerType GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type,
+ size_t idx,
+ uint32_t *bit_offset_ptr) override;
- size_t
- ConvertStringToFloatValue(lldb::opaque_compiler_type_t type, const char *s, uint8_t *dst, size_t dst_size) override;
+ CompilerType GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type,
+ size_t idx,
+ uint32_t *bit_offset_ptr) override;
- void
- DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, lldb::Format format,
- const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset, bool show_types, bool show_summary, bool verbose, uint32_t depth) override;
+ size_t ConvertStringToFloatValue(lldb::opaque_compiler_type_t type,
+ const char *s, uint8_t *dst,
+ size_t dst_size) override;
- bool
- DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s, lldb::Format format, const DataExtractor &data,
- lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope) override;
+ void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
+ Stream *s, lldb::Format format, const DataExtractor &data,
+ lldb::offset_t data_offset, size_t data_byte_size,
+ uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
+ bool show_types, bool show_summary, bool verbose,
+ uint32_t depth) override;
- void
- DumpTypeDescription(lldb::opaque_compiler_type_t type) override;
+ bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s,
+ lldb::Format format, const DataExtractor &data,
+ lldb::offset_t data_offset, size_t data_byte_size,
+ uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
+ ExecutionContextScope *exe_scope) override;
- void
- DumpTypeDescription(lldb::opaque_compiler_type_t type, Stream *s) override;
+ void DumpTypeDescription(lldb::opaque_compiler_type_t type) override;
- void
- DumpSummary(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, const DataExtractor &data,
- lldb::offset_t data_offset, size_t data_byte_size) override;
+ void DumpTypeDescription(lldb::opaque_compiler_type_t type,
+ Stream *s) override;
- CompilerType
- GetChildCompilerTypeAtIndex(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx,
- bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds,
- std::string &child_name, uint32_t &child_byte_size, int32_t &child_byte_offset,
- uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
- bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj,
- uint64_t &language_flags) override;
+ void DumpSummary(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
+ Stream *s, const DataExtractor &data,
+ lldb::offset_t data_offset, size_t data_byte_size) override;
- uint32_t
- GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, const char *name, bool omit_empty_base_classes) override;
+ CompilerType GetChildCompilerTypeAtIndex(
+ lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx,
+ bool transparent_pointers, bool omit_empty_base_classes,
+ bool ignore_array_bounds, std::string &child_name,
+ uint32_t &child_byte_size, int32_t &child_byte_offset,
+ uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
+ bool &child_is_base_class, bool &child_is_deref_of_parent,
+ ValueObject *valobj, uint64_t &language_flags) override;
- size_t
- GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type, const char *name, bool omit_empty_base_classes,
- std::vector<uint32_t> &child_indexes) override;
+ uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
+ const char *name,
+ bool omit_empty_base_classes) override;
- CompilerType
- GetLValueReferenceType(lldb::opaque_compiler_type_t type) override;
+ size_t
+ GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type,
+ const char *name, bool omit_empty_base_classes,
+ std::vector<uint32_t> &child_indexes) override;
- ConstString
- DeclContextGetScopeQualifiedName(lldb::opaque_compiler_type_t opaque_decl_ctx) override;
+ CompilerType
+ GetLValueReferenceType(lldb::opaque_compiler_type_t type) override;
- CompilerType
- CreateBaseType(const ConstString &name);
+ ConstString DeclContextGetScopeQualifiedName(
+ lldb::opaque_compiler_type_t opaque_decl_ctx) override;
- CompilerType
- CreateObjectType(const ConstString &name, const ConstString &linkage_name, uint32_t byte_size);
+ CompilerType CreateBaseType(const ConstString &name);
- CompilerType
- CreateArrayType(const ConstString &linkage_name, const CompilerType &element_type,
- const DWARFExpression &length_expression, const lldb::addr_t data_offset);
+ CompilerType CreateObjectType(const ConstString &name,
+ const ConstString &linkage_name,
+ uint32_t byte_size);
- CompilerType
- CreateReferenceType(const CompilerType &pointee_type);
+ CompilerType CreateArrayType(const ConstString &linkage_name,
+ const CompilerType &element_type,
+ const DWARFExpression &length_expression,
+ const lldb::addr_t data_offset);
- void
- CompleteObjectType(const CompilerType &object_type);
+ CompilerType CreateReferenceType(const CompilerType &pointee_type);
- void
- AddBaseClassToObject(const CompilerType &object_type, const CompilerType &member_type, uint32_t member_offset);
+ void CompleteObjectType(const CompilerType &object_type);
- void
- AddMemberToObject(const CompilerType &object_type, const ConstString &name, const CompilerType &member_type,
- uint32_t member_offset);
+ void AddBaseClassToObject(const CompilerType &object_type,
+ const CompilerType &member_type,
+ uint32_t member_offset);
- void
- SetDynamicTypeId(const CompilerType &type, const DWARFExpression &type_id);
+ void AddMemberToObject(const CompilerType &object_type,
+ const ConstString &name,
+ const CompilerType &member_type,
+ uint32_t member_offset);
- static uint64_t
- CalculateDynamicTypeId(ExecutionContext *exe_ctx, const CompilerType &type, ValueObject &in_value);
+ void SetDynamicTypeId(const CompilerType &type,
+ const DWARFExpression &type_id);
- static ConstString
- GetLinkageName(const CompilerType &type);
+ static uint64_t CalculateDynamicTypeId(ExecutionContext *exe_ctx,
+ const CompilerType &type,
+ ValueObject &in_value);
- static uint32_t
- CalculateArraySize(const CompilerType &type, ValueObject &in_value);
+ static ConstString GetLinkageName(const CompilerType &type);
- static uint64_t
- CalculateArrayElementOffset(const CompilerType &type, size_t index);
+ static uint32_t CalculateArraySize(const CompilerType &type,
+ ValueObject &in_value);
- //------------------------------------------------------------------
- // llvm casting support
- //------------------------------------------------------------------
- static bool
- classof(const TypeSystem *ts)
- {
- return ts->getKind() == TypeSystem::eKindJava;
- }
+ static uint64_t CalculateArrayElementOffset(const CompilerType &type,
+ size_t index);
+
+ //------------------------------------------------------------------
+ // llvm casting support
+ //------------------------------------------------------------------
+ static bool classof(const TypeSystem *ts) {
+ return ts->getKind() == TypeSystem::eKindJava;
+ }
private:
- uint32_t m_pointer_byte_size;
- std::unique_ptr<DWARFASTParser> m_dwarf_ast_parser_ap;
- JavaTypeMap m_array_type_map;
- JavaTypeMap m_base_type_map;
- JavaTypeMap m_reference_type_map;
- JavaTypeMap m_object_type_map;
-
- JavaASTContext(const JavaASTContext &) = delete;
- const JavaASTContext &
- operator=(const JavaASTContext &) = delete;
+ uint32_t m_pointer_byte_size;
+ std::unique_ptr<DWARFASTParser> m_dwarf_ast_parser_ap;
+ JavaTypeMap m_array_type_map;
+ JavaTypeMap m_base_type_map;
+ JavaTypeMap m_reference_type_map;
+ JavaTypeMap m_object_type_map;
+
+ JavaASTContext(const JavaASTContext &) = delete;
+ const JavaASTContext &operator=(const JavaASTContext &) = delete;
};
}
#endif // liblldb_JavaASTContext_h_
diff --git a/include/lldb/Symbol/LineEntry.h b/include/lldb/Symbol/LineEntry.h
index e6a05c10a764..3076ec41d878 100644
--- a/include/lldb/Symbol/LineEntry.h
+++ b/include/lldb/Symbol/LineEntry.h
@@ -10,9 +10,9 @@
#ifndef liblldb_LineEntry_h_
#define liblldb_LineEntry_h_
-#include "lldb/lldb-private.h"
#include "lldb/Core/AddressRange.h"
#include "lldb/Host/FileSpec.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -20,176 +20,167 @@ namespace lldb_private {
/// @class LineEntry LineEntry.h "lldb/Symbol/LineEntry.h"
/// @brief A line table entry class.
//----------------------------------------------------------------------
-struct LineEntry
-{
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Initialize all member variables to invalid values.
- //------------------------------------------------------------------
- LineEntry ();
-
- LineEntry
- (
- const lldb::SectionSP &section_sp,
- lldb::addr_t section_offset,
- lldb::addr_t byte_size,
- const FileSpec &file,
- uint32_t _line,
- uint16_t _column,
- bool _is_start_of_statement,
- bool _is_start_of_basic_block,
- bool _is_prologue_end,
- bool _is_epilogue_begin,
- bool _is_terminal_entry
- );
-
- //------------------------------------------------------------------
- /// Clear the object's state.
- ///
- /// Clears all member variables to invalid values.
- //------------------------------------------------------------------
- void
- Clear ();
-
- //------------------------------------------------------------------
- /// Dump a description of this object to a Stream.
- ///
- /// Dump a description of the contents of this object to the
- /// supplied stream \a s.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- ///
- /// @param[in] comp_unit
- /// The compile unit object that contains the support file
- /// list so the line entry can dump the file name (since this
- /// object contains a file index into the support file list).
- ///
- /// @param[in] show_file
- /// If \b true, display the filename with the line entry which
- /// requires that the compile unit object \a comp_unit be a
- /// valid pointer.
- ///
- /// @param[in] style
- /// The display style for the section offset address.
- ///
- /// @return
- /// Returns \b true if the address was able to be displayed
- /// using \a style. File and load addresses may be unresolved
- /// and it may not be possible to display a valid address value.
- /// Returns \b false if the address was not able to be properly
- /// dumped.
- ///
- /// @see Address::DumpStyle
- //------------------------------------------------------------------
- bool
- Dump (Stream *s, Target *target, bool show_file, Address::DumpStyle style, Address::DumpStyle fallback_style, bool show_range) const;
-
- bool
- GetDescription (Stream *s,
- lldb::DescriptionLevel level,
- CompileUnit* cu,
- Target *target,
- bool show_address_only) const;
-
- //------------------------------------------------------------------
- /// Dumps information specific to a process that stops at this
- /// line entry to the supplied stream \a s.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- ///
- /// @param[in] comp_unit
- /// The compile unit object that contains the support file
- /// list so the line entry can dump the file name (since this
- /// object contains a file index into the support file list).
- ///
- /// @return
- /// Returns \b true if the file and line were properly dumped,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool
- DumpStopContext (Stream *s, bool show_fullpaths) const;
-
- //------------------------------------------------------------------
- /// Check if a line entry object is valid.
- ///
- /// @return
- /// Returns \b true if the line entry contains a valid section
- /// offset address, file index, and line number, \b false
- /// otherwise.
- //------------------------------------------------------------------
- bool
- IsValid () const;
-
- //------------------------------------------------------------------
- /// Compare two LineEntry objects.
- ///
- /// @param[in] lhs
- /// The Left Hand Side const LineEntry object reference.
- ///
- /// @param[in] rhs
- /// The Right Hand Side const LineEntry object reference.
- ///
- /// @return
- /// @li -1 if lhs < rhs
- /// @li 0 if lhs == rhs
- /// @li 1 if lhs > rhs
- //------------------------------------------------------------------
- static int
- Compare (const LineEntry& lhs, const LineEntry& rhs);
-
- //------------------------------------------------------------------
- /// Give the range for this LineEntry + any additional LineEntries for
- /// this same source line that are contiguous.
- ///
- /// A compiler may emit multiple line entries for a single source line,
- /// e.g. to indicate subexpressions at different columns. This method
- /// will get the AddressRange for all of the LineEntries for this source
- /// line that are contiguous.
- //
- /// Line entries with a line number of 0 are treated specially - these
- /// are compiler-generated line table entries that the user did not
- /// write in their source code, and we want to skip past in the debugger.
- /// If this LineEntry is for line 32, and the following LineEntry is for
- /// line 0, we will extend the range to include the AddressRange of the
- /// line 0 LineEntry (and it will include the range of the following
- /// LineEntries that match either 32 or 0.)
- ///
- /// If the initial LineEntry this method is called on is a line #0, only
- /// the range of contiuous LineEntries with line #0 will be included in
- /// the complete range.
- ///
- /// @return
- /// The contiguous AddressRange for this source line.
- //------------------------------------------------------------------
- AddressRange
- GetSameLineContiguousAddressRange () const;
-
- //------------------------------------------------------------------
- /// Apply file mappings from target.source-map to the LineEntry's file.
- ///
- /// @param[in] target_sp
- /// Shared pointer to the target this LineEntry belongs to.
- //------------------------------------------------------------------
-
- void
- ApplyFileMappings(lldb::TargetSP target_sp);
-
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- AddressRange range; ///< The section offset address range for this line entry.
- FileSpec file; ///< The source file, possibly mapped by the target.source-map setting
- FileSpec original_file; ///< The original source file, from debug info.
- uint32_t line; ///< The source line number, or zero if there is no line number information.
- uint16_t column; ///< The column number of the source line, or zero if there is no column information.
- uint16_t is_start_of_statement:1, ///< Indicates this entry is the beginning of a statement.
- is_start_of_basic_block:1, ///< Indicates this entry is the beginning of a basic block.
- is_prologue_end:1, ///< Indicates this entry is one (of possibly many) where execution should be suspended for an entry breakpoint of a function.
- is_epilogue_begin:1, ///< Indicates this entry is one (of possibly many) where execution should be suspended for an exit breakpoint of a function.
- is_terminal_entry:1; ///< Indicates this entry is that of the first byte after the end of a sequence of target machine instructions.
+struct LineEntry {
+ //------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// Initialize all member variables to invalid values.
+ //------------------------------------------------------------------
+ LineEntry();
+
+ LineEntry(const lldb::SectionSP &section_sp, lldb::addr_t section_offset,
+ lldb::addr_t byte_size, const FileSpec &file, uint32_t _line,
+ uint16_t _column, bool _is_start_of_statement,
+ bool _is_start_of_basic_block, bool _is_prologue_end,
+ bool _is_epilogue_begin, bool _is_terminal_entry);
+
+ //------------------------------------------------------------------
+ /// Clear the object's state.
+ ///
+ /// Clears all member variables to invalid values.
+ //------------------------------------------------------------------
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Dump a description of this object to a Stream.
+ ///
+ /// Dump a description of the contents of this object to the
+ /// supplied stream \a s.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ ///
+ /// @param[in] comp_unit
+ /// The compile unit object that contains the support file
+ /// list so the line entry can dump the file name (since this
+ /// object contains a file index into the support file list).
+ ///
+ /// @param[in] show_file
+ /// If \b true, display the filename with the line entry which
+ /// requires that the compile unit object \a comp_unit be a
+ /// valid pointer.
+ ///
+ /// @param[in] style
+ /// The display style for the section offset address.
+ ///
+ /// @return
+ /// Returns \b true if the address was able to be displayed
+ /// using \a style. File and load addresses may be unresolved
+ /// and it may not be possible to display a valid address value.
+ /// Returns \b false if the address was not able to be properly
+ /// dumped.
+ ///
+ /// @see Address::DumpStyle
+ //------------------------------------------------------------------
+ bool Dump(Stream *s, Target *target, bool show_file, Address::DumpStyle style,
+ Address::DumpStyle fallback_style, bool show_range) const;
+
+ bool GetDescription(Stream *s, lldb::DescriptionLevel level, CompileUnit *cu,
+ Target *target, bool show_address_only) const;
+
+ //------------------------------------------------------------------
+ /// Dumps information specific to a process that stops at this
+ /// line entry to the supplied stream \a s.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ ///
+ /// @param[in] comp_unit
+ /// The compile unit object that contains the support file
+ /// list so the line entry can dump the file name (since this
+ /// object contains a file index into the support file list).
+ ///
+ /// @return
+ /// Returns \b true if the file and line were properly dumped,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool DumpStopContext(Stream *s, bool show_fullpaths) const;
+
+ //------------------------------------------------------------------
+ /// Check if a line entry object is valid.
+ ///
+ /// @return
+ /// Returns \b true if the line entry contains a valid section
+ /// offset address, file index, and line number, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ bool IsValid() const;
+
+ //------------------------------------------------------------------
+ /// Compare two LineEntry objects.
+ ///
+ /// @param[in] lhs
+ /// The Left Hand Side const LineEntry object reference.
+ ///
+ /// @param[in] rhs
+ /// The Right Hand Side const LineEntry object reference.
+ ///
+ /// @return
+ /// @li -1 if lhs < rhs
+ /// @li 0 if lhs == rhs
+ /// @li 1 if lhs > rhs
+ //------------------------------------------------------------------
+ static int Compare(const LineEntry &lhs, const LineEntry &rhs);
+
+ //------------------------------------------------------------------
+ /// Give the range for this LineEntry + any additional LineEntries for
+ /// this same source line that are contiguous.
+ ///
+ /// A compiler may emit multiple line entries for a single source line,
+ /// e.g. to indicate subexpressions at different columns. This method
+ /// will get the AddressRange for all of the LineEntries for this source
+ /// line that are contiguous.
+ //
+ /// Line entries with a line number of 0 are treated specially - these
+ /// are compiler-generated line table entries that the user did not
+ /// write in their source code, and we want to skip past in the debugger.
+ /// If this LineEntry is for line 32, and the following LineEntry is for
+ /// line 0, we will extend the range to include the AddressRange of the
+ /// line 0 LineEntry (and it will include the range of the following
+ /// LineEntries that match either 32 or 0.)
+ ///
+ /// If the initial LineEntry this method is called on is a line #0, only
+ /// the range of contiuous LineEntries with line #0 will be included in
+ /// the complete range.
+ ///
+ /// @return
+ /// The contiguous AddressRange for this source line.
+ //------------------------------------------------------------------
+ AddressRange GetSameLineContiguousAddressRange() const;
+
+ //------------------------------------------------------------------
+ /// Apply file mappings from target.source-map to the LineEntry's file.
+ ///
+ /// @param[in] target_sp
+ /// Shared pointer to the target this LineEntry belongs to.
+ //------------------------------------------------------------------
+
+ void ApplyFileMappings(lldb::TargetSP target_sp);
+
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ AddressRange range; ///< The section offset address range for this line entry.
+ FileSpec file; ///< The source file, possibly mapped by the target.source-map
+ ///setting
+ FileSpec original_file; ///< The original source file, from debug info.
+ uint32_t line; ///< The source line number, or zero if there is no line number
+ ///information.
+ uint16_t column; ///< The column number of the source line, or zero if there
+ ///is no column information.
+ uint16_t is_start_of_statement : 1, ///< Indicates this entry is the beginning
+ ///of a statement.
+ is_start_of_basic_block : 1, ///< Indicates this entry is the beginning of
+ ///a basic block.
+ is_prologue_end : 1, ///< Indicates this entry is one (of possibly many)
+ ///where execution should be suspended for an entry
+ ///breakpoint of a function.
+ is_epilogue_begin : 1, ///< Indicates this entry is one (of possibly many)
+ ///where execution should be suspended for an exit
+ ///breakpoint of a function.
+ is_terminal_entry : 1; ///< Indicates this entry is that of the first byte
+ ///after the end of a sequence of target machine
+ ///instructions.
};
//------------------------------------------------------------------
@@ -204,8 +195,8 @@ struct LineEntry
/// @return
/// Returns \b true if lhs < rhs, false otherwise.
//------------------------------------------------------------------
-bool operator<(const LineEntry& lhs, const LineEntry& rhs);
+bool operator<(const LineEntry &lhs, const LineEntry &rhs);
} // namespace lldb_private
-#endif // liblldb_LineEntry_h_
+#endif // liblldb_LineEntry_h_
diff --git a/include/lldb/Symbol/LineTable.h b/include/lldb/Symbol/LineTable.h
index cbad9bf590c2..a55e797f7b16 100644
--- a/include/lldb/Symbol/LineTable.h
+++ b/include/lldb/Symbol/LineTable.h
@@ -16,11 +16,11 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
-#include "lldb/Symbol/LineEntry.h"
#include "lldb/Core/ModuleChild.h"
-#include "lldb/Core/Section.h"
#include "lldb/Core/RangeMap.h"
+#include "lldb/Core/Section.h"
+#include "lldb/Symbol/LineEntry.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -28,392 +28,351 @@ namespace lldb_private {
/// @class LineSequence LineTable.h "lldb/Symbol/LineTable.h"
/// @brief An abstract base class used during symbol table creation.
//----------------------------------------------------------------------
-class LineSequence
-{
+class LineSequence {
public:
- LineSequence ();
+ LineSequence();
- virtual
- ~LineSequence() = default;
+ virtual ~LineSequence() = default;
- virtual void
- Clear() = 0;
+ virtual void Clear() = 0;
private:
- DISALLOW_COPY_AND_ASSIGN (LineSequence);
+ DISALLOW_COPY_AND_ASSIGN(LineSequence);
};
//----------------------------------------------------------------------
/// @class LineTable LineTable.h "lldb/Symbol/LineTable.h"
/// @brief A line table class.
//----------------------------------------------------------------------
-class LineTable
-{
+class LineTable {
public:
- //------------------------------------------------------------------
- /// Construct with compile unit.
- ///
- /// @param[in] comp_unit
- /// The compile unit to which this line table belongs.
- //------------------------------------------------------------------
- LineTable (CompileUnit* comp_unit);
-
- //------------------------------------------------------------------
- /// Destructor.
- //------------------------------------------------------------------
- ~LineTable ();
-
- //------------------------------------------------------------------
- /// Adds a new line entry to this line table.
- ///
- /// All line entries are maintained in file address order.
- ///
- /// @param[in] line_entry
- /// A const reference to a new line_entry to add to this line
- /// table.
- ///
- /// @see Address::DumpStyle
- //------------------------------------------------------------------
-// void
-// AddLineEntry (const LineEntry& line_entry);
-
- // Called when you can't guarantee the addresses are in increasing order
- void
- InsertLineEntry (lldb::addr_t file_addr,
- uint32_t line,
- uint16_t column,
- uint16_t file_idx,
- bool is_start_of_statement,
- bool is_start_of_basic_block,
- bool is_prologue_end,
- bool is_epilogue_begin,
- bool is_terminal_entry);
-
- // Used to instantiate the LineSequence helper class
- LineSequence*
- CreateLineSequenceContainer ();
-
- // Append an entry to a caller-provided collection that will later be
- // inserted in this line table.
- void
- AppendLineEntryToSequence (LineSequence* sequence,
- lldb::addr_t file_addr,
- uint32_t line,
- uint16_t column,
- uint16_t file_idx,
- bool is_start_of_statement,
- bool is_start_of_basic_block,
- bool is_prologue_end,
- bool is_epilogue_begin,
- bool is_terminal_entry);
-
- // Insert a sequence of entries into this line table.
- void
- InsertSequence (LineSequence* sequence);
-
- //------------------------------------------------------------------
- /// Dump all line entries in this line table to the stream \a s.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- ///
- /// @param[in] style
- /// The display style for the address.
- ///
- /// @see Address::DumpStyle
- //------------------------------------------------------------------
- void
- Dump (Stream *s, Target *target,
- Address::DumpStyle style,
- Address::DumpStyle fallback_style,
- bool show_line_ranges);
-
- void
- GetDescription (Stream *s,
- Target *target,
- lldb::DescriptionLevel level);
-
- //------------------------------------------------------------------
- /// Find a line entry that contains the section offset address \a
- /// so_addr.
- ///
- /// @param[in] so_addr
- /// A section offset address object containing the address we
- /// are searching for.
- ///
- /// @param[out] line_entry
- /// A copy of the line entry that was found if \b true is
- /// returned, otherwise \a entry is left unmodified.
- ///
- /// @param[out] index_ptr
- /// A pointer to a 32 bit integer that will get the actual line
- /// entry index if it is not nullptr.
- ///
- /// @return
- /// Returns \b true if \a so_addr is contained in a line entry
- /// in this line table, \b false otherwise.
- //------------------------------------------------------------------
- bool
- FindLineEntryByAddress(const Address &so_addr, LineEntry& line_entry, uint32_t *index_ptr = nullptr);
-
- //------------------------------------------------------------------
- /// Find a line entry index that has a matching file index and
- /// source line number.
- ///
- /// Finds the next line entry that has a matching \a file_idx and
- /// source line number \a line starting at the \a start_idx entries
- /// into the line entry collection.
- ///
- /// @param[in] start_idx
- /// The number of entries to skip when starting the search.
- ///
- /// @param[out] file_idx
- /// The file index to search for that should be found prior
- /// to calling this function using the following functions:
- /// CompileUnit::GetSupportFiles()
- /// FileSpecList::FindFileIndex (uint32_t, const FileSpec &) const
- ///
- /// @param[in] line
- /// The source line to match.
- ///
- /// @param[in] exact
- /// If true, match only if you find a line entry exactly matching \a line.
- /// If false, return the closest line entry greater than \a line.
- ///
- /// @param[out] line_entry
- /// A reference to a line entry object that will get a copy of
- /// the line entry if \b true is returned, otherwise \a
- /// line_entry is left untouched.
- ///
- /// @return
- /// Returns \b true if a matching line entry is found in this
- /// line table, \b false otherwise.
- ///
- /// @see CompileUnit::GetSupportFiles()
- /// @see FileSpecList::FindFileIndex (uint32_t, const FileSpec &) const
- //------------------------------------------------------------------
- uint32_t
- FindLineEntryIndexByFileIndex (uint32_t start_idx,
- uint32_t file_idx,
- uint32_t line,
- bool exact,
- LineEntry* line_entry_ptr);
-
- uint32_t
- FindLineEntryIndexByFileIndex (uint32_t start_idx,
- const std::vector<uint32_t> &file_indexes,
- uint32_t line,
- bool exact,
- LineEntry* line_entry_ptr);
-
- size_t
- FineLineEntriesForFileIndex (uint32_t file_idx,
- bool append,
- SymbolContextList &sc_list);
-
- //------------------------------------------------------------------
- /// Get the line entry from the line table at index \a idx.
- ///
- /// @param[in] idx
- /// An index into the line table entry collection.
- ///
- /// @return
- /// A valid line entry if \a idx is a valid index, or an invalid
- /// line entry if \a idx is not valid.
- ///
- /// @see LineTable::GetSize()
- /// @see LineEntry::IsValid() const
- //------------------------------------------------------------------
- bool
- GetLineEntryAtIndex(uint32_t idx, LineEntry& line_entry);
-
- //------------------------------------------------------------------
- /// Gets the size of the line table in number of line table entries.
- ///
- /// @return
- /// The number of line table entries in this line table.
- //------------------------------------------------------------------
- uint32_t
- GetSize () const;
-
- typedef lldb_private::RangeArray<lldb::addr_t, lldb::addr_t, 32> FileAddressRanges;
-
- //------------------------------------------------------------------
- /// Gets all contiguous file address ranges for the entire line table.
- ///
- /// @param[out] file_ranges
- /// A collection of file address ranges that will be filled in
- /// by this function.
- ///
- /// @param[out] append
- /// If \b true, then append to \a file_ranges, otherwise clear
- /// \a file_ranges prior to adding any ranges.
- ///
- /// @return
- /// The number of address ranges added to \a file_ranges
- //------------------------------------------------------------------
- size_t
- GetContiguousFileAddressRanges (FileAddressRanges &file_ranges, bool append);
-
- //------------------------------------------------------------------
- /// Given a file range link map, relink the current line table
- /// and return a fixed up line table.
- ///
- /// @param[out] file_range_map
- /// A collection of file ranges that maps to new file ranges
- /// that will be used when linking the line table.
- ///
- /// @return
- /// A new line table if at least one line table entry was able
- /// to be mapped.
- //------------------------------------------------------------------
- typedef RangeDataVector<lldb::addr_t, lldb::addr_t, lldb::addr_t> FileRangeMap;
-
- LineTable *
- LinkLineTable (const FileRangeMap &file_range_map);
+ //------------------------------------------------------------------
+ /// Construct with compile unit.
+ ///
+ /// @param[in] comp_unit
+ /// The compile unit to which this line table belongs.
+ //------------------------------------------------------------------
+ LineTable(CompileUnit *comp_unit);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ //------------------------------------------------------------------
+ ~LineTable();
+
+ //------------------------------------------------------------------
+ /// Adds a new line entry to this line table.
+ ///
+ /// All line entries are maintained in file address order.
+ ///
+ /// @param[in] line_entry
+ /// A const reference to a new line_entry to add to this line
+ /// table.
+ ///
+ /// @see Address::DumpStyle
+ //------------------------------------------------------------------
+ // void
+ // AddLineEntry (const LineEntry& line_entry);
+
+ // Called when you can't guarantee the addresses are in increasing order
+ void InsertLineEntry(lldb::addr_t file_addr, uint32_t line, uint16_t column,
+ uint16_t file_idx, bool is_start_of_statement,
+ bool is_start_of_basic_block, bool is_prologue_end,
+ bool is_epilogue_begin, bool is_terminal_entry);
+
+ // Used to instantiate the LineSequence helper class
+ LineSequence *CreateLineSequenceContainer();
+
+ // Append an entry to a caller-provided collection that will later be
+ // inserted in this line table.
+ void AppendLineEntryToSequence(LineSequence *sequence, lldb::addr_t file_addr,
+ uint32_t line, uint16_t column,
+ uint16_t file_idx, bool is_start_of_statement,
+ bool is_start_of_basic_block,
+ bool is_prologue_end, bool is_epilogue_begin,
+ bool is_terminal_entry);
+
+ // Insert a sequence of entries into this line table.
+ void InsertSequence(LineSequence *sequence);
+
+ //------------------------------------------------------------------
+ /// Dump all line entries in this line table to the stream \a s.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ ///
+ /// @param[in] style
+ /// The display style for the address.
+ ///
+ /// @see Address::DumpStyle
+ //------------------------------------------------------------------
+ void Dump(Stream *s, Target *target, Address::DumpStyle style,
+ Address::DumpStyle fallback_style, bool show_line_ranges);
+
+ void GetDescription(Stream *s, Target *target, lldb::DescriptionLevel level);
+
+ //------------------------------------------------------------------
+ /// Find a line entry that contains the section offset address \a
+ /// so_addr.
+ ///
+ /// @param[in] so_addr
+ /// A section offset address object containing the address we
+ /// are searching for.
+ ///
+ /// @param[out] line_entry
+ /// A copy of the line entry that was found if \b true is
+ /// returned, otherwise \a entry is left unmodified.
+ ///
+ /// @param[out] index_ptr
+ /// A pointer to a 32 bit integer that will get the actual line
+ /// entry index if it is not nullptr.
+ ///
+ /// @return
+ /// Returns \b true if \a so_addr is contained in a line entry
+ /// in this line table, \b false otherwise.
+ //------------------------------------------------------------------
+ bool FindLineEntryByAddress(const Address &so_addr, LineEntry &line_entry,
+ uint32_t *index_ptr = nullptr);
+
+ //------------------------------------------------------------------
+ /// Find a line entry index that has a matching file index and
+ /// source line number.
+ ///
+ /// Finds the next line entry that has a matching \a file_idx and
+ /// source line number \a line starting at the \a start_idx entries
+ /// into the line entry collection.
+ ///
+ /// @param[in] start_idx
+ /// The number of entries to skip when starting the search.
+ ///
+ /// @param[out] file_idx
+ /// The file index to search for that should be found prior
+ /// to calling this function using the following functions:
+ /// CompileUnit::GetSupportFiles()
+ /// FileSpecList::FindFileIndex (uint32_t, const FileSpec &) const
+ ///
+ /// @param[in] line
+ /// The source line to match.
+ ///
+ /// @param[in] exact
+ /// If true, match only if you find a line entry exactly matching \a line.
+ /// If false, return the closest line entry greater than \a line.
+ ///
+ /// @param[out] line_entry
+ /// A reference to a line entry object that will get a copy of
+ /// the line entry if \b true is returned, otherwise \a
+ /// line_entry is left untouched.
+ ///
+ /// @return
+ /// Returns \b true if a matching line entry is found in this
+ /// line table, \b false otherwise.
+ ///
+ /// @see CompileUnit::GetSupportFiles()
+ /// @see FileSpecList::FindFileIndex (uint32_t, const FileSpec &) const
+ //------------------------------------------------------------------
+ uint32_t FindLineEntryIndexByFileIndex(uint32_t start_idx, uint32_t file_idx,
+ uint32_t line, bool exact,
+ LineEntry *line_entry_ptr);
+
+ uint32_t FindLineEntryIndexByFileIndex(
+ uint32_t start_idx, const std::vector<uint32_t> &file_indexes,
+ uint32_t line, bool exact, LineEntry *line_entry_ptr);
+
+ size_t FineLineEntriesForFileIndex(uint32_t file_idx, bool append,
+ SymbolContextList &sc_list);
+
+ //------------------------------------------------------------------
+ /// Get the line entry from the line table at index \a idx.
+ ///
+ /// @param[in] idx
+ /// An index into the line table entry collection.
+ ///
+ /// @return
+ /// A valid line entry if \a idx is a valid index, or an invalid
+ /// line entry if \a idx is not valid.
+ ///
+ /// @see LineTable::GetSize()
+ /// @see LineEntry::IsValid() const
+ //------------------------------------------------------------------
+ bool GetLineEntryAtIndex(uint32_t idx, LineEntry &line_entry);
+
+ //------------------------------------------------------------------
+ /// Gets the size of the line table in number of line table entries.
+ ///
+ /// @return
+ /// The number of line table entries in this line table.
+ //------------------------------------------------------------------
+ uint32_t GetSize() const;
+
+ typedef lldb_private::RangeArray<lldb::addr_t, lldb::addr_t, 32>
+ FileAddressRanges;
+
+ //------------------------------------------------------------------
+ /// Gets all contiguous file address ranges for the entire line table.
+ ///
+ /// @param[out] file_ranges
+ /// A collection of file address ranges that will be filled in
+ /// by this function.
+ ///
+ /// @param[out] append
+ /// If \b true, then append to \a file_ranges, otherwise clear
+ /// \a file_ranges prior to adding any ranges.
+ ///
+ /// @return
+ /// The number of address ranges added to \a file_ranges
+ //------------------------------------------------------------------
+ size_t GetContiguousFileAddressRanges(FileAddressRanges &file_ranges,
+ bool append);
+
+ //------------------------------------------------------------------
+ /// Given a file range link map, relink the current line table
+ /// and return a fixed up line table.
+ ///
+ /// @param[out] file_range_map
+ /// A collection of file ranges that maps to new file ranges
+ /// that will be used when linking the line table.
+ ///
+ /// @return
+ /// A new line table if at least one line table entry was able
+ /// to be mapped.
+ //------------------------------------------------------------------
+ typedef RangeDataVector<lldb::addr_t, lldb::addr_t, lldb::addr_t>
+ FileRangeMap;
+
+ LineTable *LinkLineTable(const FileRangeMap &file_range_map);
protected:
- struct Entry
- {
- Entry () :
- file_addr (LLDB_INVALID_ADDRESS),
- line (0),
- column (0),
- file_idx (0),
- is_start_of_statement (false),
- is_start_of_basic_block (false),
- is_prologue_end (false),
- is_epilogue_begin (false),
- is_terminal_entry (false)
- {
- }
-
- Entry ( lldb::addr_t _file_addr,
- uint32_t _line,
- uint16_t _column,
- uint16_t _file_idx,
- bool _is_start_of_statement,
- bool _is_start_of_basic_block,
- bool _is_prologue_end,
- bool _is_epilogue_begin,
- bool _is_terminal_entry) :
- file_addr (_file_addr),
- line (_line),
- column (_column),
- file_idx (_file_idx),
- is_start_of_statement (_is_start_of_statement),
- is_start_of_basic_block (_is_start_of_basic_block),
- is_prologue_end (_is_prologue_end),
- is_epilogue_begin (_is_epilogue_begin),
- is_terminal_entry (_is_terminal_entry)
- {
- }
-
- int
- bsearch_compare (const void *key, const void *arrmem);
-
- void
- Clear ()
- {
- file_addr = LLDB_INVALID_ADDRESS;
- line = 0;
- column = 0;
- file_idx = 0;
- is_start_of_statement = false;
- is_start_of_basic_block = false;
- is_prologue_end = false;
- is_epilogue_begin = false;
- is_terminal_entry = false;
- }
-
- static int
- Compare (const Entry& lhs, const Entry& rhs)
- {
- // Compare the sections before calling
- #define SCALAR_COMPARE(a,b) if (a < b) return -1; if (a > b) return +1
- SCALAR_COMPARE (lhs.file_addr, rhs.file_addr);
- SCALAR_COMPARE (lhs.line, rhs.line);
- SCALAR_COMPARE (lhs.column, rhs.column);
- SCALAR_COMPARE (lhs.is_start_of_statement, rhs.is_start_of_statement);
- SCALAR_COMPARE (lhs.is_start_of_basic_block, rhs.is_start_of_basic_block);
- // rhs and lhs reversed on purpose below.
- SCALAR_COMPARE (rhs.is_prologue_end, lhs.is_prologue_end);
- SCALAR_COMPARE (lhs.is_epilogue_begin, rhs.is_epilogue_begin);
- // rhs and lhs reversed on purpose below.
- SCALAR_COMPARE (rhs.is_terminal_entry, lhs.is_terminal_entry);
- SCALAR_COMPARE (lhs.file_idx, rhs.file_idx);
- #undef SCALAR_COMPARE
- return 0;
- }
-
- class LessThanBinaryPredicate
- {
- public:
- LessThanBinaryPredicate(LineTable *line_table);
- bool operator() (const LineTable::Entry&, const LineTable::Entry&) const;
-
- protected:
- LineTable *m_line_table;
- };
-
- static bool EntryAddressLessThan (const Entry& lhs, const Entry& rhs)
- {
- return lhs.file_addr < rhs.file_addr;
- }
-
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- lldb::addr_t file_addr; ///< The file address for this line entry
- uint32_t line; ///< The source line number, or zero if there is no line number information.
- uint16_t column; ///< The column number of the source line, or zero if there is no column information.
- uint16_t file_idx:11, ///< The file index into CompileUnit's file table, or zero if there is no file information.
- is_start_of_statement:1, ///< Indicates this entry is the beginning of a statement.
- is_start_of_basic_block:1, ///< Indicates this entry is the beginning of a basic block.
- is_prologue_end:1, ///< Indicates this entry is one (of possibly many) where execution should be suspended for an entry breakpoint of a function.
- is_epilogue_begin:1, ///< Indicates this entry is one (of possibly many) where execution should be suspended for an exit breakpoint of a function.
- is_terminal_entry:1; ///< Indicates this entry is that of the first byte after the end of a sequence of target machine instructions.
- };
+ struct Entry {
+ Entry()
+ : file_addr(LLDB_INVALID_ADDRESS), line(0), column(0), file_idx(0),
+ is_start_of_statement(false), is_start_of_basic_block(false),
+ is_prologue_end(false), is_epilogue_begin(false),
+ is_terminal_entry(false) {}
+
+ Entry(lldb::addr_t _file_addr, uint32_t _line, uint16_t _column,
+ uint16_t _file_idx, bool _is_start_of_statement,
+ bool _is_start_of_basic_block, bool _is_prologue_end,
+ bool _is_epilogue_begin, bool _is_terminal_entry)
+ : file_addr(_file_addr), line(_line), column(_column),
+ file_idx(_file_idx), is_start_of_statement(_is_start_of_statement),
+ is_start_of_basic_block(_is_start_of_basic_block),
+ is_prologue_end(_is_prologue_end),
+ is_epilogue_begin(_is_epilogue_begin),
+ is_terminal_entry(_is_terminal_entry) {}
+
+ int bsearch_compare(const void *key, const void *arrmem);
+
+ void Clear() {
+ file_addr = LLDB_INVALID_ADDRESS;
+ line = 0;
+ column = 0;
+ file_idx = 0;
+ is_start_of_statement = false;
+ is_start_of_basic_block = false;
+ is_prologue_end = false;
+ is_epilogue_begin = false;
+ is_terminal_entry = false;
+ }
+
+ static int Compare(const Entry &lhs, const Entry &rhs) {
+// Compare the sections before calling
+#define SCALAR_COMPARE(a, b) \
+ if (a < b) \
+ return -1; \
+ if (a > b) \
+ return +1
+ SCALAR_COMPARE(lhs.file_addr, rhs.file_addr);
+ SCALAR_COMPARE(lhs.line, rhs.line);
+ SCALAR_COMPARE(lhs.column, rhs.column);
+ SCALAR_COMPARE(lhs.is_start_of_statement, rhs.is_start_of_statement);
+ SCALAR_COMPARE(lhs.is_start_of_basic_block, rhs.is_start_of_basic_block);
+ // rhs and lhs reversed on purpose below.
+ SCALAR_COMPARE(rhs.is_prologue_end, lhs.is_prologue_end);
+ SCALAR_COMPARE(lhs.is_epilogue_begin, rhs.is_epilogue_begin);
+ // rhs and lhs reversed on purpose below.
+ SCALAR_COMPARE(rhs.is_terminal_entry, lhs.is_terminal_entry);
+ SCALAR_COMPARE(lhs.file_idx, rhs.file_idx);
+#undef SCALAR_COMPARE
+ return 0;
+ }
+
+ class LessThanBinaryPredicate {
+ public:
+ LessThanBinaryPredicate(LineTable *line_table);
+ bool operator()(const LineTable::Entry &, const LineTable::Entry &) const;
- struct EntrySearchInfo
- {
- LineTable* line_table;
- lldb_private::Section *a_section;
- Entry *a_entry;
+ protected:
+ LineTable *m_line_table;
};
- //------------------------------------------------------------------
- // Types
- //------------------------------------------------------------------
- typedef std::vector<lldb_private::Section*> section_collection; ///< The collection type for the sections.
- typedef std::vector<Entry> entry_collection; ///< The collection type for the line entries.
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- CompileUnit* m_comp_unit; ///< The compile unit that this line table belongs to.
- entry_collection m_entries; ///< The collection of line entries in this line table.
+ static bool EntryAddressLessThan(const Entry &lhs, const Entry &rhs) {
+ return lhs.file_addr < rhs.file_addr;
+ }
//------------------------------------------------------------------
- // Helper class
+ // Member variables.
//------------------------------------------------------------------
- class LineSequenceImpl : public LineSequence
- {
- public:
- LineSequenceImpl() = default;
-
- ~LineSequenceImpl() override = default;
-
- void
- Clear() override;
-
- entry_collection m_entries; ///< The collection of line entries in this sequence.
- };
-
- bool
- ConvertEntryAtIndexToLineEntry (uint32_t idx, LineEntry &line_entry);
+ lldb::addr_t file_addr; ///< The file address for this line entry
+ uint32_t line; ///< The source line number, or zero if there is no line
+ ///number information.
+ uint16_t column; ///< The column number of the source line, or zero if there
+ ///is no column information.
+ uint16_t file_idx : 11, ///< The file index into CompileUnit's file table,
+ ///or zero if there is no file information.
+ is_start_of_statement : 1, ///< Indicates this entry is the beginning of
+ ///a statement.
+ is_start_of_basic_block : 1, ///< Indicates this entry is the beginning
+ ///of a basic block.
+ is_prologue_end : 1, ///< Indicates this entry is one (of possibly many)
+ ///where execution should be suspended for an entry
+ ///breakpoint of a function.
+ is_epilogue_begin : 1, ///< Indicates this entry is one (of possibly
+ ///many) where execution should be suspended for
+ ///an exit breakpoint of a function.
+ is_terminal_entry : 1; ///< Indicates this entry is that of the first
+ ///byte after the end of a sequence of target
+ ///machine instructions.
+ };
+
+ struct EntrySearchInfo {
+ LineTable *line_table;
+ lldb_private::Section *a_section;
+ Entry *a_entry;
+ };
+
+ //------------------------------------------------------------------
+ // Types
+ //------------------------------------------------------------------
+ typedef std::vector<lldb_private::Section *>
+ section_collection; ///< The collection type for the sections.
+ typedef std::vector<Entry>
+ entry_collection; ///< The collection type for the line entries.
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ CompileUnit
+ *m_comp_unit; ///< The compile unit that this line table belongs to.
+ entry_collection
+ m_entries; ///< The collection of line entries in this line table.
+
+ //------------------------------------------------------------------
+ // Helper class
+ //------------------------------------------------------------------
+ class LineSequenceImpl : public LineSequence {
+ public:
+ LineSequenceImpl() = default;
+
+ ~LineSequenceImpl() override = default;
+
+ void Clear() override;
+
+ entry_collection
+ m_entries; ///< The collection of line entries in this sequence.
+ };
+
+ bool ConvertEntryAtIndexToLineEntry(uint32_t idx, LineEntry &line_entry);
private:
- DISALLOW_COPY_AND_ASSIGN (LineTable);
+ DISALLOW_COPY_AND_ASSIGN(LineTable);
};
} // namespace lldb_private
diff --git a/include/lldb/Symbol/OCamlASTContext.h b/include/lldb/Symbol/OCamlASTContext.h
new file mode 100644
index 000000000000..9560866d33e6
--- /dev/null
+++ b/include/lldb/Symbol/OCamlASTContext.h
@@ -0,0 +1,324 @@
+//===-- OCamlASTContext.h ------------------------------------------*- C++
+//-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_OCamlASTContext_h_
+#define liblldb_OCamlASTContext_h_
+
+// C Includes
+// C++ Includes
+#include <map>
+#include <memory>
+#include <set>
+#include <string>
+#include <vector>
+
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/ConstString.h"
+#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Symbol/TypeSystem.h"
+
+namespace lldb_private {
+
+class OCamlASTContext : public TypeSystem {
+public:
+ class OCamlType;
+ typedef std::map<ConstString, std::unique_ptr<OCamlType>> OCamlTypeMap;
+
+ OCamlASTContext();
+ ~OCamlASTContext() override;
+
+ ConstString GetPluginName() override;
+
+ uint32_t GetPluginVersion() override;
+
+ static ConstString GetPluginNameStatic();
+
+ static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language,
+ Module *module, Target *target);
+
+ static void EnumerateSupportedLanguages(
+ std::set<lldb::LanguageType> &languages_for_types,
+ std::set<lldb::LanguageType> &languages_for_expressions);
+
+ static void Initialize();
+
+ static void Terminate();
+
+ DWARFASTParser *GetDWARFParser() override;
+
+ void SetAddressByteSize(int byte_size) { m_pointer_byte_size = byte_size; }
+
+ static bool classof(const TypeSystem *ts) {
+ return ts->getKind() == TypeSystem::eKindOCaml;
+ }
+
+ ConstString DeclGetName(void *opaque_decl) override { return ConstString(); }
+
+ bool DeclContextIsStructUnionOrClass(void *opaque_decl_ctx) override {
+ return false;
+ }
+
+ ConstString DeclContextGetName(void *opaque_decl_ctx) override {
+ return ConstString();
+ }
+
+ ConstString DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) override {
+ return ConstString();
+ }
+
+ bool
+ DeclContextIsClassMethod(void *opaque_decl_ctx,
+ lldb::LanguageType *language_ptr,
+ bool *is_instance_method_ptr,
+ ConstString *language_object_name_ptr) override {
+ return false;
+ }
+
+ bool SupportsLanguage(lldb::LanguageType language) override;
+ uint32_t GetPointerByteSize() override;
+
+ bool IsArrayType(lldb::opaque_compiler_type_t type,
+ CompilerType *element_type, uint64_t *size,
+ bool *is_incomplete) override;
+
+ bool IsAggregateType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsCharType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsCompleteType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsDefined(lldb::opaque_compiler_type_t type) override;
+
+ bool IsFloatingPointType(lldb::opaque_compiler_type_t type, uint32_t &count,
+ bool &is_complex) override;
+
+ bool IsFunctionType(lldb::opaque_compiler_type_t type,
+ bool *is_variadic_ptr = nullptr) override;
+
+ size_t
+ GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type,
+ const size_t index) override;
+
+ bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsBlockPointerType(lldb::opaque_compiler_type_t type,
+ CompilerType *function_pointer_type_ptr) override;
+
+ bool IsIntegerType(lldb::opaque_compiler_type_t type,
+ bool &is_signed) override;
+
+ bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
+ CompilerType *target_type, bool check_cplusplus,
+ bool check_objc) override;
+
+ bool IsPointerType(lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_type = nullptr) override;
+
+ bool IsScalarType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsVoidType(lldb::opaque_compiler_type_t type) override;
+
+ bool GetCompleteType(lldb::opaque_compiler_type_t type) override;
+
+ ConstString GetTypeName(lldb::opaque_compiler_type_t type) override;
+
+ uint32_t GetTypeInfo(
+ lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_or_element_compiler_type = nullptr) override;
+
+ lldb::LanguageType
+ GetMinimumLanguage(lldb::opaque_compiler_type_t type) override;
+
+ lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type,
+ uint64_t *stride = nullptr) override;
+
+ CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override;
+
+ int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type,
+ size_t idx) override;
+
+ CompilerType
+ GetFunctionReturnType(lldb::opaque_compiler_type_t type) override;
+
+ size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) override;
+
+ TypeMemberFunctionImpl
+ GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type,
+ size_t idx) override;
+
+ CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetPointerType(lldb::opaque_compiler_type_t type) override;
+
+ uint64_t GetBitSize(lldb::opaque_compiler_type_t type,
+ ExecutionContextScope *exe_scope) override;
+
+ lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type,
+ uint64_t &count) override;
+
+ lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override;
+
+ uint32_t GetNumChildren(lldb::opaque_compiler_type_t type,
+ bool omit_empty_base_classes) override;
+
+ lldb::BasicType
+ GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding,
+ size_t bit_size) override;
+
+ uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx,
+ std::string &name, uint64_t *bit_offset_ptr,
+ uint32_t *bitfield_bit_size_ptr,
+ bool *is_bitfield_ptr) override;
+
+ uint32_t GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) override {
+ return 0;
+ }
+
+ uint32_t
+ GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) override {
+ return 0;
+ }
+
+ CompilerType GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type,
+ size_t idx,
+ uint32_t *bit_offset_ptr) override {
+ return CompilerType();
+ }
+
+ CompilerType GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type,
+ size_t idx,
+ uint32_t *bit_offset_ptr) override {
+ return CompilerType();
+ }
+
+ CompilerType GetChildCompilerTypeAtIndex(
+ lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx,
+ bool transparent_pointers, bool omit_empty_base_classes,
+ bool ignore_array_bounds, std::string &child_name,
+ uint32_t &child_byte_size, int32_t &child_byte_offset,
+ uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
+ bool &child_is_base_class, bool &child_is_deref_of_parent,
+ ValueObject *valobj, uint64_t &language_flags) override;
+
+ uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
+ const char *name,
+ bool omit_empty_base_classes) override;
+
+ size_t
+ GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type,
+ const char *name, bool omit_empty_base_classes,
+ std::vector<uint32_t> &child_indexes) override;
+
+ size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type) override {
+ return 0;
+ }
+
+ CompilerType GetTemplateArgument(lldb::opaque_compiler_type_t type,
+ size_t idx,
+ lldb::TemplateArgumentKind &kind) override {
+ return CompilerType();
+ }
+
+ void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
+ Stream *s, lldb::Format format, const DataExtractor &data,
+ lldb::offset_t data_offset, size_t data_byte_size,
+ uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
+ bool show_types, bool show_summary, bool verbose,
+ uint32_t depth) override;
+
+ bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s,
+ lldb::Format format, const DataExtractor &data,
+ lldb::offset_t data_offset, size_t data_byte_size,
+ uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
+ ExecutionContextScope *exe_scope) override;
+
+ void DumpTypeDescription(lldb::opaque_compiler_type_t type) override;
+
+ void DumpTypeDescription(lldb::opaque_compiler_type_t type,
+ Stream *s) override;
+
+ bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) override;
+
+ void DumpSummary(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
+ Stream *s, const DataExtractor &data,
+ lldb::offset_t data_offset, size_t data_byte_size) override;
+
+ size_t ConvertStringToFloatValue(lldb::opaque_compiler_type_t type,
+ const char *s, uint8_t *dst,
+ size_t dst_size) override;
+
+ bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_type = nullptr) override;
+
+ unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override;
+
+ bool IsCStringType(lldb::opaque_compiler_type_t type,
+ uint32_t &length) override;
+
+ size_t GetTypeBitAlign(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override;
+
+ bool IsBeingDefined(lldb::opaque_compiler_type_t type) override;
+
+ bool IsConst(lldb::opaque_compiler_type_t type) override;
+
+ uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type,
+ CompilerType *base_type_ptr) override;
+
+ bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) override;
+
+ bool IsTypedefType(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsVectorType(lldb::opaque_compiler_type_t type,
+ CompilerType *element_type, uint64_t *size) override;
+
+ CompilerType
+ GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetNonReferenceType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsReferenceType(lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_type = nullptr,
+ bool *is_rvalue = nullptr) override;
+
+ CompilerType CreateBaseType(const ConstString &name, uint64_t);
+
+private:
+ int m_pointer_byte_size;
+ std::unique_ptr<DWARFASTParser> m_dwarf_ast_parser_ap;
+ OCamlTypeMap m_base_type_map;
+
+ OCamlASTContext(const OCamlASTContext &) = delete;
+ const OCamlASTContext &operator=(const OCamlASTContext &) = delete;
+};
+
+class OCamlASTContextForExpr : public OCamlASTContext {
+public:
+ OCamlASTContextForExpr(lldb::TargetSP target) : m_target_wp(target) {}
+
+private:
+ lldb::TargetWP m_target_wp;
+};
+}
+#endif // liblldb_OCamlASTContext_h_
diff --git a/include/lldb/Symbol/ObjectContainer.h b/include/lldb/Symbol/ObjectContainer.h
index eeda1c4ae19d..6f38b50ba567 100644
--- a/include/lldb/Symbol/ObjectContainer.h
+++ b/include/lldb/Symbol/ObjectContainer.h
@@ -14,12 +14,12 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/DataExtractor.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Core/ModuleChild.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Host/Endian.h"
+#include "lldb/Host/FileSpec.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -34,197 +34,168 @@ namespace lldb_private {
/// contain multiple named object files, and universal files that contain
/// multiple architectures.
//----------------------------------------------------------------------
-class ObjectContainer :
- public PluginInterface,
- public ModuleChild
-{
+class ObjectContainer : public PluginInterface, public ModuleChild {
public:
- //------------------------------------------------------------------
- /// Construct with a parent module, offset, and header data.
- ///
- /// Object files belong to modules and a valid module must be
- /// supplied upon construction. The at an offset within a file for
- /// objects that contain more than one architecture or object.
- //------------------------------------------------------------------
- ObjectContainer (const lldb::ModuleSP &module_sp,
- const FileSpec *file,
- lldb::offset_t file_offset,
- lldb::offset_t length,
- lldb::DataBufferSP& data_sp,
- lldb::offset_t data_offset) :
- ModuleChild (module_sp),
- m_file (), // This file can be different than the module's file spec
- m_offset (file_offset),
- m_length (length),
- m_data ()
- {
- if (file)
- m_file = *file;
- if (data_sp)
- m_data.SetData (data_sp, data_offset, length);
- }
-
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// The destructor is virtual since this class is designed to be
- /// inherited from by the plug-in instance.
- //------------------------------------------------------------------
- ~ObjectContainer() override = default;
-
- //------------------------------------------------------------------
- /// Dump a description of this object to a Stream.
- ///
- /// Dump a description of the current contents of this object
- /// to the supplied stream \a s. The dumping should include the
- /// section list if it has been parsed, and the symbol table
- /// if it has been parsed.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- //------------------------------------------------------------------
- virtual void
- Dump (Stream *s) const = 0;
-
- //------------------------------------------------------------------
- /// Gets the architecture given an index.
- ///
- /// Copies the architecture specification for index \a idx.
- ///
- /// @param[in] idx
- /// The architecture index to extract.
- ///
- /// @param[out] arch
- /// A architecture object that will be filled in if \a idx is a
- /// architecture valid index.
- ///
- /// @return
- /// Returns \b true if \a idx is valid and \a arch has been
- /// filled in, \b false otherwise.
- ///
- /// @see ObjectContainer::GetNumArchitectures() const
- //------------------------------------------------------------------
- virtual bool
- GetArchitectureAtIndex (uint32_t idx, ArchSpec& arch) const
- {
- return false;
- }
-
- //------------------------------------------------------------------
- /// Returns the offset into a file at which this object resides.
- ///
- /// Some files contain many object files, and this function allows
- /// access to an object's offset within the file.
- ///
- /// @return
- /// The offset in bytes into the file. Defaults to zero for
- /// simple object files that a represented by an entire file.
- //------------------------------------------------------------------
- virtual lldb::addr_t
- GetOffset () const
- { return m_offset; }
-
- virtual lldb::addr_t
- GetByteSize () const
- { return m_length; }
-
- //------------------------------------------------------------------
- /// Get the number of objects within this object file (archives).
- ///
- /// @return
- /// Zero for object files that are not archives, or the number
- /// of objects contained in the archive.
- //------------------------------------------------------------------
- virtual size_t
- GetNumObjects () const
- { return 0; }
-
- //------------------------------------------------------------------
- /// Get the number of architectures in this object file.
- ///
- /// The default implementation returns 1 as for object files that
- /// contain a single architecture. ObjectContainer instances that
- /// contain more than one architecture should override this function
- /// and return an appropriate value.
- ///
- /// @return
- /// The number of architectures contained in this object file.
- //------------------------------------------------------------------
- virtual size_t
- GetNumArchitectures () const
- { return 0; }
-
- //------------------------------------------------------------------
- /// Attempts to parse the object header.
- ///
- /// This function is used as a test to see if a given plug-in
- /// instance can parse the header data already contained in
- /// ObjectContainer::m_data. If an object file parser does not
- /// recognize that magic bytes in a header, false should be returned
- /// and the next plug-in can attempt to parse an object file.
- ///
- /// @return
- /// Returns \b true if the header was parsed successfully, \b
- /// false otherwise.
- //------------------------------------------------------------------
- virtual bool
- ParseHeader () = 0;
-
- //------------------------------------------------------------------
- /// Selects an architecture in an object file.
- ///
- /// Object files that contain a single architecture should verify
- /// that the specified \a arch matches the architecture in in
- /// object file and return \b true or \b false accordingly.
- ///
- /// Object files that contain more than one architecture should
- /// attempt to select that architecture, and if successful, clear
- /// out any previous state from any previously selected architecture
- /// and prepare to return information for the new architecture.
- ///
- /// @return
- /// Returns a pointer to the object file of the requested \a
- /// arch and optional \a name. Returns nullptr of no such object
- /// file exists in the container.
- //------------------------------------------------------------------
- virtual lldb::ObjectFileSP
- GetObjectFile (const FileSpec *file) = 0;
-
- virtual bool
- ObjectAtIndexIsContainer (uint32_t object_idx)
- {
- return false;
- }
-
- virtual ObjectFile *
- GetObjectFileAtIndex (uint32_t object_idx)
- {
- return nullptr;
- }
-
- virtual ObjectContainer *
- GetObjectContainerAtIndex (uint32_t object_idx)
- {
- return nullptr;
- }
-
- virtual const char *
- GetObjectNameAtIndex (uint32_t object_idx) const
- {
- return nullptr;
- }
+ //------------------------------------------------------------------
+ /// Construct with a parent module, offset, and header data.
+ ///
+ /// Object files belong to modules and a valid module must be
+ /// supplied upon construction. The at an offset within a file for
+ /// objects that contain more than one architecture or object.
+ //------------------------------------------------------------------
+ ObjectContainer(const lldb::ModuleSP &module_sp, const FileSpec *file,
+ lldb::offset_t file_offset, lldb::offset_t length,
+ lldb::DataBufferSP &data_sp, lldb::offset_t data_offset)
+ : ModuleChild(module_sp),
+ m_file(), // This file can be different than the module's file spec
+ m_offset(file_offset), m_length(length), m_data() {
+ if (file)
+ m_file = *file;
+ if (data_sp)
+ m_data.SetData(data_sp, data_offset, length);
+ }
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ ///
+ /// The destructor is virtual since this class is designed to be
+ /// inherited from by the plug-in instance.
+ //------------------------------------------------------------------
+ ~ObjectContainer() override = default;
+
+ //------------------------------------------------------------------
+ /// Dump a description of this object to a Stream.
+ ///
+ /// Dump a description of the current contents of this object
+ /// to the supplied stream \a s. The dumping should include the
+ /// section list if it has been parsed, and the symbol table
+ /// if it has been parsed.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ //------------------------------------------------------------------
+ virtual void Dump(Stream *s) const = 0;
+
+ //------------------------------------------------------------------
+ /// Gets the architecture given an index.
+ ///
+ /// Copies the architecture specification for index \a idx.
+ ///
+ /// @param[in] idx
+ /// The architecture index to extract.
+ ///
+ /// @param[out] arch
+ /// A architecture object that will be filled in if \a idx is a
+ /// architecture valid index.
+ ///
+ /// @return
+ /// Returns \b true if \a idx is valid and \a arch has been
+ /// filled in, \b false otherwise.
+ ///
+ /// @see ObjectContainer::GetNumArchitectures() const
+ //------------------------------------------------------------------
+ virtual bool GetArchitectureAtIndex(uint32_t idx, ArchSpec &arch) const {
+ return false;
+ }
+
+ //------------------------------------------------------------------
+ /// Returns the offset into a file at which this object resides.
+ ///
+ /// Some files contain many object files, and this function allows
+ /// access to an object's offset within the file.
+ ///
+ /// @return
+ /// The offset in bytes into the file. Defaults to zero for
+ /// simple object files that a represented by an entire file.
+ //------------------------------------------------------------------
+ virtual lldb::addr_t GetOffset() const { return m_offset; }
+
+ virtual lldb::addr_t GetByteSize() const { return m_length; }
+
+ //------------------------------------------------------------------
+ /// Get the number of objects within this object file (archives).
+ ///
+ /// @return
+ /// Zero for object files that are not archives, or the number
+ /// of objects contained in the archive.
+ //------------------------------------------------------------------
+ virtual size_t GetNumObjects() const { return 0; }
+
+ //------------------------------------------------------------------
+ /// Get the number of architectures in this object file.
+ ///
+ /// The default implementation returns 1 as for object files that
+ /// contain a single architecture. ObjectContainer instances that
+ /// contain more than one architecture should override this function
+ /// and return an appropriate value.
+ ///
+ /// @return
+ /// The number of architectures contained in this object file.
+ //------------------------------------------------------------------
+ virtual size_t GetNumArchitectures() const { return 0; }
+
+ //------------------------------------------------------------------
+ /// Attempts to parse the object header.
+ ///
+ /// This function is used as a test to see if a given plug-in
+ /// instance can parse the header data already contained in
+ /// ObjectContainer::m_data. If an object file parser does not
+ /// recognize that magic bytes in a header, false should be returned
+ /// and the next plug-in can attempt to parse an object file.
+ ///
+ /// @return
+ /// Returns \b true if the header was parsed successfully, \b
+ /// false otherwise.
+ //------------------------------------------------------------------
+ virtual bool ParseHeader() = 0;
+
+ //------------------------------------------------------------------
+ /// Selects an architecture in an object file.
+ ///
+ /// Object files that contain a single architecture should verify
+ /// that the specified \a arch matches the architecture in in
+ /// object file and return \b true or \b false accordingly.
+ ///
+ /// Object files that contain more than one architecture should
+ /// attempt to select that architecture, and if successful, clear
+ /// out any previous state from any previously selected architecture
+ /// and prepare to return information for the new architecture.
+ ///
+ /// @return
+ /// Returns a pointer to the object file of the requested \a
+ /// arch and optional \a name. Returns nullptr of no such object
+ /// file exists in the container.
+ //------------------------------------------------------------------
+ virtual lldb::ObjectFileSP GetObjectFile(const FileSpec *file) = 0;
+
+ virtual bool ObjectAtIndexIsContainer(uint32_t object_idx) { return false; }
+
+ virtual ObjectFile *GetObjectFileAtIndex(uint32_t object_idx) {
+ return nullptr;
+ }
+
+ virtual ObjectContainer *GetObjectContainerAtIndex(uint32_t object_idx) {
+ return nullptr;
+ }
+
+ virtual const char *GetObjectNameAtIndex(uint32_t object_idx) const {
+ return nullptr;
+ }
protected:
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- FileSpec m_file; ///< The file that represents this container objects (which can be different from the module's file).
- lldb::addr_t m_offset; ///< The offset in bytes into the file, or the address in memory
- lldb::addr_t m_length; ///< The size in bytes if known (can be zero).
- DataExtractor m_data; ///< The data for this object file so things can be parsed lazily.
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ FileSpec m_file; ///< The file that represents this container objects (which
+ ///can be different from the module's file).
+ lldb::addr_t
+ m_offset; ///< The offset in bytes into the file, or the address in memory
+ lldb::addr_t m_length; ///< The size in bytes if known (can be zero).
+ DataExtractor
+ m_data; ///< The data for this object file so things can be parsed lazily.
private:
- DISALLOW_COPY_AND_ASSIGN (ObjectContainer);
+ DISALLOW_COPY_AND_ASSIGN(ObjectContainer);
};
} // namespace lldb_private
diff --git a/include/lldb/Symbol/ObjectFile.h b/include/lldb/Symbol/ObjectFile.h
index 53f0f3c80517..e2e4500ace46 100644
--- a/include/lldb/Symbol/ObjectFile.h
+++ b/include/lldb/Symbol/ObjectFile.h
@@ -10,46 +10,35 @@
#ifndef liblldb_ObjectFile_h_
#define liblldb_ObjectFile_h_
-#include "lldb/lldb-private.h"
#include "lldb/Core/DataExtractor.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Core/FileSpecList.h"
#include "lldb/Core/ModuleChild.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Host/Endian.h"
+#include "lldb/Host/FileSpec.h"
#include "lldb/Symbol/Symtab.h"
#include "lldb/Symbol/UnwindTable.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-
-class ObjectFileJITDelegate
-{
+
+class ObjectFileJITDelegate {
public:
- ObjectFileJITDelegate ()
- {
- }
-
- virtual
- ~ObjectFileJITDelegate()
- {
- }
-
- virtual lldb::ByteOrder
- GetByteOrder () const = 0;
-
- virtual uint32_t
- GetAddressByteSize () const = 0;
-
- virtual void
- PopulateSymtab (lldb_private::ObjectFile *obj_file,
- lldb_private::Symtab &symtab) = 0;
-
- virtual void
- PopulateSectionList (lldb_private::ObjectFile *obj_file,
- lldb_private::SectionList &section_list) = 0;
-
- virtual bool
- GetArchitecture (lldb_private::ArchSpec &arch) = 0;
+ ObjectFileJITDelegate() {}
+
+ virtual ~ObjectFileJITDelegate() {}
+
+ virtual lldb::ByteOrder GetByteOrder() const = 0;
+
+ virtual uint32_t GetAddressByteSize() const = 0;
+
+ virtual void PopulateSymtab(lldb_private::ObjectFile *obj_file,
+ lldb_private::Symtab &symtab) = 0;
+
+ virtual void PopulateSectionList(lldb_private::ObjectFile *obj_file,
+ lldb_private::SectionList &section_list) = 0;
+
+ virtual bool GetArchitecture(lldb_private::ArchSpec &arch) = 0;
};
//----------------------------------------------------------------------
@@ -68,849 +57,764 @@ public:
/// Once an architecture is selected the object file information can be
/// extracted from this abstract class.
//----------------------------------------------------------------------
-class ObjectFile:
- public std::enable_shared_from_this<ObjectFile>,
- public PluginInterface,
- public ModuleChild
-{
-friend class lldb_private::Module;
+class ObjectFile : public std::enable_shared_from_this<ObjectFile>,
+ public PluginInterface,
+ public ModuleChild {
+ friend class lldb_private::Module;
public:
- typedef enum
- {
- eTypeInvalid = 0,
- eTypeCoreFile, /// A core file that has a checkpoint of a program's execution state
- eTypeExecutable, /// A normal executable
- eTypeDebugInfo, /// An object file that contains only debug information
- eTypeDynamicLinker, /// The platform's dynamic linker executable
- eTypeObjectFile, /// An intermediate object file
- eTypeSharedLibrary, /// A shared library that can be used during execution
- eTypeStubLibrary, /// A library that can be linked against but not used for execution
- eTypeJIT, /// JIT code that has symbols, sections and possibly debug info
- eTypeUnknown
- } Type;
-
- typedef enum
- {
- eStrataInvalid = 0,
- eStrataUnknown,
- eStrataUser,
- eStrataKernel,
- eStrataRawImage,
- eStrataJIT
- } Strata;
-
- //------------------------------------------------------------------
- /// Construct with a parent module, offset, and header data.
- ///
- /// Object files belong to modules and a valid module must be
- /// supplied upon construction. The at an offset within a file for
- /// objects that contain more than one architecture or object.
- //------------------------------------------------------------------
- ObjectFile (const lldb::ModuleSP &module_sp,
- const FileSpec *file_spec_ptr,
- lldb::offset_t file_offset,
- lldb::offset_t length,
- const lldb::DataBufferSP& data_sp,
- lldb::offset_t data_offset);
-
- ObjectFile (const lldb::ModuleSP &module_sp,
- const lldb::ProcessSP &process_sp,
- lldb::addr_t header_addr,
- lldb::DataBufferSP& data_sp);
-
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// The destructor is virtual since this class is designed to be
- /// inherited from by the plug-in instance.
- //------------------------------------------------------------------
- ~ObjectFile() override;
-
- //------------------------------------------------------------------
- /// Dump a description of this object to a Stream.
- ///
- /// Dump a description of the current contents of this object
- /// to the supplied stream \a s. The dumping should include the
- /// section list if it has been parsed, and the symbol table
- /// if it has been parsed.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- //------------------------------------------------------------------
- virtual void
- Dump (Stream *s) = 0;
-
- //------------------------------------------------------------------
- /// Find a ObjectFile plug-in that can parse \a file_spec.
- ///
- /// Scans all loaded plug-in interfaces that implement versions of
- /// the ObjectFile plug-in interface and returns the first
- /// instance that can parse the file.
- ///
- /// @param[in] module
- /// The parent module that owns this object file.
- ///
- /// @param[in] file_spec
- /// A file specification that indicates which file to use as the
- /// object file.
- ///
- /// @param[in] file_offset
- /// The offset into the file at which to start parsing the
- /// object. This is for files that contain multiple
- /// architectures or objects.
- ///
- /// @param[in] file_size
- /// The size of the current object file if it can be determined
- /// or if it is known. This can be zero.
- ///
- /// @see ObjectFile::ParseHeader()
- //------------------------------------------------------------------
- static lldb::ObjectFileSP
- FindPlugin (const lldb::ModuleSP &module_sp,
- const FileSpec* file_spec,
- lldb::offset_t file_offset,
- lldb::offset_t file_size,
- lldb::DataBufferSP &data_sp,
- lldb::offset_t &data_offset);
-
- //------------------------------------------------------------------
- /// Find a ObjectFile plug-in that can parse a file in memory.
- ///
- /// Scans all loaded plug-in interfaces that implement versions of
- /// the ObjectFile plug-in interface and returns the first
- /// instance that can parse the file.
- ///
- /// @param[in] module
- /// The parent module that owns this object file.
- ///
- /// @param[in] process_sp
- /// A shared pointer to the process whose memory space contains
- /// an object file. This will be stored as a std::weak_ptr.
- ///
- /// @param[in] header_addr
- /// The address of the header for the object file in memory.
- //------------------------------------------------------------------
- static lldb::ObjectFileSP
- FindPlugin (const lldb::ModuleSP &module_sp,
- const lldb::ProcessSP &process_sp,
- lldb::addr_t header_addr,
- lldb::DataBufferSP &file_data_sp);
-
-
- static size_t
- GetModuleSpecifications (const FileSpec &file,
- lldb::offset_t file_offset,
- lldb::offset_t file_size,
- ModuleSpecList &specs);
-
- static size_t
- GetModuleSpecifications (const lldb_private::FileSpec& file,
- lldb::DataBufferSP& data_sp,
- lldb::offset_t data_offset,
- lldb::offset_t file_offset,
- lldb::offset_t file_size,
- lldb_private::ModuleSpecList &specs);
- //------------------------------------------------------------------
- /// Split a path into a file path with object name.
- ///
- /// For paths like "/tmp/foo.a(bar.o)" we often need to split a path
- /// up into the actual path name and into the object name so we can
- /// make a valid object file from it.
- ///
- /// @param[in] path_with_object
- /// A path that might contain an archive path with a .o file
- /// specified in parens in the basename of the path.
- ///
- /// @param[out] archive_file
- /// If \b true is returned, \a file_spec will be filled in with
- /// the path to the archive.
- ///
- /// @param[out] archive_object
- /// If \b true is returned, \a object will be filled in with
- /// the name of the object inside the archive.
- ///
- /// @return
- /// \b true if the path matches the pattern of archive + object
- /// and \a archive_file and \a archive_object are modified,
- /// \b false otherwise and \a archive_file and \a archive_object
- /// are guaranteed to be remain unchanged.
- //------------------------------------------------------------------
- static bool
- SplitArchivePathWithObject (const char *path_with_object,
- lldb_private::FileSpec &archive_file,
- lldb_private::ConstString &archive_object,
- bool must_exist);
-
- //------------------------------------------------------------------
- /// Gets the address size in bytes for the current object file.
- ///
- /// @return
- /// The size of an address in bytes for the currently selected
- /// architecture (and object for archives). Returns zero if no
- /// architecture or object has been selected.
- //------------------------------------------------------------------
- virtual uint32_t
- GetAddressByteSize () const = 0;
-
- //------------------------------------------------------------------
- /// Get the address type given a file address in an object file.
- ///
- /// Many binary file formats know what kinds
- /// This is primarily for ARM binaries, though it can be applied to
- /// any executable file format that supports different opcode types
- /// within the same binary. ARM binaries support having both ARM and
- /// Thumb within the same executable container. We need to be able
- /// to get
- /// @return
- /// The size of an address in bytes for the currently selected
- /// architecture (and object for archives). Returns zero if no
- /// architecture or object has been selected.
- //------------------------------------------------------------------
- virtual lldb::AddressClass
- GetAddressClass (lldb::addr_t file_addr);
-
- //------------------------------------------------------------------
- /// Extract the dependent modules from an object file.
- ///
- /// If an object file has information about which other images it
- /// depends on (such as shared libraries), this function will
- /// provide the list. Since many executables or shared libraries
- /// may depend on the same files,
- /// FileSpecList::AppendIfUnique(const FileSpec &) should be
- /// used to make sure any files that are added are not already in
- /// the list.
- ///
- /// @param[out] file_list
- /// A list of file specification objects that gets dependent
- /// files appended to.
- ///
- /// @return
- /// The number of new files that were appended to \a file_list.
- ///
- /// @see FileSpecList::AppendIfUnique(const FileSpec &)
- //------------------------------------------------------------------
- virtual uint32_t
- GetDependentModules (FileSpecList& file_list) = 0;
-
- //------------------------------------------------------------------
- /// Tells whether this object file is capable of being the main executable
- /// for a process.
- ///
- /// @return
- /// \b true if it is, \b false otherwise.
- //------------------------------------------------------------------
- virtual bool
- IsExecutable () const = 0;
-
- //------------------------------------------------------------------
- /// Returns the offset into a file at which this object resides.
- ///
- /// Some files contain many object files, and this function allows
- /// access to an object's offset within the file.
- ///
- /// @return
- /// The offset in bytes into the file. Defaults to zero for
- /// simple object files that a represented by an entire file.
- //------------------------------------------------------------------
- virtual lldb::addr_t
- GetFileOffset () const
- { return m_file_offset; }
-
- virtual lldb::addr_t
- GetByteSize () const
- { return m_length; }
-
- //------------------------------------------------------------------
- /// Get accessor to the object file specification.
- ///
- /// @return
- /// The file specification object pointer if there is one, or
- /// NULL if this object is only from memory.
- //------------------------------------------------------------------
- virtual FileSpec&
- GetFileSpec() { return m_file; }
-
- //------------------------------------------------------------------
- /// Get const accessor to the object file specification.
- ///
- /// @return
- /// The const file specification object pointer if there is one,
- /// or NULL if this object is only from memory.
- //------------------------------------------------------------------
- virtual const FileSpec&
- GetFileSpec() const { return m_file; }
-
- //------------------------------------------------------------------
- /// Get the name of the cpu, vendor and OS for this object file.
- ///
- /// This value is a string that represents the target triple where
- /// the cpu type, the vendor and the OS are encoded into a string.
- ///
- /// @param[out] target_triple
- /// The string value of the target triple.
- ///
- /// @return
- /// \b True if the target triple was able to be computed, \b
- /// false otherwise.
- //------------------------------------------------------------------
- virtual bool
- GetArchitecture (ArchSpec &arch) = 0;
-
- //------------------------------------------------------------------
- /// Gets the section list for the currently selected architecture
- /// (and object for archives).
- ///
- /// Section list parsing can be deferred by ObjectFile instances
- /// until this accessor is called the first time.
- ///
- /// @return
- /// The list of sections contained in this object file.
- //------------------------------------------------------------------
- virtual SectionList *
- GetSectionList (bool update_module_section_list = true);
-
- virtual void
- CreateSections (SectionList &unified_section_list) = 0;
-
- //------------------------------------------------------------------
- /// Notify the ObjectFile that the file addresses in the Sections
- /// for this module have been changed.
- //------------------------------------------------------------------
- virtual void
- SectionFileAddressesChanged ()
- {
- }
-
- //------------------------------------------------------------------
- /// Gets the symbol table for the currently selected architecture
- /// (and object for archives).
- ///
- /// Symbol table parsing can be deferred by ObjectFile instances
- /// until this accessor is called the first time.
- ///
- /// @return
- /// The symbol table for this object file.
- //------------------------------------------------------------------
- virtual Symtab *
- GetSymtab () = 0;
-
- //------------------------------------------------------------------
- /// Appends a Symbol for the specified so_addr to the symbol table.
- ///
- /// If verify_unique is false, the symbol table is not searched
- /// to determine if a Symbol found at this address has already been
- /// added to the symbol table. When verify_unique is true, this
- /// method resolves the Symbol as the first match in the SymbolTable
- /// and appends a Symbol only if required/found.
- ///
- /// @return
- /// The resolved symbol or nullptr. Returns nullptr if a
- /// a Symbol could not be found for the specified so_addr.
- //------------------------------------------------------------------
- virtual Symbol *
- ResolveSymbolForAddress(const Address &so_addr, bool verify_unique)
- {
- // Typically overridden to lazily add stripped symbols recoverable from
- // the exception handling unwind information (i.e. without parsing
- // the entire eh_frame section.
- //
- // The availability of LC_FUNCTION_STARTS allows ObjectFileMachO
- // to efficiently add stripped symbols when the symbol table is
- // first constructed. Poorer cousins are PECoff and ELF.
- return nullptr;
- }
-
- //------------------------------------------------------------------
- /// Detect if this object file has been stripped of local symbols.
- //------------------------------------------------------------------
- /// Detect if this object file has been stripped of local symbols.
- ///
- /// @return
- /// Return \b true if the object file has been stripped of local
- /// symbols.
- //------------------------------------------------------------------
- virtual bool
- IsStripped () = 0;
-
- //------------------------------------------------------------------
- /// Frees the symbol table.
- ///
- /// This function should only be used when an object file is
- ///
- /// @param[in] flags
- /// eSymtabFromUnifiedSectionList: Whether to clear symbol table
- /// for unified module section list, or object file.
- ///
- /// @return
- /// The symbol table for this object file.
- //------------------------------------------------------------------
- virtual void
- ClearSymtab ();
-
- //------------------------------------------------------------------
- /// Gets the UUID for this object file.
- ///
- /// If the object file format contains a UUID, the value should be
- /// returned. Else ObjectFile instances should return the MD5
- /// checksum of all of the bytes for the object file (or memory for
- /// memory based object files).
- ///
- /// @return
- /// Returns \b true if a UUID was successfully extracted into
- /// \a uuid, \b false otherwise.
- //------------------------------------------------------------------
- virtual bool
- GetUUID (lldb_private::UUID* uuid) = 0;
-
- //------------------------------------------------------------------
- /// Gets the symbol file spec list for this object file.
- ///
- /// If the object file format contains a debug symbol file link,
- /// the values will be returned in the FileSpecList.
- ///
- /// @return
- /// Returns filespeclist.
- //------------------------------------------------------------------
- virtual lldb_private::FileSpecList
- GetDebugSymbolFilePaths()
- {
- return FileSpecList();
- }
-
- //------------------------------------------------------------------
- /// Gets the file spec list of libraries re-exported by this object file.
- ///
- /// If the object file format has the notion of one library re-exporting the symbols from another,
- /// the re-exported libraries will be returned in the FileSpecList.
- ///
- /// @return
- /// Returns filespeclist.
- //------------------------------------------------------------------
- virtual lldb_private::FileSpecList
- GetReExportedLibraries ()
- {
- return FileSpecList();
- }
-
- //------------------------------------------------------------------
- /// Sets the load address for an entire module, assuming a rigid
- /// slide of sections, if possible in the implementation.
- ///
- /// @return
- /// Returns true iff any section's load address changed.
- //------------------------------------------------------------------
- virtual bool
- SetLoadAddress(Target &target,
- lldb::addr_t value,
- bool value_is_offset)
- {
- return false;
+ typedef enum {
+ eTypeInvalid = 0,
+ eTypeCoreFile, /// A core file that has a checkpoint of a program's
+ /// execution state
+ eTypeExecutable, /// A normal executable
+ eTypeDebugInfo, /// An object file that contains only debug information
+ eTypeDynamicLinker, /// The platform's dynamic linker executable
+ eTypeObjectFile, /// An intermediate object file
+ eTypeSharedLibrary, /// A shared library that can be used during execution
+ eTypeStubLibrary, /// A library that can be linked against but not used for
+ /// execution
+ eTypeJIT, /// JIT code that has symbols, sections and possibly debug info
+ eTypeUnknown
+ } Type;
+
+ typedef enum {
+ eStrataInvalid = 0,
+ eStrataUnknown,
+ eStrataUser,
+ eStrataKernel,
+ eStrataRawImage,
+ eStrataJIT
+ } Strata;
+
+ //------------------------------------------------------------------
+ /// Construct with a parent module, offset, and header data.
+ ///
+ /// Object files belong to modules and a valid module must be
+ /// supplied upon construction. The at an offset within a file for
+ /// objects that contain more than one architecture or object.
+ //------------------------------------------------------------------
+ ObjectFile(const lldb::ModuleSP &module_sp, const FileSpec *file_spec_ptr,
+ lldb::offset_t file_offset, lldb::offset_t length,
+ const lldb::DataBufferSP &data_sp, lldb::offset_t data_offset);
+
+ ObjectFile(const lldb::ModuleSP &module_sp, const lldb::ProcessSP &process_sp,
+ lldb::addr_t header_addr, lldb::DataBufferSP &data_sp);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ ///
+ /// The destructor is virtual since this class is designed to be
+ /// inherited from by the plug-in instance.
+ //------------------------------------------------------------------
+ ~ObjectFile() override;
+
+ //------------------------------------------------------------------
+ /// Dump a description of this object to a Stream.
+ ///
+ /// Dump a description of the current contents of this object
+ /// to the supplied stream \a s. The dumping should include the
+ /// section list if it has been parsed, and the symbol table
+ /// if it has been parsed.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ //------------------------------------------------------------------
+ virtual void Dump(Stream *s) = 0;
+
+ //------------------------------------------------------------------
+ /// Find a ObjectFile plug-in that can parse \a file_spec.
+ ///
+ /// Scans all loaded plug-in interfaces that implement versions of
+ /// the ObjectFile plug-in interface and returns the first
+ /// instance that can parse the file.
+ ///
+ /// @param[in] module
+ /// The parent module that owns this object file.
+ ///
+ /// @param[in] file_spec
+ /// A file specification that indicates which file to use as the
+ /// object file.
+ ///
+ /// @param[in] file_offset
+ /// The offset into the file at which to start parsing the
+ /// object. This is for files that contain multiple
+ /// architectures or objects.
+ ///
+ /// @param[in] file_size
+ /// The size of the current object file if it can be determined
+ /// or if it is known. This can be zero.
+ ///
+ /// @see ObjectFile::ParseHeader()
+ //------------------------------------------------------------------
+ static lldb::ObjectFileSP
+ FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file_spec,
+ lldb::offset_t file_offset, lldb::offset_t file_size,
+ lldb::DataBufferSP &data_sp, lldb::offset_t &data_offset);
+
+ //------------------------------------------------------------------
+ /// Find a ObjectFile plug-in that can parse a file in memory.
+ ///
+ /// Scans all loaded plug-in interfaces that implement versions of
+ /// the ObjectFile plug-in interface and returns the first
+ /// instance that can parse the file.
+ ///
+ /// @param[in] module
+ /// The parent module that owns this object file.
+ ///
+ /// @param[in] process_sp
+ /// A shared pointer to the process whose memory space contains
+ /// an object file. This will be stored as a std::weak_ptr.
+ ///
+ /// @param[in] header_addr
+ /// The address of the header for the object file in memory.
+ //------------------------------------------------------------------
+ static lldb::ObjectFileSP FindPlugin(const lldb::ModuleSP &module_sp,
+ const lldb::ProcessSP &process_sp,
+ lldb::addr_t header_addr,
+ lldb::DataBufferSP &file_data_sp);
+
+ static size_t GetModuleSpecifications(const FileSpec &file,
+ lldb::offset_t file_offset,
+ lldb::offset_t file_size,
+ ModuleSpecList &specs);
+
+ static size_t GetModuleSpecifications(const lldb_private::FileSpec &file,
+ lldb::DataBufferSP &data_sp,
+ lldb::offset_t data_offset,
+ lldb::offset_t file_offset,
+ lldb::offset_t file_size,
+ lldb_private::ModuleSpecList &specs);
+ //------------------------------------------------------------------
+ /// Split a path into a file path with object name.
+ ///
+ /// For paths like "/tmp/foo.a(bar.o)" we often need to split a path
+ /// up into the actual path name and into the object name so we can
+ /// make a valid object file from it.
+ ///
+ /// @param[in] path_with_object
+ /// A path that might contain an archive path with a .o file
+ /// specified in parens in the basename of the path.
+ ///
+ /// @param[out] archive_file
+ /// If \b true is returned, \a file_spec will be filled in with
+ /// the path to the archive.
+ ///
+ /// @param[out] archive_object
+ /// If \b true is returned, \a object will be filled in with
+ /// the name of the object inside the archive.
+ ///
+ /// @return
+ /// \b true if the path matches the pattern of archive + object
+ /// and \a archive_file and \a archive_object are modified,
+ /// \b false otherwise and \a archive_file and \a archive_object
+ /// are guaranteed to be remain unchanged.
+ //------------------------------------------------------------------
+ static bool SplitArchivePathWithObject(
+ const char *path_with_object, lldb_private::FileSpec &archive_file,
+ lldb_private::ConstString &archive_object, bool must_exist);
+
+ //------------------------------------------------------------------
+ /// Gets the address size in bytes for the current object file.
+ ///
+ /// @return
+ /// The size of an address in bytes for the currently selected
+ /// architecture (and object for archives). Returns zero if no
+ /// architecture or object has been selected.
+ //------------------------------------------------------------------
+ virtual uint32_t GetAddressByteSize() const = 0;
+
+ //------------------------------------------------------------------
+ /// Get the address type given a file address in an object file.
+ ///
+ /// Many binary file formats know what kinds
+ /// This is primarily for ARM binaries, though it can be applied to
+ /// any executable file format that supports different opcode types
+ /// within the same binary. ARM binaries support having both ARM and
+ /// Thumb within the same executable container. We need to be able
+ /// to get
+ /// @return
+ /// The size of an address in bytes for the currently selected
+ /// architecture (and object for archives). Returns zero if no
+ /// architecture or object has been selected.
+ //------------------------------------------------------------------
+ virtual lldb::AddressClass GetAddressClass(lldb::addr_t file_addr);
+
+ //------------------------------------------------------------------
+ /// Extract the dependent modules from an object file.
+ ///
+ /// If an object file has information about which other images it
+ /// depends on (such as shared libraries), this function will
+ /// provide the list. Since many executables or shared libraries
+ /// may depend on the same files,
+ /// FileSpecList::AppendIfUnique(const FileSpec &) should be
+ /// used to make sure any files that are added are not already in
+ /// the list.
+ ///
+ /// @param[out] file_list
+ /// A list of file specification objects that gets dependent
+ /// files appended to.
+ ///
+ /// @return
+ /// The number of new files that were appended to \a file_list.
+ ///
+ /// @see FileSpecList::AppendIfUnique(const FileSpec &)
+ //------------------------------------------------------------------
+ virtual uint32_t GetDependentModules(FileSpecList &file_list) = 0;
+
+ //------------------------------------------------------------------
+ /// Tells whether this object file is capable of being the main executable
+ /// for a process.
+ ///
+ /// @return
+ /// \b true if it is, \b false otherwise.
+ //------------------------------------------------------------------
+ virtual bool IsExecutable() const = 0;
+
+ //------------------------------------------------------------------
+ /// Returns the offset into a file at which this object resides.
+ ///
+ /// Some files contain many object files, and this function allows
+ /// access to an object's offset within the file.
+ ///
+ /// @return
+ /// The offset in bytes into the file. Defaults to zero for
+ /// simple object files that a represented by an entire file.
+ //------------------------------------------------------------------
+ virtual lldb::addr_t GetFileOffset() const { return m_file_offset; }
+
+ virtual lldb::addr_t GetByteSize() const { return m_length; }
+
+ //------------------------------------------------------------------
+ /// Get accessor to the object file specification.
+ ///
+ /// @return
+ /// The file specification object pointer if there is one, or
+ /// NULL if this object is only from memory.
+ //------------------------------------------------------------------
+ virtual FileSpec &GetFileSpec() { return m_file; }
+
+ //------------------------------------------------------------------
+ /// Get const accessor to the object file specification.
+ ///
+ /// @return
+ /// The const file specification object pointer if there is one,
+ /// or NULL if this object is only from memory.
+ //------------------------------------------------------------------
+ virtual const FileSpec &GetFileSpec() const { return m_file; }
+
+ //------------------------------------------------------------------
+ /// Get the name of the cpu, vendor and OS for this object file.
+ ///
+ /// This value is a string that represents the target triple where
+ /// the cpu type, the vendor and the OS are encoded into a string.
+ ///
+ /// @param[out] target_triple
+ /// The string value of the target triple.
+ ///
+ /// @return
+ /// \b True if the target triple was able to be computed, \b
+ /// false otherwise.
+ //------------------------------------------------------------------
+ virtual bool GetArchitecture(ArchSpec &arch) = 0;
+
+ //------------------------------------------------------------------
+ /// Gets the section list for the currently selected architecture
+ /// (and object for archives).
+ ///
+ /// Section list parsing can be deferred by ObjectFile instances
+ /// until this accessor is called the first time.
+ ///
+ /// @return
+ /// The list of sections contained in this object file.
+ //------------------------------------------------------------------
+ virtual SectionList *GetSectionList(bool update_module_section_list = true);
+
+ virtual void CreateSections(SectionList &unified_section_list) = 0;
+
+ //------------------------------------------------------------------
+ /// Notify the ObjectFile that the file addresses in the Sections
+ /// for this module have been changed.
+ //------------------------------------------------------------------
+ virtual void SectionFileAddressesChanged() {}
+
+ //------------------------------------------------------------------
+ /// Gets the symbol table for the currently selected architecture
+ /// (and object for archives).
+ ///
+ /// Symbol table parsing can be deferred by ObjectFile instances
+ /// until this accessor is called the first time.
+ ///
+ /// @return
+ /// The symbol table for this object file.
+ //------------------------------------------------------------------
+ virtual Symtab *GetSymtab() = 0;
+
+ //------------------------------------------------------------------
+ /// Appends a Symbol for the specified so_addr to the symbol table.
+ ///
+ /// If verify_unique is false, the symbol table is not searched
+ /// to determine if a Symbol found at this address has already been
+ /// added to the symbol table. When verify_unique is true, this
+ /// method resolves the Symbol as the first match in the SymbolTable
+ /// and appends a Symbol only if required/found.
+ ///
+ /// @return
+ /// The resolved symbol or nullptr. Returns nullptr if a
+ /// a Symbol could not be found for the specified so_addr.
+ //------------------------------------------------------------------
+ virtual Symbol *ResolveSymbolForAddress(const Address &so_addr,
+ bool verify_unique) {
+ // Typically overridden to lazily add stripped symbols recoverable from
+ // the exception handling unwind information (i.e. without parsing
+ // the entire eh_frame section.
+ //
+ // The availability of LC_FUNCTION_STARTS allows ObjectFileMachO
+ // to efficiently add stripped symbols when the symbol table is
+ // first constructed. Poorer cousins are PECoff and ELF.
+ return nullptr;
+ }
+
+ //------------------------------------------------------------------
+ /// Detect if this object file has been stripped of local symbols.
+ //------------------------------------------------------------------
+ /// Detect if this object file has been stripped of local symbols.
+ ///
+ /// @return
+ /// Return \b true if the object file has been stripped of local
+ /// symbols.
+ //------------------------------------------------------------------
+ virtual bool IsStripped() = 0;
+
+ //------------------------------------------------------------------
+ /// Frees the symbol table.
+ ///
+ /// This function should only be used when an object file is
+ ///
+ /// @param[in] flags
+ /// eSymtabFromUnifiedSectionList: Whether to clear symbol table
+ /// for unified module section list, or object file.
+ ///
+ /// @return
+ /// The symbol table for this object file.
+ //------------------------------------------------------------------
+ virtual void ClearSymtab();
+
+ //------------------------------------------------------------------
+ /// Gets the UUID for this object file.
+ ///
+ /// If the object file format contains a UUID, the value should be
+ /// returned. Else ObjectFile instances should return the MD5
+ /// checksum of all of the bytes for the object file (or memory for
+ /// memory based object files).
+ ///
+ /// @return
+ /// Returns \b true if a UUID was successfully extracted into
+ /// \a uuid, \b false otherwise.
+ //------------------------------------------------------------------
+ virtual bool GetUUID(lldb_private::UUID *uuid) = 0;
+
+ //------------------------------------------------------------------
+ /// Gets the symbol file spec list for this object file.
+ ///
+ /// If the object file format contains a debug symbol file link,
+ /// the values will be returned in the FileSpecList.
+ ///
+ /// @return
+ /// Returns filespeclist.
+ //------------------------------------------------------------------
+ virtual lldb_private::FileSpecList GetDebugSymbolFilePaths() {
+ return FileSpecList();
+ }
+
+ //------------------------------------------------------------------
+ /// Gets the file spec list of libraries re-exported by this object file.
+ ///
+ /// If the object file format has the notion of one library re-exporting the
+ /// symbols from another,
+ /// the re-exported libraries will be returned in the FileSpecList.
+ ///
+ /// @return
+ /// Returns filespeclist.
+ //------------------------------------------------------------------
+ virtual lldb_private::FileSpecList GetReExportedLibraries() {
+ return FileSpecList();
+ }
+
+ //------------------------------------------------------------------
+ /// Sets the load address for an entire module, assuming a rigid
+ /// slide of sections, if possible in the implementation.
+ ///
+ /// @return
+ /// Returns true iff any section's load address changed.
+ //------------------------------------------------------------------
+ virtual bool SetLoadAddress(Target &target, lldb::addr_t value,
+ bool value_is_offset) {
+ return false;
+ }
+
+ //------------------------------------------------------------------
+ /// Gets whether endian swapping should occur when extracting data
+ /// from this object file.
+ ///
+ /// @return
+ /// Returns \b true if endian swapping is needed, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ virtual lldb::ByteOrder GetByteOrder() const = 0;
+
+ //------------------------------------------------------------------
+ /// Attempts to parse the object header.
+ ///
+ /// This function is used as a test to see if a given plug-in
+ /// instance can parse the header data already contained in
+ /// ObjectFile::m_data. If an object file parser does not
+ /// recognize that magic bytes in a header, false should be returned
+ /// and the next plug-in can attempt to parse an object file.
+ ///
+ /// @return
+ /// Returns \b true if the header was parsed successfully, \b
+ /// false otherwise.
+ //------------------------------------------------------------------
+ virtual bool ParseHeader() = 0;
+
+ //------------------------------------------------------------------
+ /// Returns a reference to the UnwindTable for this ObjectFile
+ ///
+ /// The UnwindTable contains FuncUnwinders objects for any function in
+ /// this ObjectFile. If a FuncUnwinders object hasn't been created yet
+ /// (i.e. the function has yet to be unwound in a stack walk), it
+ /// will be created when requested. Specifically, we do not create
+ /// FuncUnwinders objects for functions until they are needed.
+ ///
+ /// @return
+ /// Returns the unwind table for this object file.
+ //------------------------------------------------------------------
+ virtual lldb_private::UnwindTable &GetUnwindTable() { return m_unwind_table; }
+
+ //------------------------------------------------------------------
+ /// Returns if the function bounds for symbols in this symbol file
+ /// are likely accurate.
+ ///
+ /// The unwinder can emulate the instructions of functions to understand
+ /// prologue/epilogue code sequences, where registers are spilled on
+ /// the stack, etc. This feature relies on having the correct start
+ /// addresses of all functions. If the ObjectFile has a way to tell
+ /// that symbols have been stripped and there's no way to reconstruct
+ /// start addresses (e.g. LC_FUNCTION_STARTS on Mach-O, or eh_frame
+ /// unwind info), the ObjectFile should indicate that assembly emulation
+ /// should not be used for this module.
+ ///
+ /// It is uncommon for this to return false. An ObjectFile needs to
+ /// be sure that symbol start addresses are unavailable before false
+ /// is returned. If it is unclear, this should return true.
+ ///
+ /// @return
+ /// Returns true if assembly emulation should be used for this
+ /// module.
+ /// Only returns false if the ObjectFile is sure that symbol
+ /// addresses are insufficient for accurate assembly emulation.
+ //------------------------------------------------------------------
+ virtual bool AllowAssemblyEmulationUnwindPlans() { return true; }
+
+ //------------------------------------------------------------------
+ /// Similar to Process::GetImageInfoAddress().
+ ///
+ /// Some platforms embed auxiliary structures useful to debuggers in the
+ /// address space of the inferior process. This method returns the address
+ /// of such a structure if the information can be resolved via entries in
+ /// the object file. ELF, for example, provides a means to hook into the
+ /// runtime linker so that a debugger may monitor the loading and unloading
+ /// of shared libraries.
+ ///
+ /// @return
+ /// The address of any auxiliary tables, or an invalid address if this
+ /// object file format does not support or contain such information.
+ virtual lldb_private::Address GetImageInfoAddress(Target *target) {
+ return Address();
+ }
+
+ //------------------------------------------------------------------
+ /// Returns the address of the Entry Point in this object file - if
+ /// the object file doesn't have an entry point (because it is not an
+ /// executable file) then an invalid address is returned.
+ ///
+ /// @return
+ /// Returns the entry address for this module.
+ //------------------------------------------------------------------
+ virtual lldb_private::Address GetEntryPointAddress() { return Address(); }
+
+ //------------------------------------------------------------------
+ /// Returns the address that represents the header of this object
+ /// file.
+ ///
+ /// The header address is defined as where the header for the object
+ /// file is that describes the content of the file. If the header
+ /// doesn't appear in a section that is defined in the object file,
+ /// an address with no section is returned that has the file offset
+ /// set in the m_file_offset member of the lldb_private::Address object.
+ ///
+ /// @return
+ /// Returns the entry address for this module.
+ //------------------------------------------------------------------
+ virtual lldb_private::Address GetHeaderAddress() {
+ return Address(m_memory_addr);
+ }
+
+ virtual uint32_t GetNumThreadContexts() { return 0; }
+
+ virtual lldb::RegisterContextSP
+ GetThreadContextAtIndex(uint32_t idx, lldb_private::Thread &thread) {
+ return lldb::RegisterContextSP();
+ }
+
+ //------------------------------------------------------------------
+ /// The object file should be able to calculate its type by looking
+ /// at its file header and possibly the sections or other data in
+ /// the object file. The file type is used in the debugger to help
+ /// select the correct plug-ins for the job at hand, so this is
+ /// important to get right. If any eTypeXXX definitions do not match
+ /// up with the type of file you are loading, please feel free to
+ /// add a new enumeration value.
+ ///
+ /// @return
+ /// The calculated file type for the current object file.
+ //------------------------------------------------------------------
+ virtual Type CalculateType() = 0;
+
+ //------------------------------------------------------------------
+ /// In cases where the type can't be calculated (elf files), this
+ /// routine allows someone to explicitly set it. As an example,
+ /// SymbolVendorELF uses this routine to set eTypeDebugInfo when
+ /// loading debug link files.
+ virtual void SetType(Type type) { m_type = type; }
+
+ //------------------------------------------------------------------
+ /// The object file should be able to calculate the strata of the
+ /// object file.
+ ///
+ /// Many object files for platforms might be for either user space
+ /// debugging or for kernel debugging. If your object file subclass
+ /// can figure this out, it will help with debugger plug-in selection
+ /// when it comes time to debug.
+ ///
+ /// @return
+ /// The calculated object file strata for the current object
+ /// file.
+ //------------------------------------------------------------------
+ virtual Strata CalculateStrata() = 0;
+
+ //------------------------------------------------------------------
+ /// Get the object file version numbers.
+ ///
+ /// Many object files have a set of version numbers that describe
+ /// the version of the executable or shared library. Typically there
+ /// are major, minor and build, but there may be more. This function
+ /// will extract the versions from object files if they are available.
+ ///
+ /// If \a versions is NULL, or if \a num_versions is 0, the return
+ /// value will indicate how many version numbers are available in
+ /// this object file. Then a subsequent call can be made to this
+ /// function with a value of \a versions and \a num_versions that
+ /// has enough storage to store some or all version numbers.
+ ///
+ /// @param[out] versions
+ /// A pointer to an array of uint32_t types that is \a num_versions
+ /// long. If this value is NULL, the return value will indicate
+ /// how many version numbers are required for a subsequent call
+ /// to this function so that all versions can be retrieved. If
+ /// the value is non-NULL, then at most \a num_versions of the
+ /// existing versions numbers will be filled into \a versions.
+ /// If there is no version information available, \a versions
+ /// will be filled with \a num_versions UINT32_MAX values
+ /// and zero will be returned.
+ ///
+ /// @param[in] num_versions
+ /// The maximum number of entries to fill into \a versions. If
+ /// this value is zero, then the return value will indicate
+ /// how many version numbers there are in total so another call
+ /// to this function can be make with adequate storage in
+ /// \a versions to get all of the version numbers. If \a
+ /// num_versions is less than the actual number of version
+ /// numbers in this object file, only \a num_versions will be
+ /// filled into \a versions (if \a versions is non-NULL).
+ ///
+ /// @return
+ /// This function always returns the number of version numbers
+ /// that this object file has regardless of the number of
+ /// version numbers that were copied into \a versions.
+ //------------------------------------------------------------------
+ virtual uint32_t GetVersion(uint32_t *versions, uint32_t num_versions) {
+ if (versions && num_versions) {
+ for (uint32_t i = 0; i < num_versions; ++i)
+ versions[i] = UINT32_MAX;
}
-
- //------------------------------------------------------------------
- /// Gets whether endian swapping should occur when extracting data
- /// from this object file.
- ///
- /// @return
- /// Returns \b true if endian swapping is needed, \b false
- /// otherwise.
- //------------------------------------------------------------------
- virtual lldb::ByteOrder
- GetByteOrder () const = 0;
-
- //------------------------------------------------------------------
- /// Attempts to parse the object header.
- ///
- /// This function is used as a test to see if a given plug-in
- /// instance can parse the header data already contained in
- /// ObjectFile::m_data. If an object file parser does not
- /// recognize that magic bytes in a header, false should be returned
- /// and the next plug-in can attempt to parse an object file.
- ///
- /// @return
- /// Returns \b true if the header was parsed successfully, \b
- /// false otherwise.
- //------------------------------------------------------------------
- virtual bool
- ParseHeader () = 0;
-
- //------------------------------------------------------------------
- /// Returns a reference to the UnwindTable for this ObjectFile
- ///
- /// The UnwindTable contains FuncUnwinders objects for any function in
- /// this ObjectFile. If a FuncUnwinders object hasn't been created yet
- /// (i.e. the function has yet to be unwound in a stack walk), it
- /// will be created when requested. Specifically, we do not create
- /// FuncUnwinders objects for functions until they are needed.
- ///
- /// @return
- /// Returns the unwind table for this object file.
- //------------------------------------------------------------------
- virtual lldb_private::UnwindTable&
- GetUnwindTable () { return m_unwind_table; }
-
- //------------------------------------------------------------------
- /// Returns if the function bounds for symbols in this symbol file
- /// are likely accurate.
- ///
- /// The unwinder can emulate the instructions of functions to understand
- /// prologue/epilogue code sequences, where registers are spilled on
- /// the stack, etc. This feature relies on having the correct start
- /// addresses of all functions. If the ObjectFile has a way to tell
- /// that symbols have been stripped and there's no way to reconstruct
- /// start addresses (e.g. LC_FUNCTION_STARTS on Mach-O, or eh_frame
- /// unwind info), the ObjectFile should indicate that assembly emulation
- /// should not be used for this module.
- ///
- /// It is uncommon for this to return false. An ObjectFile needs to
- /// be sure that symbol start addresses are unavailable before false
- /// is returned. If it is unclear, this should return true.
- ///
- /// @return
- /// Returns true if assembly emulation should be used for this
- /// module.
- /// Only returns false if the ObjectFile is sure that symbol
- /// addresses are insufficient for accurate assembly emulation.
- //------------------------------------------------------------------
- virtual bool
- AllowAssemblyEmulationUnwindPlans ()
- {
- return true;
- }
-
- //------------------------------------------------------------------
- /// Similar to Process::GetImageInfoAddress().
- ///
- /// Some platforms embed auxiliary structures useful to debuggers in the
- /// address space of the inferior process. This method returns the address
- /// of such a structure if the information can be resolved via entries in
- /// the object file. ELF, for example, provides a means to hook into the
- /// runtime linker so that a debugger may monitor the loading and unloading
- /// of shared libraries.
- ///
- /// @return
- /// The address of any auxiliary tables, or an invalid address if this
- /// object file format does not support or contain such information.
- virtual lldb_private::Address
- GetImageInfoAddress (Target *target) { return Address(); }
-
- //------------------------------------------------------------------
- /// Returns the address of the Entry Point in this object file - if
- /// the object file doesn't have an entry point (because it is not an
- /// executable file) then an invalid address is returned.
- ///
- /// @return
- /// Returns the entry address for this module.
- //------------------------------------------------------------------
- virtual lldb_private::Address
- GetEntryPointAddress () { return Address();}
-
- //------------------------------------------------------------------
- /// Returns the address that represents the header of this object
- /// file.
- ///
- /// The header address is defined as where the header for the object
- /// file is that describes the content of the file. If the header
- /// doesn't appear in a section that is defined in the object file,
- /// an address with no section is returned that has the file offset
- /// set in the m_file_offset member of the lldb_private::Address object.
- ///
- /// @return
- /// Returns the entry address for this module.
- //------------------------------------------------------------------
- virtual lldb_private::Address
- GetHeaderAddress () { return Address(m_memory_addr);}
-
- virtual uint32_t
- GetNumThreadContexts ()
- {
- return 0;
- }
-
- virtual lldb::RegisterContextSP
- GetThreadContextAtIndex (uint32_t idx, lldb_private::Thread &thread)
- {
- return lldb::RegisterContextSP();
- }
-
- //------------------------------------------------------------------
- /// The object file should be able to calculate its type by looking
- /// at its file header and possibly the sections or other data in
- /// the object file. The file type is used in the debugger to help
- /// select the correct plug-ins for the job at hand, so this is
- /// important to get right. If any eTypeXXX definitions do not match
- /// up with the type of file you are loading, please feel free to
- /// add a new enumeration value.
- ///
- /// @return
- /// The calculated file type for the current object file.
- //------------------------------------------------------------------
- virtual Type
- CalculateType() = 0;
-
- //------------------------------------------------------------------
- /// In cases where the type can't be calculated (elf files), this
- /// routine allows someone to explicitly set it. As an example,
- /// SymbolVendorELF uses this routine to set eTypeDebugInfo when
- /// loading debug link files.
- virtual void
- SetType (Type type)
- {
- m_type = type;
- }
-
- //------------------------------------------------------------------
- /// The object file should be able to calculate the strata of the
- /// object file.
- ///
- /// Many object files for platforms might be for either user space
- /// debugging or for kernel debugging. If your object file subclass
- /// can figure this out, it will help with debugger plug-in selection
- /// when it comes time to debug.
- ///
- /// @return
- /// The calculated object file strata for the current object
- /// file.
- //------------------------------------------------------------------
- virtual Strata
- CalculateStrata() = 0;
-
- //------------------------------------------------------------------
- /// Get the object file version numbers.
- ///
- /// Many object files have a set of version numbers that describe
- /// the version of the executable or shared library. Typically there
- /// are major, minor and build, but there may be more. This function
- /// will extract the versions from object files if they are available.
- ///
- /// If \a versions is NULL, or if \a num_versions is 0, the return
- /// value will indicate how many version numbers are available in
- /// this object file. Then a subsequent call can be made to this
- /// function with a value of \a versions and \a num_versions that
- /// has enough storage to store some or all version numbers.
- ///
- /// @param[out] versions
- /// A pointer to an array of uint32_t types that is \a num_versions
- /// long. If this value is NULL, the return value will indicate
- /// how many version numbers are required for a subsequent call
- /// to this function so that all versions can be retrieved. If
- /// the value is non-NULL, then at most \a num_versions of the
- /// existing versions numbers will be filled into \a versions.
- /// If there is no version information available, \a versions
- /// will be filled with \a num_versions UINT32_MAX values
- /// and zero will be returned.
- ///
- /// @param[in] num_versions
- /// The maximum number of entries to fill into \a versions. If
- /// this value is zero, then the return value will indicate
- /// how many version numbers there are in total so another call
- /// to this function can be make with adequate storage in
- /// \a versions to get all of the version numbers. If \a
- /// num_versions is less than the actual number of version
- /// numbers in this object file, only \a num_versions will be
- /// filled into \a versions (if \a versions is non-NULL).
- ///
- /// @return
- /// This function always returns the number of version numbers
- /// that this object file has regardless of the number of
- /// version numbers that were copied into \a versions.
- //------------------------------------------------------------------
- virtual uint32_t
- GetVersion (uint32_t *versions, uint32_t num_versions)
- {
- if (versions && num_versions)
- {
- for (uint32_t i=0; i<num_versions; ++i)
- versions[i] = UINT32_MAX;
- }
- return 0;
- }
-
- //------------------------------------------------------------------
- /// Get the minimum OS version this object file can run on.
- ///
- /// Some object files have information that specifies the minimum OS
- /// version that they can be used on.
- ///
- /// If \a versions is NULL, or if \a num_versions is 0, the return
- /// value will indicate how many version numbers are available in
- /// this object file. Then a subsequent call can be made to this
- /// function with a value of \a versions and \a num_versions that
- /// has enough storage to store some or all version numbers.
- ///
- /// @param[out] versions
- /// A pointer to an array of uint32_t types that is \a num_versions
- /// long. If this value is NULL, the return value will indicate
- /// how many version numbers are required for a subsequent call
- /// to this function so that all versions can be retrieved. If
- /// the value is non-NULL, then at most \a num_versions of the
- /// existing versions numbers will be filled into \a versions.
- /// If there is no version information available, \a versions
- /// will be filled with \a num_versions UINT32_MAX values
- /// and zero will be returned.
- ///
- /// @param[in] num_versions
- /// The maximum number of entries to fill into \a versions. If
- /// this value is zero, then the return value will indicate
- /// how many version numbers there are in total so another call
- /// to this function can be make with adequate storage in
- /// \a versions to get all of the version numbers. If \a
- /// num_versions is less than the actual number of version
- /// numbers in this object file, only \a num_versions will be
- /// filled into \a versions (if \a versions is non-NULL).
- ///
- /// @return
- /// This function always returns the number of version numbers
- /// that this object file has regardless of the number of
- /// version numbers that were copied into \a versions.
- //------------------------------------------------------------------
- virtual uint32_t
- GetMinimumOSVersion (uint32_t *versions, uint32_t num_versions)
- {
- if (versions && num_versions)
- {
- for (uint32_t i=0; i<num_versions; ++i)
- versions[i] = UINT32_MAX;
- }
- return 0;
+ return 0;
+ }
+
+ //------------------------------------------------------------------
+ /// Get the minimum OS version this object file can run on.
+ ///
+ /// Some object files have information that specifies the minimum OS
+ /// version that they can be used on.
+ ///
+ /// If \a versions is NULL, or if \a num_versions is 0, the return
+ /// value will indicate how many version numbers are available in
+ /// this object file. Then a subsequent call can be made to this
+ /// function with a value of \a versions and \a num_versions that
+ /// has enough storage to store some or all version numbers.
+ ///
+ /// @param[out] versions
+ /// A pointer to an array of uint32_t types that is \a num_versions
+ /// long. If this value is NULL, the return value will indicate
+ /// how many version numbers are required for a subsequent call
+ /// to this function so that all versions can be retrieved. If
+ /// the value is non-NULL, then at most \a num_versions of the
+ /// existing versions numbers will be filled into \a versions.
+ /// If there is no version information available, \a versions
+ /// will be filled with \a num_versions UINT32_MAX values
+ /// and zero will be returned.
+ ///
+ /// @param[in] num_versions
+ /// The maximum number of entries to fill into \a versions. If
+ /// this value is zero, then the return value will indicate
+ /// how many version numbers there are in total so another call
+ /// to this function can be make with adequate storage in
+ /// \a versions to get all of the version numbers. If \a
+ /// num_versions is less than the actual number of version
+ /// numbers in this object file, only \a num_versions will be
+ /// filled into \a versions (if \a versions is non-NULL).
+ ///
+ /// @return
+ /// This function always returns the number of version numbers
+ /// that this object file has regardless of the number of
+ /// version numbers that were copied into \a versions.
+ //------------------------------------------------------------------
+ virtual uint32_t GetMinimumOSVersion(uint32_t *versions,
+ uint32_t num_versions) {
+ if (versions && num_versions) {
+ for (uint32_t i = 0; i < num_versions; ++i)
+ versions[i] = UINT32_MAX;
}
-
- //------------------------------------------------------------------
- /// Get the SDK OS version this object file was built with.
- ///
- /// The versions arguments and returns values are the same as the
- /// GetMinimumOSVersion()
- //------------------------------------------------------------------
- virtual uint32_t
- GetSDKVersion (uint32_t *versions, uint32_t num_versions)
- {
- if (versions && num_versions)
- {
- for (uint32_t i=0; i<num_versions; ++i)
- versions[i] = UINT32_MAX;
- }
- return 0;
- }
-
- //------------------------------------------------------------------
- /// Return true if this file is a dynamic link editor (dyld)
- ///
- /// Often times dyld has symbols that mirror symbols in libc and
- /// other shared libraries (like "malloc" and "free") and the user
- /// does _not_ want to stop in these shared libraries by default.
- /// We can ask the ObjectFile if it is such a file and should be
- /// avoided for things like settings breakpoints and doing function
- /// lookups for expressions.
- //------------------------------------------------------------------
- virtual bool
- GetIsDynamicLinkEditor()
- {
- return false;
- }
-
- //------------------------------------------------------------------
- // Member Functions
- //------------------------------------------------------------------
- Type
- GetType ()
- {
- if (m_type == eTypeInvalid)
- m_type = CalculateType();
- return m_type;
+ return 0;
+ }
+
+ //------------------------------------------------------------------
+ /// Get the SDK OS version this object file was built with.
+ ///
+ /// The versions arguments and returns values are the same as the
+ /// GetMinimumOSVersion()
+ //------------------------------------------------------------------
+ virtual uint32_t GetSDKVersion(uint32_t *versions, uint32_t num_versions) {
+ if (versions && num_versions) {
+ for (uint32_t i = 0; i < num_versions; ++i)
+ versions[i] = UINT32_MAX;
}
-
- Strata
- GetStrata ()
- {
- if (m_strata == eStrataInvalid)
- m_strata = CalculateStrata();
- return m_strata;
- }
-
- // When an object file is in memory, subclasses should try and lock
- // the process weak pointer. If the process weak pointer produces a
- // valid ProcessSP, then subclasses can call this function to read
- // memory.
- static lldb::DataBufferSP
- ReadMemory (const lldb::ProcessSP &process_sp,
- lldb::addr_t addr,
- size_t byte_size);
-
- size_t
- GetData (lldb::offset_t offset, size_t length, DataExtractor &data) const;
-
- size_t
- CopyData (lldb::offset_t offset, size_t length, void *dst) const;
-
- virtual size_t
- ReadSectionData (const Section *section,
- lldb::offset_t section_offset,
- void *dst,
- size_t dst_len) const;
-
- virtual size_t
- ReadSectionData (const Section *section,
- DataExtractor& section_data) const;
-
- size_t
- MemoryMapSectionData (const Section *section,
- DataExtractor& section_data) const;
-
- bool
- IsInMemory () const
- {
- return m_memory_addr != LLDB_INVALID_ADDRESS;
- }
-
- // Strip linker annotations (such as @@VERSION) from symbol names.
- virtual std::string
- StripLinkerSymbolAnnotations(llvm::StringRef symbol_name) const
- {
- return symbol_name.str();
- }
-
- static lldb::SymbolType
- GetSymbolTypeFromName (llvm::StringRef name,
- lldb::SymbolType symbol_type_hint = lldb::eSymbolTypeUndefined);
+ return 0;
+ }
+
+ //------------------------------------------------------------------
+ /// Return true if this file is a dynamic link editor (dyld)
+ ///
+ /// Often times dyld has symbols that mirror symbols in libc and
+ /// other shared libraries (like "malloc" and "free") and the user
+ /// does _not_ want to stop in these shared libraries by default.
+ /// We can ask the ObjectFile if it is such a file and should be
+ /// avoided for things like settings breakpoints and doing function
+ /// lookups for expressions.
+ //------------------------------------------------------------------
+ virtual bool GetIsDynamicLinkEditor() { return false; }
+
+ //------------------------------------------------------------------
+ // Member Functions
+ //------------------------------------------------------------------
+ Type GetType() {
+ if (m_type == eTypeInvalid)
+ m_type = CalculateType();
+ return m_type;
+ }
+
+ Strata GetStrata() {
+ if (m_strata == eStrataInvalid)
+ m_strata = CalculateStrata();
+ return m_strata;
+ }
+
+ // When an object file is in memory, subclasses should try and lock
+ // the process weak pointer. If the process weak pointer produces a
+ // valid ProcessSP, then subclasses can call this function to read
+ // memory.
+ static lldb::DataBufferSP ReadMemory(const lldb::ProcessSP &process_sp,
+ lldb::addr_t addr, size_t byte_size);
+
+ size_t GetData(lldb::offset_t offset, size_t length,
+ DataExtractor &data) const;
+
+ size_t CopyData(lldb::offset_t offset, size_t length, void *dst) const;
+
+ virtual size_t ReadSectionData(const Section *section,
+ lldb::offset_t section_offset, void *dst,
+ size_t dst_len) const;
+
+ virtual size_t ReadSectionData(const Section *section,
+ DataExtractor &section_data) const;
+
+ size_t MemoryMapSectionData(const Section *section,
+ DataExtractor &section_data) const;
+
+ bool IsInMemory() const { return m_memory_addr != LLDB_INVALID_ADDRESS; }
+
+ // Strip linker annotations (such as @@VERSION) from symbol names.
+ virtual std::string
+ StripLinkerSymbolAnnotations(llvm::StringRef symbol_name) const {
+ return symbol_name.str();
+ }
+
+ static lldb::SymbolType GetSymbolTypeFromName(
+ llvm::StringRef name,
+ lldb::SymbolType symbol_type_hint = lldb::eSymbolTypeUndefined);
protected:
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- FileSpec m_file;
- Type m_type;
- Strata m_strata;
- lldb::addr_t m_file_offset; ///< The offset in bytes into the file, or the address in memory
- lldb::addr_t m_length; ///< The length of this object file if it is known (can be zero if length is unknown or can't be determined).
- DataExtractor m_data; ///< The data for this object file so things can be parsed lazily.
- lldb_private::UnwindTable m_unwind_table; /// < Table of FuncUnwinders objects created for this ObjectFile's functions
- lldb::ProcessWP m_process_wp;
- const lldb::addr_t m_memory_addr;
- std::unique_ptr<lldb_private::SectionList> m_sections_ap;
- std::unique_ptr<lldb_private::Symtab> m_symtab_ap;
- uint32_t m_synthetic_symbol_idx;
-
- //------------------------------------------------------------------
- /// Sets the architecture for a module. At present the architecture
- /// can only be set if it is invalid. It is not allowed to switch from
- /// one concrete architecture to another.
- ///
- /// @param[in] new_arch
- /// The architecture this module will be set to.
- ///
- /// @return
- /// Returns \b true if the architecture was changed, \b
- /// false otherwise.
- //------------------------------------------------------------------
- bool
- SetModulesArchitecture (const ArchSpec &new_arch);
-
- ConstString
- GetNextSyntheticSymbolName();
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ FileSpec m_file;
+ Type m_type;
+ Strata m_strata;
+ lldb::addr_t m_file_offset; ///< The offset in bytes into the file, or the
+ ///address in memory
+ lldb::addr_t m_length; ///< The length of this object file if it is known (can
+ ///be zero if length is unknown or can't be
+ ///determined).
+ DataExtractor
+ m_data; ///< The data for this object file so things can be parsed lazily.
+ lldb_private::UnwindTable m_unwind_table; /// < Table of FuncUnwinders objects
+ /// created for this ObjectFile's
+ /// functions
+ lldb::ProcessWP m_process_wp;
+ const lldb::addr_t m_memory_addr;
+ std::unique_ptr<lldb_private::SectionList> m_sections_ap;
+ std::unique_ptr<lldb_private::Symtab> m_symtab_ap;
+ uint32_t m_synthetic_symbol_idx;
+
+ //------------------------------------------------------------------
+ /// Sets the architecture for a module. At present the architecture
+ /// can only be set if it is invalid. It is not allowed to switch from
+ /// one concrete architecture to another.
+ ///
+ /// @param[in] new_arch
+ /// The architecture this module will be set to.
+ ///
+ /// @return
+ /// Returns \b true if the architecture was changed, \b
+ /// false otherwise.
+ //------------------------------------------------------------------
+ bool SetModulesArchitecture(const ArchSpec &new_arch);
+
+ ConstString GetNextSyntheticSymbolName();
private:
- DISALLOW_COPY_AND_ASSIGN (ObjectFile);
+ DISALLOW_COPY_AND_ASSIGN(ObjectFile);
};
} // namespace lldb_private
diff --git a/include/lldb/Symbol/Symbol.h b/include/lldb/Symbol/Symbol.h
index 43f29f368d92..3f12b9a99b04 100644
--- a/include/lldb/Symbol/Symbol.h
+++ b/include/lldb/Symbol/Symbol.h
@@ -10,407 +10,272 @@
#ifndef liblldb_Symbol_h_
#define liblldb_Symbol_h_
-#include "lldb/lldb-private.h"
#include "lldb/Core/AddressRange.h"
#include "lldb/Core/Mangled.h"
#include "lldb/Core/UserID.h"
#include "lldb/Symbol/SymbolContextScope.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class Symbol :
- public SymbolContextScope
-{
+class Symbol : public SymbolContextScope {
public:
- // ObjectFile readers can classify their symbol table entries and searches can be made
- // on specific types where the symbol values will have drastically different meanings
- // and sorting requirements.
- Symbol();
-
- Symbol (uint32_t symID,
- const char *name,
- bool name_is_mangled,
- lldb::SymbolType type,
- bool external,
- bool is_debug,
- bool is_trampoline,
- bool is_artificial,
- const lldb::SectionSP &section_sp,
- lldb::addr_t value,
- lldb::addr_t size,
- bool size_is_valid,
- bool contains_linker_annotations,
- uint32_t flags);
-
- Symbol (uint32_t symID,
- const Mangled &mangled,
- lldb::SymbolType type,
- bool external,
- bool is_debug,
- bool is_trampoline,
- bool is_artificial,
- const AddressRange &range,
- bool size_is_valid,
- bool contains_linker_annotations,
- uint32_t flags);
-
- Symbol (const Symbol& rhs);
-
- const Symbol&
- operator= (const Symbol& rhs);
-
- void
- Clear();
-
- bool
- Compare (const ConstString& name, lldb::SymbolType type) const;
-
- void
- Dump (Stream *s, Target *target, uint32_t index) const;
-
- bool
- ValueIsAddress() const;
-
- //------------------------------------------------------------------
- // The GetAddressRef() accessor functions should only be called if
- // you previously call ValueIsAddress() otherwise you might get an
- // reference to an Address object that contains an constant integer
- // value in m_addr_range.m_base_addr.m_offset which could be
- // incorrectly used to represent an absolute address since it has
- // no section.
- //------------------------------------------------------------------
- Address &
- GetAddressRef()
- {
- return m_addr_range.GetBaseAddress();
+ // ObjectFile readers can classify their symbol table entries and searches can
+ // be made
+ // on specific types where the symbol values will have drastically different
+ // meanings
+ // and sorting requirements.
+ Symbol();
+
+ Symbol(uint32_t symID, const char *name, bool name_is_mangled,
+ lldb::SymbolType type, bool external, bool is_debug,
+ bool is_trampoline, bool is_artificial,
+ const lldb::SectionSP &section_sp, lldb::addr_t value,
+ lldb::addr_t size, bool size_is_valid,
+ bool contains_linker_annotations, uint32_t flags);
+
+ Symbol(uint32_t symID, const Mangled &mangled, lldb::SymbolType type,
+ bool external, bool is_debug, bool is_trampoline, bool is_artificial,
+ const AddressRange &range, bool size_is_valid,
+ bool contains_linker_annotations, uint32_t flags);
+
+ Symbol(const Symbol &rhs);
+
+ const Symbol &operator=(const Symbol &rhs);
+
+ void Clear();
+
+ bool Compare(const ConstString &name, lldb::SymbolType type) const;
+
+ void Dump(Stream *s, Target *target, uint32_t index) const;
+
+ bool ValueIsAddress() const;
+
+ //------------------------------------------------------------------
+ // The GetAddressRef() accessor functions should only be called if
+ // you previously call ValueIsAddress() otherwise you might get an
+ // reference to an Address object that contains an constant integer
+ // value in m_addr_range.m_base_addr.m_offset which could be
+ // incorrectly used to represent an absolute address since it has
+ // no section.
+ //------------------------------------------------------------------
+ Address &GetAddressRef() { return m_addr_range.GetBaseAddress(); }
+
+ const Address &GetAddressRef() const { return m_addr_range.GetBaseAddress(); }
+
+ //------------------------------------------------------------------
+ // Makes sure the symbol's value is an address and returns the file
+ // address. Returns LLDB_INVALID_ADDRESS if the symbol's value isn't
+ // an address.
+ //------------------------------------------------------------------
+ lldb::addr_t GetFileAddress() const;
+
+ //------------------------------------------------------------------
+ // Makes sure the symbol's value is an address and gets the load
+ // address using \a target if it is. Returns LLDB_INVALID_ADDRESS
+ // if the symbol's value isn't an address or if the section isn't
+ // loaded in \a target.
+ //------------------------------------------------------------------
+ lldb::addr_t GetLoadAddress(Target *target) const;
+
+ //------------------------------------------------------------------
+ // Access the address value. Do NOT hand out the AddressRange as an
+ // object as the byte size of the address range may not be filled in
+ // and it should be accessed via GetByteSize().
+ //------------------------------------------------------------------
+ Address GetAddress() const {
+ // Make sure the our value is an address before we hand a copy out.
+ // We use the Address inside m_addr_range to contain the value for
+ // symbols that are not address based symbols so we are using it
+ // for more than just addresses. For example undefined symbols on
+ // MacOSX have a nlist.n_value of 0 (zero) and this will get placed
+ // into m_addr_range.m_base_addr.m_offset and it will have no section.
+ // So in the GetAddress() accessor, we need to hand out an invalid
+ // address if the symbol's value isn't an address.
+ if (ValueIsAddress())
+ return m_addr_range.GetBaseAddress();
+ else
+ return Address();
+ }
+
+ // When a symbol's value isn't an address, we need to access the raw
+ // value. This function will ensure this symbol's value isn't an address
+ // and return the integer value if this checks out, otherwise it will
+ // return "fail_value" if the symbol is an address value.
+ uint64_t GetIntegerValue(uint64_t fail_value = 0) const {
+ if (ValueIsAddress()) {
+ // This symbol's value is an address. Use Symbol::GetAddress() to get the
+ // address.
+ return fail_value;
+ } else {
+ // The value is stored in the base address' offset
+ return m_addr_range.GetBaseAddress().GetOffset();
}
+ }
- const Address &
- GetAddressRef() const
- {
- return m_addr_range.GetBaseAddress();
- }
+ lldb::addr_t ResolveCallableAddress(Target &target) const;
- //------------------------------------------------------------------
- // Makes sure the symbol's value is an address and returns the file
- // address. Returns LLDB_INVALID_ADDRESS if the symbol's value isn't
- // an address.
- //------------------------------------------------------------------
- lldb::addr_t
- GetFileAddress () const;
-
- //------------------------------------------------------------------
- // Makes sure the symbol's value is an address and gets the load
- // address using \a target if it is. Returns LLDB_INVALID_ADDRESS
- // if the symbol's value isn't an address or if the section isn't
- // loaded in \a target.
- //------------------------------------------------------------------
- lldb::addr_t
- GetLoadAddress (Target *target) const;
-
- //------------------------------------------------------------------
- // Access the address value. Do NOT hand out the AddressRange as an
- // object as the byte size of the address range may not be filled in
- // and it should be accessed via GetByteSize().
- //------------------------------------------------------------------
- Address
- GetAddress() const
- {
- // Make sure the our value is an address before we hand a copy out.
- // We use the Address inside m_addr_range to contain the value for
- // symbols that are not address based symbols so we are using it
- // for more than just addresses. For example undefined symbols on
- // MacOSX have a nlist.n_value of 0 (zero) and this will get placed
- // into m_addr_range.m_base_addr.m_offset and it will have no section.
- // So in the GetAddress() accessor, we need to hand out an invalid
- // address if the symbol's value isn't an address.
- if (ValueIsAddress())
- return m_addr_range.GetBaseAddress();
- else
- return Address();
- }
+ ConstString GetName() const;
- // When a symbol's value isn't an address, we need to access the raw
- // value. This function will ensure this symbol's value isn't an address
- // and return the integer value if this checks out, otherwise it will
- // return "fail_value" if the symbol is an address value.
- uint64_t
- GetIntegerValue (uint64_t fail_value = 0) const
- {
- if (ValueIsAddress())
- {
- // This symbol's value is an address. Use Symbol::GetAddress() to get the address.
- return fail_value;
- }
- else
- {
- // The value is stored in the base address' offset
- return m_addr_range.GetBaseAddress().GetOffset();
- }
- }
+ ConstString GetNameNoArguments() const;
- lldb::addr_t
- ResolveCallableAddress(Target &target) const;
+ ConstString GetDisplayName() const;
- ConstString
- GetName () const;
+ uint32_t GetID() const { return m_uid; }
- ConstString
- GetNameNoArguments () const;
+ lldb::LanguageType GetLanguage() const {
+ // TODO: See if there is a way to determine the language for a symbol
+ // somehow, for now just return our best guess
+ return m_mangled.GuessLanguage();
+ }
- ConstString
- GetDisplayName () const;
-
- uint32_t
- GetID() const
- {
- return m_uid;
- }
+ void SetID(uint32_t uid) { m_uid = uid; }
- lldb::LanguageType
- GetLanguage() const
- {
- // TODO: See if there is a way to determine the language for a symbol somehow, for now just return our best guess
- return m_mangled.GuessLanguage();
- }
+ Mangled &GetMangled() { return m_mangled; }
- void
- SetID(uint32_t uid)
- {
- m_uid = uid;
- }
+ const Mangled &GetMangled() const { return m_mangled; }
- Mangled&
- GetMangled ()
- {
- return m_mangled;
- }
+ ConstString GetReExportedSymbolName() const;
- const Mangled&
- GetMangled () const
- {
- return m_mangled;
- }
+ FileSpec GetReExportedSymbolSharedLibrary() const;
- ConstString
- GetReExportedSymbolName() const;
+ void SetReExportedSymbolName(const ConstString &name);
- FileSpec
- GetReExportedSymbolSharedLibrary () const;
-
- void
- SetReExportedSymbolName(const ConstString &name);
+ bool SetReExportedSymbolSharedLibrary(const FileSpec &fspec);
- bool
- SetReExportedSymbolSharedLibrary (const FileSpec &fspec);
-
- Symbol *
- ResolveReExportedSymbol (Target &target) const;
+ Symbol *ResolveReExportedSymbol(Target &target) const;
- uint32_t
- GetSiblingIndex () const;
+ uint32_t GetSiblingIndex() const;
- lldb::SymbolType
- GetType () const
- {
- return (lldb::SymbolType)m_type;
- }
+ lldb::SymbolType GetType() const { return (lldb::SymbolType)m_type; }
- void
- SetType (lldb::SymbolType type)
- {
- m_type = (lldb::SymbolType)type;
- }
+ void SetType(lldb::SymbolType type) { m_type = (lldb::SymbolType)type; }
- const char *
- GetTypeAsString () const;
+ const char *GetTypeAsString() const;
- uint32_t
- GetFlags () const
- {
- return m_flags;
- }
+ uint32_t GetFlags() const { return m_flags; }
- void
- SetFlags (uint32_t flags)
- {
- m_flags = flags;
- }
+ void SetFlags(uint32_t flags) { m_flags = flags; }
- void
- GetDescription (Stream *s, lldb::DescriptionLevel level, Target *target) const;
+ void GetDescription(Stream *s, lldb::DescriptionLevel level,
+ Target *target) const;
- bool
- IsSynthetic () const
- {
- return m_is_synthetic;
- }
+ bool IsSynthetic() const { return m_is_synthetic; }
- void
- SetIsSynthetic (bool b)
- {
- m_is_synthetic = b;
- }
+ void SetIsSynthetic(bool b) { m_is_synthetic = b; }
-
- bool
- GetSizeIsSynthesized() const
- {
- return m_size_is_synthesized;
- }
-
- void
- SetSizeIsSynthesized(bool b)
- {
- m_size_is_synthesized = b;
- }
+ bool GetSizeIsSynthesized() const { return m_size_is_synthesized; }
- bool
- IsDebug () const
- {
- return m_is_debug;
- }
+ void SetSizeIsSynthesized(bool b) { m_size_is_synthesized = b; }
- void
- SetDebug (bool b)
- {
- m_is_debug = b;
- }
+ bool IsDebug() const { return m_is_debug; }
- bool
- IsExternal () const
- {
- return m_is_external;
- }
+ void SetDebug(bool b) { m_is_debug = b; }
- void
- SetExternal (bool b)
- {
- m_is_external = b;
- }
+ bool IsExternal() const { return m_is_external; }
- bool
- IsTrampoline () const;
+ void SetExternal(bool b) { m_is_external = b; }
- bool
- IsIndirect () const;
+ bool IsTrampoline() const;
- bool
- GetByteSizeIsValid () const
- {
- return m_size_is_valid;
- }
+ bool IsIndirect() const;
- lldb::addr_t
- GetByteSize () const;
-
- void
- SetByteSize (lldb::addr_t size)
- {
- m_size_is_valid = size > 0;
- m_addr_range.SetByteSize(size);
- }
+ bool GetByteSizeIsValid() const { return m_size_is_valid; }
- bool
- GetSizeIsSibling () const
- {
- return m_size_is_sibling;
- }
+ lldb::addr_t GetByteSize() const;
- void
- SetSizeIsSibling (bool b)
- {
- m_size_is_sibling = b;
- }
+ void SetByteSize(lldb::addr_t size) {
+ m_size_is_valid = size > 0;
+ m_addr_range.SetByteSize(size);
+ }
- // If m_type is "Code" or "Function" then this will return the prologue size
- // in bytes, else it will return zero.
- uint32_t
- GetPrologueByteSize ();
+ bool GetSizeIsSibling() const { return m_size_is_sibling; }
- bool
- GetDemangledNameIsSynthesized() const
- {
- return m_demangled_is_synthesized;
- }
+ void SetSizeIsSibling(bool b) { m_size_is_sibling = b; }
- void
- SetDemangledNameIsSynthesized(bool b)
- {
- m_demangled_is_synthesized = b;
- }
+ // If m_type is "Code" or "Function" then this will return the prologue size
+ // in bytes, else it will return zero.
+ uint32_t GetPrologueByteSize();
- bool
- ContainsLinkerAnnotations() const
- {
- return m_contains_linker_annotations;
- }
- void
- SetContainsLinkerAnnotations(bool b)
- {
- m_contains_linker_annotations = b;
- }
- //------------------------------------------------------------------
- /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
- ///
- /// @see SymbolContextScope
- //------------------------------------------------------------------
- void
- CalculateSymbolContext(SymbolContext *sc) override;
-
- lldb::ModuleSP
- CalculateSymbolContextModule() override;
-
- Symbol *
- CalculateSymbolContextSymbol() override;
-
- //------------------------------------------------------------------
- /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
- ///
- /// @see SymbolContextScope
- //------------------------------------------------------------------
- void
- DumpSymbolContext(Stream *s) override;
-
- lldb::DisassemblerSP
- GetInstructions (const ExecutionContext &exe_ctx,
- const char *flavor,
- bool prefer_file_cache);
-
- bool
- GetDisassembly (const ExecutionContext &exe_ctx,
- const char *flavor,
- bool prefer_file_cache,
- Stream &strm);
-
- bool
- ContainsFileAddress (lldb::addr_t file_addr) const;
+ bool GetDemangledNameIsSynthesized() const {
+ return m_demangled_is_synthesized;
+ }
+
+ void SetDemangledNameIsSynthesized(bool b) { m_demangled_is_synthesized = b; }
+
+ bool ContainsLinkerAnnotations() const {
+ return m_contains_linker_annotations;
+ }
+ void SetContainsLinkerAnnotations(bool b) {
+ m_contains_linker_annotations = b;
+ }
+ //------------------------------------------------------------------
+ /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
+ ///
+ /// @see SymbolContextScope
+ //------------------------------------------------------------------
+ void CalculateSymbolContext(SymbolContext *sc) override;
+
+ lldb::ModuleSP CalculateSymbolContextModule() override;
+
+ Symbol *CalculateSymbolContextSymbol() override;
+
+ //------------------------------------------------------------------
+ /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
+ ///
+ /// @see SymbolContextScope
+ //------------------------------------------------------------------
+ void DumpSymbolContext(Stream *s) override;
+
+ lldb::DisassemblerSP GetInstructions(const ExecutionContext &exe_ctx,
+ const char *flavor,
+ bool prefer_file_cache);
+
+ bool GetDisassembly(const ExecutionContext &exe_ctx, const char *flavor,
+ bool prefer_file_cache, Stream &strm);
+
+ bool ContainsFileAddress(lldb::addr_t file_addr) const;
protected:
- // This is the internal guts of ResolveReExportedSymbol, it assumes reexport_name is not null, and that module_spec
- // is valid. We track the modules we've already seen to make sure we don't get caught in a cycle.
-
- Symbol *
- ResolveReExportedSymbolInModuleSpec (Target &target,
- ConstString &reexport_name,
- lldb_private::ModuleSpec &module_spec,
- lldb_private::ModuleList &seen_modules) const;
-
- uint32_t m_uid; // User ID (usually the original symbol table index)
- uint16_t m_type_data; // data specific to m_type
- uint16_t m_type_data_resolved:1, // True if the data in m_type_data has already been calculated
- m_is_synthetic:1, // non-zero if this symbol is not actually in the symbol table, but synthesized from other info in the object file.
- m_is_debug:1, // non-zero if this symbol is debug information in a symbol
- m_is_external:1, // non-zero if this symbol is globally visible
- m_size_is_sibling:1, // m_size contains the index of this symbol's sibling
- m_size_is_synthesized:1,// non-zero if this symbol's size was calculated using a delta between this symbol and the next
- m_size_is_valid:1,
- m_demangled_is_synthesized:1, // The demangled name was created should not be used for expressions or other lookups
- m_contains_linker_annotations:1, // The symbol name contains linker annotations, which are optional when doing name lookups
- m_type:7;
- Mangled m_mangled; // uniqued symbol name/mangled name pair
- AddressRange m_addr_range; // Contains the value, or the section offset address when the value is an address in a section, and the size (if any)
- uint32_t m_flags; // A copy of the flags from the original symbol table, the ObjectFile plug-in can interpret these
+ // This is the internal guts of ResolveReExportedSymbol, it assumes
+ // reexport_name is not null, and that module_spec
+ // is valid. We track the modules we've already seen to make sure we don't
+ // get caught in a cycle.
+
+ Symbol *ResolveReExportedSymbolInModuleSpec(
+ Target &target, ConstString &reexport_name,
+ lldb_private::ModuleSpec &module_spec,
+ lldb_private::ModuleList &seen_modules) const;
+
+ uint32_t m_uid; // User ID (usually the original symbol table index)
+ uint16_t m_type_data; // data specific to m_type
+ uint16_t m_type_data_resolved : 1, // True if the data in m_type_data has
+ // already been calculated
+ m_is_synthetic : 1, // non-zero if this symbol is not actually in the
+ // symbol table, but synthesized from other info in
+ // the object file.
+ m_is_debug : 1, // non-zero if this symbol is debug information in a
+ // symbol
+ m_is_external : 1, // non-zero if this symbol is globally visible
+ m_size_is_sibling : 1, // m_size contains the index of this symbol's
+ // sibling
+ m_size_is_synthesized : 1, // non-zero if this symbol's size was
+ // calculated using a delta between this symbol
+ // and the next
+ m_size_is_valid : 1,
+ m_demangled_is_synthesized : 1, // The demangled name was created should
+ // not be used for expressions or other
+ // lookups
+ m_contains_linker_annotations : 1, // The symbol name contains linker
+ // annotations, which are optional when
+ // doing name lookups
+ m_type : 7;
+ Mangled m_mangled; // uniqued symbol name/mangled name pair
+ AddressRange m_addr_range; // Contains the value, or the section offset
+ // address when the value is an address in a
+ // section, and the size (if any)
+ uint32_t m_flags; // A copy of the flags from the original symbol table, the
+ // ObjectFile plug-in can interpret these
};
} // namespace lldb_private
diff --git a/include/lldb/Symbol/SymbolContext.h b/include/lldb/Symbol/SymbolContext.h
index f0e8e3590a8a..2ca3fdb71286 100644
--- a/include/lldb/Symbol/SymbolContext.h
+++ b/include/lldb/Symbol/SymbolContext.h
@@ -18,11 +18,11 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/Mangled.h"
#include "lldb/Symbol/LineEntry.h"
#include "lldb/Utility/Iterable.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -39,409 +39,380 @@ class SymbolContextScope;
/// queries include
/// @li Looking up a load address.
//----------------------------------------------------------------------
-class SymbolContext
-{
+class SymbolContext {
public:
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Initialize all pointer members to nullptr and all struct members
- /// to their default state.
- //------------------------------------------------------------------
- SymbolContext ();
-
- //------------------------------------------------------------------
- /// Construct with an object that knows how to reconstruct its
- /// symbol context.
- ///
- /// @param[in] sc_scope
- /// A symbol context scope object that knows how to reconstruct
- /// it's context.
- //------------------------------------------------------------------
- explicit
- SymbolContext (SymbolContextScope *sc_scope);
-
- //------------------------------------------------------------------
- /// Construct with module, and optional compile unit, function,
- /// block, line table, line entry and symbol.
- ///
- /// Initialize all pointer to the specified values.
- ///
- /// @param[in] module
- /// A Module pointer to the module for this context.
- ///
- /// @param[in] comp_unit
- /// A CompileUnit pointer to the compile unit for this context.
- ///
- /// @param[in] function
- /// A Function pointer to the function for this context.
- ///
- /// @param[in] block
- /// A Block pointer to the deepest block for this context.
- ///
- /// @param[in] line_entry
- /// A LineEntry pointer to the line entry for this context.
- ///
- /// @param[in] symbol
- /// A Symbol pointer to the symbol for this context.
- //------------------------------------------------------------------
- explicit
- SymbolContext(const lldb::TargetSP &target_sp,
- const lldb::ModuleSP &module_sp,
- CompileUnit *comp_unit = nullptr,
- Function *function = nullptr,
- Block *block = nullptr,
- LineEntry *line_entry = nullptr,
- Symbol *symbol = nullptr);
-
- // This version sets the target to a NULL TargetSP if you don't know it.
- explicit
- SymbolContext(const lldb::ModuleSP &module_sp,
- CompileUnit *comp_unit = nullptr,
- Function *function = nullptr,
- Block *block = nullptr,
- LineEntry *line_entry = nullptr,
- Symbol *symbol = nullptr);
-
- //------------------------------------------------------------------
- /// Copy constructor
- ///
- /// Makes a copy of the another SymbolContext object \a rhs.
- ///
- /// @param[in] rhs
- /// A const SymbolContext object reference to copy.
- //------------------------------------------------------------------
- SymbolContext (const SymbolContext& rhs);
-
- ~SymbolContext ();
-
- //------------------------------------------------------------------
- /// Assignment operator.
- ///
- /// Copies the address value from another SymbolContext object \a
- /// rhs into \a this object.
- ///
- /// @param[in] rhs
- /// A const SymbolContext object reference to copy.
- ///
- /// @return
- /// A const SymbolContext object reference to \a this.
- //------------------------------------------------------------------
- const SymbolContext&
- operator= (const SymbolContext& rhs);
-
- //------------------------------------------------------------------
- /// Clear the object's state.
- ///
- /// Resets all pointer members to nullptr, and clears any class objects
- /// to their default state.
- //------------------------------------------------------------------
- void
- Clear (bool clear_target);
-
- //------------------------------------------------------------------
- /// Dump a description of this object to a Stream.
- ///
- /// Dump a description of the contents of this object to the
- /// supplied stream \a s.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- //------------------------------------------------------------------
- void
- Dump (Stream *s, Target *target) const;
-
- //------------------------------------------------------------------
- /// Dump the stop context in this object to a Stream.
- ///
- /// Dump the best description of this object to the stream. The
- /// information displayed depends on the amount and quality of the
- /// information in this context. If a module, function, file and
- /// line number are available, they will be dumped. If only a
- /// module and function or symbol name with offset is available,
- /// that will be output. Else just the address at which the target
- /// was stopped will be displayed.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- ///
- /// @param[in] so_addr
- /// The resolved section offset address.
- ///
- /// @param[in] show_fullpaths
- /// When printing file paths (with the Module), whether the
- /// base name of the Module should be printed or the full path.
- ///
- /// @param[in] show_module
- /// Whether the module name should be printed followed by a
- /// grave accent "`" character.
- ///
- /// @param[in] show_inlined_frames
- /// If a given pc is in inlined function(s), whether the inlined
- /// functions should be printed on separate lines in addition to
- /// the concrete function containing the pc.
- ///
- /// @param[in] show_function_arguments
- /// If false, this method will try to elide the function argument
- /// types when printing the function name. This may be ambiguous
- /// for languages that have function overloading - but it may
- /// make the "function name" too long to include all the argument
- /// types.
- ///
- /// @param[in] show_function_name
- /// Normally this should be true - the function/symbol name should
- /// be printed. In disassembly formatting, where we want a format
- /// like "<*+36>", this should be false and "*" will be printed
- /// instead.
- //------------------------------------------------------------------
- bool
- DumpStopContext (Stream *s,
- ExecutionContextScope *exe_scope,
- const Address &so_addr,
- bool show_fullpaths,
- bool show_module,
- bool show_inlined_frames,
- bool show_function_arguments,
- bool show_function_name) const;
-
- //------------------------------------------------------------------
- /// Get the address range contained within a symbol context.
- ///
- /// Address range priority is as follows:
- /// - line_entry address range if line_entry is valid and eSymbolContextLineEntry is set in \a scope
- /// - block address range if block is not nullptr and eSymbolContextBlock is set in \a scope
- /// - function address range if function is not nullptr and eSymbolContextFunction is set in \a scope
- /// - symbol address range if symbol is not nullptr and eSymbolContextSymbol is set in \a scope
- ///
- /// @param[in] scope
- /// A mask of symbol context bits telling this function which
- /// address ranges it can use when trying to extract one from
- /// the valid (non-nullptr) symbol context classes.
- ///
- /// @param[in] range_idx
- /// The address range index to grab. Since many functions and
- /// blocks are not always contiguous, they may have more than
- /// one address range.
- ///
- /// @param[in] use_inline_block_range
- /// If \a scope has the eSymbolContextBlock bit set, and there
- /// is a valid block in the symbol context, return the block
- /// address range for the containing inline function block, not
- /// the deepest most block. This allows us to extract information
- /// for the address range of the inlined function block, not
- /// the deepest lexical block.
- ///
- /// @param[out] range
- /// An address range object that will be filled in if \b true
- /// is returned.
- ///
- /// @return
- /// \b True if this symbol context contains items that describe
- /// an address range, \b false otherwise.
- //------------------------------------------------------------------
- bool
- GetAddressRange (uint32_t scope,
- uint32_t range_idx,
- bool use_inline_block_range,
- AddressRange &range) const;
-
- bool
- GetAddressRangeFromHereToEndLine(uint32_t end_line, AddressRange &range, Error &error);
-
- void
- GetDescription(Stream *s,
- lldb::DescriptionLevel level,
- Target *target) const;
-
- uint32_t
- GetResolvedMask () const;
-
- lldb::LanguageType
- GetLanguage () const;
-
- //------------------------------------------------------------------
- /// Find a block that defines the function represented by this
- /// symbol context.
- ///
- /// If this symbol context points to a block that is an inlined
- /// function, or is contained within an inlined function, the block
- /// that defines the inlined function is returned.
- ///
- /// If this symbol context has no block in it, or the block is not
- /// itself an inlined function block or contained within one, we
- /// return the top level function block.
- ///
- /// This is a handy function to call when you want to get the block
- /// whose variable list will include the arguments for the function
- /// that is represented by this symbol context (whether the function
- /// is an inline function or not).
- ///
- /// @return
- /// The block object pointer that defines the function that is
- /// represented by this symbol context object, nullptr otherwise.
- //------------------------------------------------------------------
- Block *
- GetFunctionBlock ();
-
- //------------------------------------------------------------------
- /// If this symbol context represents a function that is a method,
- /// return true and provide information about the method.
- ///
- /// @param[out] language
- /// If \b true is returned, the language for the method.
- ///
- /// @param[out] is_instance_method
- /// If \b true is returned, \b true if this is a instance method,
- /// \b false if this is a static/class function.
- ///
- /// @param[out] language_object_name
- /// If \b true is returned, the name of the artificial variable
- /// for the language ("this" for C++, "self" for ObjC).
- ///
- /// @return
- /// \b True if this symbol context represents a function that
- /// is a method of a class, \b false otherwise.
- //------------------------------------------------------------------
- bool
- GetFunctionMethodInfo (lldb::LanguageType &language,
- bool &is_instance_method,
- ConstString &language_object_name);
-
- //------------------------------------------------------------------
- /// Sorts the types in TypeMap according to SymbolContext
- /// to TypeList
- ///
- //------------------------------------------------------------------
- void
- SortTypeList(TypeMap &type_map, TypeList &type_list) const;
-
- //------------------------------------------------------------------
- /// Find a name of the innermost function for the symbol context.
- ///
- /// For instance, if the symbol context contains an inlined block,
- /// it will return the inlined function name.
- ///
- /// @param[in] prefer_mangled
- /// if \btrue, then the mangled name will be returned if there
- /// is one. Otherwise the unmangled name will be returned if it
- /// is available.
- ///
- /// @return
- /// The name of the function represented by this symbol context.
- //------------------------------------------------------------------
- ConstString
- GetFunctionName (Mangled::NamePreference preference = Mangled::ePreferDemangled) const;
-
- //------------------------------------------------------------------
- /// Get the line entry that corresponds to the function.
- ///
- /// If the symbol context contains an inlined block, the line entry
- /// for the start address of the inlined function will be returned,
- /// otherwise the line entry for the start address of the function
- /// will be returned. This can be used after doing a
- /// Module::FindFunctions(...) or ModuleList::FindFunctions(...)
- /// call in order to get the correct line table information for
- /// the symbol context.
- /// it will return the inlined function name.
- ///
- /// @param[in] prefer_mangled
- /// if \btrue, then the mangled name will be returned if there
- /// is one. Otherwise the unmangled name will be returned if it
- /// is available.
- ///
- /// @return
- /// The name of the function represented by this symbol context.
- //------------------------------------------------------------------
- LineEntry
- GetFunctionStartLineEntry () const;
-
- //------------------------------------------------------------------
- /// Find the block containing the inlined block that contains this block.
- ///
- /// For instance, if the symbol context contains an inlined block,
- /// it will return the inlined function name.
- ///
- /// @param[in] curr_frame_pc
- /// The address within the block of this object.
- ///
- /// @param[out] next_frame_sc
- /// A new symbol context that does what the title says it does.
- ///
- /// @param[out] next_frame_addr
- /// This is what you should report as the PC in \a next_frame_sc.
- ///
- /// @return
- /// \b true if this SymbolContext specifies a block contained in an
- /// inlined block. If this returns \b true, \a next_frame_sc and
- /// \a next_frame_addr will be filled in correctly.
- //------------------------------------------------------------------
- bool
- GetParentOfInlinedScope (const Address &curr_frame_pc,
- SymbolContext &next_frame_sc,
- Address &inlined_frame_addr) const;
-
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- lldb::TargetSP target_sp; ///< The Target for a given query
- lldb::ModuleSP module_sp; ///< The Module for a given query
- CompileUnit * comp_unit; ///< The CompileUnit for a given query
- Function * function; ///< The Function for a given query
- Block * block; ///< The Block for a given query
- LineEntry line_entry; ///< The LineEntry for a given query
- Symbol * symbol; ///< The Symbol for a given query
- Variable * variable; ///< The global variable matching the given query
+ //------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// Initialize all pointer members to nullptr and all struct members
+ /// to their default state.
+ //------------------------------------------------------------------
+ SymbolContext();
+
+ //------------------------------------------------------------------
+ /// Construct with an object that knows how to reconstruct its
+ /// symbol context.
+ ///
+ /// @param[in] sc_scope
+ /// A symbol context scope object that knows how to reconstruct
+ /// it's context.
+ //------------------------------------------------------------------
+ explicit SymbolContext(SymbolContextScope *sc_scope);
+
+ //------------------------------------------------------------------
+ /// Construct with module, and optional compile unit, function,
+ /// block, line table, line entry and symbol.
+ ///
+ /// Initialize all pointer to the specified values.
+ ///
+ /// @param[in] module
+ /// A Module pointer to the module for this context.
+ ///
+ /// @param[in] comp_unit
+ /// A CompileUnit pointer to the compile unit for this context.
+ ///
+ /// @param[in] function
+ /// A Function pointer to the function for this context.
+ ///
+ /// @param[in] block
+ /// A Block pointer to the deepest block for this context.
+ ///
+ /// @param[in] line_entry
+ /// A LineEntry pointer to the line entry for this context.
+ ///
+ /// @param[in] symbol
+ /// A Symbol pointer to the symbol for this context.
+ //------------------------------------------------------------------
+ explicit SymbolContext(const lldb::TargetSP &target_sp,
+ const lldb::ModuleSP &module_sp,
+ CompileUnit *comp_unit = nullptr,
+ Function *function = nullptr, Block *block = nullptr,
+ LineEntry *line_entry = nullptr,
+ Symbol *symbol = nullptr);
+
+ // This version sets the target to a NULL TargetSP if you don't know it.
+ explicit SymbolContext(const lldb::ModuleSP &module_sp,
+ CompileUnit *comp_unit = nullptr,
+ Function *function = nullptr, Block *block = nullptr,
+ LineEntry *line_entry = nullptr,
+ Symbol *symbol = nullptr);
+
+ //------------------------------------------------------------------
+ /// Copy constructor
+ ///
+ /// Makes a copy of the another SymbolContext object \a rhs.
+ ///
+ /// @param[in] rhs
+ /// A const SymbolContext object reference to copy.
+ //------------------------------------------------------------------
+ SymbolContext(const SymbolContext &rhs);
+
+ ~SymbolContext();
+
+ //------------------------------------------------------------------
+ /// Assignment operator.
+ ///
+ /// Copies the address value from another SymbolContext object \a
+ /// rhs into \a this object.
+ ///
+ /// @param[in] rhs
+ /// A const SymbolContext object reference to copy.
+ ///
+ /// @return
+ /// A const SymbolContext object reference to \a this.
+ //------------------------------------------------------------------
+ const SymbolContext &operator=(const SymbolContext &rhs);
+
+ //------------------------------------------------------------------
+ /// Clear the object's state.
+ ///
+ /// Resets all pointer members to nullptr, and clears any class objects
+ /// to their default state.
+ //------------------------------------------------------------------
+ void Clear(bool clear_target);
+
+ //------------------------------------------------------------------
+ /// Dump a description of this object to a Stream.
+ ///
+ /// Dump a description of the contents of this object to the
+ /// supplied stream \a s.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ //------------------------------------------------------------------
+ void Dump(Stream *s, Target *target) const;
+
+ //------------------------------------------------------------------
+ /// Dump the stop context in this object to a Stream.
+ ///
+ /// Dump the best description of this object to the stream. The
+ /// information displayed depends on the amount and quality of the
+ /// information in this context. If a module, function, file and
+ /// line number are available, they will be dumped. If only a
+ /// module and function or symbol name with offset is available,
+ /// that will be output. Else just the address at which the target
+ /// was stopped will be displayed.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ ///
+ /// @param[in] so_addr
+ /// The resolved section offset address.
+ ///
+ /// @param[in] show_fullpaths
+ /// When printing file paths (with the Module), whether the
+ /// base name of the Module should be printed or the full path.
+ ///
+ /// @param[in] show_module
+ /// Whether the module name should be printed followed by a
+ /// grave accent "`" character.
+ ///
+ /// @param[in] show_inlined_frames
+ /// If a given pc is in inlined function(s), whether the inlined
+ /// functions should be printed on separate lines in addition to
+ /// the concrete function containing the pc.
+ ///
+ /// @param[in] show_function_arguments
+ /// If false, this method will try to elide the function argument
+ /// types when printing the function name. This may be ambiguous
+ /// for languages that have function overloading - but it may
+ /// make the "function name" too long to include all the argument
+ /// types.
+ ///
+ /// @param[in] show_function_name
+ /// Normally this should be true - the function/symbol name should
+ /// be printed. In disassembly formatting, where we want a format
+ /// like "<*+36>", this should be false and "*" will be printed
+ /// instead.
+ //------------------------------------------------------------------
+ bool DumpStopContext(Stream *s, ExecutionContextScope *exe_scope,
+ const Address &so_addr, bool show_fullpaths,
+ bool show_module, bool show_inlined_frames,
+ bool show_function_arguments,
+ bool show_function_name) const;
+
+ //------------------------------------------------------------------
+ /// Get the address range contained within a symbol context.
+ ///
+ /// Address range priority is as follows:
+ /// - line_entry address range if line_entry is valid and
+ /// eSymbolContextLineEntry is set in \a scope
+ /// - block address range if block is not nullptr and eSymbolContextBlock
+ /// is set in \a scope
+ /// - function address range if function is not nullptr and
+ /// eSymbolContextFunction is set in \a scope
+ /// - symbol address range if symbol is not nullptr and
+ /// eSymbolContextSymbol is set in \a scope
+ ///
+ /// @param[in] scope
+ /// A mask of symbol context bits telling this function which
+ /// address ranges it can use when trying to extract one from
+ /// the valid (non-nullptr) symbol context classes.
+ ///
+ /// @param[in] range_idx
+ /// The address range index to grab. Since many functions and
+ /// blocks are not always contiguous, they may have more than
+ /// one address range.
+ ///
+ /// @param[in] use_inline_block_range
+ /// If \a scope has the eSymbolContextBlock bit set, and there
+ /// is a valid block in the symbol context, return the block
+ /// address range for the containing inline function block, not
+ /// the deepest most block. This allows us to extract information
+ /// for the address range of the inlined function block, not
+ /// the deepest lexical block.
+ ///
+ /// @param[out] range
+ /// An address range object that will be filled in if \b true
+ /// is returned.
+ ///
+ /// @return
+ /// \b True if this symbol context contains items that describe
+ /// an address range, \b false otherwise.
+ //------------------------------------------------------------------
+ bool GetAddressRange(uint32_t scope, uint32_t range_idx,
+ bool use_inline_block_range, AddressRange &range) const;
+
+ bool GetAddressRangeFromHereToEndLine(uint32_t end_line, AddressRange &range,
+ Error &error);
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level,
+ Target *target) const;
+
+ uint32_t GetResolvedMask() const;
+
+ lldb::LanguageType GetLanguage() const;
+
+ //------------------------------------------------------------------
+ /// Find a block that defines the function represented by this
+ /// symbol context.
+ ///
+ /// If this symbol context points to a block that is an inlined
+ /// function, or is contained within an inlined function, the block
+ /// that defines the inlined function is returned.
+ ///
+ /// If this symbol context has no block in it, or the block is not
+ /// itself an inlined function block or contained within one, we
+ /// return the top level function block.
+ ///
+ /// This is a handy function to call when you want to get the block
+ /// whose variable list will include the arguments for the function
+ /// that is represented by this symbol context (whether the function
+ /// is an inline function or not).
+ ///
+ /// @return
+ /// The block object pointer that defines the function that is
+ /// represented by this symbol context object, nullptr otherwise.
+ //------------------------------------------------------------------
+ Block *GetFunctionBlock();
+
+ //------------------------------------------------------------------
+ /// If this symbol context represents a function that is a method,
+ /// return true and provide information about the method.
+ ///
+ /// @param[out] language
+ /// If \b true is returned, the language for the method.
+ ///
+ /// @param[out] is_instance_method
+ /// If \b true is returned, \b true if this is a instance method,
+ /// \b false if this is a static/class function.
+ ///
+ /// @param[out] language_object_name
+ /// If \b true is returned, the name of the artificial variable
+ /// for the language ("this" for C++, "self" for ObjC).
+ ///
+ /// @return
+ /// \b True if this symbol context represents a function that
+ /// is a method of a class, \b false otherwise.
+ //------------------------------------------------------------------
+ bool GetFunctionMethodInfo(lldb::LanguageType &language,
+ bool &is_instance_method,
+ ConstString &language_object_name);
+
+ //------------------------------------------------------------------
+ /// Sorts the types in TypeMap according to SymbolContext
+ /// to TypeList
+ ///
+ //------------------------------------------------------------------
+ void SortTypeList(TypeMap &type_map, TypeList &type_list) const;
+
+ //------------------------------------------------------------------
+ /// Find a name of the innermost function for the symbol context.
+ ///
+ /// For instance, if the symbol context contains an inlined block,
+ /// it will return the inlined function name.
+ ///
+ /// @param[in] prefer_mangled
+ /// if \btrue, then the mangled name will be returned if there
+ /// is one. Otherwise the unmangled name will be returned if it
+ /// is available.
+ ///
+ /// @return
+ /// The name of the function represented by this symbol context.
+ //------------------------------------------------------------------
+ ConstString GetFunctionName(
+ Mangled::NamePreference preference = Mangled::ePreferDemangled) const;
+
+ //------------------------------------------------------------------
+ /// Get the line entry that corresponds to the function.
+ ///
+ /// If the symbol context contains an inlined block, the line entry
+ /// for the start address of the inlined function will be returned,
+ /// otherwise the line entry for the start address of the function
+ /// will be returned. This can be used after doing a
+ /// Module::FindFunctions(...) or ModuleList::FindFunctions(...)
+ /// call in order to get the correct line table information for
+ /// the symbol context.
+ /// it will return the inlined function name.
+ ///
+ /// @param[in] prefer_mangled
+ /// if \btrue, then the mangled name will be returned if there
+ /// is one. Otherwise the unmangled name will be returned if it
+ /// is available.
+ ///
+ /// @return
+ /// The name of the function represented by this symbol context.
+ //------------------------------------------------------------------
+ LineEntry GetFunctionStartLineEntry() const;
+
+ //------------------------------------------------------------------
+ /// Find the block containing the inlined block that contains this block.
+ ///
+ /// For instance, if the symbol context contains an inlined block,
+ /// it will return the inlined function name.
+ ///
+ /// @param[in] curr_frame_pc
+ /// The address within the block of this object.
+ ///
+ /// @param[out] next_frame_sc
+ /// A new symbol context that does what the title says it does.
+ ///
+ /// @param[out] next_frame_addr
+ /// This is what you should report as the PC in \a next_frame_sc.
+ ///
+ /// @return
+ /// \b true if this SymbolContext specifies a block contained in an
+ /// inlined block. If this returns \b true, \a next_frame_sc and
+ /// \a next_frame_addr will be filled in correctly.
+ //------------------------------------------------------------------
+ bool GetParentOfInlinedScope(const Address &curr_frame_pc,
+ SymbolContext &next_frame_sc,
+ Address &inlined_frame_addr) const;
+
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ lldb::TargetSP target_sp; ///< The Target for a given query
+ lldb::ModuleSP module_sp; ///< The Module for a given query
+ CompileUnit *comp_unit; ///< The CompileUnit for a given query
+ Function *function; ///< The Function for a given query
+ Block *block; ///< The Block for a given query
+ LineEntry line_entry; ///< The LineEntry for a given query
+ Symbol *symbol; ///< The Symbol for a given query
+ Variable *variable; ///< The global variable matching the given query
};
-class SymbolContextSpecifier
-{
+class SymbolContextSpecifier {
public:
- typedef enum SpecificationType
- {
- eNothingSpecified = 0,
- eModuleSpecified = 1 << 0,
- eFileSpecified = 1 << 1,
- eLineStartSpecified = 1 << 2,
- eLineEndSpecified = 1 << 3,
- eFunctionSpecified = 1 << 4,
- eClassOrNamespaceSpecified = 1 << 5,
- eAddressRangeSpecified = 1 << 6
- } SpecificationType;
-
- // This one produces a specifier that matches everything...
- SymbolContextSpecifier (const lldb::TargetSP& target_sp);
-
- ~SymbolContextSpecifier();
-
- bool
- AddSpecification (const char *spec_string, SpecificationType type);
-
- bool
- AddLineSpecification (uint32_t line_no, SpecificationType type);
-
- void
- Clear();
-
- bool
- SymbolContextMatches(SymbolContext &sc);
-
- bool
- AddressMatches(lldb::addr_t addr);
-
- void
- GetDescription (Stream *s, lldb::DescriptionLevel level) const;
+ typedef enum SpecificationType {
+ eNothingSpecified = 0,
+ eModuleSpecified = 1 << 0,
+ eFileSpecified = 1 << 1,
+ eLineStartSpecified = 1 << 2,
+ eLineEndSpecified = 1 << 3,
+ eFunctionSpecified = 1 << 4,
+ eClassOrNamespaceSpecified = 1 << 5,
+ eAddressRangeSpecified = 1 << 6
+ } SpecificationType;
+
+ // This one produces a specifier that matches everything...
+ SymbolContextSpecifier(const lldb::TargetSP &target_sp);
+
+ ~SymbolContextSpecifier();
+
+ bool AddSpecification(const char *spec_string, SpecificationType type);
+
+ bool AddLineSpecification(uint32_t line_no, SpecificationType type);
+
+ void Clear();
+
+ bool SymbolContextMatches(SymbolContext &sc);
+
+ bool AddressMatches(lldb::addr_t addr);
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) const;
private:
- lldb::TargetSP m_target_sp;
- std::string m_module_spec;
- lldb::ModuleSP m_module_sp;
- std::unique_ptr<FileSpec> m_file_spec_ap;
- size_t m_start_line;
- size_t m_end_line;
- std::string m_function_spec;
- std::string m_class_name;
- std::unique_ptr<AddressRange> m_address_range_ap;
- uint32_t m_type; // Or'ed bits from SpecificationType
+ lldb::TargetSP m_target_sp;
+ std::string m_module_spec;
+ lldb::ModuleSP m_module_sp;
+ std::unique_ptr<FileSpec> m_file_spec_ap;
+ size_t m_start_line;
+ size_t m_end_line;
+ std::string m_function_spec;
+ std::string m_class_name;
+ std::unique_ptr<AddressRange> m_address_range_ap;
+ uint32_t m_type; // Or'ed bits from SpecificationType
};
//----------------------------------------------------------------------
@@ -454,165 +425,143 @@ private:
/// @li Looking up a function by name.
/// @li Finding all addresses for a specified file and line number.
//----------------------------------------------------------------------
-class SymbolContextList
-{
+class SymbolContextList {
public:
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Initialize with an empty list.
- //------------------------------------------------------------------
- SymbolContextList ();
-
- //------------------------------------------------------------------
- /// Destructor.
- //------------------------------------------------------------------
- ~SymbolContextList ();
-
- //------------------------------------------------------------------
- /// Append a new symbol context to the list.
- ///
- /// @param[in] sc
- /// A symbol context to append to the list.
- //------------------------------------------------------------------
- void
- Append (const SymbolContext& sc);
-
- void
- Append (const SymbolContextList& sc_list);
-
- bool
- AppendIfUnique (const SymbolContext& sc,
- bool merge_symbol_into_function);
-
- bool
- MergeSymbolContextIntoFunctionContext (const SymbolContext& symbol_sc,
- uint32_t start_idx = 0,
- uint32_t stop_idx = UINT32_MAX);
-
- uint32_t
- AppendIfUnique (const SymbolContextList& sc_list,
- bool merge_symbol_into_function);
-
- //------------------------------------------------------------------
- /// Clear the object's state.
- ///
- /// Clears the symbol context list.
- //------------------------------------------------------------------
- void
- Clear();
-
- //------------------------------------------------------------------
- /// Dump a description of this object to a Stream.
- ///
- /// Dump a description of the contents of each symbol context in
- /// the list to the supplied stream \a s.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- //------------------------------------------------------------------
- void
- Dump(Stream *s, Target *target) const;
-
- //------------------------------------------------------------------
- /// Get accessor for a symbol context at index \a idx.
- ///
- /// Dump a description of the contents of each symbol context in
- /// the list to the supplied stream \a s.
- ///
- /// @param[in] idx
- /// The zero based index into the symbol context list.
- ///
- /// @param[out] sc
- /// A reference to the symbol context to fill in.
- ///
- /// @return
- /// Returns \b true if \a idx was a valid index into this
- /// symbol context list and \a sc was filled in, \b false
- /// otherwise.
- //------------------------------------------------------------------
- bool
- GetContextAtIndex(size_t idx, SymbolContext& sc) const;
-
- //------------------------------------------------------------------
- /// Direct reference accessor for a symbol context at index \a idx.
- ///
- /// The index \a idx must be a valid index, no error checking will
- /// be done to ensure that it is valid.
- ///
- /// @param[in] idx
- /// The zero based index into the symbol context list.
- ///
- /// @return
- /// A const reference to the symbol context to fill in.
- //------------------------------------------------------------------
- SymbolContext&
- operator [] (size_t idx)
- {
- return m_symbol_contexts[idx];
- }
-
- const SymbolContext&
- operator [] (size_t idx) const
- {
- return m_symbol_contexts[idx];
- }
-
- //------------------------------------------------------------------
- /// Get accessor for the last symbol context in the list.
- ///
- /// @param[out] sc
- /// A reference to the symbol context to fill in.
- ///
- /// @return
- /// Returns \b true if \a sc was filled in, \b false if the
- /// list is empty.
- //------------------------------------------------------------------
- bool
- GetLastContext(SymbolContext& sc) const;
-
- bool
- RemoveContextAtIndex (size_t idx);
-
- //------------------------------------------------------------------
- /// Get accessor for a symbol context list size.
- ///
- /// @return
- /// Returns the number of symbol context objects in the list.
- //------------------------------------------------------------------
- uint32_t
- GetSize() const;
-
- uint32_t
- NumLineEntriesWithLine (uint32_t line) const;
-
- void
- GetDescription(Stream *s,
- lldb::DescriptionLevel level,
- Target *target) const;
+ //------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// Initialize with an empty list.
+ //------------------------------------------------------------------
+ SymbolContextList();
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ //------------------------------------------------------------------
+ ~SymbolContextList();
+
+ //------------------------------------------------------------------
+ /// Append a new symbol context to the list.
+ ///
+ /// @param[in] sc
+ /// A symbol context to append to the list.
+ //------------------------------------------------------------------
+ void Append(const SymbolContext &sc);
+
+ void Append(const SymbolContextList &sc_list);
+
+ bool AppendIfUnique(const SymbolContext &sc, bool merge_symbol_into_function);
+
+ bool MergeSymbolContextIntoFunctionContext(const SymbolContext &symbol_sc,
+ uint32_t start_idx = 0,
+ uint32_t stop_idx = UINT32_MAX);
+
+ uint32_t AppendIfUnique(const SymbolContextList &sc_list,
+ bool merge_symbol_into_function);
+
+ //------------------------------------------------------------------
+ /// Clear the object's state.
+ ///
+ /// Clears the symbol context list.
+ //------------------------------------------------------------------
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Dump a description of this object to a Stream.
+ ///
+ /// Dump a description of the contents of each symbol context in
+ /// the list to the supplied stream \a s.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ //------------------------------------------------------------------
+ void Dump(Stream *s, Target *target) const;
+
+ //------------------------------------------------------------------
+ /// Get accessor for a symbol context at index \a idx.
+ ///
+ /// Dump a description of the contents of each symbol context in
+ /// the list to the supplied stream \a s.
+ ///
+ /// @param[in] idx
+ /// The zero based index into the symbol context list.
+ ///
+ /// @param[out] sc
+ /// A reference to the symbol context to fill in.
+ ///
+ /// @return
+ /// Returns \b true if \a idx was a valid index into this
+ /// symbol context list and \a sc was filled in, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ bool GetContextAtIndex(size_t idx, SymbolContext &sc) const;
+
+ //------------------------------------------------------------------
+ /// Direct reference accessor for a symbol context at index \a idx.
+ ///
+ /// The index \a idx must be a valid index, no error checking will
+ /// be done to ensure that it is valid.
+ ///
+ /// @param[in] idx
+ /// The zero based index into the symbol context list.
+ ///
+ /// @return
+ /// A const reference to the symbol context to fill in.
+ //------------------------------------------------------------------
+ SymbolContext &operator[](size_t idx) { return m_symbol_contexts[idx]; }
+
+ const SymbolContext &operator[](size_t idx) const {
+ return m_symbol_contexts[idx];
+ }
+
+ //------------------------------------------------------------------
+ /// Get accessor for the last symbol context in the list.
+ ///
+ /// @param[out] sc
+ /// A reference to the symbol context to fill in.
+ ///
+ /// @return
+ /// Returns \b true if \a sc was filled in, \b false if the
+ /// list is empty.
+ //------------------------------------------------------------------
+ bool GetLastContext(SymbolContext &sc) const;
+
+ bool RemoveContextAtIndex(size_t idx);
+
+ //------------------------------------------------------------------
+ /// Get accessor for a symbol context list size.
+ ///
+ /// @return
+ /// Returns the number of symbol context objects in the list.
+ //------------------------------------------------------------------
+ uint32_t GetSize() const;
+
+ uint32_t NumLineEntriesWithLine(uint32_t line) const;
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level,
+ Target *target) const;
protected:
- typedef std::vector<SymbolContext> collection; ///< The collection type for the list.
+ typedef std::vector<SymbolContext>
+ collection; ///< The collection type for the list.
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- collection m_symbol_contexts; ///< The list of symbol contexts.
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ collection m_symbol_contexts; ///< The list of symbol contexts.
public:
- typedef AdaptedIterable<collection, SymbolContext, vector_adapter> SymbolContextIterable;
- SymbolContextIterable
- SymbolContexts()
- {
- return SymbolContextIterable(m_symbol_contexts);
- }
+ typedef AdaptedIterable<collection, SymbolContext, vector_adapter>
+ SymbolContextIterable;
+ SymbolContextIterable SymbolContexts() {
+ return SymbolContextIterable(m_symbol_contexts);
+ }
};
-bool operator== (const SymbolContext& lhs, const SymbolContext& rhs);
-bool operator!= (const SymbolContext& lhs, const SymbolContext& rhs);
+bool operator==(const SymbolContext &lhs, const SymbolContext &rhs);
+bool operator!=(const SymbolContext &lhs, const SymbolContext &rhs);
-bool operator== (const SymbolContextList& lhs, const SymbolContextList& rhs);
-bool operator!= (const SymbolContextList& lhs, const SymbolContextList& rhs);
+bool operator==(const SymbolContextList &lhs, const SymbolContextList &rhs);
+bool operator!=(const SymbolContextList &lhs, const SymbolContextList &rhs);
} // namespace lldb_private
diff --git a/include/lldb/Symbol/SymbolContextScope.h b/include/lldb/Symbol/SymbolContextScope.h
index 212d8e6df233..926e34bc03a2 100644
--- a/include/lldb/Symbol/SymbolContextScope.h
+++ b/include/lldb/Symbol/SymbolContextScope.h
@@ -19,16 +19,17 @@
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class SymbolContextScope SymbolContextScope.h "lldb/Symbol/SymbolContextScope.h"
+/// @class SymbolContextScope SymbolContextScope.h
+/// "lldb/Symbol/SymbolContextScope.h"
/// @brief Inherit from this if your object is part of a symbol context
/// and can reconstruct its symbol context.
///
/// Many objects that are part of a symbol context that have pointers
-/// back to parent objects that own them. Any members of a symbol
+/// back to parent objects that own them. Any members of a symbol
/// context that, once they are built, will not go away, can inherit
/// from this pure virtual class and can then reconstruct their symbol
-/// context without having to keep a complete SymbolContext object in
-/// the object.
+/// context without having to keep a complete SymbolContext object in
+/// the object.
///
/// Examples of these objects include:
/// @li Module
@@ -38,7 +39,7 @@ namespace lldb_private {
/// @li Symbol
///
/// Other objects can store a "SymbolContextScope *" using any pointers
-/// to one of the above objects. This allows clients to hold onto a
+/// to one of the above objects. This allows clients to hold onto a
/// pointer that uniquely will identify a symbol context. Those clients
/// can then always reconstruct the symbol context using the pointer, or
/// use it to uniquely identify a symbol context for an object.
@@ -53,12 +54,12 @@ namespace lldb_private {
/// in which the variable is defined. Function arguments can use
/// the Function object as their scope. The SymbolFile parsers
/// will set these correctly as the variables are parsed.
-/// @li Type objects that know exactly in which scope they
+/// @li Type objects that know exactly in which scope they
/// originated much like the variables above.
-/// @li StackID objects that are able to know that if the CFA
-/// (stack pointer at the beginning of a function) and the
+/// @li StackID objects that are able to know that if the CFA
+/// (stack pointer at the beginning of a function) and the
/// start PC for the function/symbol and the SymbolContextScope
-/// pointer (a unique pointer that identifies a symbol context
+/// pointer (a unique pointer that identifies a symbol context
/// location) match within the same thread, that the stack
/// frame is the same as the previous stack frame.
///
@@ -68,67 +69,45 @@ namespace lldb_private {
/// and object pairs that allow large collections of objects to be
/// passed around with minimal overhead.
//----------------------------------------------------------------------
-class SymbolContextScope
-{
+class SymbolContextScope {
public:
- virtual
- ~SymbolContextScope() = default;
+ virtual ~SymbolContextScope() = default;
- //------------------------------------------------------------------
- /// Reconstruct the object's symbol context into \a sc.
- ///
- /// The object should fill in as much of the SymbolContext as it
- /// can so function calls that require a symbol context can be made
- /// for the given object.
- ///
- /// @param[out] sc
- /// A symbol context object pointer that gets filled in.
- //------------------------------------------------------------------
- virtual void
- CalculateSymbolContext (SymbolContext *sc) = 0;
+ //------------------------------------------------------------------
+ /// Reconstruct the object's symbol context into \a sc.
+ ///
+ /// The object should fill in as much of the SymbolContext as it
+ /// can so function calls that require a symbol context can be made
+ /// for the given object.
+ ///
+ /// @param[out] sc
+ /// A symbol context object pointer that gets filled in.
+ //------------------------------------------------------------------
+ virtual void CalculateSymbolContext(SymbolContext *sc) = 0;
- virtual lldb::ModuleSP
- CalculateSymbolContextModule ()
- {
- return lldb::ModuleSP();
- }
+ virtual lldb::ModuleSP CalculateSymbolContextModule() {
+ return lldb::ModuleSP();
+ }
- virtual CompileUnit *
- CalculateSymbolContextCompileUnit ()
- {
- return nullptr;
- }
+ virtual CompileUnit *CalculateSymbolContextCompileUnit() { return nullptr; }
- virtual Function *
- CalculateSymbolContextFunction ()
- {
- return nullptr;
- }
+ virtual Function *CalculateSymbolContextFunction() { return nullptr; }
- virtual Block *
- CalculateSymbolContextBlock ()
- {
- return nullptr;
- }
+ virtual Block *CalculateSymbolContextBlock() { return nullptr; }
- virtual Symbol *
- CalculateSymbolContextSymbol ()
- {
- return nullptr;
- }
+ virtual Symbol *CalculateSymbolContextSymbol() { return nullptr; }
- //------------------------------------------------------------------
- /// Dump the object's symbol context to the stream \a s.
- ///
- /// The object should dump its symbol context to the stream \a s.
- /// This function is widely used in the DumpDebug and verbose output
- /// for lldb objects.
- ///
- /// @param[in] s
- /// The stream to which to dump the object's symbol context.
- //------------------------------------------------------------------
- virtual void
- DumpSymbolContext (Stream *s) = 0;
+ //------------------------------------------------------------------
+ /// Dump the object's symbol context to the stream \a s.
+ ///
+ /// The object should dump its symbol context to the stream \a s.
+ /// This function is widely used in the DumpDebug and verbose output
+ /// for lldb objects.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object's symbol context.
+ //------------------------------------------------------------------
+ virtual void DumpSymbolContext(Stream *s) = 0;
};
} // namespace lldb_private
diff --git a/include/lldb/Symbol/SymbolFile.h b/include/lldb/Symbol/SymbolFile.h
index db97ab4f9b65..34ae8d76e195 100644
--- a/include/lldb/Symbol/SymbolFile.h
+++ b/include/lldb/Symbol/SymbolFile.h
@@ -10,184 +10,201 @@
#ifndef liblldb_SymbolFile_h_
#define liblldb_SymbolFile_h_
-#include "lldb/lldb-private.h"
#include "lldb/Core/PluginInterface.h"
-#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/CompilerDecl.h"
#include "lldb/Symbol/CompilerDeclContext.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/Type.h"
+#include "lldb/lldb-private.h"
#include "llvm/ADT/DenseSet.h"
namespace lldb_private {
-class SymbolFile :
- public PluginInterface
-{
+class SymbolFile : public PluginInterface {
public:
- //------------------------------------------------------------------
- // Symbol file ability bits.
- //
- // Each symbol file can claim to support one or more symbol file
- // abilities. These get returned from SymbolFile::GetAbilities().
- // These help us to determine which plug-in will be best to load
- // the debug information found in files.
- //------------------------------------------------------------------
- enum Abilities
- {
- CompileUnits = (1u << 0),
- LineTables = (1u << 1),
- Functions = (1u << 2),
- Blocks = (1u << 3),
- GlobalVariables = (1u << 4),
- LocalVariables = (1u << 5),
- VariableTypes = (1u << 6),
- kAllAbilities =((1u << 7) - 1u)
- };
-
- static SymbolFile *
- FindPlugin (ObjectFile* obj_file);
-
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- SymbolFile(ObjectFile* obj_file) :
- m_obj_file(obj_file),
- m_abilities(0),
- m_calculated_abilities(false)
- {
- }
-
- ~SymbolFile() override
- {
+ //------------------------------------------------------------------
+ // Symbol file ability bits.
+ //
+ // Each symbol file can claim to support one or more symbol file
+ // abilities. These get returned from SymbolFile::GetAbilities().
+ // These help us to determine which plug-in will be best to load
+ // the debug information found in files.
+ //------------------------------------------------------------------
+ enum Abilities {
+ CompileUnits = (1u << 0),
+ LineTables = (1u << 1),
+ Functions = (1u << 2),
+ Blocks = (1u << 3),
+ GlobalVariables = (1u << 4),
+ LocalVariables = (1u << 5),
+ VariableTypes = (1u << 6),
+ kAllAbilities = ((1u << 7) - 1u)
+ };
+
+ static SymbolFile *FindPlugin(ObjectFile *obj_file);
+
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ SymbolFile(ObjectFile *obj_file)
+ : m_obj_file(obj_file), m_abilities(0), m_calculated_abilities(false) {}
+
+ ~SymbolFile() override {}
+
+ //------------------------------------------------------------------
+ /// Get a mask of what this symbol file supports for the object file
+ /// that it was constructed with.
+ ///
+ /// Each symbol file gets to respond with a mask of abilities that
+ /// it supports for each object file. This happens when we are
+ /// trying to figure out which symbol file plug-in will get used
+ /// for a given object file. The plug-in that responds with the
+ /// best mix of "SymbolFile::Abilities" bits set, will get chosen to
+ /// be the symbol file parser. This allows each plug-in to check for
+ /// sections that contain data a symbol file plug-in would need. For
+ /// example the DWARF plug-in requires DWARF sections in a file that
+ /// contain debug information. If the DWARF plug-in doesn't find
+ /// these sections, it won't respond with many ability bits set, and
+ /// we will probably fall back to the symbol table SymbolFile plug-in
+ /// which uses any information in the symbol table. Also, plug-ins
+ /// might check for some specific symbols in a symbol table in the
+ /// case where the symbol table contains debug information (STABS
+ /// and COFF). Not a lot of work should happen in these functions
+ /// as the plug-in might not get selected due to another plug-in
+ /// having more abilities. Any initialization work should be saved
+ /// for "void SymbolFile::InitializeObject()" which will get called
+ /// on the SymbolFile object with the best set of abilities.
+ ///
+ /// @return
+ /// A uint32_t mask containing bits from the SymbolFile::Abilities
+ /// enumeration. Any bits that are set represent an ability that
+ /// this symbol plug-in can parse from the object file.
+ ///------------------------------------------------------------------
+ uint32_t GetAbilities() {
+ if (!m_calculated_abilities) {
+ m_abilities = CalculateAbilities();
+ m_calculated_abilities = true;
}
- //------------------------------------------------------------------
- /// Get a mask of what this symbol file supports for the object file
- /// that it was constructed with.
- ///
- /// Each symbol file gets to respond with a mask of abilities that
- /// it supports for each object file. This happens when we are
- /// trying to figure out which symbol file plug-in will get used
- /// for a given object file. The plug-in that responds with the
- /// best mix of "SymbolFile::Abilities" bits set, will get chosen to
- /// be the symbol file parser. This allows each plug-in to check for
- /// sections that contain data a symbol file plug-in would need. For
- /// example the DWARF plug-in requires DWARF sections in a file that
- /// contain debug information. If the DWARF plug-in doesn't find
- /// these sections, it won't respond with many ability bits set, and
- /// we will probably fall back to the symbol table SymbolFile plug-in
- /// which uses any information in the symbol table. Also, plug-ins
- /// might check for some specific symbols in a symbol table in the
- /// case where the symbol table contains debug information (STABS
- /// and COFF). Not a lot of work should happen in these functions
- /// as the plug-in might not get selected due to another plug-in
- /// having more abilities. Any initialization work should be saved
- /// for "void SymbolFile::InitializeObject()" which will get called
- /// on the SymbolFile object with the best set of abilities.
- ///
- /// @return
- /// A uint32_t mask containing bits from the SymbolFile::Abilities
- /// enumeration. Any bits that are set represent an ability that
- /// this symbol plug-in can parse from the object file.
- ///------------------------------------------------------------------
- uint32_t GetAbilities ()
- {
- if (!m_calculated_abilities)
- {
- m_abilities = CalculateAbilities();
- m_calculated_abilities = true;
- }
-
- return m_abilities;
- }
-
- virtual uint32_t CalculateAbilities() = 0;
-
- //------------------------------------------------------------------
- /// Initialize the SymbolFile object.
- ///
- /// The SymbolFile object with the best set of abilities (detected
- /// in "uint32_t SymbolFile::GetAbilities()) will have this function
- /// called if it is chosen to parse an object file. More complete
- /// initialization can happen in this function which will get called
- /// prior to any other functions in the SymbolFile protocol.
- //------------------------------------------------------------------
- virtual void InitializeObject() {}
-
- //------------------------------------------------------------------
- // Compile Unit function calls
- //------------------------------------------------------------------
- // Approach 1 - iterator
- virtual uint32_t GetNumCompileUnits() = 0;
- virtual lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) = 0;
-
- virtual lldb::LanguageType ParseCompileUnitLanguage (const SymbolContext& sc) = 0;
- virtual size_t ParseCompileUnitFunctions (const SymbolContext& sc) = 0;
- virtual bool ParseCompileUnitLineTable (const SymbolContext& sc) = 0;
- virtual bool ParseCompileUnitDebugMacros (const SymbolContext& sc) = 0;
- virtual bool ParseCompileUnitSupportFiles (const SymbolContext& sc, FileSpecList& support_files) = 0;
- virtual bool
- ParseCompileUnitIsOptimized(const lldb_private::SymbolContext &sc)
- {
- return false;
- }
- virtual bool ParseImportedModules (const SymbolContext &sc, std::vector<ConstString> &imported_modules) = 0;
- virtual size_t ParseFunctionBlocks (const SymbolContext& sc) = 0;
- virtual size_t ParseTypes (const SymbolContext& sc) = 0;
- virtual size_t ParseVariablesForContext (const SymbolContext& sc) = 0;
- virtual Type* ResolveTypeUID (lldb::user_id_t type_uid) = 0;
- virtual bool CompleteType (CompilerType &compiler_type) = 0;
- virtual void ParseDeclsForContext (CompilerDeclContext decl_ctx) {}
- virtual CompilerDecl GetDeclForUID (lldb::user_id_t uid) { return CompilerDecl(); }
- virtual CompilerDeclContext GetDeclContextForUID (lldb::user_id_t uid) { return CompilerDeclContext(); }
- virtual CompilerDeclContext GetDeclContextContainingUID (lldb::user_id_t uid) { return CompilerDeclContext(); }
- virtual uint32_t ResolveSymbolContext (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc) = 0;
- virtual uint32_t ResolveSymbolContext (const FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list);
- virtual uint32_t FindGlobalVariables (const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, VariableList& variables);
- virtual uint32_t FindGlobalVariables (const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables);
- virtual uint32_t FindFunctions (const ConstString &name, const CompilerDeclContext *parent_decl_ctx, uint32_t name_type_mask, bool include_inlines, bool append, SymbolContextList& sc_list);
- virtual uint32_t FindFunctions (const RegularExpression& regex, bool include_inlines, bool append, SymbolContextList& sc_list);
- virtual uint32_t FindTypes (const SymbolContext& sc, const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeMap& types);
- virtual size_t FindTypes (const std::vector<CompilerContext> &context, bool append, TypeMap& types);
-
- virtual void GetMangledNamesForFunction(const std::string &scope_qualified_name, std::vector<ConstString> &mangled_names);
-// virtual uint32_t FindTypes (const SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, TypeList& types) = 0;
- virtual TypeList * GetTypeList ();
- virtual size_t GetTypes (lldb_private::SymbolContextScope *sc_scope,
- uint32_t type_mask,
- lldb_private::TypeList &type_list) = 0;
-
- virtual lldb_private::TypeSystem *
- GetTypeSystemForLanguage (lldb::LanguageType language);
-
- virtual CompilerDeclContext
- FindNamespace (const SymbolContext& sc,
- const ConstString &name,
- const CompilerDeclContext *parent_decl_ctx)
- {
- return CompilerDeclContext();
- }
-
- ObjectFile* GetObjectFile() { return m_obj_file; }
- const ObjectFile* GetObjectFile() const { return m_obj_file; }
-
- //------------------------------------------------------------------
- /// Notify the SymbolFile that the file addresses in the Sections
- /// for this module have been changed.
- //------------------------------------------------------------------
- virtual void
- SectionFileAddressesChanged ()
- {
- }
+ return m_abilities;
+ }
+
+ virtual uint32_t CalculateAbilities() = 0;
+
+ //------------------------------------------------------------------
+ /// Initialize the SymbolFile object.
+ ///
+ /// The SymbolFile object with the best set of abilities (detected
+ /// in "uint32_t SymbolFile::GetAbilities()) will have this function
+ /// called if it is chosen to parse an object file. More complete
+ /// initialization can happen in this function which will get called
+ /// prior to any other functions in the SymbolFile protocol.
+ //------------------------------------------------------------------
+ virtual void InitializeObject() {}
+
+ //------------------------------------------------------------------
+ // Compile Unit function calls
+ //------------------------------------------------------------------
+ // Approach 1 - iterator
+ virtual uint32_t GetNumCompileUnits() = 0;
+ virtual lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) = 0;
+
+ virtual lldb::LanguageType
+ ParseCompileUnitLanguage(const SymbolContext &sc) = 0;
+ virtual size_t ParseCompileUnitFunctions(const SymbolContext &sc) = 0;
+ virtual bool ParseCompileUnitLineTable(const SymbolContext &sc) = 0;
+ virtual bool ParseCompileUnitDebugMacros(const SymbolContext &sc) = 0;
+ virtual bool ParseCompileUnitSupportFiles(const SymbolContext &sc,
+ FileSpecList &support_files) = 0;
+ virtual bool
+ ParseCompileUnitIsOptimized(const lldb_private::SymbolContext &sc) {
+ return false;
+ }
+ virtual bool
+ ParseImportedModules(const SymbolContext &sc,
+ std::vector<ConstString> &imported_modules) = 0;
+ virtual size_t ParseFunctionBlocks(const SymbolContext &sc) = 0;
+ virtual size_t ParseTypes(const SymbolContext &sc) = 0;
+ virtual size_t ParseVariablesForContext(const SymbolContext &sc) = 0;
+ virtual Type *ResolveTypeUID(lldb::user_id_t type_uid) = 0;
+ virtual bool CompleteType(CompilerType &compiler_type) = 0;
+ virtual void ParseDeclsForContext(CompilerDeclContext decl_ctx) {}
+ virtual CompilerDecl GetDeclForUID(lldb::user_id_t uid) {
+ return CompilerDecl();
+ }
+ virtual CompilerDeclContext GetDeclContextForUID(lldb::user_id_t uid) {
+ return CompilerDeclContext();
+ }
+ virtual CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid) {
+ return CompilerDeclContext();
+ }
+ virtual uint32_t ResolveSymbolContext(const Address &so_addr,
+ uint32_t resolve_scope,
+ SymbolContext &sc) = 0;
+ virtual uint32_t ResolveSymbolContext(const FileSpec &file_spec,
+ uint32_t line, bool check_inlines,
+ uint32_t resolve_scope,
+ SymbolContextList &sc_list);
+ virtual uint32_t
+ FindGlobalVariables(const ConstString &name,
+ const CompilerDeclContext *parent_decl_ctx, bool append,
+ uint32_t max_matches, VariableList &variables);
+ virtual uint32_t FindGlobalVariables(const RegularExpression &regex,
+ bool append, uint32_t max_matches,
+ VariableList &variables);
+ virtual uint32_t FindFunctions(const ConstString &name,
+ const CompilerDeclContext *parent_decl_ctx,
+ uint32_t name_type_mask, bool include_inlines,
+ bool append, SymbolContextList &sc_list);
+ virtual uint32_t FindFunctions(const RegularExpression &regex,
+ bool include_inlines, bool append,
+ SymbolContextList &sc_list);
+ virtual uint32_t
+ FindTypes(const SymbolContext &sc, const ConstString &name,
+ const CompilerDeclContext *parent_decl_ctx, bool append,
+ uint32_t max_matches,
+ llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
+ TypeMap &types);
+ virtual size_t FindTypes(const std::vector<CompilerContext> &context,
+ bool append, TypeMap &types);
+
+ virtual void
+ GetMangledNamesForFunction(const std::string &scope_qualified_name,
+ std::vector<ConstString> &mangled_names);
+ // virtual uint32_t FindTypes (const SymbolContext& sc, const
+ // RegularExpression& regex, bool append, uint32_t max_matches, TypeList&
+ // types) = 0;
+ virtual TypeList *GetTypeList();
+ virtual size_t GetTypes(lldb_private::SymbolContextScope *sc_scope,
+ uint32_t type_mask,
+ lldb_private::TypeList &type_list) = 0;
+
+ virtual lldb_private::TypeSystem *
+ GetTypeSystemForLanguage(lldb::LanguageType language);
+
+ virtual CompilerDeclContext
+ FindNamespace(const SymbolContext &sc, const ConstString &name,
+ const CompilerDeclContext *parent_decl_ctx) {
+ return CompilerDeclContext();
+ }
+
+ ObjectFile *GetObjectFile() { return m_obj_file; }
+ const ObjectFile *GetObjectFile() const { return m_obj_file; }
+
+ //------------------------------------------------------------------
+ /// Notify the SymbolFile that the file addresses in the Sections
+ /// for this module have been changed.
+ //------------------------------------------------------------------
+ virtual void SectionFileAddressesChanged() {}
protected:
- ObjectFile* m_obj_file; // The object file that symbols can be extracted from.
- uint32_t m_abilities;
- bool m_calculated_abilities;
+ ObjectFile *m_obj_file; // The object file that symbols can be extracted from.
+ uint32_t m_abilities;
+ bool m_calculated_abilities;
private:
- DISALLOW_COPY_AND_ASSIGN (SymbolFile);
+ DISALLOW_COPY_AND_ASSIGN(SymbolFile);
};
} // namespace lldb_private
diff --git a/include/lldb/Symbol/SymbolVendor.h b/include/lldb/Symbol/SymbolVendor.h
index e992c5cde607..7db3de6e690c 100644
--- a/include/lldb/Symbol/SymbolVendor.h
+++ b/include/lldb/Symbol/SymbolVendor.h
@@ -12,11 +12,11 @@
#include <vector>
-#include "lldb/lldb-private.h"
#include "lldb/Core/ModuleChild.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Symbol/TypeList.h"
#include "lldb/Symbol/TypeMap.h"
+#include "lldb/lldb-private.h"
#include "llvm/ADT/DenseSet.h"
namespace lldb_private {
@@ -31,197 +31,146 @@ namespace lldb_private {
// objects) to provide the information and only parse as deep as needed
// in order to provide the information that is requested.
//----------------------------------------------------------------------
-class SymbolVendor :
- public ModuleChild,
- public PluginInterface
-{
+class SymbolVendor : public ModuleChild, public PluginInterface {
public:
- static SymbolVendor*
- FindPlugin (const lldb::ModuleSP &module_sp,
- Stream *feedback_strm);
-
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- SymbolVendor(const lldb::ModuleSP &module_sp);
-
- ~SymbolVendor() override;
-
- void
- AddSymbolFileRepresentation(const lldb::ObjectFileSP &objfile_sp);
-
- virtual void
- Dump(Stream *s);
-
- virtual lldb::LanguageType
- ParseCompileUnitLanguage (const SymbolContext& sc);
-
- virtual size_t
- ParseCompileUnitFunctions (const SymbolContext& sc);
-
- virtual bool
- ParseCompileUnitLineTable (const SymbolContext& sc);
-
- virtual bool
- ParseCompileUnitDebugMacros (const SymbolContext& sc);
-
- virtual bool
- ParseCompileUnitSupportFiles (const SymbolContext& sc,
- FileSpecList& support_files);
-
- virtual bool
- ParseCompileUnitIsOptimized(const SymbolContext &sc);
-
- virtual bool
- ParseImportedModules (const SymbolContext &sc,
- std::vector<ConstString> &imported_modules);
-
- virtual size_t
- ParseFunctionBlocks (const SymbolContext& sc);
-
- virtual size_t
- ParseTypes (const SymbolContext& sc);
-
- virtual size_t
- ParseVariablesForContext (const SymbolContext& sc);
-
- virtual Type*
- ResolveTypeUID(lldb::user_id_t type_uid);
-
- virtual uint32_t
- ResolveSymbolContext (const Address& so_addr,
- uint32_t resolve_scope,
- SymbolContext& sc);
-
- virtual uint32_t
- ResolveSymbolContext (const FileSpec& file_spec,
- uint32_t line,
- bool check_inlines,
- uint32_t resolve_scope,
- SymbolContextList& sc_list);
-
- virtual size_t
- FindGlobalVariables (const ConstString &name,
- const CompilerDeclContext *parent_decl_ctx,
- bool append,
- size_t max_matches,
- VariableList& variables);
-
- virtual size_t
- FindGlobalVariables (const RegularExpression& regex,
- bool append,
- size_t max_matches,
- VariableList& variables);
-
- virtual size_t
- FindFunctions (const ConstString &name,
- const CompilerDeclContext *parent_decl_ctx,
- uint32_t name_type_mask,
- bool include_inlines,
- bool append,
- SymbolContextList& sc_list);
-
- virtual size_t
- FindFunctions (const RegularExpression& regex,
- bool include_inlines,
- bool append,
- SymbolContextList& sc_list);
-
- virtual size_t
- FindTypes (const SymbolContext& sc,
- const ConstString &name,
- const CompilerDeclContext *parent_decl_ctx,
- bool append,
- size_t max_matches,
- llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
- TypeMap& types);
-
- virtual size_t
- FindTypes (const std::vector<CompilerContext> &context, bool append, TypeMap& types);
-
- virtual CompilerDeclContext
- FindNamespace (const SymbolContext& sc,
- const ConstString &name,
- const CompilerDeclContext *parent_decl_ctx);
-
- virtual size_t
- GetNumCompileUnits();
-
- virtual bool
- SetCompileUnitAtIndex (size_t cu_idx,
- const lldb::CompUnitSP &cu_sp);
-
- virtual lldb::CompUnitSP
- GetCompileUnitAtIndex(size_t idx);
-
- TypeList&
- GetTypeList()
- {
- return m_type_list;
- }
-
- const TypeList&
- GetTypeList() const
- {
- return m_type_list;
- }
-
- virtual size_t
- GetTypes (SymbolContextScope *sc_scope,
- uint32_t type_mask,
- TypeList &type_list);
-
- SymbolFile *
- GetSymbolFile()
- {
- return m_sym_file_ap.get();
- }
-
- FileSpec
- GetMainFileSpec() const;
-
- // Get module unified section list symbol table.
- virtual Symtab *
- GetSymtab ();
-
- // Clear module unified section list symbol table.
- virtual void
- ClearSymtab ();
-
- //------------------------------------------------------------------
- /// Notify the SymbolVendor that the file addresses in the Sections
- /// for this module have been changed.
- //------------------------------------------------------------------
- virtual void
- SectionFileAddressesChanged ();
-
- //------------------------------------------------------------------
- // PluginInterface protocol
- //------------------------------------------------------------------
- ConstString
- GetPluginName() override;
-
- uint32_t
- GetPluginVersion() override;
+ static SymbolVendor *FindPlugin(const lldb::ModuleSP &module_sp,
+ Stream *feedback_strm);
+
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ SymbolVendor(const lldb::ModuleSP &module_sp);
+
+ ~SymbolVendor() override;
+
+ void AddSymbolFileRepresentation(const lldb::ObjectFileSP &objfile_sp);
+
+ virtual void Dump(Stream *s);
+
+ virtual lldb::LanguageType ParseCompileUnitLanguage(const SymbolContext &sc);
+
+ virtual size_t ParseCompileUnitFunctions(const SymbolContext &sc);
+
+ virtual bool ParseCompileUnitLineTable(const SymbolContext &sc);
+
+ virtual bool ParseCompileUnitDebugMacros(const SymbolContext &sc);
+
+ virtual bool ParseCompileUnitSupportFiles(const SymbolContext &sc,
+ FileSpecList &support_files);
+
+ virtual bool ParseCompileUnitIsOptimized(const SymbolContext &sc);
+
+ virtual bool ParseImportedModules(const SymbolContext &sc,
+ std::vector<ConstString> &imported_modules);
+
+ virtual size_t ParseFunctionBlocks(const SymbolContext &sc);
+
+ virtual size_t ParseTypes(const SymbolContext &sc);
+
+ virtual size_t ParseVariablesForContext(const SymbolContext &sc);
+
+ virtual Type *ResolveTypeUID(lldb::user_id_t type_uid);
+
+ virtual uint32_t ResolveSymbolContext(const Address &so_addr,
+ uint32_t resolve_scope,
+ SymbolContext &sc);
+
+ virtual uint32_t ResolveSymbolContext(const FileSpec &file_spec,
+ uint32_t line, bool check_inlines,
+ uint32_t resolve_scope,
+ SymbolContextList &sc_list);
+
+ virtual size_t FindGlobalVariables(const ConstString &name,
+ const CompilerDeclContext *parent_decl_ctx,
+ bool append, size_t max_matches,
+ VariableList &variables);
+
+ virtual size_t FindGlobalVariables(const RegularExpression &regex,
+ bool append, size_t max_matches,
+ VariableList &variables);
+
+ virtual size_t FindFunctions(const ConstString &name,
+ const CompilerDeclContext *parent_decl_ctx,
+ uint32_t name_type_mask, bool include_inlines,
+ bool append, SymbolContextList &sc_list);
+
+ virtual size_t FindFunctions(const RegularExpression &regex,
+ bool include_inlines, bool append,
+ SymbolContextList &sc_list);
+
+ virtual size_t
+ FindTypes(const SymbolContext &sc, const ConstString &name,
+ const CompilerDeclContext *parent_decl_ctx, bool append,
+ size_t max_matches,
+ llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
+ TypeMap &types);
+
+ virtual size_t FindTypes(const std::vector<CompilerContext> &context,
+ bool append, TypeMap &types);
+
+ virtual CompilerDeclContext
+ FindNamespace(const SymbolContext &sc, const ConstString &name,
+ const CompilerDeclContext *parent_decl_ctx);
+
+ virtual size_t GetNumCompileUnits();
+
+ virtual bool SetCompileUnitAtIndex(size_t cu_idx,
+ const lldb::CompUnitSP &cu_sp);
+
+ virtual lldb::CompUnitSP GetCompileUnitAtIndex(size_t idx);
+
+ TypeList &GetTypeList() { return m_type_list; }
+
+ const TypeList &GetTypeList() const { return m_type_list; }
+
+ virtual size_t GetTypes(SymbolContextScope *sc_scope, uint32_t type_mask,
+ TypeList &type_list);
+
+ SymbolFile *GetSymbolFile() { return m_sym_file_ap.get(); }
+
+ FileSpec GetMainFileSpec() const;
+
+ // Get module unified section list symbol table.
+ virtual Symtab *GetSymtab();
+
+ // Clear module unified section list symbol table.
+ virtual void ClearSymtab();
+
+ //------------------------------------------------------------------
+ /// Notify the SymbolVendor that the file addresses in the Sections
+ /// for this module have been changed.
+ //------------------------------------------------------------------
+ virtual void SectionFileAddressesChanged();
+
+ //------------------------------------------------------------------
+ // PluginInterface protocol
+ //------------------------------------------------------------------
+ ConstString GetPluginName() override;
+
+ uint32_t GetPluginVersion() override;
protected:
- //------------------------------------------------------------------
- // Classes that inherit from SymbolVendor can see and modify these
- //------------------------------------------------------------------
- typedef std::vector<lldb::CompUnitSP> CompileUnits;
- typedef CompileUnits::iterator CompileUnitIter;
- typedef CompileUnits::const_iterator CompileUnitConstIter;
-
- TypeList m_type_list; // Uniqued types for all parsers owned by this module
- CompileUnits m_compile_units; // The current compile units
- lldb::ObjectFileSP m_objfile_sp; // Keep a reference to the object file in case it isn't the same as the module object file (debug symbols in a separate file)
- std::unique_ptr<SymbolFile> m_sym_file_ap; // A single symbol file. Subclasses can add more of these if needed.
+ //------------------------------------------------------------------
+ // Classes that inherit from SymbolVendor can see and modify these
+ //------------------------------------------------------------------
+ typedef std::vector<lldb::CompUnitSP> CompileUnits;
+ typedef CompileUnits::iterator CompileUnitIter;
+ typedef CompileUnits::const_iterator CompileUnitConstIter;
+
+ TypeList m_type_list; // Uniqued types for all parsers owned by this module
+ CompileUnits m_compile_units; // The current compile units
+ lldb::ObjectFileSP m_objfile_sp; // Keep a reference to the object file in
+ // case it isn't the same as the module
+ // object file (debug symbols in a separate
+ // file)
+ std::unique_ptr<SymbolFile> m_sym_file_ap; // A single symbol file. Subclasses
+ // can add more of these if needed.
private:
- //------------------------------------------------------------------
- // For SymbolVendor only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (SymbolVendor);
+ //------------------------------------------------------------------
+ // For SymbolVendor only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(SymbolVendor);
};
} // namespace lldb_private
diff --git a/include/lldb/Symbol/Symtab.h b/include/lldb/Symbol/Symtab.h
index 4203a3f7599a..6a8d62cea8b7 100644
--- a/include/lldb/Symbol/Symtab.h
+++ b/include/lldb/Symbol/Symtab.h
@@ -7,169 +7,198 @@
//
//===----------------------------------------------------------------------===//
-
#ifndef liblldb_Symtab_h_
#define liblldb_Symtab_h_
#include <mutex>
#include <vector>
-#include "lldb/lldb-private.h"
#include "lldb/Core/RangeMap.h"
#include "lldb/Core/UniqueCStringMap.h"
#include "lldb/Symbol/Symbol.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class Symtab
-{
+class Symtab {
public:
- typedef std::vector<uint32_t> IndexCollection;
- typedef UniqueCStringMap<uint32_t> NameToIndexMap;
-
- typedef enum Debug {
- eDebugNo, // Not a debug symbol
- eDebugYes, // A debug symbol
- eDebugAny
- } Debug;
-
- typedef enum Visibility {
- eVisibilityAny,
- eVisibilityExtern,
- eVisibilityPrivate
- } Visibility;
-
- Symtab(ObjectFile *objfile);
- ~Symtab();
-
- void Reserve (size_t count);
- Symbol * Resize (size_t count);
- uint32_t AddSymbol(const Symbol& symbol);
- size_t GetNumSymbols() const;
- void SectionFileAddressesChanged ();
- void Dump(Stream *s, Target *target, SortOrder sort_type);
- void Dump(Stream *s, Target *target, std::vector<uint32_t>& indexes) const;
- uint32_t GetIndexForSymbol (const Symbol *symbol) const;
- std::recursive_mutex &
- GetMutex()
- {
- return m_mutex;
- }
- Symbol * FindSymbolByID (lldb::user_id_t uid) const;
- Symbol * SymbolAtIndex (size_t idx);
- const Symbol * SymbolAtIndex (size_t idx) const;
- Symbol * FindSymbolWithType (lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, uint32_t &start_idx);
- //----------------------------------------------------------------------
- /// Get the parent symbol for the given symbol.
- ///
- /// Many symbols in symbol tables are scoped by other symbols that
- /// contain one or more symbol. This function will look for such a
- /// containing symbol and return it if there is one.
- //----------------------------------------------------------------------
- const Symbol * GetParent (Symbol *symbol) const;
- uint32_t AppendSymbolIndexesWithType (lldb::SymbolType symbol_type, std::vector<uint32_t>& indexes, uint32_t start_idx = 0, uint32_t end_index = UINT32_MAX) const;
- uint32_t AppendSymbolIndexesWithTypeAndFlagsValue (lldb::SymbolType symbol_type, uint32_t flags_value, std::vector<uint32_t>& indexes, uint32_t start_idx = 0, uint32_t end_index = UINT32_MAX) const;
- uint32_t AppendSymbolIndexesWithType (lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& matches, uint32_t start_idx = 0, uint32_t end_index = UINT32_MAX) const;
- uint32_t AppendSymbolIndexesWithName (const ConstString& symbol_name, std::vector<uint32_t>& matches);
- uint32_t AppendSymbolIndexesWithName (const ConstString& symbol_name, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& matches);
- uint32_t AppendSymbolIndexesWithNameAndType (const ConstString& symbol_name, lldb::SymbolType symbol_type, std::vector<uint32_t>& matches);
- uint32_t AppendSymbolIndexesWithNameAndType (const ConstString& symbol_name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& matches);
- uint32_t AppendSymbolIndexesMatchingRegExAndType (const RegularExpression &regex, lldb::SymbolType symbol_type, std::vector<uint32_t>& indexes);
- uint32_t AppendSymbolIndexesMatchingRegExAndType (const RegularExpression &regex, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& indexes);
- size_t FindAllSymbolsWithNameAndType (const ConstString &name, lldb::SymbolType symbol_type, std::vector<uint32_t>& symbol_indexes);
- size_t FindAllSymbolsWithNameAndType (const ConstString &name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& symbol_indexes);
- size_t FindAllSymbolsMatchingRexExAndType (const RegularExpression &regex, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& symbol_indexes);
- Symbol * FindFirstSymbolWithNameAndType (const ConstString &name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility);
- Symbol * FindSymbolAtFileAddress (lldb::addr_t file_addr);
- Symbol * FindSymbolContainingFileAddress (lldb::addr_t file_addr);
- void ForEachSymbolContainingFileAddress(lldb::addr_t file_addr, std::function<bool(Symbol *)> const &callback);
- size_t FindFunctionSymbols (const ConstString &name, uint32_t name_type_mask, SymbolContextList& sc_list);
- void CalculateSymbolSizes ();
-
- void SortSymbolIndexesByValue (std::vector<uint32_t>& indexes, bool remove_duplicates) const;
-
- static void DumpSymbolHeader (Stream *s);
-
-
- void Finalize ()
- {
- // Shrink to fit the symbols so we don't waste memory
- if (m_symbols.capacity() > m_symbols.size())
- {
- collection new_symbols (m_symbols.begin(), m_symbols.end());
- m_symbols.swap (new_symbols);
- }
- }
-
- void AppendSymbolNamesToMap (const IndexCollection &indexes,
- bool add_demangled,
- bool add_mangled,
- NameToIndexMap &name_to_index_map) const;
-
- ObjectFile * GetObjectFile()
- {
- return m_objfile;
- }
+ typedef std::vector<uint32_t> IndexCollection;
+ typedef UniqueCStringMap<uint32_t> NameToIndexMap;
+
+ typedef enum Debug {
+ eDebugNo, // Not a debug symbol
+ eDebugYes, // A debug symbol
+ eDebugAny
+ } Debug;
+
+ typedef enum Visibility {
+ eVisibilityAny,
+ eVisibilityExtern,
+ eVisibilityPrivate
+ } Visibility;
+
+ Symtab(ObjectFile *objfile);
+ ~Symtab();
+
+ void Reserve(size_t count);
+ Symbol *Resize(size_t count);
+ uint32_t AddSymbol(const Symbol &symbol);
+ size_t GetNumSymbols() const;
+ void SectionFileAddressesChanged();
+ void Dump(Stream *s, Target *target, SortOrder sort_type);
+ void Dump(Stream *s, Target *target, std::vector<uint32_t> &indexes) const;
+ uint32_t GetIndexForSymbol(const Symbol *symbol) const;
+ std::recursive_mutex &GetMutex() { return m_mutex; }
+ Symbol *FindSymbolByID(lldb::user_id_t uid) const;
+ Symbol *SymbolAtIndex(size_t idx);
+ const Symbol *SymbolAtIndex(size_t idx) const;
+ Symbol *FindSymbolWithType(lldb::SymbolType symbol_type,
+ Debug symbol_debug_type,
+ Visibility symbol_visibility, uint32_t &start_idx);
+ //----------------------------------------------------------------------
+ /// Get the parent symbol for the given symbol.
+ ///
+ /// Many symbols in symbol tables are scoped by other symbols that
+ /// contain one or more symbol. This function will look for such a
+ /// containing symbol and return it if there is one.
+ //----------------------------------------------------------------------
+ const Symbol *GetParent(Symbol *symbol) const;
+ uint32_t AppendSymbolIndexesWithType(lldb::SymbolType symbol_type,
+ std::vector<uint32_t> &indexes,
+ uint32_t start_idx = 0,
+ uint32_t end_index = UINT32_MAX) const;
+ uint32_t AppendSymbolIndexesWithTypeAndFlagsValue(
+ lldb::SymbolType symbol_type, uint32_t flags_value,
+ std::vector<uint32_t> &indexes, uint32_t start_idx = 0,
+ uint32_t end_index = UINT32_MAX) const;
+ uint32_t AppendSymbolIndexesWithType(lldb::SymbolType symbol_type,
+ Debug symbol_debug_type,
+ Visibility symbol_visibility,
+ std::vector<uint32_t> &matches,
+ uint32_t start_idx = 0,
+ uint32_t end_index = UINT32_MAX) const;
+ uint32_t AppendSymbolIndexesWithName(const ConstString &symbol_name,
+ std::vector<uint32_t> &matches);
+ uint32_t AppendSymbolIndexesWithName(const ConstString &symbol_name,
+ Debug symbol_debug_type,
+ Visibility symbol_visibility,
+ std::vector<uint32_t> &matches);
+ uint32_t AppendSymbolIndexesWithNameAndType(const ConstString &symbol_name,
+ lldb::SymbolType symbol_type,
+ std::vector<uint32_t> &matches);
+ uint32_t AppendSymbolIndexesWithNameAndType(const ConstString &symbol_name,
+ lldb::SymbolType symbol_type,
+ Debug symbol_debug_type,
+ Visibility symbol_visibility,
+ std::vector<uint32_t> &matches);
+ uint32_t
+ AppendSymbolIndexesMatchingRegExAndType(const RegularExpression &regex,
+ lldb::SymbolType symbol_type,
+ std::vector<uint32_t> &indexes);
+ uint32_t AppendSymbolIndexesMatchingRegExAndType(
+ const RegularExpression &regex, lldb::SymbolType symbol_type,
+ Debug symbol_debug_type, Visibility symbol_visibility,
+ std::vector<uint32_t> &indexes);
+ size_t FindAllSymbolsWithNameAndType(const ConstString &name,
+ lldb::SymbolType symbol_type,
+ std::vector<uint32_t> &symbol_indexes);
+ size_t FindAllSymbolsWithNameAndType(const ConstString &name,
+ lldb::SymbolType symbol_type,
+ Debug symbol_debug_type,
+ Visibility symbol_visibility,
+ std::vector<uint32_t> &symbol_indexes);
+ size_t FindAllSymbolsMatchingRexExAndType(
+ const RegularExpression &regex, lldb::SymbolType symbol_type,
+ Debug symbol_debug_type, Visibility symbol_visibility,
+ std::vector<uint32_t> &symbol_indexes);
+ Symbol *FindFirstSymbolWithNameAndType(const ConstString &name,
+ lldb::SymbolType symbol_type,
+ Debug symbol_debug_type,
+ Visibility symbol_visibility);
+ Symbol *FindSymbolAtFileAddress(lldb::addr_t file_addr);
+ Symbol *FindSymbolContainingFileAddress(lldb::addr_t file_addr);
+ void ForEachSymbolContainingFileAddress(
+ lldb::addr_t file_addr, std::function<bool(Symbol *)> const &callback);
+ size_t FindFunctionSymbols(const ConstString &name, uint32_t name_type_mask,
+ SymbolContextList &sc_list);
+ void CalculateSymbolSizes();
+
+ void SortSymbolIndexesByValue(std::vector<uint32_t> &indexes,
+ bool remove_duplicates) const;
+
+ static void DumpSymbolHeader(Stream *s);
+
+ void Finalize() {
+ // Shrink to fit the symbols so we don't waste memory
+ if (m_symbols.capacity() > m_symbols.size()) {
+ collection new_symbols(m_symbols.begin(), m_symbols.end());
+ m_symbols.swap(new_symbols);
+ }
+ }
+
+ void AppendSymbolNamesToMap(const IndexCollection &indexes,
+ bool add_demangled, bool add_mangled,
+ NameToIndexMap &name_to_index_map) const;
+
+ ObjectFile *GetObjectFile() { return m_objfile; }
+
protected:
- typedef std::vector<Symbol> collection;
- typedef collection::iterator iterator;
- typedef collection::const_iterator const_iterator;
- typedef RangeDataVector<lldb::addr_t, lldb::addr_t, uint32_t> FileRangeToIndexMap;
- void InitNameIndexes ();
- void InitAddressIndexes ();
-
- ObjectFile * m_objfile;
- collection m_symbols;
- FileRangeToIndexMap m_file_addr_to_index;
- UniqueCStringMap<uint32_t> m_name_to_index;
- UniqueCStringMap<uint32_t> m_basename_to_index;
- UniqueCStringMap<uint32_t> m_method_to_index;
- UniqueCStringMap<uint32_t> m_selector_to_index;
- mutable std::recursive_mutex m_mutex; // Provide thread safety for this symbol table
- bool m_file_addr_to_index_computed:1,
- m_name_indexes_computed:1;
+ typedef std::vector<Symbol> collection;
+ typedef collection::iterator iterator;
+ typedef collection::const_iterator const_iterator;
+ typedef RangeDataVector<lldb::addr_t, lldb::addr_t, uint32_t>
+ FileRangeToIndexMap;
+ void InitNameIndexes();
+ void InitAddressIndexes();
+
+ ObjectFile *m_objfile;
+ collection m_symbols;
+ FileRangeToIndexMap m_file_addr_to_index;
+ UniqueCStringMap<uint32_t> m_name_to_index;
+ UniqueCStringMap<uint32_t> m_basename_to_index;
+ UniqueCStringMap<uint32_t> m_method_to_index;
+ UniqueCStringMap<uint32_t> m_selector_to_index;
+ mutable std::recursive_mutex
+ m_mutex; // Provide thread safety for this symbol table
+ bool m_file_addr_to_index_computed : 1, m_name_indexes_computed : 1;
+
private:
+ bool CheckSymbolAtIndex(size_t idx, Debug symbol_debug_type,
+ Visibility symbol_visibility) const {
+ switch (symbol_debug_type) {
+ case eDebugNo:
+ if (m_symbols[idx].IsDebug() == true)
+ return false;
+ break;
- bool
- CheckSymbolAtIndex (size_t idx, Debug symbol_debug_type, Visibility symbol_visibility) const
- {
- switch (symbol_debug_type)
- {
- case eDebugNo:
- if (m_symbols[idx].IsDebug() == true)
- return false;
- break;
-
- case eDebugYes:
- if (m_symbols[idx].IsDebug() == false)
- return false;
- break;
-
- case eDebugAny:
- break;
- }
-
- switch (symbol_visibility)
- {
- case eVisibilityAny:
- return true;
-
- case eVisibilityExtern:
- return m_symbols[idx].IsExternal();
-
- case eVisibilityPrivate:
- return !m_symbols[idx].IsExternal();
- }
+ case eDebugYes:
+ if (m_symbols[idx].IsDebug() == false)
return false;
+ break;
+
+ case eDebugAny:
+ break;
+ }
+
+ switch (symbol_visibility) {
+ case eVisibilityAny:
+ return true;
+
+ case eVisibilityExtern:
+ return m_symbols[idx].IsExternal();
+
+ case eVisibilityPrivate:
+ return !m_symbols[idx].IsExternal();
}
+ return false;
+ }
- void
- SymbolIndicesToSymbolContextList (std::vector<uint32_t> &symbol_indexes,
- SymbolContextList &sc_list);
+ void SymbolIndicesToSymbolContextList(std::vector<uint32_t> &symbol_indexes,
+ SymbolContextList &sc_list);
- DISALLOW_COPY_AND_ASSIGN (Symtab);
+ DISALLOW_COPY_AND_ASSIGN(Symtab);
};
} // namespace lldb_private
-#endif // liblldb_Symtab_h_
+#endif // liblldb_Symtab_h_
diff --git a/include/lldb/Symbol/TaggedASTType.h b/include/lldb/Symbol/TaggedASTType.h
index 82431a562287..eabd41ebbf29 100644
--- a/include/lldb/Symbol/TaggedASTType.h
+++ b/include/lldb/Symbol/TaggedASTType.h
@@ -12,50 +12,33 @@
#include "lldb/Symbol/CompilerType.h"
-namespace lldb_private
-{
+namespace lldb_private {
// For cases in which there are multiple classes of types that are not
// interchangeable, to allow static type checking.
-template <unsigned int C> class TaggedASTType : public CompilerType
-{
+template <unsigned int C> class TaggedASTType : public CompilerType {
public:
- TaggedASTType (const CompilerType &compiler_type) :
- CompilerType(compiler_type)
- {
- }
-
- TaggedASTType (lldb::opaque_compiler_type_t type, TypeSystem * type_system) :
- CompilerType(type_system, type)
- {
- }
-
- TaggedASTType (const TaggedASTType<C> &tw) :
- CompilerType(tw)
- {
- }
-
- TaggedASTType () :
- CompilerType()
- {
- }
-
- virtual
- ~TaggedASTType()
- {
- }
-
- TaggedASTType<C> &operator= (const TaggedASTType<C> &tw)
- {
- CompilerType::operator= (tw);
- return *this;
- }
+ TaggedASTType(const CompilerType &compiler_type)
+ : CompilerType(compiler_type) {}
+
+ TaggedASTType(lldb::opaque_compiler_type_t type, TypeSystem *type_system)
+ : CompilerType(type_system, type) {}
+
+ TaggedASTType(const TaggedASTType<C> &tw) : CompilerType(tw) {}
+
+ TaggedASTType() : CompilerType() {}
+
+ virtual ~TaggedASTType() {}
+
+ TaggedASTType<C> &operator=(const TaggedASTType<C> &tw) {
+ CompilerType::operator=(tw);
+ return *this;
+ }
};
// Commonly-used tagged types, so code using them is interoperable
-typedef TaggedASTType<0> TypeFromParser;
-typedef TaggedASTType<1> TypeFromUser;
-
+typedef TaggedASTType<0> TypeFromParser;
+typedef TaggedASTType<1> TypeFromUser;
}
#endif
diff --git a/include/lldb/Symbol/Type.h b/include/lldb/Symbol/Type.h
index 9158f28998e3..13c95e71ffeb 100644
--- a/include/lldb/Symbol/Type.h
+++ b/include/lldb/Symbol/Type.h
@@ -10,13 +10,13 @@
#ifndef liblldb_Type_h_
#define liblldb_Type_h_
-#include "lldb/lldb-private.h"
#include "lldb/Core/ClangForward.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/UserID.h"
#include "lldb/Symbol/CompilerDecl.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/Declaration.h"
+#include "lldb/lldb-private.h"
#include "llvm/ADT/APSInt.h"
@@ -28,989 +28,647 @@ namespace lldb_private {
// CompilerContext allows an array of these items to be passed to
// perform detailed lookups in SymbolVendor and SymbolFile functions.
//----------------------------------------------------------------------
-struct CompilerContext
-{
- CompilerContext (CompilerContextKind t, const ConstString &n) :
- type(t),
- name(n)
- {
- }
-
- bool
- operator == (const CompilerContext &rhs) const
- {
- return type == rhs.type && name == rhs.name;
- }
-
- void
- Dump () const;
-
- CompilerContextKind type;
- ConstString name;
+struct CompilerContext {
+ CompilerContext(CompilerContextKind t, const ConstString &n)
+ : type(t), name(n) {}
+
+ bool operator==(const CompilerContext &rhs) const {
+ return type == rhs.type && name == rhs.name;
+ }
+
+ void Dump() const;
+
+ CompilerContextKind type;
+ ConstString name;
};
-class SymbolFileType :
- public std::enable_shared_from_this<SymbolFileType>,
- public UserID
- {
- public:
- SymbolFileType (SymbolFile &symbol_file, lldb::user_id_t uid) :
- UserID (uid),
- m_symbol_file (symbol_file)
- {
- }
-
- SymbolFileType (SymbolFile &symbol_file, const lldb::TypeSP &type_sp);
-
-
- ~SymbolFileType ()
- {
- }
-
- Type *
- operator->()
- {
- return GetType ();
- }
-
- Type *
- GetType ();
-
- protected:
- SymbolFile &m_symbol_file;
- lldb::TypeSP m_type_sp;
- };
-
-class Type :
- public std::enable_shared_from_this<Type>,
- public UserID
-{
+class SymbolFileType : public std::enable_shared_from_this<SymbolFileType>,
+ public UserID {
public:
- typedef enum EncodingDataTypeTag
- {
- eEncodingInvalid,
- eEncodingIsUID, ///< This type is the type whose UID is m_encoding_uid
- eEncodingIsConstUID, ///< This type is the type whose UID is m_encoding_uid with the const qualifier added
- eEncodingIsRestrictUID, ///< This type is the type whose UID is m_encoding_uid with the restrict qualifier added
- eEncodingIsVolatileUID, ///< This type is the type whose UID is m_encoding_uid with the volatile qualifier added
- eEncodingIsTypedefUID, ///< This type is pointer to a type whose UID is m_encoding_uid
- eEncodingIsPointerUID, ///< This type is pointer to a type whose UID is m_encoding_uid
- eEncodingIsLValueReferenceUID, ///< This type is L value reference to a type whose UID is m_encoding_uid
- eEncodingIsRValueReferenceUID, ///< This type is R value reference to a type whose UID is m_encoding_uid
- eEncodingIsSyntheticUID
- } EncodingDataType;
-
- // We must force the underlying type of the enum to be unsigned here. Not all compilers
- // behave the same with regards to the default underlying type of an enum, but because
- // this enum is used in an enum bitfield and integer comparisons are done with the value
- // we need to guarantee that it's always unsigned so that, for example, eResolveStateFull
- // doesn't compare less than eResolveStateUnresolved when used in a 2-bit bitfield.
- typedef enum ResolveStateTag : unsigned
- {
- eResolveStateUnresolved = 0,
- eResolveStateForward = 1,
- eResolveStateLayout = 2,
- eResolveStateFull = 3
- } ResolveState;
-
- Type (lldb::user_id_t uid,
- SymbolFile* symbol_file,
- const ConstString &name,
- uint64_t byte_size,
- SymbolContextScope *context,
- lldb::user_id_t encoding_uid,
- EncodingDataType encoding_uid_type,
- const Declaration& decl,
- const CompilerType &compiler_qual_type,
- ResolveState compiler_type_resolve_state);
-
- // This makes an invalid type. Used for functions that return a Type when they
- // get an error.
- Type();
-
- Type (const Type &rhs);
-
- const Type&
- operator= (const Type& rhs);
-
- void
- Dump(Stream *s, bool show_context);
-
- void
- DumpTypeName(Stream *s);
-
- // Since Type instances only keep a "SymbolFile *" internally, other classes
- // like TypeImpl need make sure the module is still around before playing with
- // Type instances. They can store a weak pointer to the Module;
- lldb::ModuleSP
- GetModule();
-
- void
- GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_name);
-
- SymbolFile *
- GetSymbolFile()
- {
- return m_symbol_file;
- }
- const SymbolFile *
- GetSymbolFile() const
- {
- return m_symbol_file;
- }
-
- TypeList*
- GetTypeList();
-
- const ConstString&
- GetName();
-
- uint64_t
- GetByteSize();
-
- uint32_t
- GetNumChildren (bool omit_empty_base_classes);
-
- bool
- IsAggregateType ();
-
- bool
- IsValidType ()
- {
- return m_encoding_uid_type != eEncodingInvalid;
- }
-
- bool
- IsTypedef ()
- {
- return m_encoding_uid_type == eEncodingIsTypedefUID;
- }
-
- lldb::TypeSP
- GetTypedefType();
-
- const ConstString &
- GetName () const
- {
- return m_name;
- }
-
- ConstString
- GetQualifiedName ();
-
- void
- DumpValue(ExecutionContext *exe_ctx,
- Stream *s,
- const DataExtractor &data,
- uint32_t data_offset,
- bool show_type,
- bool show_summary,
- bool verbose,
- lldb::Format format = lldb::eFormatDefault);
-
- bool
- DumpValueInMemory(ExecutionContext *exe_ctx,
- Stream *s,
- lldb::addr_t address,
- AddressType address_type,
- bool show_types,
- bool show_summary,
- bool verbose);
-
- bool
- ReadFromMemory (ExecutionContext *exe_ctx,
- lldb::addr_t address,
- AddressType address_type,
- DataExtractor &data);
-
- bool
- WriteToMemory (ExecutionContext *exe_ctx,
- lldb::addr_t address,
- AddressType address_type,
- DataExtractor &data);
-
- bool
- GetIsDeclaration() const;
-
- void
- SetIsDeclaration(bool b);
-
- bool
- GetIsExternal() const;
-
- void
- SetIsExternal(bool b);
-
- lldb::Format
- GetFormat ();
-
- lldb::Encoding
- GetEncoding (uint64_t &count);
-
- SymbolContextScope *
- GetSymbolContextScope()
- {
- return m_context;
- }
- const SymbolContextScope *
- GetSymbolContextScope() const
- {
- return m_context;
- }
- void
- SetSymbolContextScope(SymbolContextScope *context)
- {
- m_context = context;
- }
-
- const lldb_private::Declaration &
- GetDeclaration () const;
-
- // Get the clang type, and resolve definitions for any
- // class/struct/union/enum types completely.
- CompilerType
- GetFullCompilerType ();
-
- // Get the clang type, and resolve definitions enough so that the type could
- // have layout performed. This allows ptrs and refs to class/struct/union/enum
- // types remain forward declarations.
- CompilerType
- GetLayoutCompilerType ();
-
- // Get the clang type and leave class/struct/union/enum types as forward
- // declarations if they haven't already been fully defined.
- CompilerType
- GetForwardCompilerType ();
-
- static int
- Compare(const Type &a, const Type &b);
-
- // From a fully qualified typename, split the type into the type basename
- // and the remaining type scope (namespaces/classes).
- static bool
- GetTypeScopeAndBasename (const char* &name_cstr,
- std::string &scope,
- std::string &basename,
- lldb::TypeClass &type_class);
- void
- SetEncodingType (Type *encoding_type)
- {
- m_encoding_type = encoding_type;
- }
-
- uint32_t
- GetEncodingMask ();
-
- bool
- IsCompleteObjCClass()
- {
- return m_flags.is_complete_objc_class;
- }
-
- void
- SetIsCompleteObjCClass(bool is_complete_objc_class)
- {
- m_flags.is_complete_objc_class = is_complete_objc_class;
- }
+ SymbolFileType(SymbolFile &symbol_file, lldb::user_id_t uid)
+ : UserID(uid), m_symbol_file(symbol_file) {}
+
+ SymbolFileType(SymbolFile &symbol_file, const lldb::TypeSP &type_sp);
+
+ ~SymbolFileType() {}
+
+ Type *operator->() { return GetType(); }
+
+ Type *GetType();
+
+protected:
+ SymbolFile &m_symbol_file;
+ lldb::TypeSP m_type_sp;
+};
+
+class Type : public std::enable_shared_from_this<Type>, public UserID {
+public:
+ typedef enum EncodingDataTypeTag {
+ eEncodingInvalid,
+ eEncodingIsUID, ///< This type is the type whose UID is m_encoding_uid
+ eEncodingIsConstUID, ///< This type is the type whose UID is m_encoding_uid
+ ///with the const qualifier added
+ eEncodingIsRestrictUID, ///< This type is the type whose UID is
+ ///m_encoding_uid with the restrict qualifier added
+ eEncodingIsVolatileUID, ///< This type is the type whose UID is
+ ///m_encoding_uid with the volatile qualifier added
+ eEncodingIsTypedefUID, ///< This type is pointer to a type whose UID is
+ ///m_encoding_uid
+ eEncodingIsPointerUID, ///< This type is pointer to a type whose UID is
+ ///m_encoding_uid
+ eEncodingIsLValueReferenceUID, ///< This type is L value reference to a type
+ ///whose UID is m_encoding_uid
+ eEncodingIsRValueReferenceUID, ///< This type is R value reference to a type
+ ///whose UID is m_encoding_uid
+ eEncodingIsSyntheticUID
+ } EncodingDataType;
+
+ // We must force the underlying type of the enum to be unsigned here. Not all
+ // compilers
+ // behave the same with regards to the default underlying type of an enum, but
+ // because
+ // this enum is used in an enum bitfield and integer comparisons are done with
+ // the value
+ // we need to guarantee that it's always unsigned so that, for example,
+ // eResolveStateFull
+ // doesn't compare less than eResolveStateUnresolved when used in a 2-bit
+ // bitfield.
+ typedef enum ResolveStateTag : unsigned {
+ eResolveStateUnresolved = 0,
+ eResolveStateForward = 1,
+ eResolveStateLayout = 2,
+ eResolveStateFull = 3
+ } ResolveState;
+
+ Type(lldb::user_id_t uid, SymbolFile *symbol_file, const ConstString &name,
+ uint64_t byte_size, SymbolContextScope *context,
+ lldb::user_id_t encoding_uid, EncodingDataType encoding_uid_type,
+ const Declaration &decl, const CompilerType &compiler_qual_type,
+ ResolveState compiler_type_resolve_state);
+
+ // This makes an invalid type. Used for functions that return a Type when
+ // they
+ // get an error.
+ Type();
+
+ Type(const Type &rhs);
+
+ const Type &operator=(const Type &rhs);
+
+ void Dump(Stream *s, bool show_context);
+
+ void DumpTypeName(Stream *s);
+
+ // Since Type instances only keep a "SymbolFile *" internally, other classes
+ // like TypeImpl need make sure the module is still around before playing with
+ // Type instances. They can store a weak pointer to the Module;
+ lldb::ModuleSP GetModule();
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level, bool show_name);
+
+ SymbolFile *GetSymbolFile() { return m_symbol_file; }
+ const SymbolFile *GetSymbolFile() const { return m_symbol_file; }
+
+ TypeList *GetTypeList();
+
+ const ConstString &GetName();
+
+ uint64_t GetByteSize();
+
+ uint32_t GetNumChildren(bool omit_empty_base_classes);
+
+ bool IsAggregateType();
+
+ bool IsValidType() { return m_encoding_uid_type != eEncodingInvalid; }
+
+ bool IsTypedef() { return m_encoding_uid_type == eEncodingIsTypedefUID; }
+
+ lldb::TypeSP GetTypedefType();
+
+ const ConstString &GetName() const { return m_name; }
+
+ ConstString GetQualifiedName();
+
+ void DumpValue(ExecutionContext *exe_ctx, Stream *s,
+ const DataExtractor &data, uint32_t data_offset,
+ bool show_type, bool show_summary, bool verbose,
+ lldb::Format format = lldb::eFormatDefault);
+
+ bool DumpValueInMemory(ExecutionContext *exe_ctx, Stream *s,
+ lldb::addr_t address, AddressType address_type,
+ bool show_types, bool show_summary, bool verbose);
+
+ bool ReadFromMemory(ExecutionContext *exe_ctx, lldb::addr_t address,
+ AddressType address_type, DataExtractor &data);
+
+ bool WriteToMemory(ExecutionContext *exe_ctx, lldb::addr_t address,
+ AddressType address_type, DataExtractor &data);
+
+ bool GetIsDeclaration() const;
+
+ void SetIsDeclaration(bool b);
+
+ bool GetIsExternal() const;
+
+ void SetIsExternal(bool b);
+
+ lldb::Format GetFormat();
+
+ lldb::Encoding GetEncoding(uint64_t &count);
+
+ SymbolContextScope *GetSymbolContextScope() { return m_context; }
+ const SymbolContextScope *GetSymbolContextScope() const { return m_context; }
+ void SetSymbolContextScope(SymbolContextScope *context) {
+ m_context = context;
+ }
+
+ const lldb_private::Declaration &GetDeclaration() const;
+
+ // Get the clang type, and resolve definitions for any
+ // class/struct/union/enum types completely.
+ CompilerType GetFullCompilerType();
+
+ // Get the clang type, and resolve definitions enough so that the type could
+ // have layout performed. This allows ptrs and refs to class/struct/union/enum
+ // types remain forward declarations.
+ CompilerType GetLayoutCompilerType();
+
+ // Get the clang type and leave class/struct/union/enum types as forward
+ // declarations if they haven't already been fully defined.
+ CompilerType GetForwardCompilerType();
+
+ static int Compare(const Type &a, const Type &b);
+
+ // From a fully qualified typename, split the type into the type basename
+ // and the remaining type scope (namespaces/classes).
+ static bool GetTypeScopeAndBasename(const char *&name_cstr,
+ std::string &scope, std::string &basename,
+ lldb::TypeClass &type_class);
+ void SetEncodingType(Type *encoding_type) { m_encoding_type = encoding_type; }
+
+ uint32_t GetEncodingMask();
+
+ bool IsCompleteObjCClass() { return m_flags.is_complete_objc_class; }
+
+ void SetIsCompleteObjCClass(bool is_complete_objc_class) {
+ m_flags.is_complete_objc_class = is_complete_objc_class;
+ }
protected:
- ConstString m_name;
- SymbolFile *m_symbol_file;
- SymbolContextScope *m_context; // The symbol context in which this type is defined
- Type *m_encoding_type;
- lldb::user_id_t m_encoding_uid;
- EncodingDataType m_encoding_uid_type;
- uint64_t m_byte_size;
- Declaration m_decl;
- CompilerType m_compiler_type;
-
- struct Flags {
+ ConstString m_name;
+ SymbolFile *m_symbol_file;
+ SymbolContextScope
+ *m_context; // The symbol context in which this type is defined
+ Type *m_encoding_type;
+ lldb::user_id_t m_encoding_uid;
+ EncodingDataType m_encoding_uid_type;
+ uint64_t m_byte_size;
+ Declaration m_decl;
+ CompilerType m_compiler_type;
+
+ struct Flags {
#ifdef __GNUC__
- // using unsigned type here to work around a very noisy gcc warning
- unsigned compiler_type_resolve_state : 2;
+ // using unsigned type here to work around a very noisy gcc warning
+ unsigned compiler_type_resolve_state : 2;
#else
- ResolveState compiler_type_resolve_state : 2;
+ ResolveState compiler_type_resolve_state : 2;
#endif
- bool is_complete_objc_class : 1;
- } m_flags;
-
- Type *
- GetEncodingType ();
-
- bool
- ResolveClangType (ResolveState compiler_type_resolve_state);
+ bool is_complete_objc_class : 1;
+ } m_flags;
+
+ Type *GetEncodingType();
+
+ bool ResolveClangType(ResolveState compiler_type_resolve_state);
};
// these classes are used to back the SBType* objects
-class TypePair
-{
+class TypePair {
public:
- TypePair () :
- compiler_type(),
- type_sp()
- {
- }
-
- TypePair (CompilerType type) :
- compiler_type(type),
- type_sp()
- {
- }
-
- TypePair (lldb::TypeSP type) :
- compiler_type(),
- type_sp(type)
- {
- compiler_type = type_sp->GetForwardCompilerType ();
- }
-
- bool
- IsValid () const
- {
- return compiler_type.IsValid() || (type_sp.get() != nullptr);
- }
-
- explicit operator bool () const
- {
- return IsValid();
- }
-
- bool
- operator == (const TypePair& rhs) const
- {
- return compiler_type == rhs.compiler_type &&
- type_sp.get() == rhs.type_sp.get();
- }
-
- bool
- operator != (const TypePair& rhs) const
- {
- return compiler_type != rhs.compiler_type ||
- type_sp.get() != rhs.type_sp.get();
- }
-
- void
- Clear ()
- {
- compiler_type.Clear();
- type_sp.reset();
- }
-
- ConstString
- GetName () const
- {
- if (type_sp)
- return type_sp->GetName();
- if (compiler_type)
- return compiler_type.GetTypeName();
- return ConstString ();
- }
-
- ConstString
- GetDisplayTypeName () const
- {
- if (type_sp)
- return type_sp->GetForwardCompilerType ().GetDisplayTypeName();
- if (compiler_type)
- return compiler_type.GetDisplayTypeName();
- return ConstString();
- }
-
- void
- SetType (CompilerType type)
- {
- type_sp.reset();
- compiler_type = type;
- }
-
- void
- SetType (lldb::TypeSP type)
- {
- type_sp = type;
- if (type_sp)
- compiler_type = type_sp->GetForwardCompilerType ();
- else
- compiler_type.Clear();
- }
-
- lldb::TypeSP
- GetTypeSP () const
- {
- return type_sp;
- }
-
- CompilerType
- GetCompilerType () const
- {
- return compiler_type;
- }
-
- CompilerType
- GetPointerType () const
- {
- if (type_sp)
- return type_sp->GetForwardCompilerType().GetPointerType();
- return compiler_type.GetPointerType();
- }
-
- CompilerType
- GetPointeeType () const
- {
- if (type_sp)
- return type_sp->GetForwardCompilerType ().GetPointeeType();
- return compiler_type.GetPointeeType();
- }
-
- CompilerType
- GetReferenceType () const
- {
- if (type_sp)
- return type_sp->GetForwardCompilerType ().GetLValueReferenceType();
- else
- return compiler_type.GetLValueReferenceType();
- }
-
- CompilerType
- GetTypedefedType () const
- {
- if (type_sp)
- return type_sp->GetForwardCompilerType ().GetTypedefedType();
- else
- return compiler_type.GetTypedefedType();
- }
-
- CompilerType
- GetDereferencedType () const
- {
- if (type_sp)
- return type_sp->GetForwardCompilerType ().GetNonReferenceType();
- else
- return compiler_type.GetNonReferenceType();
- }
-
- CompilerType
- GetUnqualifiedType () const
- {
- if (type_sp)
- return type_sp->GetForwardCompilerType ().GetFullyUnqualifiedType();
- else
- return compiler_type.GetFullyUnqualifiedType();
- }
-
- CompilerType
- GetCanonicalType () const
- {
- if (type_sp)
- return type_sp->GetForwardCompilerType ().GetCanonicalType();
- return compiler_type.GetCanonicalType();
- }
-
- TypeSystem *
- GetTypeSystem () const
- {
- return compiler_type.GetTypeSystem();
- }
-
- lldb::ModuleSP
- GetModule () const
- {
- if (type_sp)
- return type_sp->GetModule();
- return lldb::ModuleSP();
- }
+ TypePair() : compiler_type(), type_sp() {}
+
+ TypePair(CompilerType type) : compiler_type(type), type_sp() {}
+
+ TypePair(lldb::TypeSP type) : compiler_type(), type_sp(type) {
+ compiler_type = type_sp->GetForwardCompilerType();
+ }
+
+ bool IsValid() const {
+ return compiler_type.IsValid() || (type_sp.get() != nullptr);
+ }
+
+ explicit operator bool() const { return IsValid(); }
+
+ bool operator==(const TypePair &rhs) const {
+ return compiler_type == rhs.compiler_type &&
+ type_sp.get() == rhs.type_sp.get();
+ }
+
+ bool operator!=(const TypePair &rhs) const {
+ return compiler_type != rhs.compiler_type ||
+ type_sp.get() != rhs.type_sp.get();
+ }
+
+ void Clear() {
+ compiler_type.Clear();
+ type_sp.reset();
+ }
+
+ ConstString GetName() const {
+ if (type_sp)
+ return type_sp->GetName();
+ if (compiler_type)
+ return compiler_type.GetTypeName();
+ return ConstString();
+ }
+
+ ConstString GetDisplayTypeName() const {
+ if (type_sp)
+ return type_sp->GetForwardCompilerType().GetDisplayTypeName();
+ if (compiler_type)
+ return compiler_type.GetDisplayTypeName();
+ return ConstString();
+ }
+
+ void SetType(CompilerType type) {
+ type_sp.reset();
+ compiler_type = type;
+ }
+
+ void SetType(lldb::TypeSP type) {
+ type_sp = type;
+ if (type_sp)
+ compiler_type = type_sp->GetForwardCompilerType();
+ else
+ compiler_type.Clear();
+ }
+
+ lldb::TypeSP GetTypeSP() const { return type_sp; }
+
+ CompilerType GetCompilerType() const { return compiler_type; }
+
+ CompilerType GetPointerType() const {
+ if (type_sp)
+ return type_sp->GetForwardCompilerType().GetPointerType();
+ return compiler_type.GetPointerType();
+ }
+
+ CompilerType GetPointeeType() const {
+ if (type_sp)
+ return type_sp->GetForwardCompilerType().GetPointeeType();
+ return compiler_type.GetPointeeType();
+ }
+
+ CompilerType GetReferenceType() const {
+ if (type_sp)
+ return type_sp->GetForwardCompilerType().GetLValueReferenceType();
+ else
+ return compiler_type.GetLValueReferenceType();
+ }
+
+ CompilerType GetTypedefedType() const {
+ if (type_sp)
+ return type_sp->GetForwardCompilerType().GetTypedefedType();
+ else
+ return compiler_type.GetTypedefedType();
+ }
+
+ CompilerType GetDereferencedType() const {
+ if (type_sp)
+ return type_sp->GetForwardCompilerType().GetNonReferenceType();
+ else
+ return compiler_type.GetNonReferenceType();
+ }
+
+ CompilerType GetUnqualifiedType() const {
+ if (type_sp)
+ return type_sp->GetForwardCompilerType().GetFullyUnqualifiedType();
+ else
+ return compiler_type.GetFullyUnqualifiedType();
+ }
+
+ CompilerType GetCanonicalType() const {
+ if (type_sp)
+ return type_sp->GetForwardCompilerType().GetCanonicalType();
+ return compiler_type.GetCanonicalType();
+ }
+
+ TypeSystem *GetTypeSystem() const { return compiler_type.GetTypeSystem(); }
+
+ lldb::ModuleSP GetModule() const {
+ if (type_sp)
+ return type_sp->GetModule();
+ return lldb::ModuleSP();
+ }
+
protected:
- CompilerType compiler_type;
- lldb::TypeSP type_sp;
+ CompilerType compiler_type;
+ lldb::TypeSP type_sp;
};
-
+
// the two classes here are used by the public API as a backend to
// the SBType and SBTypeList classes
-
-class TypeImpl
-{
+
+class TypeImpl {
public:
-
- TypeImpl();
-
- ~TypeImpl () {}
-
- TypeImpl(const TypeImpl& rhs);
-
- TypeImpl (const lldb::TypeSP &type_sp);
-
- TypeImpl (const CompilerType &compiler_type);
-
- TypeImpl (const lldb::TypeSP &type_sp, const CompilerType &dynamic);
-
- TypeImpl (const CompilerType &compiler_type, const CompilerType &dynamic);
-
- TypeImpl (const TypePair &pair, const CompilerType &dynamic);
-
- void
- SetType (const lldb::TypeSP &type_sp);
-
- void
- SetType (const CompilerType &compiler_type);
-
- void
- SetType (const lldb::TypeSP &type_sp, const CompilerType &dynamic);
-
- void
- SetType (const CompilerType &compiler_type, const CompilerType &dynamic);
-
- void
- SetType (const TypePair &pair, const CompilerType &dynamic);
-
- TypeImpl&
- operator = (const TypeImpl& rhs);
-
- bool
- operator == (const TypeImpl& rhs) const;
-
- bool
- operator != (const TypeImpl& rhs) const;
-
- bool
- IsValid() const;
-
- explicit operator bool () const;
-
- void Clear();
-
- ConstString
- GetName () const;
-
- ConstString
- GetDisplayTypeName () const;
-
- TypeImpl
- GetPointerType () const;
-
- TypeImpl
- GetPointeeType () const;
-
- TypeImpl
- GetReferenceType () const;
-
- TypeImpl
- GetTypedefedType () const;
-
- TypeImpl
- GetDereferencedType () const;
-
- TypeImpl
- GetUnqualifiedType() const;
-
- TypeImpl
- GetCanonicalType() const;
-
- CompilerType
- GetCompilerType (bool prefer_dynamic);
-
- TypeSystem *
- GetTypeSystem (bool prefer_dynamic);
-
- bool
- GetDescription (lldb_private::Stream &strm,
- lldb::DescriptionLevel description_level);
-
+ TypeImpl();
+
+ ~TypeImpl() {}
+
+ TypeImpl(const TypeImpl &rhs);
+
+ TypeImpl(const lldb::TypeSP &type_sp);
+
+ TypeImpl(const CompilerType &compiler_type);
+
+ TypeImpl(const lldb::TypeSP &type_sp, const CompilerType &dynamic);
+
+ TypeImpl(const CompilerType &compiler_type, const CompilerType &dynamic);
+
+ TypeImpl(const TypePair &pair, const CompilerType &dynamic);
+
+ void SetType(const lldb::TypeSP &type_sp);
+
+ void SetType(const CompilerType &compiler_type);
+
+ void SetType(const lldb::TypeSP &type_sp, const CompilerType &dynamic);
+
+ void SetType(const CompilerType &compiler_type, const CompilerType &dynamic);
+
+ void SetType(const TypePair &pair, const CompilerType &dynamic);
+
+ TypeImpl &operator=(const TypeImpl &rhs);
+
+ bool operator==(const TypeImpl &rhs) const;
+
+ bool operator!=(const TypeImpl &rhs) const;
+
+ bool IsValid() const;
+
+ explicit operator bool() const;
+
+ void Clear();
+
+ ConstString GetName() const;
+
+ ConstString GetDisplayTypeName() const;
+
+ TypeImpl GetPointerType() const;
+
+ TypeImpl GetPointeeType() const;
+
+ TypeImpl GetReferenceType() const;
+
+ TypeImpl GetTypedefedType() const;
+
+ TypeImpl GetDereferencedType() const;
+
+ TypeImpl GetUnqualifiedType() const;
+
+ TypeImpl GetCanonicalType() const;
+
+ CompilerType GetCompilerType(bool prefer_dynamic);
+
+ TypeSystem *GetTypeSystem(bool prefer_dynamic);
+
+ bool GetDescription(lldb_private::Stream &strm,
+ lldb::DescriptionLevel description_level);
+
private:
-
- bool
- CheckModule (lldb::ModuleSP &module_sp) const;
+ bool CheckModule(lldb::ModuleSP &module_sp) const;
- lldb::ModuleWP m_module_wp;
- TypePair m_static_type;
- CompilerType m_dynamic_type;
+ lldb::ModuleWP m_module_wp;
+ TypePair m_static_type;
+ CompilerType m_dynamic_type;
};
-class TypeListImpl
-{
+class TypeListImpl {
public:
- TypeListImpl() :
- m_content()
- {
- }
-
- void
- Append (const lldb::TypeImplSP& type)
- {
- m_content.push_back(type);
- }
-
- class AppendVisitor
- {
- public:
- AppendVisitor(TypeListImpl &type_list) :
- m_type_list(type_list)
- {
- }
-
- void
- operator() (const lldb::TypeImplSP& type)
- {
- m_type_list.Append(type);
- }
-
- private:
- TypeListImpl &m_type_list;
- };
-
- void
- Append (const lldb_private::TypeList &type_list);
-
- lldb::TypeImplSP
- GetTypeAtIndex(size_t idx)
- {
- lldb::TypeImplSP type_sp;
- if (idx < GetSize())
- type_sp = m_content[idx];
- return type_sp;
- }
-
- size_t
- GetSize()
- {
- return m_content.size();
- }
-
+ TypeListImpl() : m_content() {}
+
+ void Append(const lldb::TypeImplSP &type) { m_content.push_back(type); }
+
+ class AppendVisitor {
+ public:
+ AppendVisitor(TypeListImpl &type_list) : m_type_list(type_list) {}
+
+ void operator()(const lldb::TypeImplSP &type) { m_type_list.Append(type); }
+
+ private:
+ TypeListImpl &m_type_list;
+ };
+
+ void Append(const lldb_private::TypeList &type_list);
+
+ lldb::TypeImplSP GetTypeAtIndex(size_t idx) {
+ lldb::TypeImplSP type_sp;
+ if (idx < GetSize())
+ type_sp = m_content[idx];
+ return type_sp;
+ }
+
+ size_t GetSize() { return m_content.size(); }
+
private:
- std::vector<lldb::TypeImplSP> m_content;
+ std::vector<lldb::TypeImplSP> m_content;
};
-
-class TypeMemberImpl
-{
+
+class TypeMemberImpl {
public:
- TypeMemberImpl () :
- m_type_impl_sp (),
- m_bit_offset (0),
- m_name (),
- m_bitfield_bit_size (0),
- m_is_bitfield (false)
-
- {
- }
-
- TypeMemberImpl (const lldb::TypeImplSP &type_impl_sp,
- uint64_t bit_offset,
- const ConstString &name,
- uint32_t bitfield_bit_size = 0,
- bool is_bitfield = false) :
- m_type_impl_sp (type_impl_sp),
- m_bit_offset (bit_offset),
- m_name (name),
- m_bitfield_bit_size (bitfield_bit_size),
- m_is_bitfield (is_bitfield)
- {
- }
-
- TypeMemberImpl (const lldb::TypeImplSP &type_impl_sp,
- uint64_t bit_offset):
- m_type_impl_sp (type_impl_sp),
- m_bit_offset (bit_offset),
- m_name (),
- m_bitfield_bit_size (0),
- m_is_bitfield (false)
- {
- if (m_type_impl_sp)
- m_name = m_type_impl_sp->GetName();
- }
-
- const lldb::TypeImplSP &
- GetTypeImpl ()
- {
- return m_type_impl_sp;
- }
-
- const ConstString &
- GetName () const
- {
- return m_name;
- }
-
- uint64_t
- GetBitOffset () const
- {
- return m_bit_offset;
- }
-
- uint32_t
- GetBitfieldBitSize () const
- {
- return m_bitfield_bit_size;
- }
-
- void
- SetBitfieldBitSize (uint32_t bitfield_bit_size)
- {
- m_bitfield_bit_size = bitfield_bit_size;
- }
-
- bool
- GetIsBitfield () const
- {
- return m_is_bitfield;
- }
-
- void
- SetIsBitfield (bool is_bitfield)
- {
- m_is_bitfield = is_bitfield;
- }
+ TypeMemberImpl()
+ : m_type_impl_sp(), m_bit_offset(0), m_name(), m_bitfield_bit_size(0),
+ m_is_bitfield(false)
+
+ {}
+
+ TypeMemberImpl(const lldb::TypeImplSP &type_impl_sp, uint64_t bit_offset,
+ const ConstString &name, uint32_t bitfield_bit_size = 0,
+ bool is_bitfield = false)
+ : m_type_impl_sp(type_impl_sp), m_bit_offset(bit_offset), m_name(name),
+ m_bitfield_bit_size(bitfield_bit_size), m_is_bitfield(is_bitfield) {}
+
+ TypeMemberImpl(const lldb::TypeImplSP &type_impl_sp, uint64_t bit_offset)
+ : m_type_impl_sp(type_impl_sp), m_bit_offset(bit_offset), m_name(),
+ m_bitfield_bit_size(0), m_is_bitfield(false) {
+ if (m_type_impl_sp)
+ m_name = m_type_impl_sp->GetName();
+ }
+
+ const lldb::TypeImplSP &GetTypeImpl() { return m_type_impl_sp; }
+
+ const ConstString &GetName() const { return m_name; }
+
+ uint64_t GetBitOffset() const { return m_bit_offset; }
+
+ uint32_t GetBitfieldBitSize() const { return m_bitfield_bit_size; }
+
+ void SetBitfieldBitSize(uint32_t bitfield_bit_size) {
+ m_bitfield_bit_size = bitfield_bit_size;
+ }
+
+ bool GetIsBitfield() const { return m_is_bitfield; }
+
+ void SetIsBitfield(bool is_bitfield) { m_is_bitfield = is_bitfield; }
protected:
- lldb::TypeImplSP m_type_impl_sp;
- uint64_t m_bit_offset;
- ConstString m_name;
- uint32_t m_bitfield_bit_size; // Bit size for bitfield members only
- bool m_is_bitfield;
+ lldb::TypeImplSP m_type_impl_sp;
+ uint64_t m_bit_offset;
+ ConstString m_name;
+ uint32_t m_bitfield_bit_size; // Bit size for bitfield members only
+ bool m_is_bitfield;
};
-
///
-/// Sometimes you can find the name of the type corresponding to an object, but we don't have debug
-/// information for it. If that is the case, you can return one of these objects, and then if it
-/// has a full type, you can use that, but if not at least you can print the name for informational
+/// Sometimes you can find the name of the type corresponding to an object, but
+/// we don't have debug
+/// information for it. If that is the case, you can return one of these
+/// objects, and then if it
+/// has a full type, you can use that, but if not at least you can print the
+/// name for informational
/// purposes.
///
-class TypeAndOrName
-{
+class TypeAndOrName {
public:
- TypeAndOrName ();
- TypeAndOrName (lldb::TypeSP &type_sp);
- TypeAndOrName (const CompilerType &compiler_type);
- TypeAndOrName (const char *type_str);
- TypeAndOrName (const TypeAndOrName &rhs);
- TypeAndOrName (ConstString &type_const_string);
-
- TypeAndOrName &
- operator= (const TypeAndOrName &rhs);
-
- bool
- operator==(const TypeAndOrName &other) const;
-
- bool
- operator!=(const TypeAndOrName &other) const;
-
- ConstString GetName () const;
-
- lldb::TypeSP
- GetTypeSP () const
- {
- return m_type_pair.GetTypeSP();
- }
-
- CompilerType
- GetCompilerType () const
- {
- return m_type_pair.GetCompilerType();
- }
-
- void
- SetName (const ConstString &type_name);
-
- void
- SetName (const char *type_name_cstr);
-
- void
- SetTypeSP (lldb::TypeSP type_sp);
-
- void
- SetCompilerType (CompilerType compiler_type);
-
- bool
- IsEmpty () const;
-
- bool
- HasName () const;
-
- bool
- HasTypeSP () const;
-
- bool
- HasCompilerType () const;
-
- bool
- HasType () const
- {
- return HasTypeSP() || HasCompilerType();
- }
-
- void
- Clear ();
-
- explicit operator bool ()
- {
- return !IsEmpty();
- }
-
+ TypeAndOrName();
+ TypeAndOrName(lldb::TypeSP &type_sp);
+ TypeAndOrName(const CompilerType &compiler_type);
+ TypeAndOrName(const char *type_str);
+ TypeAndOrName(const TypeAndOrName &rhs);
+ TypeAndOrName(ConstString &type_const_string);
+
+ TypeAndOrName &operator=(const TypeAndOrName &rhs);
+
+ bool operator==(const TypeAndOrName &other) const;
+
+ bool operator!=(const TypeAndOrName &other) const;
+
+ ConstString GetName() const;
+
+ lldb::TypeSP GetTypeSP() const { return m_type_pair.GetTypeSP(); }
+
+ CompilerType GetCompilerType() const { return m_type_pair.GetCompilerType(); }
+
+ void SetName(const ConstString &type_name);
+
+ void SetName(const char *type_name_cstr);
+
+ void SetTypeSP(lldb::TypeSP type_sp);
+
+ void SetCompilerType(CompilerType compiler_type);
+
+ bool IsEmpty() const;
+
+ bool HasName() const;
+
+ bool HasTypeSP() const;
+
+ bool HasCompilerType() const;
+
+ bool HasType() const { return HasTypeSP() || HasCompilerType(); }
+
+ void Clear();
+
+ explicit operator bool() { return !IsEmpty(); }
+
private:
- TypePair m_type_pair;
- ConstString m_type_name;
+ TypePair m_type_pair;
+ ConstString m_type_name;
};
-
-class TypeMemberFunctionImpl
-{
+
+class TypeMemberFunctionImpl {
public:
- TypeMemberFunctionImpl() :
- m_type (),
- m_decl (),
- m_name(),
- m_kind (lldb::eMemberFunctionKindUnknown)
- {
- }
-
- TypeMemberFunctionImpl (const CompilerType& type,
- const CompilerDecl& decl,
- const std::string& name,
- const lldb::MemberFunctionKind& kind) :
- m_type (type),
- m_decl (decl),
- m_name(name),
- m_kind (kind)
- {
- }
-
- bool
- IsValid ();
-
- ConstString
- GetName () const;
-
- ConstString
- GetMangledName () const;
-
- CompilerType
- GetType () const;
-
- CompilerType
- GetReturnType () const;
-
- size_t
- GetNumArguments () const;
-
- CompilerType
- GetArgumentAtIndex (size_t idx) const;
-
- lldb::MemberFunctionKind
- GetKind () const;
-
- bool
- GetDescription (Stream& stream);
-
+ TypeMemberFunctionImpl()
+ : m_type(), m_decl(), m_name(), m_kind(lldb::eMemberFunctionKindUnknown) {
+ }
+
+ TypeMemberFunctionImpl(const CompilerType &type, const CompilerDecl &decl,
+ const std::string &name,
+ const lldb::MemberFunctionKind &kind)
+ : m_type(type), m_decl(decl), m_name(name), m_kind(kind) {}
+
+ bool IsValid();
+
+ ConstString GetName() const;
+
+ ConstString GetMangledName() const;
+
+ CompilerType GetType() const;
+
+ CompilerType GetReturnType() const;
+
+ size_t GetNumArguments() const;
+
+ CompilerType GetArgumentAtIndex(size_t idx) const;
+
+ lldb::MemberFunctionKind GetKind() const;
+
+ bool GetDescription(Stream &stream);
+
protected:
- std::string
- GetPrintableTypeName ();
+ std::string GetPrintableTypeName();
private:
- CompilerType m_type;
- CompilerDecl m_decl;
- ConstString m_name;
- lldb::MemberFunctionKind m_kind;
+ CompilerType m_type;
+ CompilerDecl m_decl;
+ ConstString m_name;
+ lldb::MemberFunctionKind m_kind;
};
-class TypeEnumMemberImpl
-{
+class TypeEnumMemberImpl {
public:
- TypeEnumMemberImpl () :
- m_integer_type_sp(),
- m_name("<invalid>"),
- m_value(),
- m_valid(false)
- {
- }
-
- TypeEnumMemberImpl (const lldb::TypeImplSP &integer_type_sp,
- const ConstString &name,
- const llvm::APSInt &value);
-
- TypeEnumMemberImpl (const TypeEnumMemberImpl& rhs) :
- m_integer_type_sp(rhs.m_integer_type_sp),
- m_name(rhs.m_name),
- m_value(rhs.m_value),
- m_valid(rhs.m_valid)
- {
- }
-
- TypeEnumMemberImpl&
- operator = (const TypeEnumMemberImpl& rhs);
-
- bool
- IsValid ()
- {
- return m_valid;
- }
-
- const ConstString &
- GetName () const
- {
- return m_name;
- }
-
- const lldb::TypeImplSP &
- GetIntegerType () const
- {
- return m_integer_type_sp;
- }
-
- uint64_t
- GetValueAsUnsigned () const
- {
- return m_value.getZExtValue();
- }
-
- int64_t
- GetValueAsSigned () const
- {
- return m_value.getSExtValue();
- }
+ TypeEnumMemberImpl()
+ : m_integer_type_sp(), m_name("<invalid>"), m_value(), m_valid(false) {}
+
+ TypeEnumMemberImpl(const lldb::TypeImplSP &integer_type_sp,
+ const ConstString &name, const llvm::APSInt &value);
+
+ TypeEnumMemberImpl(const TypeEnumMemberImpl &rhs)
+ : m_integer_type_sp(rhs.m_integer_type_sp), m_name(rhs.m_name),
+ m_value(rhs.m_value), m_valid(rhs.m_valid) {}
+
+ TypeEnumMemberImpl &operator=(const TypeEnumMemberImpl &rhs);
+
+ bool IsValid() { return m_valid; }
+
+ const ConstString &GetName() const { return m_name; }
+
+ const lldb::TypeImplSP &GetIntegerType() const { return m_integer_type_sp; }
+
+ uint64_t GetValueAsUnsigned() const { return m_value.getZExtValue(); }
+
+ int64_t GetValueAsSigned() const { return m_value.getSExtValue(); }
protected:
- lldb::TypeImplSP m_integer_type_sp;
- ConstString m_name;
- llvm::APSInt m_value;
- bool m_valid;
+ lldb::TypeImplSP m_integer_type_sp;
+ ConstString m_name;
+ llvm::APSInt m_value;
+ bool m_valid;
};
-class TypeEnumMemberListImpl
-{
+class TypeEnumMemberListImpl {
public:
- TypeEnumMemberListImpl() :
- m_content()
- {
- }
-
- void
- Append (const lldb::TypeEnumMemberImplSP& type)
- {
- m_content.push_back(type);
- }
-
- void
- Append (const lldb_private::TypeEnumMemberListImpl& type_list);
-
- lldb::TypeEnumMemberImplSP
- GetTypeEnumMemberAtIndex(size_t idx)
- {
- lldb::TypeEnumMemberImplSP enum_member;
- if (idx < GetSize())
- enum_member = m_content[idx];
- return enum_member;
- }
-
- size_t
- GetSize()
- {
- return m_content.size();
- }
+ TypeEnumMemberListImpl() : m_content() {}
+
+ void Append(const lldb::TypeEnumMemberImplSP &type) {
+ m_content.push_back(type);
+ }
+
+ void Append(const lldb_private::TypeEnumMemberListImpl &type_list);
+
+ lldb::TypeEnumMemberImplSP GetTypeEnumMemberAtIndex(size_t idx) {
+ lldb::TypeEnumMemberImplSP enum_member;
+ if (idx < GetSize())
+ enum_member = m_content[idx];
+ return enum_member;
+ }
+
+ size_t GetSize() { return m_content.size(); }
private:
- std::vector<lldb::TypeEnumMemberImplSP> m_content;
+ std::vector<lldb::TypeEnumMemberImplSP> m_content;
};
} // namespace lldb_private
-#endif // liblldb_Type_h_
-
+#endif // liblldb_Type_h_
diff --git a/include/lldb/Symbol/TypeList.h b/include/lldb/Symbol/TypeList.h
index f3642576ddcb..b6a4e41ff301 100644
--- a/include/lldb/Symbol/TypeList.h
+++ b/include/lldb/Symbol/TypeList.h
@@ -10,84 +10,66 @@
#ifndef liblldb_TypeList_h_
#define liblldb_TypeList_h_
-#include "lldb/lldb-private.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Utility/Iterable.h"
-#include <vector>
+#include "lldb/lldb-private.h"
#include <functional>
+#include <vector>
namespace lldb_private {
-class TypeList
-{
+class TypeList {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- TypeList();
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ TypeList();
+
+ virtual ~TypeList();
- virtual
- ~TypeList();
+ void Clear();
- void
- Clear();
+ void Dump(Stream *s, bool show_context);
- void
- Dump(Stream *s, bool show_context);
+ // lldb::TypeSP
+ // FindType(lldb::user_id_t uid);
-// lldb::TypeSP
-// FindType(lldb::user_id_t uid);
+ TypeList FindTypes(const ConstString &name);
- TypeList
- FindTypes(const ConstString &name);
+ void Insert(const lldb::TypeSP &type);
- void
- Insert (const lldb::TypeSP& type);
+ uint32_t GetSize() const;
- uint32_t
- GetSize() const;
+ lldb::TypeSP GetTypeAtIndex(uint32_t idx);
- lldb::TypeSP
- GetTypeAtIndex(uint32_t idx);
-
- typedef std::vector<lldb::TypeSP> collection;
- typedef AdaptedIterable<collection, lldb::TypeSP, vector_adapter> TypeIterable;
-
- TypeIterable
- Types ()
- {
- return TypeIterable(m_types);
- }
+ typedef std::vector<lldb::TypeSP> collection;
+ typedef AdaptedIterable<collection, lldb::TypeSP, vector_adapter>
+ TypeIterable;
- void
- ForEach (std::function <bool(const lldb::TypeSP &type_sp)> const &callback) const;
+ TypeIterable Types() { return TypeIterable(m_types); }
- void
- ForEach (std::function <bool(lldb::TypeSP &type_sp)> const &callback);
+ void ForEach(
+ std::function<bool(const lldb::TypeSP &type_sp)> const &callback) const;
+ void ForEach(std::function<bool(lldb::TypeSP &type_sp)> const &callback);
- void
- RemoveMismatchedTypes (const char *qualified_typename,
- bool exact_match);
+ void RemoveMismatchedTypes(const char *qualified_typename, bool exact_match);
- void
- RemoveMismatchedTypes (const std::string &type_scope,
- const std::string &type_basename,
- lldb::TypeClass type_class,
- bool exact_match);
+ void RemoveMismatchedTypes(const std::string &type_scope,
+ const std::string &type_basename,
+ lldb::TypeClass type_class, bool exact_match);
- void
- RemoveMismatchedTypes (lldb::TypeClass type_class);
+ void RemoveMismatchedTypes(lldb::TypeClass type_class);
private:
- typedef collection::iterator iterator;
- typedef collection::const_iterator const_iterator;
+ typedef collection::iterator iterator;
+ typedef collection::const_iterator const_iterator;
- collection m_types;
+ collection m_types;
- DISALLOW_COPY_AND_ASSIGN (TypeList);
+ DISALLOW_COPY_AND_ASSIGN(TypeList);
};
} // namespace lldb_private
-#endif // liblldb_TypeList_h_
+#endif // liblldb_TypeList_h_
diff --git a/include/lldb/Symbol/TypeMap.h b/include/lldb/Symbol/TypeMap.h
index 4398acd789ae..6bf9831c1389 100644
--- a/include/lldb/Symbol/TypeMap.h
+++ b/include/lldb/Symbol/TypeMap.h
@@ -10,89 +10,68 @@
#ifndef liblldb_TypeMap_h_
#define liblldb_TypeMap_h_
-#include "lldb/lldb-private.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Utility/Iterable.h"
-#include <map>
+#include "lldb/lldb-private.h"
#include <functional>
+#include <map>
namespace lldb_private {
-class TypeMap
-{
+class TypeMap {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- TypeMap();
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ TypeMap();
+
+ virtual ~TypeMap();
+
+ void Clear();
- virtual
- ~TypeMap();
+ void Dump(Stream *s, bool show_context);
- void
- Clear();
+ TypeMap FindTypes(const ConstString &name);
- void
- Dump(Stream *s, bool show_context);
+ void Insert(const lldb::TypeSP &type);
- TypeMap
- FindTypes(const ConstString &name);
+ bool Empty() const;
- void
- Insert (const lldb::TypeSP& type);
+ bool InsertUnique(const lldb::TypeSP &type);
- bool
- Empty() const;
+ uint32_t GetSize() const;
- bool
- InsertUnique (const lldb::TypeSP& type);
+ lldb::TypeSP GetTypeAtIndex(uint32_t idx);
- uint32_t
- GetSize() const;
+ typedef std::multimap<lldb::user_id_t, lldb::TypeSP> collection;
+ typedef AdaptedIterable<collection, lldb::TypeSP, map_adapter> TypeIterable;
- lldb::TypeSP
- GetTypeAtIndex(uint32_t idx);
-
- typedef std::multimap<lldb::user_id_t, lldb::TypeSP> collection;
- typedef AdaptedIterable<collection, lldb::TypeSP, map_adapter> TypeIterable;
-
- TypeIterable
- Types ()
- {
- return TypeIterable(m_types);
- }
+ TypeIterable Types() { return TypeIterable(m_types); }
- void
- ForEach (std::function <bool(const lldb::TypeSP &type_sp)> const &callback) const;
+ void ForEach(
+ std::function<bool(const lldb::TypeSP &type_sp)> const &callback) const;
- void
- ForEach (std::function <bool(lldb::TypeSP &type_sp)> const &callback);
+ void ForEach(std::function<bool(lldb::TypeSP &type_sp)> const &callback);
- bool
- Remove (const lldb::TypeSP &type_sp);
+ bool Remove(const lldb::TypeSP &type_sp);
- void
- RemoveMismatchedTypes (const char *qualified_typename,
- bool exact_match);
+ void RemoveMismatchedTypes(const char *qualified_typename, bool exact_match);
- void
- RemoveMismatchedTypes (const std::string &type_scope,
- const std::string &type_basename,
- lldb::TypeClass type_class,
- bool exact_match);
+ void RemoveMismatchedTypes(const std::string &type_scope,
+ const std::string &type_basename,
+ lldb::TypeClass type_class, bool exact_match);
- void
- RemoveMismatchedTypes (lldb::TypeClass type_class);
+ void RemoveMismatchedTypes(lldb::TypeClass type_class);
private:
- typedef collection::iterator iterator;
- typedef collection::const_iterator const_iterator;
+ typedef collection::iterator iterator;
+ typedef collection::const_iterator const_iterator;
- collection m_types;
+ collection m_types;
- DISALLOW_COPY_AND_ASSIGN (TypeMap);
+ DISALLOW_COPY_AND_ASSIGN(TypeMap);
};
} // namespace lldb_private
-#endif // liblldb_TypeMap_h_
+#endif // liblldb_TypeMap_h_
diff --git a/include/lldb/Symbol/TypeSystem.h b/include/lldb/Symbol/TypeSystem.h
index 466699366f0a..b4f84c0dd67c 100644
--- a/include/lldb/Symbol/TypeSystem.h
+++ b/include/lldb/Symbol/TypeSystem.h
@@ -22,606 +22,517 @@
#include "llvm/Support/Casting.h"
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Expression/Expression.h"
#include "lldb/Symbol/CompilerDecl.h"
#include "lldb/Symbol/CompilerDeclContext.h"
+#include "lldb/lldb-private.h"
class DWARFDIE;
class DWARFASTParser;
namespace lldb_private {
-
+
//----------------------------------------------------------------------
// Interface for representing the Type Systems in different languages.
//----------------------------------------------------------------------
-class TypeSystem : public PluginInterface
-{
+class TypeSystem : public PluginInterface {
public:
- //----------------------------------------------------------------------
- // Intrusive type system that allows us to use llvm casting.
- //
- // To add a new type system:
- //
- // 1 - Add a new enumeration for llvm casting below for your TypeSystem
- // subclass, here we will use eKindFoo
- //
- // 2 - Your TypeSystem subclass will inherit from TypeSystem and needs
- // to implement a static classof() function that returns your
- // enumeration:
- //
- // class Foo : public lldb_private::TypeSystem
- // {
- // static bool classof(const TypeSystem *ts)
- // {
- // return ts->getKind() == TypeSystem::eKindFoo;
- // }
- // };
- //
- // 3 - Contruct your TypeSystem subclass with the enumeration from below
- //
- // Foo() :
- // TypeSystem(TypeSystem::eKindFoo),
- // ...
- // {
- // }
- //
- // Then you can use the llvm casting on any "TypeSystem *" to get an
- // instance of your subclass.
- //----------------------------------------------------------------------
- enum LLVMCastKind {
- eKindClang,
- eKindSwift,
- eKindGo,
- eKindJava,
- kNumKinds
- };
-
- //----------------------------------------------------------------------
- // Constructors and Destructors
- //----------------------------------------------------------------------
- TypeSystem(LLVMCastKind kind);
-
- ~TypeSystem() override;
-
- LLVMCastKind getKind() const { return m_kind; }
-
- static lldb::TypeSystemSP
- CreateInstance (lldb::LanguageType language, Module *module);
-
- static lldb::TypeSystemSP
- CreateInstance (lldb::LanguageType language, Target *target);
-
-
- // Free up any resources associated with this TypeSystem. Done before removing
- // all the TypeSystems from the TypeSystemMap.
- virtual void
- Finalize() {}
-
- virtual DWARFASTParser *
- GetDWARFParser()
- {
- return nullptr;
- }
-
- virtual SymbolFile *
- GetSymbolFile () const
- {
- return m_sym_file;
- }
-
- // Returns true if the symbol file changed during the set accessor.
- virtual void
- SetSymbolFile (SymbolFile *sym_file)
- {
- m_sym_file = sym_file;
- }
-
- //----------------------------------------------------------------------
- // CompilerDecl functions
- //----------------------------------------------------------------------
- virtual ConstString
- DeclGetName (void *opaque_decl) = 0;
-
- virtual ConstString
- DeclGetMangledName (void *opaque_decl);
-
- virtual CompilerDeclContext
- DeclGetDeclContext (void *opaque_decl);
-
- virtual CompilerType
- DeclGetFunctionReturnType(void *opaque_decl);
-
- virtual size_t
- DeclGetFunctionNumArguments(void *opaque_decl);
-
- virtual CompilerType
- DeclGetFunctionArgumentType (void *opaque_decl, size_t arg_idx);
-
- //----------------------------------------------------------------------
- // CompilerDeclContext functions
- //----------------------------------------------------------------------
-
- virtual std::vector<CompilerDecl>
- DeclContextFindDeclByName (void *opaque_decl_ctx,
- ConstString name,
- const bool ignore_imported_decls);
-
- virtual bool
- DeclContextIsStructUnionOrClass (void *opaque_decl_ctx) = 0;
-
- virtual ConstString
- DeclContextGetName (void *opaque_decl_ctx) = 0;
-
- virtual ConstString
- DeclContextGetScopeQualifiedName (void *opaque_decl_ctx) = 0;
-
- virtual bool
- DeclContextIsClassMethod (void *opaque_decl_ctx,
- lldb::LanguageType *language_ptr,
- bool *is_instance_method_ptr,
- ConstString *language_object_name_ptr) = 0;
-
- //----------------------------------------------------------------------
- // Tests
- //----------------------------------------------------------------------
-
- virtual bool
- IsArrayType (lldb::opaque_compiler_type_t type,
- CompilerType *element_type,
- uint64_t *size,
- bool *is_incomplete) = 0;
-
- virtual bool
- IsAggregateType (lldb::opaque_compiler_type_t type) = 0;
-
- virtual bool
- IsAnonymousType (lldb::opaque_compiler_type_t type);
-
- virtual bool
- IsCharType (lldb::opaque_compiler_type_t type) = 0;
-
- virtual bool
- IsCompleteType (lldb::opaque_compiler_type_t type) = 0;
-
- virtual bool
- IsDefined(lldb::opaque_compiler_type_t type) = 0;
-
- virtual bool
- IsFloatingPointType (lldb::opaque_compiler_type_t type, uint32_t &count, bool &is_complex) = 0;
-
- virtual bool
- IsFunctionType (lldb::opaque_compiler_type_t type, bool *is_variadic_ptr) = 0;
-
- virtual size_t
- GetNumberOfFunctionArguments (lldb::opaque_compiler_type_t type) = 0;
-
- virtual CompilerType
- GetFunctionArgumentAtIndex (lldb::opaque_compiler_type_t type, const size_t index) = 0;
-
- virtual bool
- IsFunctionPointerType (lldb::opaque_compiler_type_t type) = 0;
-
- virtual bool
- IsBlockPointerType (lldb::opaque_compiler_type_t type, CompilerType *function_pointer_type_ptr) = 0;
-
- virtual bool
- IsIntegerType (lldb::opaque_compiler_type_t type, bool &is_signed) = 0;
-
- virtual bool
- IsEnumerationType (lldb::opaque_compiler_type_t type, bool &is_signed)
- {
- is_signed = false;
- return false;
- }
-
- virtual bool
- IsPossibleDynamicType (lldb::opaque_compiler_type_t type,
- CompilerType *target_type, // Can pass NULL
- bool check_cplusplus,
- bool check_objc) = 0;
-
- virtual bool
- IsPointerType (lldb::opaque_compiler_type_t type, CompilerType *pointee_type) = 0;
-
- virtual bool
- IsScalarType (lldb::opaque_compiler_type_t type) = 0;
-
- virtual bool
- IsVoidType (lldb::opaque_compiler_type_t type) = 0;
-
- // TypeSystems can support more than one language
- virtual bool
- SupportsLanguage (lldb::LanguageType language) = 0;
-
- //----------------------------------------------------------------------
- // Type Completion
- //----------------------------------------------------------------------
-
- virtual bool
- GetCompleteType (lldb::opaque_compiler_type_t type) = 0;
-
- //----------------------------------------------------------------------
- // AST related queries
- //----------------------------------------------------------------------
-
- virtual uint32_t
- GetPointerByteSize () = 0;
-
- //----------------------------------------------------------------------
- // Accessors
- //----------------------------------------------------------------------
-
- virtual ConstString
- GetTypeName (lldb::opaque_compiler_type_t type) = 0;
-
- virtual uint32_t
- GetTypeInfo (lldb::opaque_compiler_type_t type, CompilerType *pointee_or_element_compiler_type) = 0;
-
- virtual lldb::LanguageType
- GetMinimumLanguage (lldb::opaque_compiler_type_t type) = 0;
-
- virtual lldb::TypeClass
- GetTypeClass (lldb::opaque_compiler_type_t type) = 0;
-
- //----------------------------------------------------------------------
- // Creating related types
- //----------------------------------------------------------------------
-
- virtual CompilerType
- GetArrayElementType (lldb::opaque_compiler_type_t type, uint64_t *stride) = 0;
-
- virtual CompilerType
- GetCanonicalType (lldb::opaque_compiler_type_t type) = 0;
-
- // Returns -1 if this isn't a function of if the function doesn't have a prototype
- // Returns a value >= 0 if there is a prototype.
- virtual int
- GetFunctionArgumentCount (lldb::opaque_compiler_type_t type) = 0;
-
- virtual CompilerType
- GetFunctionArgumentTypeAtIndex (lldb::opaque_compiler_type_t type, size_t idx) = 0;
-
- virtual CompilerType
- GetFunctionReturnType (lldb::opaque_compiler_type_t type) = 0;
-
- virtual size_t
- GetNumMemberFunctions (lldb::opaque_compiler_type_t type) = 0;
-
- virtual TypeMemberFunctionImpl
- GetMemberFunctionAtIndex (lldb::opaque_compiler_type_t type, size_t idx) = 0;
-
- virtual CompilerType
- GetPointeeType (lldb::opaque_compiler_type_t type) = 0;
-
- virtual CompilerType
- GetPointerType (lldb::opaque_compiler_type_t type) = 0;
-
- virtual CompilerType
- GetLValueReferenceType (lldb::opaque_compiler_type_t type);
-
- virtual CompilerType
- GetRValueReferenceType (lldb::opaque_compiler_type_t type);
-
- virtual CompilerType
- AddConstModifier (lldb::opaque_compiler_type_t type);
-
- virtual CompilerType
- AddVolatileModifier (lldb::opaque_compiler_type_t type);
-
- virtual CompilerType
- AddRestrictModifier (lldb::opaque_compiler_type_t type);
-
- virtual CompilerType
- CreateTypedef (lldb::opaque_compiler_type_t type, const char *name, const CompilerDeclContext &decl_ctx);
-
- //----------------------------------------------------------------------
- // Exploring the type
- //----------------------------------------------------------------------
-
- virtual uint64_t
- GetBitSize (lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) = 0;
-
- virtual lldb::Encoding
- GetEncoding (lldb::opaque_compiler_type_t type, uint64_t &count) = 0;
-
- virtual lldb::Format
- GetFormat (lldb::opaque_compiler_type_t type) = 0;
-
- virtual uint32_t
- GetNumChildren (lldb::opaque_compiler_type_t type, bool omit_empty_base_classes) = 0;
-
- virtual CompilerType
- GetBuiltinTypeByName (const ConstString &name);
-
- virtual lldb::BasicType
- GetBasicTypeEnumeration (lldb::opaque_compiler_type_t type) = 0;
-
- virtual void
- ForEachEnumerator (lldb::opaque_compiler_type_t type, std::function <bool (const CompilerType &integer_type, const ConstString &name, const llvm::APSInt &value)> const &callback)
- {
- }
-
- virtual uint32_t
- GetNumFields (lldb::opaque_compiler_type_t type) = 0;
-
- virtual CompilerType
- GetFieldAtIndex (lldb::opaque_compiler_type_t type,
- size_t idx,
- std::string& name,
- uint64_t *bit_offset_ptr,
- uint32_t *bitfield_bit_size_ptr,
- bool *is_bitfield_ptr) = 0;
-
- virtual uint32_t
- GetNumDirectBaseClasses (lldb::opaque_compiler_type_t type) = 0;
-
- virtual uint32_t
- GetNumVirtualBaseClasses (lldb::opaque_compiler_type_t type) = 0;
-
- virtual CompilerType
- GetDirectBaseClassAtIndex (lldb::opaque_compiler_type_t type,
- size_t idx,
- uint32_t *bit_offset_ptr) = 0;
-
- virtual CompilerType
- GetVirtualBaseClassAtIndex (lldb::opaque_compiler_type_t type,
- size_t idx,
- uint32_t *bit_offset_ptr) = 0;
-
- virtual CompilerType
- GetChildCompilerTypeAtIndex (lldb::opaque_compiler_type_t type,
- ExecutionContext *exe_ctx,
- size_t idx,
- bool transparent_pointers,
- bool omit_empty_base_classes,
- bool ignore_array_bounds,
- std::string& child_name,
- uint32_t &child_byte_size,
- int32_t &child_byte_offset,
- uint32_t &child_bitfield_bit_size,
- uint32_t &child_bitfield_bit_offset,
- bool &child_is_base_class,
- bool &child_is_deref_of_parent,
- ValueObject *valobj,
- uint64_t &language_flags) = 0;
-
- // Lookup a child given a name. This function will match base class names
- // and member member names in "clang_type" only, not descendants.
- virtual uint32_t
- GetIndexOfChildWithName (lldb::opaque_compiler_type_t type,
- const char *name,
- bool omit_empty_base_classes) = 0;
-
- // Lookup a child member given a name. This function will match member names
- // only and will descend into "clang_type" children in search for the first
- // member in this class, or any base class that matches "name".
- // TODO: Return all matches for a given name by returning a vector<vector<uint32_t>>
- // so we catch all names that match a given child name, not just the first.
- virtual size_t
- GetIndexOfChildMemberWithName (lldb::opaque_compiler_type_t type,
- const char *name,
- bool omit_empty_base_classes,
- std::vector<uint32_t>& child_indexes) = 0;
-
- virtual size_t
- GetNumTemplateArguments (lldb::opaque_compiler_type_t type) = 0;
-
- virtual CompilerType
- GetTemplateArgument (lldb::opaque_compiler_type_t type,
- size_t idx,
- lldb::TemplateArgumentKind &kind) = 0;
-
- //----------------------------------------------------------------------
- // Dumping types
- //----------------------------------------------------------------------
-
- virtual void
- DumpValue (lldb::opaque_compiler_type_t type,
- ExecutionContext *exe_ctx,
- Stream *s,
- lldb::Format format,
- const DataExtractor &data,
- lldb::offset_t data_offset,
- size_t data_byte_size,
- uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset,
- bool show_types,
- bool show_summary,
- bool verbose,
- uint32_t depth) = 0;
-
- virtual bool
- DumpTypeValue (lldb::opaque_compiler_type_t type,
- Stream *s,
- lldb::Format format,
- const DataExtractor &data,
- lldb::offset_t data_offset,
- size_t data_byte_size,
- uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset,
- ExecutionContextScope *exe_scope) = 0;
-
- virtual void
- DumpTypeDescription (lldb::opaque_compiler_type_t type) = 0; // Dump to stdout
-
- virtual void
- DumpTypeDescription (lldb::opaque_compiler_type_t type, Stream *s) = 0;
-
- //----------------------------------------------------------------------
- // TODO: These methods appear unused. Should they be removed?
- //----------------------------------------------------------------------
-
- virtual bool
- IsRuntimeGeneratedType (lldb::opaque_compiler_type_t type) = 0;
-
- virtual void
- DumpSummary (lldb::opaque_compiler_type_t type,
- ExecutionContext *exe_ctx,
- Stream *s,
- const DataExtractor &data,
- lldb::offset_t data_offset,
- size_t data_byte_size) = 0;
-
- // Converts "s" to a floating point value and place resulting floating
- // point bytes in the "dst" buffer.
- virtual size_t
- ConvertStringToFloatValue (lldb::opaque_compiler_type_t type,
- const char *s,
- uint8_t *dst,
- size_t dst_size) = 0;
-
- //----------------------------------------------------------------------
- // TODO: Determine if these methods should move to ClangASTContext.
- //----------------------------------------------------------------------
-
- virtual bool
- IsPointerOrReferenceType (lldb::opaque_compiler_type_t type, CompilerType *pointee_type) = 0;
-
- virtual unsigned
- GetTypeQualifiers(lldb::opaque_compiler_type_t type) = 0;
-
- virtual bool
- IsCStringType (lldb::opaque_compiler_type_t type, uint32_t &length) = 0;
-
- virtual size_t
- GetTypeBitAlign (lldb::opaque_compiler_type_t type) = 0;
-
- virtual CompilerType
- GetBasicTypeFromAST (lldb::BasicType basic_type) = 0;
-
- virtual CompilerType
- GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding,
- size_t bit_size) = 0;
-
- virtual bool
- IsBeingDefined (lldb::opaque_compiler_type_t type) = 0;
-
- virtual bool
- IsConst(lldb::opaque_compiler_type_t type) = 0;
-
- virtual uint32_t
- IsHomogeneousAggregate (lldb::opaque_compiler_type_t type, CompilerType* base_type_ptr) = 0;
-
- virtual bool
- IsPolymorphicClass (lldb::opaque_compiler_type_t type) = 0;
-
- virtual bool
- IsTypedefType (lldb::opaque_compiler_type_t type) = 0;
-
- // If the current object represents a typedef type, get the underlying type
- virtual CompilerType
- GetTypedefedType (lldb::opaque_compiler_type_t type) = 0;
-
- virtual bool
- IsVectorType (lldb::opaque_compiler_type_t type,
- CompilerType *element_type,
- uint64_t *size) = 0;
-
- virtual CompilerType
- GetFullyUnqualifiedType (lldb::opaque_compiler_type_t type) = 0;
-
- virtual CompilerType
- GetNonReferenceType (lldb::opaque_compiler_type_t type) = 0;
-
- virtual bool
- IsReferenceType (lldb::opaque_compiler_type_t type, CompilerType *pointee_type, bool* is_rvalue) = 0;
-
- virtual bool
- ShouldTreatScalarValueAsAddress (lldb::opaque_compiler_type_t type)
- {
- return IsPointerOrReferenceType(type, nullptr);
- }
-
- virtual UserExpression *
- GetUserExpression (const char *expr,
- const char *expr_prefix,
- lldb::LanguageType language,
- Expression::ResultType desired_type,
- const EvaluateExpressionOptions &options)
- {
- return nullptr;
- }
-
- virtual FunctionCaller *
- GetFunctionCaller (const CompilerType &return_type,
- const Address& function_address,
- const ValueList &arg_value_list,
- const char *name)
- {
- return nullptr;
- }
-
- virtual UtilityFunction *
- GetUtilityFunction(const char *text, const char *name)
- {
- return nullptr;
- }
-
- virtual PersistentExpressionState *
- GetPersistentExpressionState()
- {
- return nullptr;
- }
-
- virtual CompilerType
- GetTypeForFormatters (void* type);
-
- virtual LazyBool
- ShouldPrintAsOneLiner (void* type, ValueObject* valobj);
-
- // Type systems can have types that are placeholder types, which are meant to indicate
- // the presence of a type, but offer no actual information about said types, and leave
- // the burden of actually figuring type information out to dynamic type resolution. For instance
- // a language with a generics system, can use placeholder types to indicate "type argument goes here",
- // without promising uniqueness of the placeholder, nor attaching any actually idenfiable information
- // to said placeholder. This API allows type systems to tell LLDB when such a type has been encountered
- // In response, the debugger can react by not using this type as a cache entry in any type-specific way
- // For instance, LLDB will currently not cache any formatters that are discovered on such a type as
- // attributable to the meaningless type itself, instead preferring to use the dynamic type
- virtual bool
- IsMeaninglessWithoutDynamicResolution (void* type);
-
-protected:
- const LLVMCastKind m_kind; // Support for llvm casting
- SymbolFile *m_sym_file;
+ //----------------------------------------------------------------------
+ // Intrusive type system that allows us to use llvm casting.
+ //
+ // To add a new type system:
+ //
+ // 1 - Add a new enumeration for llvm casting below for your TypeSystem
+ // subclass, here we will use eKindFoo
+ //
+ // 2 - Your TypeSystem subclass will inherit from TypeSystem and needs
+ // to implement a static classof() function that returns your
+ // enumeration:
+ //
+ // class Foo : public lldb_private::TypeSystem
+ // {
+ // static bool classof(const TypeSystem *ts)
+ // {
+ // return ts->getKind() == TypeSystem::eKindFoo;
+ // }
+ // };
+ //
+ // 3 - Contruct your TypeSystem subclass with the enumeration from below
+ //
+ // Foo() :
+ // TypeSystem(TypeSystem::eKindFoo),
+ // ...
+ // {
+ // }
+ //
+ // Then you can use the llvm casting on any "TypeSystem *" to get an
+ // instance of your subclass.
+ //----------------------------------------------------------------------
+ enum LLVMCastKind {
+ eKindClang,
+ eKindSwift,
+ eKindGo,
+ eKindJava,
+ eKindOCaml,
+ kNumKinds
+ };
+
+ //----------------------------------------------------------------------
+ // Constructors and Destructors
+ //----------------------------------------------------------------------
+ TypeSystem(LLVMCastKind kind);
+
+ ~TypeSystem() override;
+
+ LLVMCastKind getKind() const { return m_kind; }
+
+ static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language,
+ Module *module);
+
+ static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language,
+ Target *target);
+
+ // Free up any resources associated with this TypeSystem. Done before
+ // removing
+ // all the TypeSystems from the TypeSystemMap.
+ virtual void Finalize() {}
+
+ virtual DWARFASTParser *GetDWARFParser() { return nullptr; }
+
+ virtual SymbolFile *GetSymbolFile() const { return m_sym_file; }
+
+ // Returns true if the symbol file changed during the set accessor.
+ virtual void SetSymbolFile(SymbolFile *sym_file) { m_sym_file = sym_file; }
+
+ //----------------------------------------------------------------------
+ // CompilerDecl functions
+ //----------------------------------------------------------------------
+ virtual ConstString DeclGetName(void *opaque_decl) = 0;
+
+ virtual ConstString DeclGetMangledName(void *opaque_decl);
+
+ virtual CompilerDeclContext DeclGetDeclContext(void *opaque_decl);
+
+ virtual CompilerType DeclGetFunctionReturnType(void *opaque_decl);
+
+ virtual size_t DeclGetFunctionNumArguments(void *opaque_decl);
+
+ virtual CompilerType DeclGetFunctionArgumentType(void *opaque_decl,
+ size_t arg_idx);
+
+ //----------------------------------------------------------------------
+ // CompilerDeclContext functions
+ //----------------------------------------------------------------------
+
+ virtual std::vector<CompilerDecl>
+ DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name,
+ const bool ignore_imported_decls);
+
+ virtual bool DeclContextIsStructUnionOrClass(void *opaque_decl_ctx) = 0;
+
+ virtual ConstString DeclContextGetName(void *opaque_decl_ctx) = 0;
+
+ virtual ConstString
+ DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) = 0;
+
+ virtual bool DeclContextIsClassMethod(
+ void *opaque_decl_ctx, lldb::LanguageType *language_ptr,
+ bool *is_instance_method_ptr, ConstString *language_object_name_ptr) = 0;
+
+ //----------------------------------------------------------------------
+ // Tests
+ //----------------------------------------------------------------------
+
+ virtual bool IsArrayType(lldb::opaque_compiler_type_t type,
+ CompilerType *element_type, uint64_t *size,
+ bool *is_incomplete) = 0;
+
+ virtual bool IsAggregateType(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual bool IsAnonymousType(lldb::opaque_compiler_type_t type);
+
+ virtual bool IsCharType(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual bool IsCompleteType(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual bool IsDefined(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual bool IsFloatingPointType(lldb::opaque_compiler_type_t type,
+ uint32_t &count, bool &is_complex) = 0;
+
+ virtual bool IsFunctionType(lldb::opaque_compiler_type_t type,
+ bool *is_variadic_ptr) = 0;
+
+ virtual size_t
+ GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual CompilerType
+ GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type,
+ const size_t index) = 0;
+
+ virtual bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual bool IsBlockPointerType(lldb::opaque_compiler_type_t type,
+ CompilerType *function_pointer_type_ptr) = 0;
+
+ virtual bool IsIntegerType(lldb::opaque_compiler_type_t type,
+ bool &is_signed) = 0;
+
+ virtual bool IsEnumerationType(lldb::opaque_compiler_type_t type,
+ bool &is_signed) {
+ is_signed = false;
+ return false;
+ }
+
+ virtual bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
+ CompilerType *target_type, // Can pass NULL
+ bool check_cplusplus, bool check_objc) = 0;
+
+ virtual bool IsPointerType(lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_type) = 0;
+
+ virtual bool IsScalarType(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual bool IsVoidType(lldb::opaque_compiler_type_t type) = 0;
+
+ // TypeSystems can support more than one language
+ virtual bool SupportsLanguage(lldb::LanguageType language) = 0;
+
+ //----------------------------------------------------------------------
+ // Type Completion
+ //----------------------------------------------------------------------
+
+ virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0;
+
+ //----------------------------------------------------------------------
+ // AST related queries
+ //----------------------------------------------------------------------
+
+ virtual uint32_t GetPointerByteSize() = 0;
+
+ //----------------------------------------------------------------------
+ // Accessors
+ //----------------------------------------------------------------------
+
+ virtual ConstString GetTypeName(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual uint32_t
+ GetTypeInfo(lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_or_element_compiler_type) = 0;
+
+ virtual lldb::LanguageType
+ GetMinimumLanguage(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) = 0;
+
+ //----------------------------------------------------------------------
+ // Creating related types
+ //----------------------------------------------------------------------
+
+ virtual CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type,
+ uint64_t *stride) = 0;
+ virtual CompilerType GetArrayType(lldb::opaque_compiler_type_t type,
+ uint64_t size);
+
+ virtual CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) = 0;
+
+ // Returns -1 if this isn't a function of if the function doesn't have a
+ // prototype
+ // Returns a value >= 0 if there is a prototype.
+ virtual int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual CompilerType
+ GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type,
+ size_t idx) = 0;
+
+ virtual CompilerType
+ GetFunctionReturnType(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual TypeMemberFunctionImpl
+ GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type, size_t idx) = 0;
+
+ virtual CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual CompilerType GetPointerType(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual CompilerType
+ GetLValueReferenceType(lldb::opaque_compiler_type_t type);
+
+ virtual CompilerType
+ GetRValueReferenceType(lldb::opaque_compiler_type_t type);
+
+ virtual CompilerType AddConstModifier(lldb::opaque_compiler_type_t type);
+
+ virtual CompilerType AddVolatileModifier(lldb::opaque_compiler_type_t type);
+
+ virtual CompilerType AddRestrictModifier(lldb::opaque_compiler_type_t type);
+
+ virtual CompilerType CreateTypedef(lldb::opaque_compiler_type_t type,
+ const char *name,
+ const CompilerDeclContext &decl_ctx);
+
+ //----------------------------------------------------------------------
+ // Exploring the type
+ //----------------------------------------------------------------------
+
+ virtual uint64_t GetBitSize(lldb::opaque_compiler_type_t type,
+ ExecutionContextScope *exe_scope) = 0;
+
+ virtual lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type,
+ uint64_t &count) = 0;
+
+ virtual lldb::Format GetFormat(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual uint32_t GetNumChildren(lldb::opaque_compiler_type_t type,
+ bool omit_empty_base_classes) = 0;
+
+ virtual CompilerType GetBuiltinTypeByName(const ConstString &name);
+
+ virtual lldb::BasicType
+ GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual void ForEachEnumerator(
+ lldb::opaque_compiler_type_t type,
+ std::function<bool(const CompilerType &integer_type,
+ const ConstString &name,
+ const llvm::APSInt &value)> const &callback) {}
+
+ virtual uint32_t GetNumFields(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type,
+ size_t idx, std::string &name,
+ uint64_t *bit_offset_ptr,
+ uint32_t *bitfield_bit_size_ptr,
+ bool *is_bitfield_ptr) = 0;
+
+ virtual uint32_t
+ GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual uint32_t
+ GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual CompilerType
+ GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx,
+ uint32_t *bit_offset_ptr) = 0;
+
+ virtual CompilerType
+ GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx,
+ uint32_t *bit_offset_ptr) = 0;
+
+ virtual CompilerType GetChildCompilerTypeAtIndex(
+ lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx,
+ bool transparent_pointers, bool omit_empty_base_classes,
+ bool ignore_array_bounds, std::string &child_name,
+ uint32_t &child_byte_size, int32_t &child_byte_offset,
+ uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
+ bool &child_is_base_class, bool &child_is_deref_of_parent,
+ ValueObject *valobj, uint64_t &language_flags) = 0;
+
+ // Lookup a child given a name. This function will match base class names
+ // and member member names in "clang_type" only, not descendants.
+ virtual uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
+ const char *name,
+ bool omit_empty_base_classes) = 0;
+
+ // Lookup a child member given a name. This function will match member names
+ // only and will descend into "clang_type" children in search for the first
+ // member in this class, or any base class that matches "name".
+ // TODO: Return all matches for a given name by returning a
+ // vector<vector<uint32_t>>
+ // so we catch all names that match a given child name, not just the first.
+ virtual size_t
+ GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type,
+ const char *name, bool omit_empty_base_classes,
+ std::vector<uint32_t> &child_indexes) = 0;
+
+ virtual size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual CompilerType
+ GetTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx,
+ lldb::TemplateArgumentKind &kind) = 0;
+
+ //----------------------------------------------------------------------
+ // Dumping types
+ //----------------------------------------------------------------------
+
+ virtual void DumpValue(lldb::opaque_compiler_type_t type,
+ ExecutionContext *exe_ctx, Stream *s,
+ lldb::Format format, const DataExtractor &data,
+ lldb::offset_t data_offset, size_t data_byte_size,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset, bool show_types,
+ bool show_summary, bool verbose, uint32_t depth) = 0;
+
+ virtual bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s,
+ lldb::Format format, const DataExtractor &data,
+ lldb::offset_t data_offset, size_t data_byte_size,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset,
+ ExecutionContextScope *exe_scope) = 0;
+
+ virtual void
+ DumpTypeDescription(lldb::opaque_compiler_type_t type) = 0; // Dump to stdout
+
+ virtual void DumpTypeDescription(lldb::opaque_compiler_type_t type,
+ Stream *s) = 0;
+
+ //----------------------------------------------------------------------
+ // TODO: These methods appear unused. Should they be removed?
+ //----------------------------------------------------------------------
+
+ virtual bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual void DumpSummary(lldb::opaque_compiler_type_t type,
+ ExecutionContext *exe_ctx, Stream *s,
+ const DataExtractor &data,
+ lldb::offset_t data_offset,
+ size_t data_byte_size) = 0;
+
+ // Converts "s" to a floating point value and place resulting floating
+ // point bytes in the "dst" buffer.
+ virtual size_t ConvertStringToFloatValue(lldb::opaque_compiler_type_t type,
+ const char *s, uint8_t *dst,
+ size_t dst_size) = 0;
+
+ //----------------------------------------------------------------------
+ // TODO: Determine if these methods should move to ClangASTContext.
+ //----------------------------------------------------------------------
+
+ virtual bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_type) = 0;
+
+ virtual unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual bool IsCStringType(lldb::opaque_compiler_type_t type,
+ uint32_t &length) = 0;
+
+ virtual size_t GetTypeBitAlign(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) = 0;
+
+ virtual CompilerType
+ GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding,
+ size_t bit_size) = 0;
+
+ virtual bool IsBeingDefined(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual bool IsConst(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type,
+ CompilerType *base_type_ptr) = 0;
+
+ virtual bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual bool IsTypedefType(lldb::opaque_compiler_type_t type) = 0;
+
+ // If the current object represents a typedef type, get the underlying type
+ virtual CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual bool IsVectorType(lldb::opaque_compiler_type_t type,
+ CompilerType *element_type, uint64_t *size) = 0;
+
+ virtual CompilerType
+ GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual CompilerType
+ GetNonReferenceType(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual bool IsReferenceType(lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_type, bool *is_rvalue) = 0;
+
+ virtual bool
+ ShouldTreatScalarValueAsAddress(lldb::opaque_compiler_type_t type) {
+ return IsPointerOrReferenceType(type, nullptr);
+ }
+
+ virtual UserExpression *
+ GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix,
+ lldb::LanguageType language,
+ Expression::ResultType desired_type,
+ const EvaluateExpressionOptions &options) {
+ return nullptr;
+ }
+
+ virtual FunctionCaller *GetFunctionCaller(const CompilerType &return_type,
+ const Address &function_address,
+ const ValueList &arg_value_list,
+ const char *name) {
+ return nullptr;
+ }
+
+ virtual UtilityFunction *GetUtilityFunction(const char *text,
+ const char *name) {
+ return nullptr;
+ }
+
+ virtual PersistentExpressionState *GetPersistentExpressionState() {
+ return nullptr;
+ }
+
+ virtual CompilerType GetTypeForFormatters(void *type);
+
+ virtual LazyBool ShouldPrintAsOneLiner(void *type, ValueObject *valobj);
+
+ // Type systems can have types that are placeholder types, which are meant to
+ // indicate
+ // the presence of a type, but offer no actual information about said types,
+ // and leave
+ // the burden of actually figuring type information out to dynamic type
+ // resolution. For instance
+ // a language with a generics system, can use placeholder types to indicate
+ // "type argument goes here",
+ // without promising uniqueness of the placeholder, nor attaching any actually
+ // idenfiable information
+ // to said placeholder. This API allows type systems to tell LLDB when such a
+ // type has been encountered
+ // In response, the debugger can react by not using this type as a cache entry
+ // in any type-specific way
+ // For instance, LLDB will currently not cache any formatters that are
+ // discovered on such a type as
+ // attributable to the meaningless type itself, instead preferring to use the
+ // dynamic type
+ virtual bool IsMeaninglessWithoutDynamicResolution(void *type);
+
+protected:
+ const LLVMCastKind m_kind; // Support for llvm casting
+ SymbolFile *m_sym_file;
};
- class TypeSystemMap
- {
- public:
- TypeSystemMap ();
- ~TypeSystemMap();
-
- // Clear calls Finalize on all the TypeSystems managed by this map, and then
- // empties the map.
- void
- Clear ();
-
- // Iterate through all of the type systems that are created. Return true
- // from callback to keep iterating, false to stop iterating.
- void
- ForEach (std::function <bool(TypeSystem *)> const &callback);
-
- TypeSystem *
- GetTypeSystemForLanguage (lldb::LanguageType language, Module *module, bool can_create);
-
- TypeSystem *
- GetTypeSystemForLanguage (lldb::LanguageType language, Target *target, bool can_create);
-
- protected:
- // This function does not take the map mutex, and should only be called from
- // functions that do take the mutex.
- void
- AddToMap (lldb::LanguageType language, lldb::TypeSystemSP const &type_system_sp);
-
- typedef std::map<lldb::LanguageType, lldb::TypeSystemSP> collection;
- mutable std::mutex m_mutex; ///< A mutex to keep this object happy in multi-threaded environments.
- collection m_map;
- bool m_clear_in_progress;
- };
+class TypeSystemMap {
+public:
+ TypeSystemMap();
+ ~TypeSystemMap();
+
+ // Clear calls Finalize on all the TypeSystems managed by this map, and then
+ // empties the map.
+ void Clear();
+
+ // Iterate through all of the type systems that are created. Return true
+ // from callback to keep iterating, false to stop iterating.
+ void ForEach(std::function<bool(TypeSystem *)> const &callback);
+
+ TypeSystem *GetTypeSystemForLanguage(lldb::LanguageType language,
+ Module *module, bool can_create);
+
+ TypeSystem *GetTypeSystemForLanguage(lldb::LanguageType language,
+ Target *target, bool can_create);
+
+protected:
+ // This function does not take the map mutex, and should only be called from
+ // functions that do take the mutex.
+ void AddToMap(lldb::LanguageType language,
+ lldb::TypeSystemSP const &type_system_sp);
+
+ typedef std::map<lldb::LanguageType, lldb::TypeSystemSP> collection;
+ mutable std::mutex m_mutex; ///< A mutex to keep this object happy in
+ ///multi-threaded environments.
+ collection m_map;
+ bool m_clear_in_progress;
+};
} // namespace lldb_private
diff --git a/include/lldb/Symbol/UnwindPlan.h b/include/lldb/Symbol/UnwindPlan.h
index 64c00bf12c27..dfcf55bc8864 100644
--- a/include/lldb/Symbol/UnwindPlan.h
+++ b/include/lldb/Symbol/UnwindPlan.h
@@ -18,10 +18,10 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/AddressRange.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ConstString.h"
+#include "lldb/Core/Stream.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -39,673 +39,455 @@ namespace lldb_private {
// Internally, the UnwindPlan is structured as a vector of register locations
// organized by code address in the function, showing which registers have been
-// saved at that point and where they are saved.
-// It can be thought of as the expanded table form of the DWARF CFI
+// saved at that point and where they are saved.
+// It can be thought of as the expanded table form of the DWARF CFI
// encoded information.
// Other unwind information sources will be converted into UnwindPlans before
-// being added to a FuncUnwinders object. The unwind source may be
-// an eh_frame FDE, a DWARF debug_frame FDE, or assembly language based
+// being added to a FuncUnwinders object. The unwind source may be
+// an eh_frame FDE, a DWARF debug_frame FDE, or assembly language based
// prologue analysis.
// The UnwindPlan is the canonical form of this information that the unwinder
// code will use when walking the stack.
class UnwindPlan {
public:
- class Row {
+ class Row {
+ public:
+ class RegisterLocation {
public:
- class RegisterLocation
- {
- public:
- enum RestoreType
- {
- unspecified, // not specified, we may be able to assume this
- // is the same register. gcc doesn't specify all
- // initial values so we really don't know...
- undefined, // reg is not available, e.g. volatile reg
- same, // reg is unchanged
- atCFAPlusOffset, // reg = deref(CFA + offset)
- isCFAPlusOffset, // reg = CFA + offset
- inOtherRegister, // reg = other reg
- atDWARFExpression, // reg = deref(eval(dwarf_expr))
- isDWARFExpression // reg = eval(dwarf_expr)
- };
-
- RegisterLocation() :
- m_type(unspecified),
- m_location()
- {
- }
-
- bool
- operator == (const RegisterLocation& rhs) const;
-
- bool
- operator != (const RegisterLocation &rhs) const
- {
- return !(*this == rhs);
- }
-
- void
- SetUnspecified()
- {
- m_type = unspecified;
- }
-
- void
- SetUndefined()
- {
- m_type = undefined;
- }
-
- void
- SetSame()
- {
- m_type = same;
- }
-
- bool
- IsSame () const
- {
- return m_type == same;
- }
-
- bool
- IsUnspecified () const
- {
- return m_type == unspecified;
- }
-
- bool
- IsUndefined () const
- {
- return m_type == undefined;
- }
-
- bool
- IsCFAPlusOffset () const
- {
- return m_type == isCFAPlusOffset;
- }
-
- bool
- IsAtCFAPlusOffset () const
- {
- return m_type == atCFAPlusOffset;
- }
-
- bool
- IsInOtherRegister () const
- {
- return m_type == inOtherRegister;
- }
-
- bool
- IsAtDWARFExpression () const
- {
- return m_type == atDWARFExpression;
- }
-
- bool
- IsDWARFExpression () const
- {
- return m_type == isDWARFExpression;
- }
-
- void
- SetAtCFAPlusOffset (int32_t offset)
- {
- m_type = atCFAPlusOffset;
- m_location.offset = offset;
- }
-
- void
- SetIsCFAPlusOffset (int32_t offset)
- {
- m_type = isCFAPlusOffset;
- m_location.offset = offset;
- }
-
- void
- SetInRegister (uint32_t reg_num)
- {
- m_type = inOtherRegister;
- m_location.reg_num = reg_num;
- }
-
- uint32_t
- GetRegisterNumber () const
- {
- if (m_type == inOtherRegister)
- return m_location.reg_num;
- return LLDB_INVALID_REGNUM;
- }
-
- RestoreType
- GetLocationType () const
- {
- return m_type;
- }
-
- int32_t
- GetOffset () const
- {
- if (m_type == atCFAPlusOffset || m_type == isCFAPlusOffset)
- return m_location.offset;
- return 0;
- }
-
- void
- GetDWARFExpr (const uint8_t **opcodes, uint16_t& len) const
- {
- if (m_type == atDWARFExpression || m_type == isDWARFExpression)
- {
- *opcodes = m_location.expr.opcodes;
- len = m_location.expr.length;
- }
- else
- {
- *opcodes = nullptr;
- len = 0;
- }
- }
-
- void
- SetAtDWARFExpression (const uint8_t *opcodes, uint32_t len);
-
- void
- SetIsDWARFExpression (const uint8_t *opcodes, uint32_t len);
-
- const uint8_t *
- GetDWARFExpressionBytes ()
- {
- if (m_type == atDWARFExpression || m_type == isDWARFExpression)
- return m_location.expr.opcodes;
- return nullptr;
- }
-
- int
- GetDWARFExpressionLength ()
- {
- if (m_type == atDWARFExpression || m_type == isDWARFExpression)
- return m_location.expr.length;
- return 0;
- }
-
- void
- Dump (Stream &s,
- const UnwindPlan* unwind_plan,
- const UnwindPlan::Row* row,
- Thread* thread,
- bool verbose) const;
-
- private:
- RestoreType m_type; // How do we locate this register?
- union
- {
- // For m_type == atCFAPlusOffset or m_type == isCFAPlusOffset
- int32_t offset;
- // For m_type == inOtherRegister
- uint32_t reg_num; // The register number
- // For m_type == atDWARFExpression or m_type == isDWARFExpression
- struct {
- const uint8_t *opcodes;
- uint16_t length;
- } expr;
- } m_location;
- };
-
- class CFAValue
- {
- public:
- enum ValueType
- {
- unspecified, // not specified
- isRegisterPlusOffset, // CFA = register + offset
- isRegisterDereferenced, // CFA = [reg]
- isDWARFExpression // CFA = eval(dwarf_expr)
- };
-
- CFAValue() :
- m_type(unspecified),
- m_value()
- {
- }
-
- bool
- operator == (const CFAValue& rhs) const;
-
- bool
- operator != (const CFAValue &rhs) const
- {
- return !(*this == rhs);
- }
-
- void
- SetUnspecified()
- {
- m_type = unspecified;
- }
-
- bool
- IsUnspecified () const
- {
- return m_type == unspecified;
- }
-
- bool
- IsRegisterPlusOffset () const
- {
- return m_type == isRegisterPlusOffset;
- }
-
- void
- SetIsRegisterPlusOffset (uint32_t reg_num, int32_t offset)
- {
- m_type = isRegisterPlusOffset;
- m_value.reg.reg_num = reg_num;
- m_value.reg.offset = offset;
- }
-
- bool
- IsRegisterDereferenced () const
- {
- return m_type == isRegisterDereferenced;
- }
-
- void
- SetIsRegisterDereferenced (uint32_t reg_num)
- {
- m_type = isRegisterDereferenced;
- m_value.reg.reg_num = reg_num;
- }
-
- bool
- IsDWARFExpression () const
- {
- return m_type == isDWARFExpression;
- }
-
- void
- SetIsDWARFExpression (const uint8_t *opcodes, uint32_t len)
- {
- m_type = isDWARFExpression;
- m_value.expr.opcodes = opcodes;
- m_value.expr.length = len;
- }
-
- uint32_t
- GetRegisterNumber () const
- {
- if (m_type == isRegisterDereferenced || m_type == isRegisterPlusOffset)
- return m_value.reg.reg_num;
- return LLDB_INVALID_REGNUM;
- }
-
- ValueType
- GetValueType () const
- {
- return m_type;
- }
-
- int32_t
- GetOffset () const
- {
- if (m_type == isRegisterPlusOffset)
- return m_value.reg.offset;
- return 0;
- }
-
- void IncOffset (int32_t delta)
- {
- if (m_type == isRegisterPlusOffset)
- m_value.reg.offset += delta;
- }
-
- void SetOffset (int32_t offset)
- {
- if (m_type == isRegisterPlusOffset)
- m_value.reg.offset = offset;
- }
-
- void
- GetDWARFExpr (const uint8_t **opcodes, uint16_t& len) const
- {
- if (m_type == isDWARFExpression)
- {
- *opcodes = m_value.expr.opcodes;
- len = m_value.expr.length;
- }
- else
- {
- *opcodes = nullptr;
- len = 0;
- }
- }
-
- const uint8_t *
- GetDWARFExpressionBytes ()
- {
- if (m_type == isDWARFExpression)
- return m_value.expr.opcodes;
- return nullptr;
- }
-
- int
- GetDWARFExpressionLength ()
- {
- if (m_type == isDWARFExpression)
- return m_value.expr.length;
- return 0;
- }
-
- void
- Dump (Stream &s,
- const UnwindPlan* unwind_plan,
- Thread* thread) const;
-
- private:
- ValueType m_type; // How do we compute CFA value?
- union
- {
- struct {
- // For m_type == isRegisterPlusOffset or m_type == isRegisterDereferenced
- uint32_t reg_num; // The register number
- // For m_type == isRegisterPlusOffset
- int32_t offset;
- } reg;
- // For m_type == isDWARFExpression
- struct {
- const uint8_t *opcodes;
- uint16_t length;
- } expr;
- } m_value;
- }; // class CFAValue
+ enum RestoreType {
+ unspecified, // not specified, we may be able to assume this
+ // is the same register. gcc doesn't specify all
+ // initial values so we really don't know...
+ undefined, // reg is not available, e.g. volatile reg
+ same, // reg is unchanged
+ atCFAPlusOffset, // reg = deref(CFA + offset)
+ isCFAPlusOffset, // reg = CFA + offset
+ inOtherRegister, // reg = other reg
+ atDWARFExpression, // reg = deref(eval(dwarf_expr))
+ isDWARFExpression // reg = eval(dwarf_expr)
+ };
- public:
- Row ();
+ RegisterLocation() : m_type(unspecified), m_location() {}
- Row (const UnwindPlan::Row& rhs) = default;
+ bool operator==(const RegisterLocation &rhs) const;
- bool
- operator == (const Row &rhs) const;
+ bool operator!=(const RegisterLocation &rhs) const {
+ return !(*this == rhs);
+ }
- bool
- GetRegisterInfo (uint32_t reg_num, RegisterLocation& register_location) const;
-
- void
- SetRegisterInfo (uint32_t reg_num, const RegisterLocation register_location);
+ void SetUnspecified() { m_type = unspecified; }
- void
- RemoveRegisterInfo (uint32_t reg_num);
+ void SetUndefined() { m_type = undefined; }
- lldb::addr_t
- GetOffset() const
- {
- return m_offset;
- }
+ void SetSame() { m_type = same; }
- void
- SetOffset(lldb::addr_t offset)
- {
- m_offset = offset;
- }
+ bool IsSame() const { return m_type == same; }
- void
- SlideOffset(lldb::addr_t offset)
- {
- m_offset += offset;
- }
+ bool IsUnspecified() const { return m_type == unspecified; }
+
+ bool IsUndefined() const { return m_type == undefined; }
+
+ bool IsCFAPlusOffset() const { return m_type == isCFAPlusOffset; }
+
+ bool IsAtCFAPlusOffset() const { return m_type == atCFAPlusOffset; }
+
+ bool IsInOtherRegister() const { return m_type == inOtherRegister; }
+
+ bool IsAtDWARFExpression() const { return m_type == atDWARFExpression; }
+
+ bool IsDWARFExpression() const { return m_type == isDWARFExpression; }
+
+ void SetAtCFAPlusOffset(int32_t offset) {
+ m_type = atCFAPlusOffset;
+ m_location.offset = offset;
+ }
+
+ void SetIsCFAPlusOffset(int32_t offset) {
+ m_type = isCFAPlusOffset;
+ m_location.offset = offset;
+ }
+
+ void SetInRegister(uint32_t reg_num) {
+ m_type = inOtherRegister;
+ m_location.reg_num = reg_num;
+ }
- CFAValue& GetCFAValue()
- {
- return m_cfa_value;
+ uint32_t GetRegisterNumber() const {
+ if (m_type == inOtherRegister)
+ return m_location.reg_num;
+ return LLDB_INVALID_REGNUM;
+ }
+
+ RestoreType GetLocationType() const { return m_type; }
+
+ int32_t GetOffset() const {
+ if (m_type == atCFAPlusOffset || m_type == isCFAPlusOffset)
+ return m_location.offset;
+ return 0;
+ }
+
+ void GetDWARFExpr(const uint8_t **opcodes, uint16_t &len) const {
+ if (m_type == atDWARFExpression || m_type == isDWARFExpression) {
+ *opcodes = m_location.expr.opcodes;
+ len = m_location.expr.length;
+ } else {
+ *opcodes = nullptr;
+ len = 0;
+ }
+ }
+
+ void SetAtDWARFExpression(const uint8_t *opcodes, uint32_t len);
+
+ void SetIsDWARFExpression(const uint8_t *opcodes, uint32_t len);
+
+ const uint8_t *GetDWARFExpressionBytes() {
+ if (m_type == atDWARFExpression || m_type == isDWARFExpression)
+ return m_location.expr.opcodes;
+ return nullptr;
+ }
+
+ int GetDWARFExpressionLength() {
+ if (m_type == atDWARFExpression || m_type == isDWARFExpression)
+ return m_location.expr.length;
+ return 0;
+ }
+
+ void Dump(Stream &s, const UnwindPlan *unwind_plan,
+ const UnwindPlan::Row *row, Thread *thread, bool verbose) const;
+
+ private:
+ RestoreType m_type; // How do we locate this register?
+ union {
+ // For m_type == atCFAPlusOffset or m_type == isCFAPlusOffset
+ int32_t offset;
+ // For m_type == inOtherRegister
+ uint32_t reg_num; // The register number
+ // For m_type == atDWARFExpression or m_type == isDWARFExpression
+ struct {
+ const uint8_t *opcodes;
+ uint16_t length;
+ } expr;
+ } m_location;
+ };
+
+ class CFAValue {
+ public:
+ enum ValueType {
+ unspecified, // not specified
+ isRegisterPlusOffset, // CFA = register + offset
+ isRegisterDereferenced, // CFA = [reg]
+ isDWARFExpression // CFA = eval(dwarf_expr)
+ };
+
+ CFAValue() : m_type(unspecified), m_value() {}
+
+ bool operator==(const CFAValue &rhs) const;
+
+ bool operator!=(const CFAValue &rhs) const { return !(*this == rhs); }
+
+ void SetUnspecified() { m_type = unspecified; }
+
+ bool IsUnspecified() const { return m_type == unspecified; }
+
+ bool IsRegisterPlusOffset() const {
+ return m_type == isRegisterPlusOffset;
+ }
+
+ void SetIsRegisterPlusOffset(uint32_t reg_num, int32_t offset) {
+ m_type = isRegisterPlusOffset;
+ m_value.reg.reg_num = reg_num;
+ m_value.reg.offset = offset;
+ }
+
+ bool IsRegisterDereferenced() const {
+ return m_type == isRegisterDereferenced;
+ }
+
+ void SetIsRegisterDereferenced(uint32_t reg_num) {
+ m_type = isRegisterDereferenced;
+ m_value.reg.reg_num = reg_num;
+ }
+
+ bool IsDWARFExpression() const { return m_type == isDWARFExpression; }
+
+ void SetIsDWARFExpression(const uint8_t *opcodes, uint32_t len) {
+ m_type = isDWARFExpression;
+ m_value.expr.opcodes = opcodes;
+ m_value.expr.length = len;
+ }
+
+ uint32_t GetRegisterNumber() const {
+ if (m_type == isRegisterDereferenced || m_type == isRegisterPlusOffset)
+ return m_value.reg.reg_num;
+ return LLDB_INVALID_REGNUM;
+ }
+
+ ValueType GetValueType() const { return m_type; }
+
+ int32_t GetOffset() const {
+ if (m_type == isRegisterPlusOffset)
+ return m_value.reg.offset;
+ return 0;
+ }
+
+ void IncOffset(int32_t delta) {
+ if (m_type == isRegisterPlusOffset)
+ m_value.reg.offset += delta;
+ }
+
+ void SetOffset(int32_t offset) {
+ if (m_type == isRegisterPlusOffset)
+ m_value.reg.offset = offset;
+ }
+
+ void GetDWARFExpr(const uint8_t **opcodes, uint16_t &len) const {
+ if (m_type == isDWARFExpression) {
+ *opcodes = m_value.expr.opcodes;
+ len = m_value.expr.length;
+ } else {
+ *opcodes = nullptr;
+ len = 0;
}
+ }
+
+ const uint8_t *GetDWARFExpressionBytes() {
+ if (m_type == isDWARFExpression)
+ return m_value.expr.opcodes;
+ return nullptr;
+ }
+
+ int GetDWARFExpressionLength() {
+ if (m_type == isDWARFExpression)
+ return m_value.expr.length;
+ return 0;
+ }
+
+ void Dump(Stream &s, const UnwindPlan *unwind_plan, Thread *thread) const;
+
+ private:
+ ValueType m_type; // How do we compute CFA value?
+ union {
+ struct {
+ // For m_type == isRegisterPlusOffset or m_type ==
+ // isRegisterDereferenced
+ uint32_t reg_num; // The register number
+ // For m_type == isRegisterPlusOffset
+ int32_t offset;
+ } reg;
+ // For m_type == isDWARFExpression
+ struct {
+ const uint8_t *opcodes;
+ uint16_t length;
+ } expr;
+ } m_value;
+ }; // class CFAValue
+
+ public:
+ Row();
+
+ Row(const UnwindPlan::Row &rhs) = default;
+
+ bool operator==(const Row &rhs) const;
+
+ bool GetRegisterInfo(uint32_t reg_num,
+ RegisterLocation &register_location) const;
+
+ void SetRegisterInfo(uint32_t reg_num,
+ const RegisterLocation register_location);
+
+ void RemoveRegisterInfo(uint32_t reg_num);
+
+ lldb::addr_t GetOffset() const { return m_offset; }
- bool
- SetRegisterLocationToAtCFAPlusOffset (uint32_t reg_num,
- int32_t offset,
+ void SetOffset(lldb::addr_t offset) { m_offset = offset; }
+
+ void SlideOffset(lldb::addr_t offset) { m_offset += offset; }
+
+ CFAValue &GetCFAValue() { return m_cfa_value; }
+
+ bool SetRegisterLocationToAtCFAPlusOffset(uint32_t reg_num, int32_t offset,
bool can_replace);
- bool
- SetRegisterLocationToIsCFAPlusOffset (uint32_t reg_num,
- int32_t offset,
+ bool SetRegisterLocationToIsCFAPlusOffset(uint32_t reg_num, int32_t offset,
bool can_replace);
- bool
- SetRegisterLocationToUndefined (uint32_t reg_num,
- bool can_replace,
+ bool SetRegisterLocationToUndefined(uint32_t reg_num, bool can_replace,
bool can_replace_only_if_unspecified);
- bool
- SetRegisterLocationToUnspecified (uint32_t reg_num,
- bool can_replace);
+ bool SetRegisterLocationToUnspecified(uint32_t reg_num, bool can_replace);
- bool
- SetRegisterLocationToRegister (uint32_t reg_num,
- uint32_t other_reg_num,
+ bool SetRegisterLocationToRegister(uint32_t reg_num, uint32_t other_reg_num,
bool can_replace);
- bool
- SetRegisterLocationToSame (uint32_t reg_num,
- bool must_replace);
+ bool SetRegisterLocationToSame(uint32_t reg_num, bool must_replace);
- void
- Clear ();
+ void Clear();
- void
- Dump (Stream& s, const UnwindPlan* unwind_plan, Thread* thread, lldb::addr_t base_addr) const;
+ void Dump(Stream &s, const UnwindPlan *unwind_plan, Thread *thread,
+ lldb::addr_t base_addr) const;
- protected:
- typedef std::map<uint32_t, RegisterLocation> collection;
- lldb::addr_t m_offset; // Offset into the function for this row
+ protected:
+ typedef std::map<uint32_t, RegisterLocation> collection;
+ lldb::addr_t m_offset; // Offset into the function for this row
- CFAValue m_cfa_value;
- collection m_register_locations;
- }; // class Row
+ CFAValue m_cfa_value;
+ collection m_register_locations;
+ }; // class Row
public:
- typedef std::shared_ptr<Row> RowSP;
-
- UnwindPlan (lldb::RegisterKind reg_kind) :
- m_row_list (),
- m_plan_valid_address_range (),
- m_register_kind (reg_kind),
- m_return_addr_register (LLDB_INVALID_REGNUM),
- m_source_name (),
- m_plan_is_sourced_from_compiler (eLazyBoolCalculate),
- m_plan_is_valid_at_all_instruction_locations (eLazyBoolCalculate),
- m_lsda_address (),
- m_personality_func_addr ()
- {
- }
-
- // Performs a deep copy of the plan, including all the rows (expensive).
- UnwindPlan (const UnwindPlan &rhs) :
- m_plan_valid_address_range (rhs.m_plan_valid_address_range),
- m_register_kind (rhs.m_register_kind),
- m_return_addr_register (rhs.m_return_addr_register),
- m_source_name (rhs.m_source_name),
- m_plan_is_sourced_from_compiler (rhs.m_plan_is_sourced_from_compiler),
- m_plan_is_valid_at_all_instruction_locations (rhs.m_plan_is_valid_at_all_instruction_locations),
- m_lsda_address (rhs.m_lsda_address),
- m_personality_func_addr (rhs.m_personality_func_addr)
- {
- m_row_list.reserve (rhs.m_row_list.size());
- for (const RowSP &row_sp: rhs.m_row_list)
- m_row_list.emplace_back (new Row (*row_sp));
- }
-
- ~UnwindPlan() = default;
-
- void
- Dump (Stream& s, Thread* thread, lldb::addr_t base_addr) const;
-
- void
- AppendRow (const RowSP& row_sp);
-
- void
- InsertRow (const RowSP& row_sp, bool replace_existing = false);
-
- // Returns a pointer to the best row for the given offset into the function's instructions.
- // If offset is -1 it indicates that the function start is unknown - the final row in the UnwindPlan is returned.
- // In practice, the UnwindPlan for a function with no known start address will be the architectural default
- // UnwindPlan which will only have one row.
- UnwindPlan::RowSP
- GetRowForFunctionOffset (int offset) const;
-
- lldb::RegisterKind
- GetRegisterKind () const
- {
- return m_register_kind;
- }
-
- void
- SetRegisterKind (lldb::RegisterKind kind)
- {
- m_register_kind = kind;
- }
-
- void
- SetReturnAddressRegister (uint32_t regnum)
- {
- m_return_addr_register = regnum;
- }
-
- uint32_t
- GetReturnAddressRegister (void)
- {
- return m_return_addr_register;
- }
-
- uint32_t
- GetInitialCFARegister () const
- {
- if (m_row_list.empty())
- return LLDB_INVALID_REGNUM;
- return m_row_list.front()->GetCFAValue().GetRegisterNumber();
- }
-
- // This UnwindPlan may not be valid at every address of the function span.
- // For instance, a FastUnwindPlan will not be valid at the prologue setup
- // instructions - only in the body of the function.
- void
- SetPlanValidAddressRange (const AddressRange& range);
-
- const AddressRange &
- GetAddressRange () const
- {
- return m_plan_valid_address_range;
- }
-
- bool
- PlanValidAtAddress (Address addr);
-
- bool
- IsValidRowIndex (uint32_t idx) const;
-
- const UnwindPlan::RowSP
- GetRowAtIndex (uint32_t idx) const;
-
- const UnwindPlan::RowSP
- GetLastRow () const;
-
- lldb_private::ConstString
- GetSourceName () const;
-
- void
- SetSourceName (const char *);
-
- // Was this UnwindPlan emitted by a compiler?
- lldb_private::LazyBool
- GetSourcedFromCompiler () const
- {
- return m_plan_is_sourced_from_compiler;
- }
-
- // Was this UnwindPlan emitted by a compiler?
- void
- SetSourcedFromCompiler (lldb_private::LazyBool from_compiler)
- {
- m_plan_is_sourced_from_compiler = from_compiler;
- }
-
- // Is this UnwindPlan valid at all instructions? If not, then it is assumed valid at call sites,
- // e.g. for exception handling.
- lldb_private::LazyBool
- GetUnwindPlanValidAtAllInstructions () const
- {
- return m_plan_is_valid_at_all_instruction_locations;
- }
-
- // Is this UnwindPlan valid at all instructions? If not, then it is assumed valid at call sites,
- // e.g. for exception handling.
- void
- SetUnwindPlanValidAtAllInstructions (lldb_private::LazyBool valid_at_all_insn)
- {
- m_plan_is_valid_at_all_instruction_locations = valid_at_all_insn;
- }
-
- int
- GetRowCount () const;
-
- void
- Clear()
- {
- m_row_list.clear();
- m_plan_valid_address_range.Clear();
- m_register_kind = lldb::eRegisterKindDWARF;
- m_source_name.Clear();
- m_plan_is_sourced_from_compiler = eLazyBoolCalculate;
- m_plan_is_valid_at_all_instruction_locations = eLazyBoolCalculate;
- m_lsda_address.Clear();
- m_personality_func_addr.Clear();
- }
-
- const RegisterInfo *
- GetRegisterInfo (Thread* thread, uint32_t reg_num) const;
-
- Address
- GetLSDAAddress () const
- {
- return m_lsda_address;
- }
-
- void
- SetLSDAAddress (Address lsda_addr)
- {
- m_lsda_address = lsda_addr;
- }
-
- Address
- GetPersonalityFunctionPtr () const
- {
- return m_personality_func_addr;
- }
-
- void
- SetPersonalityFunctionPtr (Address presonality_func_ptr)
- {
- m_personality_func_addr = presonality_func_ptr;
- }
+ typedef std::shared_ptr<Row> RowSP;
+
+ UnwindPlan(lldb::RegisterKind reg_kind)
+ : m_row_list(), m_plan_valid_address_range(), m_register_kind(reg_kind),
+ m_return_addr_register(LLDB_INVALID_REGNUM), m_source_name(),
+ m_plan_is_sourced_from_compiler(eLazyBoolCalculate),
+ m_plan_is_valid_at_all_instruction_locations(eLazyBoolCalculate),
+ m_lsda_address(), m_personality_func_addr() {}
+
+ // Performs a deep copy of the plan, including all the rows (expensive).
+ UnwindPlan(const UnwindPlan &rhs)
+ : m_plan_valid_address_range(rhs.m_plan_valid_address_range),
+ m_register_kind(rhs.m_register_kind),
+ m_return_addr_register(rhs.m_return_addr_register),
+ m_source_name(rhs.m_source_name),
+ m_plan_is_sourced_from_compiler(rhs.m_plan_is_sourced_from_compiler),
+ m_plan_is_valid_at_all_instruction_locations(
+ rhs.m_plan_is_valid_at_all_instruction_locations),
+ m_lsda_address(rhs.m_lsda_address),
+ m_personality_func_addr(rhs.m_personality_func_addr) {
+ m_row_list.reserve(rhs.m_row_list.size());
+ for (const RowSP &row_sp : rhs.m_row_list)
+ m_row_list.emplace_back(new Row(*row_sp));
+ }
+
+ ~UnwindPlan() = default;
+
+ void Dump(Stream &s, Thread *thread, lldb::addr_t base_addr) const;
+
+ void AppendRow(const RowSP &row_sp);
+
+ void InsertRow(const RowSP &row_sp, bool replace_existing = false);
+
+ // Returns a pointer to the best row for the given offset into the function's
+ // instructions.
+ // If offset is -1 it indicates that the function start is unknown - the final
+ // row in the UnwindPlan is returned.
+ // In practice, the UnwindPlan for a function with no known start address will
+ // be the architectural default
+ // UnwindPlan which will only have one row.
+ UnwindPlan::RowSP GetRowForFunctionOffset(int offset) const;
+
+ lldb::RegisterKind GetRegisterKind() const { return m_register_kind; }
+
+ void SetRegisterKind(lldb::RegisterKind kind) { m_register_kind = kind; }
+
+ void SetReturnAddressRegister(uint32_t regnum) {
+ m_return_addr_register = regnum;
+ }
+
+ uint32_t GetReturnAddressRegister(void) { return m_return_addr_register; }
+
+ uint32_t GetInitialCFARegister() const {
+ if (m_row_list.empty())
+ return LLDB_INVALID_REGNUM;
+ return m_row_list.front()->GetCFAValue().GetRegisterNumber();
+ }
+
+ // This UnwindPlan may not be valid at every address of the function span.
+ // For instance, a FastUnwindPlan will not be valid at the prologue setup
+ // instructions - only in the body of the function.
+ void SetPlanValidAddressRange(const AddressRange &range);
+
+ const AddressRange &GetAddressRange() const {
+ return m_plan_valid_address_range;
+ }
+
+ bool PlanValidAtAddress(Address addr);
+
+ bool IsValidRowIndex(uint32_t idx) const;
+
+ const UnwindPlan::RowSP GetRowAtIndex(uint32_t idx) const;
+
+ const UnwindPlan::RowSP GetLastRow() const;
+
+ lldb_private::ConstString GetSourceName() const;
+
+ void SetSourceName(const char *);
+
+ // Was this UnwindPlan emitted by a compiler?
+ lldb_private::LazyBool GetSourcedFromCompiler() const {
+ return m_plan_is_sourced_from_compiler;
+ }
+
+ // Was this UnwindPlan emitted by a compiler?
+ void SetSourcedFromCompiler(lldb_private::LazyBool from_compiler) {
+ m_plan_is_sourced_from_compiler = from_compiler;
+ }
+
+ // Is this UnwindPlan valid at all instructions? If not, then it is assumed
+ // valid at call sites,
+ // e.g. for exception handling.
+ lldb_private::LazyBool GetUnwindPlanValidAtAllInstructions() const {
+ return m_plan_is_valid_at_all_instruction_locations;
+ }
+
+ // Is this UnwindPlan valid at all instructions? If not, then it is assumed
+ // valid at call sites,
+ // e.g. for exception handling.
+ void SetUnwindPlanValidAtAllInstructions(
+ lldb_private::LazyBool valid_at_all_insn) {
+ m_plan_is_valid_at_all_instruction_locations = valid_at_all_insn;
+ }
+
+ int GetRowCount() const;
+
+ void Clear() {
+ m_row_list.clear();
+ m_plan_valid_address_range.Clear();
+ m_register_kind = lldb::eRegisterKindDWARF;
+ m_source_name.Clear();
+ m_plan_is_sourced_from_compiler = eLazyBoolCalculate;
+ m_plan_is_valid_at_all_instruction_locations = eLazyBoolCalculate;
+ m_lsda_address.Clear();
+ m_personality_func_addr.Clear();
+ }
+
+ const RegisterInfo *GetRegisterInfo(Thread *thread, uint32_t reg_num) const;
+
+ Address GetLSDAAddress() const { return m_lsda_address; }
+
+ void SetLSDAAddress(Address lsda_addr) { m_lsda_address = lsda_addr; }
+
+ Address GetPersonalityFunctionPtr() const { return m_personality_func_addr; }
+
+ void SetPersonalityFunctionPtr(Address presonality_func_ptr) {
+ m_personality_func_addr = presonality_func_ptr;
+ }
private:
- typedef std::vector<RowSP> collection;
- collection m_row_list;
- AddressRange m_plan_valid_address_range;
- lldb::RegisterKind m_register_kind; // The RegisterKind these register numbers are in terms of - will need to be
- // translated to lldb native reg nums at unwind time
- uint32_t m_return_addr_register; // The register that has the return address for the caller frame
- // e.g. the lr on arm
- lldb_private::ConstString m_source_name; // for logging, where this UnwindPlan originated from
- lldb_private::LazyBool m_plan_is_sourced_from_compiler;
- lldb_private::LazyBool m_plan_is_valid_at_all_instruction_locations;
-
- Address m_lsda_address; // Where the language specific data area exists in the module - used
- // in exception handling.
- Address m_personality_func_addr; // The address of a pointer to the personality function - used in
- // exception handling.
-}; // class UnwindPlan
+ typedef std::vector<RowSP> collection;
+ collection m_row_list;
+ AddressRange m_plan_valid_address_range;
+ lldb::RegisterKind m_register_kind; // The RegisterKind these register numbers
+ // are in terms of - will need to be
+ // translated to lldb native reg nums at unwind time
+ uint32_t m_return_addr_register; // The register that has the return address
+ // for the caller frame
+ // e.g. the lr on arm
+ lldb_private::ConstString
+ m_source_name; // for logging, where this UnwindPlan originated from
+ lldb_private::LazyBool m_plan_is_sourced_from_compiler;
+ lldb_private::LazyBool m_plan_is_valid_at_all_instruction_locations;
+
+ Address m_lsda_address; // Where the language specific data area exists in the
+ // module - used
+ // in exception handling.
+ Address m_personality_func_addr; // The address of a pointer to the
+ // personality function - used in
+ // exception handling.
+}; // class UnwindPlan
} // namespace lldb_private
diff --git a/include/lldb/Symbol/UnwindTable.h b/include/lldb/Symbol/UnwindTable.h
index cb0080aff881..e730454b04d1 100644
--- a/include/lldb/Symbol/UnwindTable.h
+++ b/include/lldb/Symbol/UnwindTable.h
@@ -7,14 +7,13 @@
//
//===----------------------------------------------------------------------===//
-
#ifndef liblldb_UnwindTable_h
#define liblldb_UnwindTable_h
#include <map>
#include <mutex>
-#include "lldb/lldb-private.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -22,62 +21,61 @@ namespace lldb_private {
// The UnwindTable is populated with FuncUnwinders objects lazily during
// the debug session.
-class UnwindTable
-{
+class UnwindTable {
public:
- UnwindTable(ObjectFile& objfile);
- ~UnwindTable();
+ UnwindTable(ObjectFile &objfile);
+ ~UnwindTable();
- lldb_private::DWARFCallFrameInfo *
- GetEHFrameInfo ();
+ lldb_private::DWARFCallFrameInfo *GetEHFrameInfo();
- lldb_private::CompactUnwindInfo *
- GetCompactUnwindInfo ();
+ lldb_private::CompactUnwindInfo *GetCompactUnwindInfo();
- ArmUnwindInfo *
- GetArmUnwindInfo ();
+ ArmUnwindInfo *GetArmUnwindInfo();
- lldb::FuncUnwindersSP
- GetFuncUnwindersContainingAddress (const Address& addr, SymbolContext &sc);
+ lldb::FuncUnwindersSP GetFuncUnwindersContainingAddress(const Address &addr,
+ SymbolContext &sc);
- bool
- GetAllowAssemblyEmulationUnwindPlans ();
+ bool GetAllowAssemblyEmulationUnwindPlans();
-// Normally when we create a new FuncUnwinders object we track it in this UnwindTable so it can
-// be reused later. But for the target modules show-unwind we want to create brand new
-// UnwindPlans for the function of interest - so ignore any existing FuncUnwinders for that
-// function and don't add this new one to our UnwindTable.
-// This FuncUnwinders object does have a reference to the UnwindTable but the lifetime of this
-// uncached FuncUnwinders is expected to be short so in practice this will not be a problem.
- lldb::FuncUnwindersSP
- GetUncachedFuncUnwindersContainingAddress (const Address& addr, SymbolContext &sc);
+ // Normally when we create a new FuncUnwinders object we track it in this
+ // UnwindTable so it can
+ // be reused later. But for the target modules show-unwind we want to create
+ // brand new
+ // UnwindPlans for the function of interest - so ignore any existing
+ // FuncUnwinders for that
+ // function and don't add this new one to our UnwindTable.
+ // This FuncUnwinders object does have a reference to the UnwindTable but the
+ // lifetime of this
+ // uncached FuncUnwinders is expected to be short so in practice this will not
+ // be a problem.
+ lldb::FuncUnwindersSP
+ GetUncachedFuncUnwindersContainingAddress(const Address &addr,
+ SymbolContext &sc);
- bool
- GetArchitecture (lldb_private::ArchSpec &arch);
+ bool GetArchitecture(lldb_private::ArchSpec &arch);
private:
- void
- Dump (Stream &s);
-
- void Initialize ();
+ void Dump(Stream &s);
+
+ void Initialize();
- typedef std::map<lldb::addr_t, lldb::FuncUnwindersSP> collection;
- typedef collection::iterator iterator;
- typedef collection::const_iterator const_iterator;
+ typedef std::map<lldb::addr_t, lldb::FuncUnwindersSP> collection;
+ typedef collection::iterator iterator;
+ typedef collection::const_iterator const_iterator;
- ObjectFile& m_object_file;
- collection m_unwinds;
+ ObjectFile &m_object_file;
+ collection m_unwinds;
- bool m_initialized; // delay some initialization until ObjectFile is set up
- std::mutex m_mutex;
+ bool m_initialized; // delay some initialization until ObjectFile is set up
+ std::mutex m_mutex;
- std::unique_ptr<DWARFCallFrameInfo> m_eh_frame_up;
- std::unique_ptr<CompactUnwindInfo> m_compact_unwind_up;
- std::unique_ptr<ArmUnwindInfo> m_arm_unwind_up;
+ std::unique_ptr<DWARFCallFrameInfo> m_eh_frame_up;
+ std::unique_ptr<CompactUnwindInfo> m_compact_unwind_up;
+ std::unique_ptr<ArmUnwindInfo> m_arm_unwind_up;
- DISALLOW_COPY_AND_ASSIGN (UnwindTable);
+ DISALLOW_COPY_AND_ASSIGN(UnwindTable);
};
} // namespace lldb_private
-#endif // liblldb_UnwindTable_h
+#endif // liblldb_UnwindTable_h
diff --git a/include/lldb/Symbol/Variable.h b/include/lldb/Symbol/Variable.h
index 00761424d107..33249891d36b 100644
--- a/include/lldb/Symbol/Variable.h
+++ b/include/lldb/Symbol/Variable.h
@@ -1,5 +1,4 @@
-//===-- Variable.h ----------------------------------------------*- C++
-//-*-===//
+//===-- Variable.h -----------------------------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,193 +13,129 @@
#include <memory>
#include <vector>
-#include "lldb/lldb-private.h"
-#include "lldb/lldb-enumerations.h"
#include "lldb/Core/Mangled.h"
#include "lldb/Core/RangeMap.h"
#include "lldb/Core/UserID.h"
#include "lldb/Expression/DWARFExpression.h"
#include "lldb/Symbol/Declaration.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class Variable : public UserID,
- public std::enable_shared_from_this<Variable>
-{
+class Variable : public UserID, public std::enable_shared_from_this<Variable> {
public:
- typedef RangeVector<lldb::addr_t, lldb::addr_t> RangeList;
-
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- Variable (lldb::user_id_t uid,
- const char *name,
- const char *mangled, // The mangled or fully qualified name of the variable.
- const lldb::SymbolFileTypeSP &symfile_type_sp,
- lldb::ValueType scope,
- SymbolContextScope *owner_scope,
- const RangeList& scope_range,
- Declaration* decl,
- const DWARFExpression& location,
- bool external,
- bool artificial,
- bool static_member = false);
-
- virtual
- ~Variable();
-
- void
- Dump(Stream *s, bool show_context) const;
-
- bool
- DumpDeclaration (Stream *s,
- bool show_fullpaths,
- bool show_module);
-
- const Declaration&
- GetDeclaration() const
- {
- return m_declaration;
- }
-
- ConstString
- GetName() const;
-
- ConstString
- GetUnqualifiedName() const;
-
- SymbolContextScope *
- GetSymbolContextScope() const
- {
- return m_owner_scope;
- }
-
- // Since a variable can have a basename "i" and also a mangled
- // named "_ZN12_GLOBAL__N_11iE" and a demangled mangled name
- // "(anonymous namespace)::i", this function will allow a generic match
- // function that can be called by commands and expression parsers to make
- // sure we match anything we come across.
- bool
- NameMatches (const ConstString &name) const;
-
- bool
- NameMatches (const RegularExpression& regex) const;
-
- Type *
- GetType();
-
- lldb::LanguageType
- GetLanguage () const;
-
- lldb::ValueType
- GetScope() const
- {
- return m_scope;
- }
-
- bool
- IsExternal() const
- {
- return m_external;
- }
-
- bool
- IsArtificial() const
- {
- return m_artificial;
- }
-
- bool IsStaticMember() const
- {
- return m_static_member;
- }
-
- DWARFExpression &
- LocationExpression()
- {
- return m_location;
- }
-
- const DWARFExpression &
- LocationExpression() const
- {
- return m_location;
- }
-
- bool
- DumpLocationForAddress (Stream *s,
- const Address &address);
-
- size_t
- MemorySize() const;
-
- void
- CalculateSymbolContext (SymbolContext *sc);
-
- bool
- IsInScope (StackFrame *frame);
-
- bool
- LocationIsValidForFrame (StackFrame *frame);
-
- bool
- LocationIsValidForAddress (const Address &address);
-
- bool
- GetLocationIsConstantValueData () const
- {
- return m_loc_is_const_data;
- }
-
- void
- SetLocationIsConstantValueData (bool b)
- {
- m_loc_is_const_data = b;
- }
-
- typedef size_t (*GetVariableCallback) (void *baton,
- const char *name,
- VariableList &var_list);
-
-
- static Error
- GetValuesForVariableExpressionPath (const char *variable_expr_path,
- ExecutionContextScope *scope,
- GetVariableCallback callback,
- void *baton,
- VariableList &variable_list,
- ValueObjectList &valobj_list);
-
- static size_t
- AutoComplete (const ExecutionContext &exe_ctx,
- const char *name,
- StringList &matches,
- bool &word_complete);
-
- CompilerDeclContext
- GetDeclContext ();
-
- CompilerDecl
- GetDecl ();
+ typedef RangeVector<lldb::addr_t, lldb::addr_t> RangeList;
+
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ Variable(lldb::user_id_t uid, const char *name,
+ const char
+ *mangled, // The mangled or fully qualified name of the variable.
+ const lldb::SymbolFileTypeSP &symfile_type_sp,
+ lldb::ValueType scope, SymbolContextScope *owner_scope,
+ const RangeList &scope_range, Declaration *decl,
+ const DWARFExpression &location, bool external, bool artificial,
+ bool static_member = false);
+
+ virtual ~Variable();
+
+ void Dump(Stream *s, bool show_context) const;
+
+ bool DumpDeclaration(Stream *s, bool show_fullpaths, bool show_module);
+
+ const Declaration &GetDeclaration() const { return m_declaration; }
+
+ ConstString GetName() const;
+
+ ConstString GetUnqualifiedName() const;
+
+ SymbolContextScope *GetSymbolContextScope() const { return m_owner_scope; }
+
+ // Since a variable can have a basename "i" and also a mangled
+ // named "_ZN12_GLOBAL__N_11iE" and a demangled mangled name
+ // "(anonymous namespace)::i", this function will allow a generic match
+ // function that can be called by commands and expression parsers to make
+ // sure we match anything we come across.
+ bool NameMatches(const ConstString &name) const;
+
+ bool NameMatches(const RegularExpression &regex) const;
+
+ Type *GetType();
+
+ lldb::LanguageType GetLanguage() const;
+
+ lldb::ValueType GetScope() const { return m_scope; }
+
+ bool IsExternal() const { return m_external; }
+
+ bool IsArtificial() const { return m_artificial; }
+
+ bool IsStaticMember() const { return m_static_member; }
+
+ DWARFExpression &LocationExpression() { return m_location; }
+
+ const DWARFExpression &LocationExpression() const { return m_location; }
+
+ bool DumpLocationForAddress(Stream *s, const Address &address);
+
+ size_t MemorySize() const;
+
+ void CalculateSymbolContext(SymbolContext *sc);
+
+ bool IsInScope(StackFrame *frame);
+
+ bool LocationIsValidForFrame(StackFrame *frame);
+
+ bool LocationIsValidForAddress(const Address &address);
+
+ bool GetLocationIsConstantValueData() const { return m_loc_is_const_data; }
+
+ void SetLocationIsConstantValueData(bool b) { m_loc_is_const_data = b; }
+
+ typedef size_t (*GetVariableCallback)(void *baton, const char *name,
+ VariableList &var_list);
+
+ static Error GetValuesForVariableExpressionPath(
+ llvm::StringRef variable_expr_path, ExecutionContextScope *scope,
+ GetVariableCallback callback, void *baton, VariableList &variable_list,
+ ValueObjectList &valobj_list);
+
+ static size_t AutoComplete(const ExecutionContext &exe_ctx,
+ llvm::StringRef name, StringList &matches,
+ bool &word_complete);
+
+ CompilerDeclContext GetDeclContext();
+
+ CompilerDecl GetDecl();
protected:
- ConstString m_name; // The basename of the variable (no namespaces)
- Mangled m_mangled; // The mangled name of the variable
- lldb::SymbolFileTypeSP m_symfile_type_sp; // The type pointer of the variable (int, struct, class, etc)
- lldb::ValueType m_scope; // global, parameter, local
- SymbolContextScope *m_owner_scope; // The symbol file scope that this variable was defined in
- RangeList m_scope_range; // The list of ranges inside the owner's scope where this variable is valid
- Declaration m_declaration; // Declaration location for this item.
- DWARFExpression m_location; // The location of this variable that can be fed to DWARFExpression::Evaluate()
- uint8_t m_external:1, // Visible outside the containing compile unit?
- m_artificial:1, // Non-zero if the variable is not explicitly declared in source
- m_loc_is_const_data:1, // The m_location expression contains the constant variable value data, not a DWARF location
- m_static_member:1; // Non-zero if variable is static member of a class or struct.
+ ConstString m_name; // The basename of the variable (no namespaces)
+ Mangled m_mangled; // The mangled name of the variable
+ lldb::SymbolFileTypeSP m_symfile_type_sp; // The type pointer of the variable
+ // (int, struct, class, etc)
+ lldb::ValueType m_scope; // global, parameter, local
+ SymbolContextScope
+ *m_owner_scope; // The symbol file scope that this variable was defined in
+ RangeList m_scope_range; // The list of ranges inside the owner's scope where
+ // this variable is valid
+ Declaration m_declaration; // Declaration location for this item.
+ DWARFExpression m_location; // The location of this variable that can be fed
+ // to DWARFExpression::Evaluate()
+ uint8_t m_external : 1, // Visible outside the containing compile unit?
+ m_artificial : 1, // Non-zero if the variable is not explicitly declared
+ // in source
+ m_loc_is_const_data : 1, // The m_location expression contains the
+ // constant variable value data, not a DWARF
+ // location
+ m_static_member : 1; // Non-zero if variable is static member of a class
+ // or struct.
private:
- Variable(const Variable& rhs);
- Variable& operator=(const Variable& rhs);
+ Variable(const Variable &rhs);
+ Variable &operator=(const Variable &rhs);
};
} // namespace lldb_private
-#endif // liblldb_Variable_h_
+#endif // liblldb_Variable_h_
diff --git a/include/lldb/Symbol/VariableList.h b/include/lldb/Symbol/VariableList.h
index 1c1d5dfefb9e..c9e0be89a3bc 100644
--- a/include/lldb/Symbol/VariableList.h
+++ b/include/lldb/Symbol/VariableList.h
@@ -10,92 +10,77 @@
#ifndef liblldb_VariableList_h_
#define liblldb_VariableList_h_
-#include "lldb/lldb-private.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/Variable.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class VariableList
-{
+class VariableList {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
-// VariableList(const SymbolContext &symbol_context);
- VariableList();
- virtual ~VariableList();
-
- void
- AddVariable (const lldb::VariableSP &var_sp);
-
- bool
- AddVariableIfUnique (const lldb::VariableSP &var_sp);
-
- void
- AddVariables (VariableList *variable_list);
-
- void
- Clear();
-
- void
- Dump(Stream *s, bool show_context) const;
-
- lldb::VariableSP
- GetVariableAtIndex(size_t idx) const;
-
- lldb::VariableSP
- RemoveVariableAtIndex (size_t idx);
-
- lldb::VariableSP
- FindVariable (const ConstString& name, bool include_static_members = true);
-
- lldb::VariableSP
- FindVariable (const ConstString& name, lldb::ValueType value_type, bool include_static_members = true);
-
- uint32_t
- FindVariableIndex (const lldb::VariableSP &var_sp);
-
- size_t
- AppendVariablesIfUnique(VariableList &var_list);
-
- // Returns the actual number of unique variables that were added to the
- // list. "total_matches" will get updated with the actually number of
- // matches that were found regardless of whether they were unique or not
- // to allow for error conditions when nothing is found, versus conditions
- // where any variables that match "regex" were already in "var_list".
- size_t
- AppendVariablesIfUnique (const RegularExpression& regex,
- VariableList &var_list,
- size_t& total_matches);
-
- size_t
- AppendVariablesWithScope (lldb::ValueType type,
- VariableList &var_list,
- bool if_unique = true);
-
- uint32_t
- FindIndexForVariable (Variable* variable);
-
- size_t
- MemorySize() const;
-
- size_t
- GetSize() const;
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ // VariableList(const SymbolContext &symbol_context);
+ VariableList();
+ virtual ~VariableList();
+
+ void AddVariable(const lldb::VariableSP &var_sp);
+
+ bool AddVariableIfUnique(const lldb::VariableSP &var_sp);
+
+ void AddVariables(VariableList *variable_list);
+
+ void Clear();
+
+ void Dump(Stream *s, bool show_context) const;
+
+ lldb::VariableSP GetVariableAtIndex(size_t idx) const;
+
+ lldb::VariableSP RemoveVariableAtIndex(size_t idx);
+
+ lldb::VariableSP FindVariable(const ConstString &name,
+ bool include_static_members = true);
+
+ lldb::VariableSP FindVariable(const ConstString &name,
+ lldb::ValueType value_type,
+ bool include_static_members = true);
+
+ uint32_t FindVariableIndex(const lldb::VariableSP &var_sp);
+
+ size_t AppendVariablesIfUnique(VariableList &var_list);
+
+ // Returns the actual number of unique variables that were added to the
+ // list. "total_matches" will get updated with the actually number of
+ // matches that were found regardless of whether they were unique or not
+ // to allow for error conditions when nothing is found, versus conditions
+ // where any variables that match "regex" were already in "var_list".
+ size_t AppendVariablesIfUnique(const RegularExpression &regex,
+ VariableList &var_list, size_t &total_matches);
+
+ size_t AppendVariablesWithScope(lldb::ValueType type, VariableList &var_list,
+ bool if_unique = true);
+
+ uint32_t FindIndexForVariable(Variable *variable);
+
+ size_t MemorySize() const;
+
+ size_t GetSize() const;
protected:
- typedef std::vector<lldb::VariableSP> collection;
- typedef collection::iterator iterator;
- typedef collection::const_iterator const_iterator;
+ typedef std::vector<lldb::VariableSP> collection;
+ typedef collection::iterator iterator;
+ typedef collection::const_iterator const_iterator;
+
+ collection m_variables;
- collection m_variables;
private:
- //------------------------------------------------------------------
- // For VariableList only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (VariableList);
+ //------------------------------------------------------------------
+ // For VariableList only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(VariableList);
};
} // namespace lldb_private
-#endif // liblldb_VariableList_h_
+#endif // liblldb_VariableList_h_
diff --git a/include/lldb/Symbol/VerifyDecl.h b/include/lldb/Symbol/VerifyDecl.h
index 228e635652e6..f4b61e6355ce 100644
--- a/include/lldb/Symbol/VerifyDecl.h
+++ b/include/lldb/Symbol/VerifyDecl.h
@@ -12,9 +12,8 @@
#include "lldb/Core/ClangForward.h"
-namespace lldb_private
-{
- void VerifyDecl (clang::Decl *decl);
+namespace lldb_private {
+void VerifyDecl(clang::Decl *decl);
}
#endif
diff --git a/include/lldb/Target/ABI.h b/include/lldb/Target/ABI.h
index cd0b57e61ff8..8a1243613616 100644
--- a/include/lldb/Target/ABI.h
+++ b/include/lldb/Target/ABI.h
@@ -22,145 +22,125 @@
#include "llvm/ADT/ArrayRef.h"
// forward define the llvm::Type class
-namespace llvm { class Type; }
+namespace llvm {
+class Type;
+}
namespace lldb_private {
-class ABI :
- public PluginInterface
-{
+class ABI : public PluginInterface {
public:
-
- struct CallArgument
- {
- enum eType
- {
- HostPointer = 0, /* pointer to host data */
- TargetValue , /* value is on the target or literal */
- };
- eType type; /* value of eType */
- size_t size; /* size in bytes of this argument */
-
- lldb::addr_t value; /* literal value */
- std::unique_ptr<uint8_t[]> data_ap; /* host data pointer */
+ struct CallArgument {
+ enum eType {
+ HostPointer = 0, /* pointer to host data */
+ TargetValue, /* value is on the target or literal */
};
+ eType type; /* value of eType */
+ size_t size; /* size in bytes of this argument */
+
+ lldb::addr_t value; /* literal value */
+ std::unique_ptr<uint8_t[]> data_ap; /* host data pointer */
+ };
+
+ ~ABI() override;
+
+ virtual size_t GetRedZoneSize() const = 0;
+
+ virtual bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp,
+ lldb::addr_t functionAddress,
+ lldb::addr_t returnAddress,
+ llvm::ArrayRef<lldb::addr_t> args) const = 0;
+
+ // Prepare trivial call used from ThreadPlanFunctionCallUsingABI
+ // AD:
+ // . Because i don't want to change other ABI's this is not declared pure
+ // virtual.
+ // The dummy implementation will simply fail. Only HexagonABI will
+ // currently
+ // use this method.
+ // . Two PrepareTrivialCall's is not good design so perhaps this should be
+ // combined.
+ //
+ virtual bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp,
+ lldb::addr_t functionAddress,
+ lldb::addr_t returnAddress,
+ llvm::Type &prototype,
+ llvm::ArrayRef<CallArgument> args) const;
+
+ virtual bool GetArgumentValues(Thread &thread, ValueList &values) const = 0;
+
+ lldb::ValueObjectSP GetReturnValueObject(Thread &thread, CompilerType &type,
+ bool persistent = true) const;
+
+ // specialized to work with llvm IR types
+ lldb::ValueObjectSP GetReturnValueObject(Thread &thread, llvm::Type &type,
+ bool persistent = true) const;
+
+ // Set the Return value object in the current frame as though a function with
+ virtual Error SetReturnValueObject(lldb::StackFrameSP &frame_sp,
+ lldb::ValueObjectSP &new_value) = 0;
- ~ABI() override;
-
- virtual size_t
- GetRedZoneSize () const = 0;
-
- virtual bool
- PrepareTrivialCall ( lldb_private::Thread &thread,
- lldb::addr_t sp,
- lldb::addr_t functionAddress,
- lldb::addr_t returnAddress,
- llvm::ArrayRef<lldb::addr_t> args) const = 0;
-
- // Prepare trivial call used from ThreadPlanFunctionCallUsingABI
- // AD:
- // . Because i don't want to change other ABI's this is not declared pure virtual.
- // The dummy implementation will simply fail. Only HexagonABI will currently
- // use this method.
- // . Two PrepareTrivialCall's is not good design so perhaps this should be combined.
- //
- virtual bool
- PrepareTrivialCall ( lldb_private::Thread &thread,
- lldb::addr_t sp,
- lldb::addr_t functionAddress,
- lldb::addr_t returnAddress,
- llvm::Type &prototype,
- llvm::ArrayRef<CallArgument> args) const;
-
- virtual bool
- GetArgumentValues (Thread &thread,
- ValueList &values) const = 0;
-
- lldb::ValueObjectSP
- GetReturnValueObject (Thread &thread,
- CompilerType &type,
- bool persistent = true) const;
-
- // specialized to work with llvm IR types
- lldb::ValueObjectSP
- GetReturnValueObject (Thread &thread,
- llvm::Type &type,
- bool persistent = true) const;
-
- // Set the Return value object in the current frame as though a function with
- virtual Error
- SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) = 0;
-
-protected:
- // This is the method the ABI will call to actually calculate the return value.
- // Don't put it in a persistent value object, that will be done by the ABI::GetReturnValueObject.
- virtual lldb::ValueObjectSP
- GetReturnValueObjectImpl (Thread &thread, CompilerType &ast_type) const = 0;
-
- // specialized to work with llvm IR types
- virtual lldb::ValueObjectSP
- GetReturnValueObjectImpl( Thread &thread, llvm::Type &ir_type ) const;
+protected:
+ // This is the method the ABI will call to actually calculate the return
+ // value.
+ // Don't put it in a persistent value object, that will be done by the
+ // ABI::GetReturnValueObject.
+ virtual lldb::ValueObjectSP
+ GetReturnValueObjectImpl(Thread &thread, CompilerType &ast_type) const = 0;
+
+ // specialized to work with llvm IR types
+ virtual lldb::ValueObjectSP
+ GetReturnValueObjectImpl(Thread &thread, llvm::Type &ir_type) const;
public:
- virtual bool
- CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) = 0;
-
- virtual bool
- CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) = 0;
-
- virtual bool
- RegisterIsVolatile (const RegisterInfo *reg_info) = 0;
-
- virtual bool
- GetFallbackRegisterLocation (const RegisterInfo *reg_info,
- UnwindPlan::Row::RegisterLocation &unwind_regloc);
-
- // Should take a look at a call frame address (CFA) which is just the stack
- // pointer value upon entry to a function. ABIs usually impose alignment
- // restrictions (4, 8 or 16 byte aligned), and zero is usually not allowed.
- // This function should return true if "cfa" is valid call frame address for
- // the ABI, and false otherwise. This is used by the generic stack frame unwinding
- // code to help determine when a stack ends.
- virtual bool
- CallFrameAddressIsValid (lldb::addr_t cfa) = 0;
-
- // Validates a possible PC value and returns true if an opcode can be at "pc".
- virtual bool
- CodeAddressIsValid (lldb::addr_t pc) = 0;
-
- virtual lldb::addr_t
- FixCodeAddress (lldb::addr_t pc)
- {
- // Some targets might use bits in a code address to indicate
- // a mode switch. ARM uses bit zero to signify a code address is
- // thumb, so any ARM ABI plug-ins would strip those bits.
- return pc;
- }
-
- virtual const RegisterInfo *
- GetRegisterInfoArray (uint32_t &count) = 0;
-
- bool
- GetRegisterInfoByName (const ConstString &name, RegisterInfo &info);
-
- bool
- GetRegisterInfoByKind (lldb::RegisterKind reg_kind,
- uint32_t reg_num,
- RegisterInfo &info);
-
- static lldb::ABISP
- FindPlugin (const ArchSpec &arch);
-
-protected:
+ virtual bool CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) = 0;
- //------------------------------------------------------------------
- // Classes that inherit from ABI can see and modify these
- //------------------------------------------------------------------
- ABI();
+ virtual bool CreateDefaultUnwindPlan(UnwindPlan &unwind_plan) = 0;
-private:
+ virtual bool RegisterIsVolatile(const RegisterInfo *reg_info) = 0;
+
+ virtual bool
+ GetFallbackRegisterLocation(const RegisterInfo *reg_info,
+ UnwindPlan::Row::RegisterLocation &unwind_regloc);
+
+ // Should take a look at a call frame address (CFA) which is just the stack
+ // pointer value upon entry to a function. ABIs usually impose alignment
+ // restrictions (4, 8 or 16 byte aligned), and zero is usually not allowed.
+ // This function should return true if "cfa" is valid call frame address for
+ // the ABI, and false otherwise. This is used by the generic stack frame
+ // unwinding
+ // code to help determine when a stack ends.
+ virtual bool CallFrameAddressIsValid(lldb::addr_t cfa) = 0;
+
+ // Validates a possible PC value and returns true if an opcode can be at "pc".
+ virtual bool CodeAddressIsValid(lldb::addr_t pc) = 0;
+
+ virtual lldb::addr_t FixCodeAddress(lldb::addr_t pc) {
+ // Some targets might use bits in a code address to indicate
+ // a mode switch. ARM uses bit zero to signify a code address is
+ // thumb, so any ARM ABI plug-ins would strip those bits.
+ return pc;
+ }
- DISALLOW_COPY_AND_ASSIGN (ABI);
+ virtual const RegisterInfo *GetRegisterInfoArray(uint32_t &count) = 0;
+
+ bool GetRegisterInfoByName(const ConstString &name, RegisterInfo &info);
+
+ bool GetRegisterInfoByKind(lldb::RegisterKind reg_kind, uint32_t reg_num,
+ RegisterInfo &info);
+
+ virtual bool GetPointerReturnRegister(const char *&name) { return false; }
+
+ static lldb::ABISP FindPlugin(const ArchSpec &arch);
+
+protected:
+ //------------------------------------------------------------------
+ // Classes that inherit from ABI can see and modify these
+ //------------------------------------------------------------------
+ ABI();
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(ABI);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/CPPLanguageRuntime.h b/include/lldb/Target/CPPLanguageRuntime.h
index 788f4e60a493..aae85f420ef7 100644
--- a/include/lldb/Target/CPPLanguageRuntime.h
+++ b/include/lldb/Target/CPPLanguageRuntime.h
@@ -1,4 +1,5 @@
-//===-- CPPLanguageRuntime.h ---------------------------------------------------*- C++ -*-===//
+//===-- CPPLanguageRuntime.h
+//---------------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,42 +17,34 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/PluginInterface.h"
-#include "lldb/lldb-private.h"
#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class CPPLanguageRuntime :
- public LanguageRuntime
-{
+class CPPLanguageRuntime : public LanguageRuntime {
public:
- ~CPPLanguageRuntime() override;
-
- lldb::LanguageType
- GetLanguageType() const override
- {
- return lldb::eLanguageTypeC_plus_plus;
- }
-
- virtual bool
- IsVTableName (const char *name) = 0;
-
- bool
- GetObjectDescription(Stream &str, ValueObject &object) override;
-
- bool
- GetObjectDescription(Stream &str, Value &value, ExecutionContextScope *exe_scope) override;
-
-protected:
+ ~CPPLanguageRuntime() override;
- //------------------------------------------------------------------
- // Classes that inherit from CPPLanguageRuntime can see and modify these
- //------------------------------------------------------------------
- CPPLanguageRuntime(Process *process);
+ lldb::LanguageType GetLanguageType() const override {
+ return lldb::eLanguageTypeC_plus_plus;
+ }
-private:
+ virtual bool IsVTableName(const char *name) = 0;
+
+ bool GetObjectDescription(Stream &str, ValueObject &object) override;
- DISALLOW_COPY_AND_ASSIGN (CPPLanguageRuntime);
+ bool GetObjectDescription(Stream &str, Value &value,
+ ExecutionContextScope *exe_scope) override;
+
+protected:
+ //------------------------------------------------------------------
+ // Classes that inherit from CPPLanguageRuntime can see and modify these
+ //------------------------------------------------------------------
+ CPPLanguageRuntime(Process *process);
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(CPPLanguageRuntime);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/DynamicLoader.h b/include/lldb/Target/DynamicLoader.h
index 2c4956829b29..071cbe69d880 100644
--- a/include/lldb/Target/DynamicLoader.h
+++ b/include/lldb/Target/DynamicLoader.h
@@ -11,9 +11,10 @@
#define liblldb_DynamicLoader_h_
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/UUID.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -32,285 +33,313 @@ namespace lldb_private {
///
/// Breakpoints can also be set in the process which can register
/// functions that get called using:
-/// Process::BreakpointSetCallback (lldb::user_id_t, BreakpointHitCallback, void *).
+/// Process::BreakpointSetCallback (lldb::user_id_t, BreakpointHitCallback, void
+/// *).
/// These breakpoint callbacks return a boolean value that indicates if
/// the process should continue or halt and should return the global
/// setting for this using:
/// DynamicLoader::StopWhenImagesChange() const.
//----------------------------------------------------------------------
-class DynamicLoader :
- public PluginInterface
-{
+class DynamicLoader : public PluginInterface {
public:
- //------------------------------------------------------------------
- /// Find a dynamic loader plugin for a given process.
- ///
- /// Scans the installed DynamicLoader plug-ins and tries to find
- /// an instance that can be used to track image changes in \a
- /// process.
- ///
- /// @param[in] process
- /// The process for which to try and locate a dynamic loader
- /// plug-in instance.
- ///
- /// @param[in] plugin_name
- /// An optional name of a specific dynamic loader plug-in that
- /// should be used. If NULL, pick the best plug-in.
- //------------------------------------------------------------------
- static DynamicLoader*
- FindPlugin (Process *process, const char *plugin_name);
+ //------------------------------------------------------------------
+ /// Find a dynamic loader plugin for a given process.
+ ///
+ /// Scans the installed DynamicLoader plug-ins and tries to find
+ /// an instance that can be used to track image changes in \a
+ /// process.
+ ///
+ /// @param[in] process
+ /// The process for which to try and locate a dynamic loader
+ /// plug-in instance.
+ ///
+ /// @param[in] plugin_name
+ /// An optional name of a specific dynamic loader plug-in that
+ /// should be used. If NULL, pick the best plug-in.
+ //------------------------------------------------------------------
+ static DynamicLoader *FindPlugin(Process *process, const char *plugin_name);
- //------------------------------------------------------------------
- /// Construct with a process.
- //------------------------------------------------------------------
- DynamicLoader (Process *process);
+ //------------------------------------------------------------------
+ /// Construct with a process.
+ //------------------------------------------------------------------
+ DynamicLoader(Process *process);
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// The destructor is virtual since this class is designed to be
- /// inherited from by the plug-in instance.
- //------------------------------------------------------------------
- virtual ~DynamicLoader() override;
+ //------------------------------------------------------------------
+ /// Destructor.
+ ///
+ /// The destructor is virtual since this class is designed to be
+ /// inherited from by the plug-in instance.
+ //------------------------------------------------------------------
+ virtual ~DynamicLoader() override;
- //------------------------------------------------------------------
- /// Called after attaching a process.
- ///
- /// Allow DynamicLoader plug-ins to execute some code after
- /// attaching to a process.
- //------------------------------------------------------------------
- virtual void
- DidAttach () = 0;
+ //------------------------------------------------------------------
+ /// Called after attaching a process.
+ ///
+ /// Allow DynamicLoader plug-ins to execute some code after
+ /// attaching to a process.
+ //------------------------------------------------------------------
+ virtual void DidAttach() = 0;
- //------------------------------------------------------------------
- /// Called after launching a process.
- ///
- /// Allow DynamicLoader plug-ins to execute some code after
- /// the process has stopped for the first time on launch.
- //------------------------------------------------------------------
- virtual void
- DidLaunch () = 0;
-
-
- //------------------------------------------------------------------
- /// Helper function that can be used to detect when a process has
- /// called exec and is now a new and different process. This can
- /// be called when necessary to try and detect the exec. The process
- /// might be able to answer this question, but sometimes it might
- /// not be able and the dynamic loader often knows what the program
- /// entry point is. So the process and the dynamic loader can work
- /// together to detect this.
- //------------------------------------------------------------------
- virtual bool
- ProcessDidExec ()
- {
- return false;
- }
- //------------------------------------------------------------------
- /// Get whether the process should stop when images change.
- ///
- /// When images (executables and shared libraries) get loaded or
- /// unloaded, often debug sessions will want to try and resolve or
- /// unresolve breakpoints that are set in these images. Any
- /// breakpoints set by DynamicLoader plug-in instances should
- /// return this value to ensure consistent debug session behaviour.
- ///
- /// @return
- /// Returns \b true if the process should stop when images
- /// change, \b false if the process should resume.
- //------------------------------------------------------------------
- bool
- GetStopWhenImagesChange () const;
+ //------------------------------------------------------------------
+ /// Called after launching a process.
+ ///
+ /// Allow DynamicLoader plug-ins to execute some code after
+ /// the process has stopped for the first time on launch.
+ //------------------------------------------------------------------
+ virtual void DidLaunch() = 0;
- //------------------------------------------------------------------
- /// Set whether the process should stop when images change.
- ///
- /// When images (executables and shared libraries) get loaded or
- /// unloaded, often debug sessions will want to try and resolve or
- /// unresolve breakpoints that are set in these images. The default
- /// is set so that the process stops when images change, but this
- /// can be overridden using this function callback.
- ///
- /// @param[in] stop
- /// Boolean value that indicates whether the process should stop
- /// when images change.
- //------------------------------------------------------------------
- void
- SetStopWhenImagesChange (bool stop);
+ //------------------------------------------------------------------
+ /// Helper function that can be used to detect when a process has
+ /// called exec and is now a new and different process. This can
+ /// be called when necessary to try and detect the exec. The process
+ /// might be able to answer this question, but sometimes it might
+ /// not be able and the dynamic loader often knows what the program
+ /// entry point is. So the process and the dynamic loader can work
+ /// together to detect this.
+ //------------------------------------------------------------------
+ virtual bool ProcessDidExec() { return false; }
+ //------------------------------------------------------------------
+ /// Get whether the process should stop when images change.
+ ///
+ /// When images (executables and shared libraries) get loaded or
+ /// unloaded, often debug sessions will want to try and resolve or
+ /// unresolve breakpoints that are set in these images. Any
+ /// breakpoints set by DynamicLoader plug-in instances should
+ /// return this value to ensure consistent debug session behaviour.
+ ///
+ /// @return
+ /// Returns \b true if the process should stop when images
+ /// change, \b false if the process should resume.
+ //------------------------------------------------------------------
+ bool GetStopWhenImagesChange() const;
- //------------------------------------------------------------------
- /// Provides a plan to step through the dynamic loader trampoline
- /// for the current state of \a thread.
- ///
- ///
- /// @param[in] stop_others
- /// Whether the plan should be set to stop other threads.
- ///
- /// @return
- /// A pointer to the plan (caller owned) or NULL if we are not at such
- /// a trampoline.
- //------------------------------------------------------------------
- virtual lldb::ThreadPlanSP
- GetStepThroughTrampolinePlan (Thread &thread, bool stop_others) = 0;
+ //------------------------------------------------------------------
+ /// Set whether the process should stop when images change.
+ ///
+ /// When images (executables and shared libraries) get loaded or
+ /// unloaded, often debug sessions will want to try and resolve or
+ /// unresolve breakpoints that are set in these images. The default
+ /// is set so that the process stops when images change, but this
+ /// can be overridden using this function callback.
+ ///
+ /// @param[in] stop
+ /// Boolean value that indicates whether the process should stop
+ /// when images change.
+ //------------------------------------------------------------------
+ void SetStopWhenImagesChange(bool stop);
+ //------------------------------------------------------------------
+ /// Provides a plan to step through the dynamic loader trampoline
+ /// for the current state of \a thread.
+ ///
+ ///
+ /// @param[in] stop_others
+ /// Whether the plan should be set to stop other threads.
+ ///
+ /// @return
+ /// A pointer to the plan (caller owned) or NULL if we are not at such
+ /// a trampoline.
+ //------------------------------------------------------------------
+ virtual lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
+ bool stop_others) = 0;
- //------------------------------------------------------------------
- /// Some dynamic loaders provide features where there are a group of symbols "equivalent to"
- /// a given symbol one of which will be chosen when the symbol is bound. If you want to
- /// set a breakpoint on one of these symbols, you really need to set it on all the
- /// equivalent symbols.
- ///
- ///
- /// @param[in] original_symbol
- /// The symbol for which we are finding equivalences.
- ///
- /// @param[in] module_list
- /// The set of modules in which to search.
- ///
- /// @param[out] equivalent_symbols
- /// The equivalent symbol list - any equivalent symbols found are appended to this list.
- ///
- /// @return
- /// Number of equivalent symbols found.
- //------------------------------------------------------------------
- virtual size_t
- FindEquivalentSymbols (Symbol *original_symbol, ModuleList &module_list, SymbolContextList &equivalent_symbols)
- {
- return 0;
- }
+ //------------------------------------------------------------------
+ /// Some dynamic loaders provide features where there are a group of symbols
+ /// "equivalent to"
+ /// a given symbol one of which will be chosen when the symbol is bound. If
+ /// you want to
+ /// set a breakpoint on one of these symbols, you really need to set it on all
+ /// the
+ /// equivalent symbols.
+ ///
+ ///
+ /// @param[in] original_symbol
+ /// The symbol for which we are finding equivalences.
+ ///
+ /// @param[in] module_list
+ /// The set of modules in which to search.
+ ///
+ /// @param[out] equivalent_symbols
+ /// The equivalent symbol list - any equivalent symbols found are appended
+ /// to this list.
+ ///
+ /// @return
+ /// Number of equivalent symbols found.
+ //------------------------------------------------------------------
+ virtual size_t FindEquivalentSymbols(Symbol *original_symbol,
+ ModuleList &module_list,
+ SymbolContextList &equivalent_symbols) {
+ return 0;
+ }
- //------------------------------------------------------------------
- /// Ask if it is ok to try and load or unload an shared library
- /// (image).
- ///
- /// The dynamic loader often knows when it would be ok to try and
- /// load or unload a shared library. This function call allows the
- /// dynamic loader plug-ins to check any current dyld state to make
- /// sure it is an ok time to load a shared library.
- ///
- /// @return
- /// \b true if it is currently ok to try and load a shared
- /// library into the process, \b false otherwise.
- //------------------------------------------------------------------
- virtual Error
- CanLoadImage () = 0;
+ //------------------------------------------------------------------
+ /// Ask if it is ok to try and load or unload an shared library
+ /// (image).
+ ///
+ /// The dynamic loader often knows when it would be ok to try and
+ /// load or unload a shared library. This function call allows the
+ /// dynamic loader plug-ins to check any current dyld state to make
+ /// sure it is an ok time to load a shared library.
+ ///
+ /// @return
+ /// \b true if it is currently ok to try and load a shared
+ /// library into the process, \b false otherwise.
+ //------------------------------------------------------------------
+ virtual Error CanLoadImage() = 0;
- //------------------------------------------------------------------
- /// Ask if the eh_frame information for the given SymbolContext should
- /// be relied on even when it's the first frame in a stack unwind.
- ///
- /// The CFI instructions from the eh_frame section are normally only
- /// valid at call sites -- places where a program could throw an
- /// exception and need to unwind out. But some Modules may be known
- /// to the system as having reliable eh_frame information at all call
- /// sites. This would be the case if the Module's contents are largely
- /// hand-written assembly with hand-written eh_frame information.
- /// Normally when unwinding from a function at the beginning of a stack
- /// unwind lldb will examine the assembly instructions to understand
- /// how the stack frame is set up and where saved registers are stored.
- /// But with hand-written assembly this is not reliable enough -- we need
- /// to consult those function's hand-written eh_frame information.
- ///
- /// @return
- /// \b True if the symbol context should use eh_frame instructions
- /// unconditionally when unwinding from this frame. Else \b false,
- /// the normal lldb unwind behavior of only using eh_frame when the
- /// function appears in the middle of the stack.
- //------------------------------------------------------------------
- virtual bool
- AlwaysRelyOnEHUnwindInfo (SymbolContext &sym_ctx)
- {
- return false;
- }
+ //------------------------------------------------------------------
+ /// Ask if the eh_frame information for the given SymbolContext should
+ /// be relied on even when it's the first frame in a stack unwind.
+ ///
+ /// The CFI instructions from the eh_frame section are normally only
+ /// valid at call sites -- places where a program could throw an
+ /// exception and need to unwind out. But some Modules may be known
+ /// to the system as having reliable eh_frame information at all call
+ /// sites. This would be the case if the Module's contents are largely
+ /// hand-written assembly with hand-written eh_frame information.
+ /// Normally when unwinding from a function at the beginning of a stack
+ /// unwind lldb will examine the assembly instructions to understand
+ /// how the stack frame is set up and where saved registers are stored.
+ /// But with hand-written assembly this is not reliable enough -- we need
+ /// to consult those function's hand-written eh_frame information.
+ ///
+ /// @return
+ /// \b True if the symbol context should use eh_frame instructions
+ /// unconditionally when unwinding from this frame. Else \b false,
+ /// the normal lldb unwind behavior of only using eh_frame when the
+ /// function appears in the middle of the stack.
+ //------------------------------------------------------------------
+ virtual bool AlwaysRelyOnEHUnwindInfo(SymbolContext &sym_ctx) {
+ return false;
+ }
- //------------------------------------------------------------------
- /// Retrieves the per-module TLS block for a given thread.
- ///
- /// @param[in] module
- /// The module to query TLS data for.
- ///
- /// @param[in] thread
- /// The specific thread to query TLS data for.
- ///
- /// @return
- /// If the given thread has TLS data allocated for the
- /// module, the address of the TLS block. Otherwise
- /// LLDB_INVALID_ADDRESS is returned.
- //------------------------------------------------------------------
- virtual lldb::addr_t
- GetThreadLocalData(const lldb::ModuleSP module, const lldb::ThreadSP thread, lldb::addr_t tls_file_addr)
- {
- return LLDB_INVALID_ADDRESS;
- }
+ //------------------------------------------------------------------
+ /// Retrieves the per-module TLS block for a given thread.
+ ///
+ /// @param[in] module
+ /// The module to query TLS data for.
+ ///
+ /// @param[in] thread
+ /// The specific thread to query TLS data for.
+ ///
+ /// @return
+ /// If the given thread has TLS data allocated for the
+ /// module, the address of the TLS block. Otherwise
+ /// LLDB_INVALID_ADDRESS is returned.
+ //------------------------------------------------------------------
+ virtual lldb::addr_t GetThreadLocalData(const lldb::ModuleSP module,
+ const lldb::ThreadSP thread,
+ lldb::addr_t tls_file_addr) {
+ return LLDB_INVALID_ADDRESS;
+ }
- /// Locates or creates a module given by @p file and updates/loads the
- /// resulting module at the virtual base address @p base_addr.
- virtual lldb::ModuleSP
- LoadModuleAtAddress(const lldb_private::FileSpec &file,
- lldb::addr_t link_map_addr,
- lldb::addr_t base_addr,
- bool base_addr_is_offset);
+ /// Locates or creates a module given by @p file and updates/loads the
+ /// resulting module at the virtual base address @p base_addr.
+ virtual lldb::ModuleSP LoadModuleAtAddress(const lldb_private::FileSpec &file,
+ lldb::addr_t link_map_addr,
+ lldb::addr_t base_addr,
+ bool base_addr_is_offset);
+
+ //------------------------------------------------------------------
+ /// Get information about the shared cache for a process, if possible.
+ ///
+ /// On some systems (e.g. Darwin based systems), a set of libraries
+ /// that are common to most processes may be put in a single region
+ /// of memory and mapped into every process, this is called the
+ /// shared cache, as a performance optimization.
+ ///
+ /// Many targets will not have the concept of a shared cache.
+ ///
+ /// Depending on how the DynamicLoader gathers information about the
+ /// shared cache, it may be able to only return basic information -
+ /// like the UUID of the cache - or it may be able to return additional
+ /// information about the cache.
+ ///
+ /// @param[out] base_address
+ /// The base address (load address) of the shared cache.
+ /// LLDB_INVALID_ADDRESS if it cannot be determined.
+ ///
+ /// @param[out] uuid
+ /// The UUID of the shared cache, if it can be determined.
+ /// If the UUID cannot be fetched, IsValid() will be false.
+ ///
+ /// @param[out] using_shared_cache
+ /// If this process is using a shared cache.
+ /// If unknown, eLazyBoolCalculate is returned.
+ ///
+ /// @param[out] private_shared_cache
+ /// A LazyBool indicating whether this process is using a
+ /// private shared cache.
+ /// If this information cannot be fetched, eLazyBoolCalculate.
+ ///
+ /// @return
+ /// Returns false if this DynamicLoader cannot gather information
+ /// about the shared cache / has no concept of a shared cache.
+ //------------------------------------------------------------------
+ virtual bool GetSharedCacheInformation(lldb::addr_t &base_address, UUID &uuid,
+ LazyBool &using_shared_cache,
+ LazyBool &private_shared_cache) {
+ base_address = LLDB_INVALID_ADDRESS;
+ uuid.Clear();
+ using_shared_cache = eLazyBoolCalculate;
+ private_shared_cache = eLazyBoolCalculate;
+ return false;
+ }
protected:
- //------------------------------------------------------------------
- // Utility methods for derived classes
- //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ // Utility methods for derived classes
+ //------------------------------------------------------------------
- /// Checks to see if the target module has changed, updates the target
- /// accordingly and returns the target executable module.
- lldb::ModuleSP
- GetTargetExecutable();
+ /// Checks to see if the target module has changed, updates the target
+ /// accordingly and returns the target executable module.
+ lldb::ModuleSP GetTargetExecutable();
- /// Updates the load address of every allocatable section in @p module.
- ///
- /// @param module The module to traverse.
- ///
- /// @param link_map_addr The virtual address of the link map for the @p module.
- ///
- /// @param base_addr The virtual base address @p module is loaded at.
- virtual void
- UpdateLoadedSections(lldb::ModuleSP module,
- lldb::addr_t link_map_addr,
- lldb::addr_t base_addr,
- bool base_addr_is_offset);
+ /// Updates the load address of every allocatable section in @p module.
+ ///
+ /// @param module The module to traverse.
+ ///
+ /// @param link_map_addr The virtual address of the link map for the @p
+ /// module.
+ ///
+ /// @param base_addr The virtual base address @p module is loaded at.
+ virtual void UpdateLoadedSections(lldb::ModuleSP module,
+ lldb::addr_t link_map_addr,
+ lldb::addr_t base_addr,
+ bool base_addr_is_offset);
- // Utility method so base classes can share implementation of UpdateLoadedSections
- void
- UpdateLoadedSectionsCommon(lldb::ModuleSP module,
- lldb::addr_t base_addr,
- bool base_addr_is_offset);
+ // Utility method so base classes can share implementation of
+ // UpdateLoadedSections
+ void UpdateLoadedSectionsCommon(lldb::ModuleSP module, lldb::addr_t base_addr,
+ bool base_addr_is_offset);
- /// Removes the loaded sections from the target in @p module.
- ///
- /// @param module The module to traverse.
- virtual void
- UnloadSections(const lldb::ModuleSP module);
+ /// Removes the loaded sections from the target in @p module.
+ ///
+ /// @param module The module to traverse.
+ virtual void UnloadSections(const lldb::ModuleSP module);
- // Utility method so base classes can share implementation of UnloadSections
- void
- UnloadSectionsCommon(const lldb::ModuleSP module);
+ // Utility method so base classes can share implementation of UnloadSections
+ void UnloadSectionsCommon(const lldb::ModuleSP module);
- const lldb_private::SectionList *
- GetSectionListFromModule(const lldb::ModuleSP module) const;
+ const lldb_private::SectionList *
+ GetSectionListFromModule(const lldb::ModuleSP module) const;
- // Read an unsigned int of the given size from memory at the given addr.
- // Return -1 if the read fails, otherwise return the result as an int64_t.
- int64_t
- ReadUnsignedIntWithSizeInBytes(lldb::addr_t addr, int size_in_bytes);
+ // Read an unsigned int of the given size from memory at the given addr.
+ // Return -1 if the read fails, otherwise return the result as an int64_t.
+ int64_t ReadUnsignedIntWithSizeInBytes(lldb::addr_t addr, int size_in_bytes);
- // Read a pointer from memory at the given addr.
- // Return LLDB_INVALID_ADDRESS if the read fails.
- lldb::addr_t
- ReadPointer(lldb::addr_t addr);
+ // Read a pointer from memory at the given addr.
+ // Return LLDB_INVALID_ADDRESS if the read fails.
+ lldb::addr_t ReadPointer(lldb::addr_t addr);
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- Process* m_process; ///< The process that this dynamic loader plug-in is tracking.
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ Process
+ *m_process; ///< The process that this dynamic loader plug-in is tracking.
private:
-
- DISALLOW_COPY_AND_ASSIGN (DynamicLoader);
+ DISALLOW_COPY_AND_ASSIGN(DynamicLoader);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/ExecutionContext.h b/include/lldb/Target/ExecutionContext.h
index da585e4c9dad..04af3ebc278d 100644
--- a/include/lldb/Target/ExecutionContext.h
+++ b/include/lldb/Target/ExecutionContext.h
@@ -16,26 +16,26 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Target/StackID.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
//===----------------------------------------------------------------------===//
/// Execution context objects refer to objects in the execution of the
-/// program that is being debugged. The consist of one or more of the
+/// program that is being debugged. The consist of one or more of the
/// following objects: target, process, thread, and frame. Many objects
/// in the debugger need to track different executions contexts. For
/// example, a local function variable might have an execution context
-/// that refers to a stack frame. A global or static variable might
+/// that refers to a stack frame. A global or static variable might
/// refer to a target since a stack frame isn't required in order to
/// evaluate a global or static variable (a process isn't necessarily
/// needed for a global variable since we might be able to read the
-/// variable value from a data section in one of the object files in
+/// variable value from a data section in one of the object files in
/// a target). There are two types of objects that hold onto execution
/// contexts: ExecutionContextRef and ExecutionContext. Both of these
/// objects are described below.
-///
+///
/// Not all objects in an ExectionContext objects will be valid. If you want
/// to refer strongly (ExectionContext) or weakly (ExectionContextRef) to
/// a process, then only the process and target references will be valid.
@@ -47,7 +47,8 @@ namespace lldb_private {
//===----------------------------------------------------------------------===//
//----------------------------------------------------------------------
-/// @class ExecutionContextRef ExecutionContext.h "lldb/Target/ExecutionContext.h"
+/// @class ExecutionContextRef ExecutionContext.h
+/// "lldb/Target/ExecutionContext.h"
/// @brief A class that holds a weak reference to an execution context.
///
/// ExecutionContextRef objects are designed to hold onto an execution
@@ -62,296 +63,267 @@ namespace lldb_private {
/// to a stack frame and a stack frame is no longer in a thread, then a
/// ExecutionContextRef object that refers to that frame will not be able
/// to get a shared pointer to those objects since they are no longer around.
-///
+///
/// ExecutionContextRef objects can also be used as objects in classes
-/// that want to track a "previous execution context". Since the weak
+/// that want to track a "previous execution context". Since the weak
/// references to the execution objects (target, process, thread and frame)
-/// don't keep these objects around, they are safe to keep around.
+/// don't keep these objects around, they are safe to keep around.
///
/// The general rule of thumb is all long lived objects that want to
/// refer to execution contexts should use ExecutionContextRef objects.
-/// The ExecutionContext class is used to temporarily get shared
+/// The ExecutionContext class is used to temporarily get shared
/// pointers to any execution context objects that are still around
/// so they are guaranteed to exist during a function that requires the
/// objects. ExecutionContext objects should NOT be used for long term
-/// storage since they will keep objects alive with extra shared pointer
+/// storage since they will keep objects alive with extra shared pointer
/// references to these objects.
//----------------------------------------------------------------------
-class ExecutionContextRef
-{
+class ExecutionContextRef {
public:
- //------------------------------------------------------------------
- /// Default Constructor.
- //------------------------------------------------------------------
- ExecutionContextRef();
-
- //------------------------------------------------------------------
- /// Copy Constructor.
- //------------------------------------------------------------------
- ExecutionContextRef (const ExecutionContextRef &rhs);
-
- //------------------------------------------------------------------
- /// Construct using an ExecutionContext object that might be nullptr.
- ///
- /// If \a exe_ctx_ptr is valid, then make weak references to any
- /// valid objects in the ExecutionContext, otherwise no weak
- /// references to any execution context objects will be made.
- //------------------------------------------------------------------
- ExecutionContextRef (const ExecutionContext *exe_ctx_ptr);
-
- //------------------------------------------------------------------
- /// Construct using an ExecutionContext object.
- ///
- /// Make weak references to any valid objects in the ExecutionContext.
- //------------------------------------------------------------------
- ExecutionContextRef (const ExecutionContext &exe_ctx);
-
- //------------------------------------------------------------------
- /// Construct using the target and all the selected items inside of it
- /// (the process and its selected thread, and the thread's selected
- /// frame). If there is no selected thread, default to the first thread
- /// If there is no selected frame, default to the first frame.
- //------------------------------------------------------------------
- ExecutionContextRef (Target *target, bool adopt_selected);
-
- //------------------------------------------------------------------
- /// Construct using an execution context scope.
- ///
- /// If the ExecutionContextScope object is valid and refers to a frame,
- /// make weak references too the frame, thread, process and target.
- /// If the ExecutionContextScope object is valid and refers to a thread,
- /// make weak references too the thread, process and target.
- /// If the ExecutionContextScope object is valid and refers to a process,
- /// make weak references too the process and target.
- /// If the ExecutionContextScope object is valid and refers to a target,
- /// make weak references too the target.
- //------------------------------------------------------------------
- ExecutionContextRef (ExecutionContextScope *exe_scope);
-
- //------------------------------------------------------------------
- /// Construct using an execution context scope.
- ///
- /// If the ExecutionContextScope object refers to a frame,
- /// make weak references too the frame, thread, process and target.
- /// If the ExecutionContextScope object refers to a thread,
- /// make weak references too the thread, process and target.
- /// If the ExecutionContextScope object refers to a process,
- /// make weak references too the process and target.
- /// If the ExecutionContextScope object refers to a target,
- /// make weak references too the target.
- //------------------------------------------------------------------
- ExecutionContextRef (ExecutionContextScope &exe_scope);
-
- ~ExecutionContextRef();
-
- //------------------------------------------------------------------
- /// Assignment operator
- ///
- /// Copy all weak references in \a rhs.
- //------------------------------------------------------------------
- ExecutionContextRef &
- operator =(const ExecutionContextRef &rhs);
-
- //------------------------------------------------------------------
- /// Assignment operator from a ExecutionContext
- ///
- /// Make weak references to any strongly referenced objects in \a exe_ctx.
- //------------------------------------------------------------------
- ExecutionContextRef &
- operator =(const ExecutionContext &exe_ctx);
-
- //------------------------------------------------------------------
- /// Clear the object's state.
- ///
- /// Sets the process and thread to nullptr, and the frame index to an
- /// invalid value.
- //------------------------------------------------------------------
- void
- Clear ();
-
- //------------------------------------------------------------------
- /// Set accessor that creates a weak reference to the target
- /// referenced in \a target_sp.
- ///
- /// If \a target_sp is valid this object will create a weak
- /// reference to that object, otherwise any previous target weak
- /// reference contained in this object will be reset.
- ///
- /// Only the weak reference to the target will be updated, no other
- /// weak references will be modified. If you want this execution
- /// context to make a weak reference to the target's process, use
- /// the ExecutionContextRef::SetContext() functions.
- ///
- /// @see ExecutionContextRef::SetContext(const lldb::TargetSP &, bool)
- //------------------------------------------------------------------
- void
- SetTargetSP (const lldb::TargetSP &target_sp);
-
- //------------------------------------------------------------------
- /// Set accessor that creates a weak reference to the process
- /// referenced in \a process_sp.
- ///
- /// If \a process_sp is valid this object will create a weak
- /// reference to that object, otherwise any previous process weak
- /// reference contained in this object will be reset.
- ///
- /// Only the weak reference to the process will be updated, no other
- /// weak references will be modified. If you want this execution
- /// context to make a weak reference to the target, use the
- /// ExecutionContextRef::SetContext() functions.
- ///
- /// @see ExecutionContextRef::SetContext(const lldb::ProcessSP &)
- //------------------------------------------------------------------
- void
- SetProcessSP (const lldb::ProcessSP &process_sp);
-
- //------------------------------------------------------------------
- /// Set accessor that creates a weak reference to the thread
- /// referenced in \a thread_sp.
- ///
- /// If \a thread_sp is valid this object will create a weak
- /// reference to that object, otherwise any previous thread weak
- /// reference contained in this object will be reset.
- ///
- /// Only the weak reference to the thread will be updated, no other
- /// weak references will be modified. If you want this execution
- /// context to make a weak reference to the thread's process and
- /// target, use the ExecutionContextRef::SetContext() functions.
- ///
- /// @see ExecutionContextRef::SetContext(const lldb::ThreadSP &)
- //------------------------------------------------------------------
- void
- SetThreadSP (const lldb::ThreadSP &thread_sp);
-
- //------------------------------------------------------------------
- /// Set accessor that creates a weak reference to the frame
- /// referenced in \a frame_sp.
- ///
- /// If \a frame_sp is valid this object will create a weak
- /// reference to that object, otherwise any previous frame weak
- /// reference contained in this object will be reset.
- ///
- /// Only the weak reference to the frame will be updated, no other
- /// weak references will be modified. If you want this execution
- /// context to make a weak reference to the frame's thread, process
- /// and target, use the ExecutionContextRef::SetContext() functions.
- ///
- /// @see ExecutionContextRef::SetContext(const lldb::StackFrameSP &)
- //------------------------------------------------------------------
- void
- SetFrameSP (const lldb::StackFrameSP &frame_sp);
-
- void
- SetTargetPtr (Target* target, bool adopt_selected);
-
- void
- SetProcessPtr (Process *process);
-
- void
- SetThreadPtr (Thread *thread);
-
- void
- SetFramePtr (StackFrame *frame);
-
- //------------------------------------------------------------------
- /// Get accessor that creates a strong reference from the weak target
- /// reference contained in this object.
- ///
- /// @returns
- /// A shared pointer to a target that is not guaranteed to be valid.
- //------------------------------------------------------------------
- lldb::TargetSP
- GetTargetSP () const;
-
- //------------------------------------------------------------------
- /// Get accessor that creates a strong reference from the weak process
- /// reference contained in this object.
- ///
- /// @returns
- /// A shared pointer to a process that is not guaranteed to be valid.
- //------------------------------------------------------------------
- lldb::ProcessSP
- GetProcessSP () const;
-
- //------------------------------------------------------------------
- /// Get accessor that creates a strong reference from the weak thread
- /// reference contained in this object.
- ///
- /// @returns
- /// A shared pointer to a thread that is not guaranteed to be valid.
- //------------------------------------------------------------------
- lldb::ThreadSP
- GetThreadSP () const;
-
- //------------------------------------------------------------------
- /// Get accessor that creates a strong reference from the weak frame
- /// reference contained in this object.
- ///
- /// @returns
- /// A shared pointer to a frame that is not guaranteed to be valid.
- //------------------------------------------------------------------
- lldb::StackFrameSP
- GetFrameSP () const;
-
- //------------------------------------------------------------------
- /// Create an ExecutionContext object from this object.
- ///
- /// Create strong references to any execution context objects that
- /// are still valid. Any of the returned shared pointers in the
- /// ExecutionContext objects is not guaranteed to be valid.
- /// @returns
- /// An execution context object that has strong references to
- /// any valid weak references in this object.
- //------------------------------------------------------------------
- ExecutionContext
- Lock (bool thread_and_frame_only_if_stopped) const;
-
- //------------------------------------------------------------------
- /// Returns true if this object has a weak reference to a thread.
- /// The return value is only an indication of whether this object has
- /// a weak reference and does not indicate whether the weak reference
- /// is valid or not.
- //------------------------------------------------------------------
- bool
- HasThreadRef () const
- {
- return m_tid != LLDB_INVALID_THREAD_ID;
- }
-
- //------------------------------------------------------------------
- /// Returns true if this object has a weak reference to a frame.
- /// The return value is only an indication of whether this object has
- /// a weak reference and does not indicate whether the weak reference
- /// is valid or not.
- //------------------------------------------------------------------
- bool
- HasFrameRef () const
- {
- return m_stack_id.IsValid();
- }
-
- void
- ClearThread ()
- {
- m_thread_wp.reset();
- m_tid = LLDB_INVALID_THREAD_ID;
- }
-
- void
- ClearFrame ()
- {
- m_stack_id.Clear();
- }
+ //------------------------------------------------------------------
+ /// Default Constructor.
+ //------------------------------------------------------------------
+ ExecutionContextRef();
+
+ //------------------------------------------------------------------
+ /// Copy Constructor.
+ //------------------------------------------------------------------
+ ExecutionContextRef(const ExecutionContextRef &rhs);
+
+ //------------------------------------------------------------------
+ /// Construct using an ExecutionContext object that might be nullptr.
+ ///
+ /// If \a exe_ctx_ptr is valid, then make weak references to any
+ /// valid objects in the ExecutionContext, otherwise no weak
+ /// references to any execution context objects will be made.
+ //------------------------------------------------------------------
+ ExecutionContextRef(const ExecutionContext *exe_ctx_ptr);
+
+ //------------------------------------------------------------------
+ /// Construct using an ExecutionContext object.
+ ///
+ /// Make weak references to any valid objects in the ExecutionContext.
+ //------------------------------------------------------------------
+ ExecutionContextRef(const ExecutionContext &exe_ctx);
+
+ //------------------------------------------------------------------
+ /// Construct using the target and all the selected items inside of it
+ /// (the process and its selected thread, and the thread's selected
+ /// frame). If there is no selected thread, default to the first thread
+ /// If there is no selected frame, default to the first frame.
+ //------------------------------------------------------------------
+ ExecutionContextRef(Target *target, bool adopt_selected);
+
+ //------------------------------------------------------------------
+ /// Construct using an execution context scope.
+ ///
+ /// If the ExecutionContextScope object is valid and refers to a frame,
+ /// make weak references too the frame, thread, process and target.
+ /// If the ExecutionContextScope object is valid and refers to a thread,
+ /// make weak references too the thread, process and target.
+ /// If the ExecutionContextScope object is valid and refers to a process,
+ /// make weak references too the process and target.
+ /// If the ExecutionContextScope object is valid and refers to a target,
+ /// make weak references too the target.
+ //------------------------------------------------------------------
+ ExecutionContextRef(ExecutionContextScope *exe_scope);
+
+ //------------------------------------------------------------------
+ /// Construct using an execution context scope.
+ ///
+ /// If the ExecutionContextScope object refers to a frame,
+ /// make weak references too the frame, thread, process and target.
+ /// If the ExecutionContextScope object refers to a thread,
+ /// make weak references too the thread, process and target.
+ /// If the ExecutionContextScope object refers to a process,
+ /// make weak references too the process and target.
+ /// If the ExecutionContextScope object refers to a target,
+ /// make weak references too the target.
+ //------------------------------------------------------------------
+ ExecutionContextRef(ExecutionContextScope &exe_scope);
+
+ ~ExecutionContextRef();
+
+ //------------------------------------------------------------------
+ /// Assignment operator
+ ///
+ /// Copy all weak references in \a rhs.
+ //------------------------------------------------------------------
+ ExecutionContextRef &operator=(const ExecutionContextRef &rhs);
+
+ //------------------------------------------------------------------
+ /// Assignment operator from a ExecutionContext
+ ///
+ /// Make weak references to any strongly referenced objects in \a exe_ctx.
+ //------------------------------------------------------------------
+ ExecutionContextRef &operator=(const ExecutionContext &exe_ctx);
+
+ //------------------------------------------------------------------
+ /// Clear the object's state.
+ ///
+ /// Sets the process and thread to nullptr, and the frame index to an
+ /// invalid value.
+ //------------------------------------------------------------------
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Set accessor that creates a weak reference to the target
+ /// referenced in \a target_sp.
+ ///
+ /// If \a target_sp is valid this object will create a weak
+ /// reference to that object, otherwise any previous target weak
+ /// reference contained in this object will be reset.
+ ///
+ /// Only the weak reference to the target will be updated, no other
+ /// weak references will be modified. If you want this execution
+ /// context to make a weak reference to the target's process, use
+ /// the ExecutionContextRef::SetContext() functions.
+ ///
+ /// @see ExecutionContextRef::SetContext(const lldb::TargetSP &, bool)
+ //------------------------------------------------------------------
+ void SetTargetSP(const lldb::TargetSP &target_sp);
+
+ //------------------------------------------------------------------
+ /// Set accessor that creates a weak reference to the process
+ /// referenced in \a process_sp.
+ ///
+ /// If \a process_sp is valid this object will create a weak
+ /// reference to that object, otherwise any previous process weak
+ /// reference contained in this object will be reset.
+ ///
+ /// Only the weak reference to the process will be updated, no other
+ /// weak references will be modified. If you want this execution
+ /// context to make a weak reference to the target, use the
+ /// ExecutionContextRef::SetContext() functions.
+ ///
+ /// @see ExecutionContextRef::SetContext(const lldb::ProcessSP &)
+ //------------------------------------------------------------------
+ void SetProcessSP(const lldb::ProcessSP &process_sp);
+
+ //------------------------------------------------------------------
+ /// Set accessor that creates a weak reference to the thread
+ /// referenced in \a thread_sp.
+ ///
+ /// If \a thread_sp is valid this object will create a weak
+ /// reference to that object, otherwise any previous thread weak
+ /// reference contained in this object will be reset.
+ ///
+ /// Only the weak reference to the thread will be updated, no other
+ /// weak references will be modified. If you want this execution
+ /// context to make a weak reference to the thread's process and
+ /// target, use the ExecutionContextRef::SetContext() functions.
+ ///
+ /// @see ExecutionContextRef::SetContext(const lldb::ThreadSP &)
+ //------------------------------------------------------------------
+ void SetThreadSP(const lldb::ThreadSP &thread_sp);
+
+ //------------------------------------------------------------------
+ /// Set accessor that creates a weak reference to the frame
+ /// referenced in \a frame_sp.
+ ///
+ /// If \a frame_sp is valid this object will create a weak
+ /// reference to that object, otherwise any previous frame weak
+ /// reference contained in this object will be reset.
+ ///
+ /// Only the weak reference to the frame will be updated, no other
+ /// weak references will be modified. If you want this execution
+ /// context to make a weak reference to the frame's thread, process
+ /// and target, use the ExecutionContextRef::SetContext() functions.
+ ///
+ /// @see ExecutionContextRef::SetContext(const lldb::StackFrameSP &)
+ //------------------------------------------------------------------
+ void SetFrameSP(const lldb::StackFrameSP &frame_sp);
+
+ void SetTargetPtr(Target *target, bool adopt_selected);
+
+ void SetProcessPtr(Process *process);
+
+ void SetThreadPtr(Thread *thread);
+
+ void SetFramePtr(StackFrame *frame);
+
+ //------------------------------------------------------------------
+ /// Get accessor that creates a strong reference from the weak target
+ /// reference contained in this object.
+ ///
+ /// @returns
+ /// A shared pointer to a target that is not guaranteed to be valid.
+ //------------------------------------------------------------------
+ lldb::TargetSP GetTargetSP() const;
+
+ //------------------------------------------------------------------
+ /// Get accessor that creates a strong reference from the weak process
+ /// reference contained in this object.
+ ///
+ /// @returns
+ /// A shared pointer to a process that is not guaranteed to be valid.
+ //------------------------------------------------------------------
+ lldb::ProcessSP GetProcessSP() const;
+
+ //------------------------------------------------------------------
+ /// Get accessor that creates a strong reference from the weak thread
+ /// reference contained in this object.
+ ///
+ /// @returns
+ /// A shared pointer to a thread that is not guaranteed to be valid.
+ //------------------------------------------------------------------
+ lldb::ThreadSP GetThreadSP() const;
+
+ //------------------------------------------------------------------
+ /// Get accessor that creates a strong reference from the weak frame
+ /// reference contained in this object.
+ ///
+ /// @returns
+ /// A shared pointer to a frame that is not guaranteed to be valid.
+ //------------------------------------------------------------------
+ lldb::StackFrameSP GetFrameSP() const;
+
+ //------------------------------------------------------------------
+ /// Create an ExecutionContext object from this object.
+ ///
+ /// Create strong references to any execution context objects that
+ /// are still valid. Any of the returned shared pointers in the
+ /// ExecutionContext objects is not guaranteed to be valid.
+ /// @returns
+ /// An execution context object that has strong references to
+ /// any valid weak references in this object.
+ //------------------------------------------------------------------
+ ExecutionContext Lock(bool thread_and_frame_only_if_stopped) const;
+
+ //------------------------------------------------------------------
+ /// Returns true if this object has a weak reference to a thread.
+ /// The return value is only an indication of whether this object has
+ /// a weak reference and does not indicate whether the weak reference
+ /// is valid or not.
+ //------------------------------------------------------------------
+ bool HasThreadRef() const { return m_tid != LLDB_INVALID_THREAD_ID; }
+
+ //------------------------------------------------------------------
+ /// Returns true if this object has a weak reference to a frame.
+ /// The return value is only an indication of whether this object has
+ /// a weak reference and does not indicate whether the weak reference
+ /// is valid or not.
+ //------------------------------------------------------------------
+ bool HasFrameRef() const { return m_stack_id.IsValid(); }
+
+ void ClearThread() {
+ m_thread_wp.reset();
+ m_tid = LLDB_INVALID_THREAD_ID;
+ }
+
+ void ClearFrame() { m_stack_id.Clear(); }
protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- lldb::TargetWP m_target_wp; ///< A weak reference to a target
- lldb::ProcessWP m_process_wp; ///< A weak reference to a process
- mutable lldb::ThreadWP m_thread_wp; ///< A weak reference to a thread
- lldb::tid_t m_tid; ///< The thread ID that this object refers to in case the backing object changes
- StackID m_stack_id; ///< The stack ID that this object refers to in case the backing object changes
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ lldb::TargetWP m_target_wp; ///< A weak reference to a target
+ lldb::ProcessWP m_process_wp; ///< A weak reference to a process
+ mutable lldb::ThreadWP m_thread_wp; ///< A weak reference to a thread
+ lldb::tid_t m_tid; ///< The thread ID that this object refers to in case the
+ ///backing object changes
+ StackID m_stack_id; ///< The stack ID that this object refers to in case the
+ ///backing object changes
};
//----------------------------------------------------------------------
@@ -362,7 +334,7 @@ protected:
/// a context that specifies a target, process, thread and frame.
/// These objects are designed to be used for short term execution
/// context object storage while a function might be trying to evaluate
-/// something that requires a thread or frame. ExecutionContextRef
+/// something that requires a thread or frame. ExecutionContextRef
/// objects can be used to initialize one of these objects to turn
/// the weak execution context object references to the target, process,
/// thread and frame into strong references (shared pointers) so that
@@ -375,413 +347,360 @@ protected:
/// require specific contexts. They should NOT be used for long term
/// storage, for long term storage use ExecutionContextRef objects.
//----------------------------------------------------------------------
-class ExecutionContext
-{
+class ExecutionContext {
public:
- //------------------------------------------------------------------
- /// Default Constructor.
- //------------------------------------------------------------------
- ExecutionContext();
-
- //------------------------------------------------------------------
- // Copy constructor
- //------------------------------------------------------------------
- ExecutionContext (const ExecutionContext &rhs);
-
- //------------------------------------------------------------------
- // Adopt the target and optionally its current context.
- //------------------------------------------------------------------
- ExecutionContext (Target* t, bool fill_current_process_thread_frame = true);
-
- //------------------------------------------------------------------
- // Create execution contexts from shared pointers
- //------------------------------------------------------------------
- ExecutionContext (const lldb::TargetSP &target_sp, bool get_process);
- ExecutionContext (const lldb::ProcessSP &process_sp);
- ExecutionContext (const lldb::ThreadSP &thread_sp);
- ExecutionContext (const lldb::StackFrameSP &frame_sp);
-
- //------------------------------------------------------------------
- // Create execution contexts from weak pointers
- //------------------------------------------------------------------
- ExecutionContext (const lldb::TargetWP &target_wp, bool get_process);
- ExecutionContext (const lldb::ProcessWP &process_wp);
- ExecutionContext (const lldb::ThreadWP &thread_wp);
- ExecutionContext (const lldb::StackFrameWP &frame_wp);
- ExecutionContext (const ExecutionContextRef &exe_ctx_ref);
- ExecutionContext (const ExecutionContextRef *exe_ctx_ref, bool thread_and_frame_only_if_stopped = false);
-
- // These two variants take in a locker, and grab the target, lock the API mutex into locker, then
- // fill in the rest of the shared pointers.
- ExecutionContext(const ExecutionContextRef &exe_ctx_ref, std::unique_lock<std::recursive_mutex> &locker);
- ExecutionContext(const ExecutionContextRef *exe_ctx_ref, std::unique_lock<std::recursive_mutex> &locker);
- //------------------------------------------------------------------
- // Create execution contexts from execution context scopes
- //------------------------------------------------------------------
- ExecutionContext (ExecutionContextScope *exe_scope);
- ExecutionContext (ExecutionContextScope &exe_scope);
-
- //------------------------------------------------------------------
- /// Construct with process, thread, and frame index.
- ///
- /// Initialize with process \a p, thread \a t, and frame index \a f.
- ///
- /// @param[in] process
- /// The process for this execution context.
- ///
- /// @param[in] thread
- /// The thread for this execution context.
- ///
- /// @param[in] frame
- /// The frame index for this execution context.
- //------------------------------------------------------------------
- ExecutionContext(Process* process,
- Thread *thread = nullptr,
- StackFrame * frame = nullptr);
-
-
- ~ExecutionContext();
-
- ExecutionContext &
- operator =(const ExecutionContext &rhs);
-
- bool
- operator ==(const ExecutionContext &rhs) const;
-
- bool
- operator !=(const ExecutionContext &rhs) const;
-
- //------------------------------------------------------------------
- /// Clear the object's state.
- ///
- /// Sets the process and thread to nullptr, and the frame index to an
- /// invalid value.
- //------------------------------------------------------------------
- void
- Clear ();
-
- RegisterContext *
- GetRegisterContext () const;
-
- ExecutionContextScope *
- GetBestExecutionContextScope () const;
-
- uint32_t
- GetAddressByteSize() const;
-
- lldb::ByteOrder
- GetByteOrder() const;
-
- //------------------------------------------------------------------
- /// Returns a pointer to the target object.
- ///
- /// The returned pointer might be nullptr. Calling HasTargetScope(),
- /// HasProcessScope(), HasThreadScope(), or HasFrameScope()
- /// can help to pre-validate this pointer so that this accessor can
- /// freely be used without having to check for nullptr each time.
- ///
- /// @see ExecutionContext::HasTargetScope() const
- /// @see ExecutionContext::HasProcessScope() const
- /// @see ExecutionContext::HasThreadScope() const
- /// @see ExecutionContext::HasFrameScope() const
- //------------------------------------------------------------------
- Target *
- GetTargetPtr () const;
-
- //------------------------------------------------------------------
- /// Returns a pointer to the process object.
- ///
- /// The returned pointer might be nullptr. Calling HasProcessScope(),
- /// HasThreadScope(), or HasFrameScope() can help to pre-validate
- /// this pointer so that this accessor can freely be used without
- /// having to check for nullptr each time.
- ///
- /// @see ExecutionContext::HasProcessScope() const
- /// @see ExecutionContext::HasThreadScope() const
- /// @see ExecutionContext::HasFrameScope() const
- //------------------------------------------------------------------
- Process *
- GetProcessPtr () const;
-
- //------------------------------------------------------------------
- /// Returns a pointer to the thread object.
- ///
- /// The returned pointer might be nullptr. Calling HasThreadScope() or
- /// HasFrameScope() can help to pre-validate this pointer so that
- /// this accessor can freely be used without having to check for
- /// nullptr each time.
- ///
- /// @see ExecutionContext::HasThreadScope() const
- /// @see ExecutionContext::HasFrameScope() const
- //------------------------------------------------------------------
- Thread *
- GetThreadPtr () const
- {
- return m_thread_sp.get();
- }
-
- //------------------------------------------------------------------
- /// Returns a pointer to the frame object.
- ///
- /// The returned pointer might be nullptr. Calling HasFrameScope(),
- /// can help to pre-validate this pointer so that this accessor can
- /// freely be used without having to check for nullptr each time.
- ///
- /// @see ExecutionContext::HasFrameScope() const
- //------------------------------------------------------------------
- StackFrame *
- GetFramePtr () const
- {
- return m_frame_sp.get();
- }
-
- //------------------------------------------------------------------
- /// Returns a reference to the target object.
- ///
- /// Clients should call HasTargetScope(), HasProcessScope(),
- /// HasThreadScope(), or HasFrameScope() prior to calling this
- /// function to ensure that this ExecutionContext object contains
- /// a valid target.
- ///
- /// @see ExecutionContext::HasTargetScope() const
- /// @see ExecutionContext::HasProcessScope() const
- /// @see ExecutionContext::HasThreadScope() const
- /// @see ExecutionContext::HasFrameScope() const
- //------------------------------------------------------------------
- Target &
- GetTargetRef () const;
-
- //------------------------------------------------------------------
- /// Returns a reference to the process object.
- ///
- /// Clients should call HasProcessScope(), HasThreadScope(), or
- /// HasFrameScope() prior to calling this function to ensure that
- /// this ExecutionContext object contains a valid target.
- ///
- /// @see ExecutionContext::HasProcessScope() const
- /// @see ExecutionContext::HasThreadScope() const
- /// @see ExecutionContext::HasFrameScope() const
- //------------------------------------------------------------------
- Process &
- GetProcessRef () const;
-
- //------------------------------------------------------------------
- /// Returns a reference to the thread object.
- ///
- /// Clients should call HasThreadScope(), or HasFrameScope() prior
- /// to calling this function to ensure that this ExecutionContext
- /// object contains a valid target.
- ///
- /// @see ExecutionContext::HasThreadScope() const
- /// @see ExecutionContext::HasFrameScope() const
- //------------------------------------------------------------------
- Thread &
- GetThreadRef () const;
-
- //------------------------------------------------------------------
- /// Returns a reference to the thread object.
- ///
- /// Clients should call HasFrameScope() prior to calling this
- /// function to ensure that this ExecutionContext object contains
- /// a valid target.
- ///
- /// @see ExecutionContext::HasFrameScope() const
- //------------------------------------------------------------------
- StackFrame &
- GetFrameRef () const;
-
- //------------------------------------------------------------------
- /// Get accessor to get the target shared pointer.
- ///
- /// The returned shared pointer is not guaranteed to be valid.
- //------------------------------------------------------------------
- const lldb::TargetSP &
- GetTargetSP () const
- {
- return m_target_sp;
- }
-
- //------------------------------------------------------------------
- /// Get accessor to get the process shared pointer.
- ///
- /// The returned shared pointer is not guaranteed to be valid.
- //------------------------------------------------------------------
- const lldb::ProcessSP &
- GetProcessSP () const
- {
- return m_process_sp;
- }
-
- //------------------------------------------------------------------
- /// Get accessor to get the thread shared pointer.
- ///
- /// The returned shared pointer is not guaranteed to be valid.
- //------------------------------------------------------------------
- const lldb::ThreadSP &
- GetThreadSP () const
- {
- return m_thread_sp;
- }
-
- //------------------------------------------------------------------
- /// Get accessor to get the frame shared pointer.
- ///
- /// The returned shared pointer is not guaranteed to be valid.
- //------------------------------------------------------------------
- const lldb::StackFrameSP &
- GetFrameSP () const
- {
- return m_frame_sp;
- }
-
- //------------------------------------------------------------------
- /// Set accessor to set only the target shared pointer.
- //------------------------------------------------------------------
- void
- SetTargetSP (const lldb::TargetSP &target_sp);
-
- //------------------------------------------------------------------
- /// Set accessor to set only the process shared pointer.
- //------------------------------------------------------------------
- void
- SetProcessSP (const lldb::ProcessSP &process_sp);
-
- //------------------------------------------------------------------
- /// Set accessor to set only the thread shared pointer.
- //------------------------------------------------------------------
- void
- SetThreadSP (const lldb::ThreadSP &thread_sp);
-
- //------------------------------------------------------------------
- /// Set accessor to set only the frame shared pointer.
- //------------------------------------------------------------------
- void
- SetFrameSP (const lldb::StackFrameSP &frame_sp);
-
- //------------------------------------------------------------------
- /// Set accessor to set only the target shared pointer from a target
- /// pointer.
- //------------------------------------------------------------------
- void
- SetTargetPtr (Target* target);
-
- //------------------------------------------------------------------
- /// Set accessor to set only the process shared pointer from a
- /// process pointer.
- //------------------------------------------------------------------
- void
- SetProcessPtr (Process *process);
-
- //------------------------------------------------------------------
- /// Set accessor to set only the thread shared pointer from a thread
- /// pointer.
- //------------------------------------------------------------------
- void
- SetThreadPtr (Thread *thread);
-
- //------------------------------------------------------------------
- /// Set accessor to set only the frame shared pointer from a frame
- /// pointer.
- //------------------------------------------------------------------
- void
- SetFramePtr (StackFrame *frame);
-
- //------------------------------------------------------------------
- // Set the execution context using a target shared pointer.
- //
- // If "target_sp" is valid, sets the target context to match and
- // if "get_process" is true, sets the process shared pointer if
- // the target currently has a process.
- //------------------------------------------------------------------
- void
- SetContext (const lldb::TargetSP &target_sp, bool get_process);
-
- //------------------------------------------------------------------
- // Set the execution context using a process shared pointer.
- //
- // If "process_sp" is valid, then set the process and target in this
- // context. Thread and frame contexts will be cleared.
- // If "process_sp" is not valid, all shared pointers are reset.
- //------------------------------------------------------------------
- void
- SetContext (const lldb::ProcessSP &process_sp);
-
- //------------------------------------------------------------------
- // Set the execution context using a thread shared pointer.
- //
- // If "thread_sp" is valid, then set the thread, process and target
- // in this context. The frame context will be cleared.
- // If "thread_sp" is not valid, all shared pointers are reset.
- //------------------------------------------------------------------
- void
- SetContext (const lldb::ThreadSP &thread_sp);
-
- //------------------------------------------------------------------
- // Set the execution context using a frame shared pointer.
- //
- // If "frame_sp" is valid, then set the frame, thread, process and
- // target in this context
- // If "frame_sp" is not valid, all shared pointers are reset.
- //------------------------------------------------------------------
- void
- SetContext (const lldb::StackFrameSP &frame_sp);
-
- //------------------------------------------------------------------
- /// Returns true the ExecutionContext object contains a valid
- /// target.
- ///
- /// This function can be called after initializing an ExecutionContext
- /// object, and if it returns true, calls to GetTargetPtr() and
- /// GetTargetRef() do not need to be checked for validity.
- //------------------------------------------------------------------
- bool
- HasTargetScope () const;
-
- //------------------------------------------------------------------
- /// Returns true the ExecutionContext object contains a valid
- /// target and process.
- ///
- /// This function can be called after initializing an ExecutionContext
- /// object, and if it returns true, calls to GetTargetPtr() and
- /// GetTargetRef(), GetProcessPtr(), and GetProcessRef(), do not
- /// need to be checked for validity.
- //------------------------------------------------------------------
- bool
- HasProcessScope () const;
-
- //------------------------------------------------------------------
- /// Returns true the ExecutionContext object contains a valid
- /// target, process, and thread.
- ///
- /// This function can be called after initializing an ExecutionContext
- /// object, and if it returns true, calls to GetTargetPtr(),
- /// GetTargetRef(), GetProcessPtr(), GetProcessRef(), GetThreadPtr(),
- /// and GetThreadRef() do not need to be checked for validity.
- //------------------------------------------------------------------
- bool
- HasThreadScope () const;
-
- //------------------------------------------------------------------
- /// Returns true the ExecutionContext object contains a valid
- /// target, process, thread and frame.
- ///
- /// This function can be called after initializing an ExecutionContext
- /// object, and if it returns true, calls to GetTargetPtr(),
- /// GetTargetRef(), GetProcessPtr(), GetProcessRef(), GetThreadPtr(),
- /// GetThreadRef(), GetFramePtr(), and GetFrameRef() do not need
- /// to be checked for validity.
- //------------------------------------------------------------------
- bool
- HasFrameScope () const;
-
+ //------------------------------------------------------------------
+ /// Default Constructor.
+ //------------------------------------------------------------------
+ ExecutionContext();
+
+ //------------------------------------------------------------------
+ // Copy constructor
+ //------------------------------------------------------------------
+ ExecutionContext(const ExecutionContext &rhs);
+
+ //------------------------------------------------------------------
+ // Adopt the target and optionally its current context.
+ //------------------------------------------------------------------
+ ExecutionContext(Target *t, bool fill_current_process_thread_frame = true);
+
+ //------------------------------------------------------------------
+ // Create execution contexts from shared pointers
+ //------------------------------------------------------------------
+ ExecutionContext(const lldb::TargetSP &target_sp, bool get_process);
+ ExecutionContext(const lldb::ProcessSP &process_sp);
+ ExecutionContext(const lldb::ThreadSP &thread_sp);
+ ExecutionContext(const lldb::StackFrameSP &frame_sp);
+
+ //------------------------------------------------------------------
+ // Create execution contexts from weak pointers
+ //------------------------------------------------------------------
+ ExecutionContext(const lldb::TargetWP &target_wp, bool get_process);
+ ExecutionContext(const lldb::ProcessWP &process_wp);
+ ExecutionContext(const lldb::ThreadWP &thread_wp);
+ ExecutionContext(const lldb::StackFrameWP &frame_wp);
+ ExecutionContext(const ExecutionContextRef &exe_ctx_ref);
+ ExecutionContext(const ExecutionContextRef *exe_ctx_ref,
+ bool thread_and_frame_only_if_stopped = false);
+
+ // These two variants take in a locker, and grab the target, lock the API
+ // mutex into locker, then
+ // fill in the rest of the shared pointers.
+ ExecutionContext(const ExecutionContextRef &exe_ctx_ref,
+ std::unique_lock<std::recursive_mutex> &locker);
+ ExecutionContext(const ExecutionContextRef *exe_ctx_ref,
+ std::unique_lock<std::recursive_mutex> &locker);
+ //------------------------------------------------------------------
+ // Create execution contexts from execution context scopes
+ //------------------------------------------------------------------
+ ExecutionContext(ExecutionContextScope *exe_scope);
+ ExecutionContext(ExecutionContextScope &exe_scope);
+
+ //------------------------------------------------------------------
+ /// Construct with process, thread, and frame index.
+ ///
+ /// Initialize with process \a p, thread \a t, and frame index \a f.
+ ///
+ /// @param[in] process
+ /// The process for this execution context.
+ ///
+ /// @param[in] thread
+ /// The thread for this execution context.
+ ///
+ /// @param[in] frame
+ /// The frame index for this execution context.
+ //------------------------------------------------------------------
+ ExecutionContext(Process *process, Thread *thread = nullptr,
+ StackFrame *frame = nullptr);
+
+ ~ExecutionContext();
+
+ ExecutionContext &operator=(const ExecutionContext &rhs);
+
+ bool operator==(const ExecutionContext &rhs) const;
+
+ bool operator!=(const ExecutionContext &rhs) const;
+
+ //------------------------------------------------------------------
+ /// Clear the object's state.
+ ///
+ /// Sets the process and thread to nullptr, and the frame index to an
+ /// invalid value.
+ //------------------------------------------------------------------
+ void Clear();
+
+ RegisterContext *GetRegisterContext() const;
+
+ ExecutionContextScope *GetBestExecutionContextScope() const;
+
+ uint32_t GetAddressByteSize() const;
+
+ lldb::ByteOrder GetByteOrder() const;
+
+ //------------------------------------------------------------------
+ /// Returns a pointer to the target object.
+ ///
+ /// The returned pointer might be nullptr. Calling HasTargetScope(),
+ /// HasProcessScope(), HasThreadScope(), or HasFrameScope()
+ /// can help to pre-validate this pointer so that this accessor can
+ /// freely be used without having to check for nullptr each time.
+ ///
+ /// @see ExecutionContext::HasTargetScope() const
+ /// @see ExecutionContext::HasProcessScope() const
+ /// @see ExecutionContext::HasThreadScope() const
+ /// @see ExecutionContext::HasFrameScope() const
+ //------------------------------------------------------------------
+ Target *GetTargetPtr() const;
+
+ //------------------------------------------------------------------
+ /// Returns a pointer to the process object.
+ ///
+ /// The returned pointer might be nullptr. Calling HasProcessScope(),
+ /// HasThreadScope(), or HasFrameScope() can help to pre-validate
+ /// this pointer so that this accessor can freely be used without
+ /// having to check for nullptr each time.
+ ///
+ /// @see ExecutionContext::HasProcessScope() const
+ /// @see ExecutionContext::HasThreadScope() const
+ /// @see ExecutionContext::HasFrameScope() const
+ //------------------------------------------------------------------
+ Process *GetProcessPtr() const;
+
+ //------------------------------------------------------------------
+ /// Returns a pointer to the thread object.
+ ///
+ /// The returned pointer might be nullptr. Calling HasThreadScope() or
+ /// HasFrameScope() can help to pre-validate this pointer so that
+ /// this accessor can freely be used without having to check for
+ /// nullptr each time.
+ ///
+ /// @see ExecutionContext::HasThreadScope() const
+ /// @see ExecutionContext::HasFrameScope() const
+ //------------------------------------------------------------------
+ Thread *GetThreadPtr() const { return m_thread_sp.get(); }
+
+ //------------------------------------------------------------------
+ /// Returns a pointer to the frame object.
+ ///
+ /// The returned pointer might be nullptr. Calling HasFrameScope(),
+ /// can help to pre-validate this pointer so that this accessor can
+ /// freely be used without having to check for nullptr each time.
+ ///
+ /// @see ExecutionContext::HasFrameScope() const
+ //------------------------------------------------------------------
+ StackFrame *GetFramePtr() const { return m_frame_sp.get(); }
+
+ //------------------------------------------------------------------
+ /// Returns a reference to the target object.
+ ///
+ /// Clients should call HasTargetScope(), HasProcessScope(),
+ /// HasThreadScope(), or HasFrameScope() prior to calling this
+ /// function to ensure that this ExecutionContext object contains
+ /// a valid target.
+ ///
+ /// @see ExecutionContext::HasTargetScope() const
+ /// @see ExecutionContext::HasProcessScope() const
+ /// @see ExecutionContext::HasThreadScope() const
+ /// @see ExecutionContext::HasFrameScope() const
+ //------------------------------------------------------------------
+ Target &GetTargetRef() const;
+
+ //------------------------------------------------------------------
+ /// Returns a reference to the process object.
+ ///
+ /// Clients should call HasProcessScope(), HasThreadScope(), or
+ /// HasFrameScope() prior to calling this function to ensure that
+ /// this ExecutionContext object contains a valid target.
+ ///
+ /// @see ExecutionContext::HasProcessScope() const
+ /// @see ExecutionContext::HasThreadScope() const
+ /// @see ExecutionContext::HasFrameScope() const
+ //------------------------------------------------------------------
+ Process &GetProcessRef() const;
+
+ //------------------------------------------------------------------
+ /// Returns a reference to the thread object.
+ ///
+ /// Clients should call HasThreadScope(), or HasFrameScope() prior
+ /// to calling this function to ensure that this ExecutionContext
+ /// object contains a valid target.
+ ///
+ /// @see ExecutionContext::HasThreadScope() const
+ /// @see ExecutionContext::HasFrameScope() const
+ //------------------------------------------------------------------
+ Thread &GetThreadRef() const;
+
+ //------------------------------------------------------------------
+ /// Returns a reference to the thread object.
+ ///
+ /// Clients should call HasFrameScope() prior to calling this
+ /// function to ensure that this ExecutionContext object contains
+ /// a valid target.
+ ///
+ /// @see ExecutionContext::HasFrameScope() const
+ //------------------------------------------------------------------
+ StackFrame &GetFrameRef() const;
+
+ //------------------------------------------------------------------
+ /// Get accessor to get the target shared pointer.
+ ///
+ /// The returned shared pointer is not guaranteed to be valid.
+ //------------------------------------------------------------------
+ const lldb::TargetSP &GetTargetSP() const { return m_target_sp; }
+
+ //------------------------------------------------------------------
+ /// Get accessor to get the process shared pointer.
+ ///
+ /// The returned shared pointer is not guaranteed to be valid.
+ //------------------------------------------------------------------
+ const lldb::ProcessSP &GetProcessSP() const { return m_process_sp; }
+
+ //------------------------------------------------------------------
+ /// Get accessor to get the thread shared pointer.
+ ///
+ /// The returned shared pointer is not guaranteed to be valid.
+ //------------------------------------------------------------------
+ const lldb::ThreadSP &GetThreadSP() const { return m_thread_sp; }
+
+ //------------------------------------------------------------------
+ /// Get accessor to get the frame shared pointer.
+ ///
+ /// The returned shared pointer is not guaranteed to be valid.
+ //------------------------------------------------------------------
+ const lldb::StackFrameSP &GetFrameSP() const { return m_frame_sp; }
+
+ //------------------------------------------------------------------
+ /// Set accessor to set only the target shared pointer.
+ //------------------------------------------------------------------
+ void SetTargetSP(const lldb::TargetSP &target_sp);
+
+ //------------------------------------------------------------------
+ /// Set accessor to set only the process shared pointer.
+ //------------------------------------------------------------------
+ void SetProcessSP(const lldb::ProcessSP &process_sp);
+
+ //------------------------------------------------------------------
+ /// Set accessor to set only the thread shared pointer.
+ //------------------------------------------------------------------
+ void SetThreadSP(const lldb::ThreadSP &thread_sp);
+
+ //------------------------------------------------------------------
+ /// Set accessor to set only the frame shared pointer.
+ //------------------------------------------------------------------
+ void SetFrameSP(const lldb::StackFrameSP &frame_sp);
+
+ //------------------------------------------------------------------
+ /// Set accessor to set only the target shared pointer from a target
+ /// pointer.
+ //------------------------------------------------------------------
+ void SetTargetPtr(Target *target);
+
+ //------------------------------------------------------------------
+ /// Set accessor to set only the process shared pointer from a
+ /// process pointer.
+ //------------------------------------------------------------------
+ void SetProcessPtr(Process *process);
+
+ //------------------------------------------------------------------
+ /// Set accessor to set only the thread shared pointer from a thread
+ /// pointer.
+ //------------------------------------------------------------------
+ void SetThreadPtr(Thread *thread);
+
+ //------------------------------------------------------------------
+ /// Set accessor to set only the frame shared pointer from a frame
+ /// pointer.
+ //------------------------------------------------------------------
+ void SetFramePtr(StackFrame *frame);
+
+ //------------------------------------------------------------------
+ // Set the execution context using a target shared pointer.
+ //
+ // If "target_sp" is valid, sets the target context to match and
+ // if "get_process" is true, sets the process shared pointer if
+ // the target currently has a process.
+ //------------------------------------------------------------------
+ void SetContext(const lldb::TargetSP &target_sp, bool get_process);
+
+ //------------------------------------------------------------------
+ // Set the execution context using a process shared pointer.
+ //
+ // If "process_sp" is valid, then set the process and target in this
+ // context. Thread and frame contexts will be cleared.
+ // If "process_sp" is not valid, all shared pointers are reset.
+ //------------------------------------------------------------------
+ void SetContext(const lldb::ProcessSP &process_sp);
+
+ //------------------------------------------------------------------
+ // Set the execution context using a thread shared pointer.
+ //
+ // If "thread_sp" is valid, then set the thread, process and target
+ // in this context. The frame context will be cleared.
+ // If "thread_sp" is not valid, all shared pointers are reset.
+ //------------------------------------------------------------------
+ void SetContext(const lldb::ThreadSP &thread_sp);
+
+ //------------------------------------------------------------------
+ // Set the execution context using a frame shared pointer.
+ //
+ // If "frame_sp" is valid, then set the frame, thread, process and
+ // target in this context
+ // If "frame_sp" is not valid, all shared pointers are reset.
+ //------------------------------------------------------------------
+ void SetContext(const lldb::StackFrameSP &frame_sp);
+
+ //------------------------------------------------------------------
+ /// Returns true the ExecutionContext object contains a valid
+ /// target.
+ ///
+ /// This function can be called after initializing an ExecutionContext
+ /// object, and if it returns true, calls to GetTargetPtr() and
+ /// GetTargetRef() do not need to be checked for validity.
+ //------------------------------------------------------------------
+ bool HasTargetScope() const;
+
+ //------------------------------------------------------------------
+ /// Returns true the ExecutionContext object contains a valid
+ /// target and process.
+ ///
+ /// This function can be called after initializing an ExecutionContext
+ /// object, and if it returns true, calls to GetTargetPtr() and
+ /// GetTargetRef(), GetProcessPtr(), and GetProcessRef(), do not
+ /// need to be checked for validity.
+ //------------------------------------------------------------------
+ bool HasProcessScope() const;
+
+ //------------------------------------------------------------------
+ /// Returns true the ExecutionContext object contains a valid
+ /// target, process, and thread.
+ ///
+ /// This function can be called after initializing an ExecutionContext
+ /// object, and if it returns true, calls to GetTargetPtr(),
+ /// GetTargetRef(), GetProcessPtr(), GetProcessRef(), GetThreadPtr(),
+ /// and GetThreadRef() do not need to be checked for validity.
+ //------------------------------------------------------------------
+ bool HasThreadScope() const;
+
+ //------------------------------------------------------------------
+ /// Returns true the ExecutionContext object contains a valid
+ /// target, process, thread and frame.
+ ///
+ /// This function can be called after initializing an ExecutionContext
+ /// object, and if it returns true, calls to GetTargetPtr(),
+ /// GetTargetRef(), GetProcessPtr(), GetProcessRef(), GetThreadPtr(),
+ /// GetThreadRef(), GetFramePtr(), and GetFrameRef() do not need
+ /// to be checked for validity.
+ //------------------------------------------------------------------
+ bool HasFrameScope() const;
+
protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- lldb::TargetSP m_target_sp; ///< The target that owns the process/thread/frame
- lldb::ProcessSP m_process_sp; ///< The process that owns the thread/frame
- lldb::ThreadSP m_thread_sp; ///< The thread that owns the frame
- lldb::StackFrameSP m_frame_sp; ///< The stack frame in thread.
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ lldb::TargetSP m_target_sp; ///< The target that owns the process/thread/frame
+ lldb::ProcessSP m_process_sp; ///< The process that owns the thread/frame
+ lldb::ThreadSP m_thread_sp; ///< The thread that owns the frame
+ lldb::StackFrameSP m_frame_sp; ///< The stack frame in thread.
};
} // namespace lldb_private
diff --git a/include/lldb/Target/ExecutionContextScope.h b/include/lldb/Target/ExecutionContextScope.h
index 4a1b17d5a114..36d3d9de49b0 100644
--- a/include/lldb/Target/ExecutionContextScope.h
+++ b/include/lldb/Target/ExecutionContextScope.h
@@ -19,7 +19,8 @@
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class ExecutionContextScope ExecutionContextScope.h "lldb/Symbol/ExecutionContextScope.h"
+/// @class ExecutionContextScope ExecutionContextScope.h
+/// "lldb/Symbol/ExecutionContextScope.h"
/// @brief Inherit from this if your object can reconstruct its
/// execution context.
///
@@ -36,39 +37,32 @@ namespace lldb_private {
/// execution context to allow functions that take a execution contexts
/// to be called.
//----------------------------------------------------------------------
-class ExecutionContextScope
-{
+class ExecutionContextScope {
public:
- virtual
- ~ExecutionContextScope () {}
+ virtual ~ExecutionContextScope() {}
- virtual lldb::TargetSP
- CalculateTarget () = 0;
+ virtual lldb::TargetSP CalculateTarget() = 0;
- virtual lldb::ProcessSP
- CalculateProcess () = 0;
+ virtual lldb::ProcessSP CalculateProcess() = 0;
- virtual lldb::ThreadSP
- CalculateThread () = 0;
+ virtual lldb::ThreadSP CalculateThread() = 0;
- virtual lldb::StackFrameSP
- CalculateStackFrame () = 0;
+ virtual lldb::StackFrameSP CalculateStackFrame() = 0;
- //------------------------------------------------------------------
- /// Reconstruct the object's execution context into \a sc.
- ///
- /// The object should fill in as much of the ExecutionContextScope as it
- /// can so function calls that require a execution context can be made
- /// for the given object.
- ///
- /// @param[out] exe_ctx
- /// A reference to an execution context object that gets filled
- /// in.
- //------------------------------------------------------------------
- virtual void
- CalculateExecutionContext (ExecutionContext &exe_ctx) = 0;
+ //------------------------------------------------------------------
+ /// Reconstruct the object's execution context into \a sc.
+ ///
+ /// The object should fill in as much of the ExecutionContextScope as it
+ /// can so function calls that require a execution context can be made
+ /// for the given object.
+ ///
+ /// @param[out] exe_ctx
+ /// A reference to an execution context object that gets filled
+ /// in.
+ //------------------------------------------------------------------
+ virtual void CalculateExecutionContext(ExecutionContext &exe_ctx) = 0;
};
} // namespace lldb_private
-#endif // liblldb_ExecutionContextScope_h_
+#endif // liblldb_ExecutionContextScope_h_
diff --git a/include/lldb/Target/FileAction.h b/include/lldb/Target/FileAction.h
index 907c4d937beb..81122ec68798 100644
--- a/include/lldb/Target/FileAction.h
+++ b/include/lldb/Target/FileAction.h
@@ -10,65 +10,48 @@
#ifndef liblldb_Target_FileAction_h
#define liblldb_Target_FileAction_h
-#include <string>
#include "lldb/Host/FileSpec.h"
+#include <string>
-namespace lldb_private
-{
+namespace lldb_private {
-class FileAction
-{
- public:
- enum Action
- {
- eFileActionNone,
- eFileActionClose,
- eFileActionDuplicate,
- eFileActionOpen
- };
+class FileAction {
+public:
+ enum Action {
+ eFileActionNone,
+ eFileActionClose,
+ eFileActionDuplicate,
+ eFileActionOpen
+ };
- FileAction();
+ FileAction();
- void Clear();
+ void Clear();
- bool Close(int fd);
+ bool Close(int fd);
- bool Duplicate(int fd, int dup_fd);
+ bool Duplicate(int fd, int dup_fd);
- bool Open(int fd, const FileSpec &file_spec, bool read, bool write);
+ bool Open(int fd, const FileSpec &file_spec, bool read, bool write);
- int
- GetFD() const
- {
- return m_fd;
- }
+ int GetFD() const { return m_fd; }
- Action
- GetAction() const
- {
- return m_action;
- }
+ Action GetAction() const { return m_action; }
- int
- GetActionArgument() const
- {
- return m_arg;
- }
+ int GetActionArgument() const { return m_arg; }
- const char *
- GetPath() const;
+ llvm::StringRef GetPath() const;
- const FileSpec &
- GetFileSpec() const;
+ const FileSpec &GetFileSpec() const;
- void
- Dump (Stream &stream) const;
+ void Dump(Stream &stream) const;
- protected:
- Action m_action; // The action for this file
- int m_fd; // An existing file descriptor
- int m_arg; // oflag for eFileActionOpen*, dup_fd for eFileActionDuplicate
- FileSpec m_file_spec; // A file spec to use for opening after fork or posix_spawn
+protected:
+ Action m_action; // The action for this file
+ int m_fd; // An existing file descriptor
+ int m_arg; // oflag for eFileActionOpen*, dup_fd for eFileActionDuplicate
+ FileSpec
+ m_file_spec; // A file spec to use for opening after fork or posix_spawn
};
} // namespace lldb_private
diff --git a/include/lldb/Target/InstrumentationRuntime.h b/include/lldb/Target/InstrumentationRuntime.h
index a5dc853ab55b..a40914d04ea9 100644
--- a/include/lldb/Target/InstrumentationRuntime.h
+++ b/include/lldb/Target/InstrumentationRuntime.h
@@ -12,40 +12,89 @@
// C Includes
// C++ Includes
-#include <vector>
#include <map>
+#include <vector>
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
-#include "lldb/lldb-types.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "lldb/lldb-private.h"
+#include "lldb/lldb-types.h"
namespace lldb_private {
-
-typedef std::map<lldb::InstrumentationRuntimeType, lldb::InstrumentationRuntimeSP> InstrumentationRuntimeCollection;
-
-class InstrumentationRuntime :
- public std::enable_shared_from_this<InstrumentationRuntime>,
- public PluginInterface
-{
+
+typedef std::map<lldb::InstrumentationRuntimeType,
+ lldb::InstrumentationRuntimeSP>
+ InstrumentationRuntimeCollection;
+
+class InstrumentationRuntime
+ : public std::enable_shared_from_this<InstrumentationRuntime>,
+ public PluginInterface {
+ /// The instrumented process.
+ lldb::ProcessWP m_process_wp;
+
+ /// The module containing the instrumentation runtime.
+ lldb::ModuleSP m_runtime_module;
+
+ /// The breakpoint in the instrumentation runtime.
+ lldb::user_id_t m_breakpoint_id;
+
+ /// Indicates whether or not breakpoints have been registered in the
+ /// instrumentation runtime.
+ bool m_is_active;
+
+protected:
+ InstrumentationRuntime(const lldb::ProcessSP &process_sp)
+ : m_process_wp(), m_runtime_module(), m_breakpoint_id(0),
+ m_is_active(false) {
+ if (process_sp)
+ m_process_wp = process_sp;
+ }
+
+ lldb::ProcessSP GetProcessSP() { return m_process_wp.lock(); }
+
+ lldb::ModuleSP GetRuntimeModuleSP() { return m_runtime_module; }
+
+ void SetRuntimeModuleSP(lldb::ModuleSP module_sp) {
+ m_runtime_module = module_sp;
+ }
+
+ lldb::user_id_t GetBreakpointID() const { return m_breakpoint_id; }
+
+ void SetBreakpointID(lldb::user_id_t ID) { m_breakpoint_id = ID; }
+
+ void SetActive(bool IsActive) { m_is_active = IsActive; }
+
+ /// Return a regular expression which can be used to identify a valid version
+ /// of the runtime library.
+ virtual const RegularExpression &GetPatternForRuntimeLibrary() = 0;
+
+ /// Check whether \p module_sp corresponds to a valid runtime library.
+ virtual bool CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp) = 0;
+
+ /// Register a breakpoint in the runtime library and perform any other
+ /// necessary initialization. The runtime library
+ /// is guaranteed to be loaded.
+ virtual void Activate() = 0;
+
public:
-
- static void
- ModulesDidLoad(lldb_private::ModuleList &module_list, Process *process, InstrumentationRuntimeCollection &runtimes);
-
- virtual void
- ModulesDidLoad(lldb_private::ModuleList &module_list);
-
- virtual bool
- IsActive();
-
- virtual lldb::ThreadCollectionSP
- GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info);
-
+ static void ModulesDidLoad(lldb_private::ModuleList &module_list,
+ Process *process,
+ InstrumentationRuntimeCollection &runtimes);
+
+ /// Look for the instrumentation runtime in \p module_list. Register and
+ /// activate the runtime if this hasn't already
+ /// been done.
+ void ModulesDidLoad(lldb_private::ModuleList &module_list);
+
+ bool IsActive() const { return m_is_active; }
+
+ virtual lldb::ThreadCollectionSP
+ GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info);
};
-
+
} // namespace lldb_private
-#endif // liblldb_InstrumentationRuntime_h_
+#endif // liblldb_InstrumentationRuntime_h_
diff --git a/include/lldb/Target/InstrumentationRuntimeStopInfo.h b/include/lldb/Target/InstrumentationRuntimeStopInfo.h
index df1b937e6e26..0a4a17003d93 100644
--- a/include/lldb/Target/InstrumentationRuntimeStopInfo.h
+++ b/include/lldb/Target/InstrumentationRuntimeStopInfo.h
@@ -16,40 +16,30 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Target/StopInfo.h"
#include "lldb/Core/StructuredData.h"
+#include "lldb/Target/StopInfo.h"
namespace lldb_private {
-class InstrumentationRuntimeStopInfo : public StopInfo
-{
+class InstrumentationRuntimeStopInfo : public StopInfo {
public:
-
- ~InstrumentationRuntimeStopInfo() override
- {
- }
-
- lldb::StopReason
- GetStopReason() const override
- {
- return lldb::eStopReasonInstrumentation;
- }
-
- const char *
- GetDescription() override;
-
- bool
- DoShouldNotify(Event *event_ptr) override
- {
- return true;
- }
-
- static lldb::StopInfoSP
- CreateStopReasonWithInstrumentationData (Thread &thread, std::string description, StructuredData::ObjectSP additional_data);
-
+ ~InstrumentationRuntimeStopInfo() override {}
+
+ lldb::StopReason GetStopReason() const override {
+ return lldb::eStopReasonInstrumentation;
+ }
+
+ const char *GetDescription() override;
+
+ bool DoShouldNotify(Event *event_ptr) override { return true; }
+
+ static lldb::StopInfoSP CreateStopReasonWithInstrumentationData(
+ Thread &thread, std::string description,
+ StructuredData::ObjectSP additional_data);
+
private:
-
- InstrumentationRuntimeStopInfo(Thread &thread, std::string description, StructuredData::ObjectSP additional_data);
+ InstrumentationRuntimeStopInfo(Thread &thread, std::string description,
+ StructuredData::ObjectSP additional_data);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/JITLoader.h b/include/lldb/Target/JITLoader.h
index 8a2d6828db2f..97f2a9796a80 100644
--- a/include/lldb/Target/JITLoader.h
+++ b/include/lldb/Target/JITLoader.h
@@ -21,67 +21,61 @@ namespace lldb_private {
/// @class JITLoader JITLoader.h "lldb/Target/JITLoader.h"
/// @brief A plug-in interface definition class for JIT loaders.
///
-/// Plugins of this kind listen for code generated at runtime in the
+/// Plugins of this kind listen for code generated at runtime in the
/// target. They are very similar to dynamic loader, with the difference
/// that they do not have information about the target's dyld and
-/// that there may be multiple JITLoader plugins per process, while
-/// there is at most one DynamicLoader.
+/// that there may be multiple JITLoader plugins per process, while
+/// there is at most one DynamicLoader.
//----------------------------------------------------------------------
-class JITLoader :
- public PluginInterface
-{
+class JITLoader : public PluginInterface {
public:
- //------------------------------------------------------------------
- /// Find a JIT loader plugin for a given process.
- ///
- /// Scans the installed DynamicLoader plug-ins and tries to find
- /// all applicable instances for the current process.
- ///
- /// @param[in] process
- /// The process for which to try and locate a JIT loader
- /// plug-in instance.
- ///
- //------------------------------------------------------------------
- static void
- LoadPlugins (Process *process, lldb_private::JITLoaderList &list);
+ //------------------------------------------------------------------
+ /// Find a JIT loader plugin for a given process.
+ ///
+ /// Scans the installed DynamicLoader plug-ins and tries to find
+ /// all applicable instances for the current process.
+ ///
+ /// @param[in] process
+ /// The process for which to try and locate a JIT loader
+ /// plug-in instance.
+ ///
+ //------------------------------------------------------------------
+ static void LoadPlugins(Process *process, lldb_private::JITLoaderList &list);
- //------------------------------------------------------------------
- /// Construct with a process.
- //------------------------------------------------------------------
- JITLoader (Process *process);
+ //------------------------------------------------------------------
+ /// Construct with a process.
+ //------------------------------------------------------------------
+ JITLoader(Process *process);
- ~JITLoader() override;
+ ~JITLoader() override;
- //------------------------------------------------------------------
- /// Called after attaching a process.
- ///
- /// Allow JITLoader plug-ins to execute some code after
- /// attaching to a process.
- //------------------------------------------------------------------
- virtual void
- DidAttach () = 0;
+ //------------------------------------------------------------------
+ /// Called after attaching a process.
+ ///
+ /// Allow JITLoader plug-ins to execute some code after
+ /// attaching to a process.
+ //------------------------------------------------------------------
+ virtual void DidAttach() = 0;
- //------------------------------------------------------------------
- /// Called after launching a process.
- ///
- /// Allow JITLoader plug-ins to execute some code after
- /// the process has stopped for the first time on launch.
- //------------------------------------------------------------------
- virtual void
- DidLaunch () = 0;
+ //------------------------------------------------------------------
+ /// Called after launching a process.
+ ///
+ /// Allow JITLoader plug-ins to execute some code after
+ /// the process has stopped for the first time on launch.
+ //------------------------------------------------------------------
+ virtual void DidLaunch() = 0;
- //------------------------------------------------------------------
- /// Called after a new shared object has been loaded so that it can
- /// be probed for JIT entry point hooks.
- //------------------------------------------------------------------
- virtual void
- ModulesDidLoad (lldb_private::ModuleList &module_list) = 0;
+ //------------------------------------------------------------------
+ /// Called after a new shared object has been loaded so that it can
+ /// be probed for JIT entry point hooks.
+ //------------------------------------------------------------------
+ virtual void ModulesDidLoad(lldb_private::ModuleList &module_list) = 0;
protected:
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- Process* m_process;
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ Process *m_process;
};
} // namespace lldb_private
diff --git a/include/lldb/Target/JITLoaderList.h b/include/lldb/Target/JITLoaderList.h
index c86043c5cf1f..4b9d79bbfcab 100644
--- a/include/lldb/Target/JITLoaderList.h
+++ b/include/lldb/Target/JITLoaderList.h
@@ -22,37 +22,28 @@ namespace lldb_private {
///
/// Class used by the Process to hold a list of its JITLoaders.
//----------------------------------------------------------------------
-class JITLoaderList
-{
+class JITLoaderList {
public:
+ JITLoaderList();
+ ~JITLoaderList();
- JITLoaderList();
- ~JITLoaderList();
+ void Append(const lldb::JITLoaderSP &jit_loader_sp);
- void
- Append (const lldb::JITLoaderSP &jit_loader_sp);
+ void Remove(const lldb::JITLoaderSP &jit_loader_sp);
- void
- Remove (const lldb::JITLoaderSP &jit_loader_sp);
+ size_t GetSize() const;
- size_t
- GetSize() const;
+ lldb::JITLoaderSP GetLoaderAtIndex(size_t idx);
- lldb::JITLoaderSP
- GetLoaderAtIndex (size_t idx);
+ void DidLaunch();
- void
- DidLaunch();
+ void DidAttach();
- void
- DidAttach();
-
- void
- ModulesDidLoad (ModuleList &module_list);
+ void ModulesDidLoad(ModuleList &module_list);
private:
- std::vector<lldb::JITLoaderSP> m_jit_loaders_vec;
- std::recursive_mutex m_jit_loaders_mutex;
+ std::vector<lldb::JITLoaderSP> m_jit_loaders_vec;
+ std::recursive_mutex m_jit_loaders_mutex;
};
} // namespace lldb_private
diff --git a/include/lldb/Target/Language.h b/include/lldb/Target/Language.h
index d1a3ff8e6747..bcf840f93edd 100644
--- a/include/lldb/Target/Language.h
+++ b/include/lldb/Target/Language.h
@@ -1,4 +1,5 @@
-//===-- Language.h ---------------------------------------------------*- C++ -*-===//
+//===-- Language.h ---------------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -19,191 +20,255 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
-#include "lldb/lldb-private.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/DataFormatters/DumpValueObjectOptions.h"
#include "lldb/DataFormatters/FormatClasses.h"
#include "lldb/DataFormatters/StringPrinter.h"
+#include "lldb/lldb-private.h"
+#include "lldb/lldb-public.h"
namespace lldb_private {
-
-class Language :
-public PluginInterface
-{
+
+class Language : public PluginInterface {
public:
- class TypeScavenger
- {
+ class TypeScavenger {
+ public:
+ class Result {
public:
- class Result
- {
- public:
- virtual bool
- IsValid () = 0;
-
- virtual bool
- DumpToStream (Stream& stream,
- bool print_help_if_available) = 0;
-
- virtual ~Result() = default;
- };
-
- typedef std::set<std::unique_ptr<Result>> ResultSet;
-
- virtual ~TypeScavenger () = default;
-
- size_t
- Find (ExecutionContextScope *exe_scope,
- const char *key,
- ResultSet &results,
- bool append = true);
-
- protected:
- TypeScavenger () = default;
-
- virtual bool
- Find_Impl (ExecutionContextScope *exe_scope,
- const char *key,
- ResultSet &results) = 0;
+ virtual bool IsValid() = 0;
+
+ virtual bool DumpToStream(Stream &stream,
+ bool print_help_if_available) = 0;
+
+ virtual ~Result() = default;
};
-
- enum class FunctionNameRepresentation
- {
- eName,
- eNameWithArgs,
- eNameWithNoArgs
+
+ typedef std::set<std::unique_ptr<Result>> ResultSet;
+
+ virtual ~TypeScavenger() = default;
+
+ size_t Find(ExecutionContextScope *exe_scope, const char *key,
+ ResultSet &results, bool append = true);
+
+ protected:
+ TypeScavenger() = default;
+
+ virtual bool Find_Impl(ExecutionContextScope *exe_scope, const char *key,
+ ResultSet &results) = 0;
+ };
+
+ class ImageListTypeScavenger : public TypeScavenger {
+ class Result : public Language::TypeScavenger::Result {
+ public:
+ Result(CompilerType type)
+ : Language::TypeScavenger::Result(), m_compiler_type(type) {}
+
+ bool IsValid() override { return m_compiler_type.IsValid(); }
+
+ bool DumpToStream(Stream &stream, bool print_help_if_available) override {
+ if (IsValid()) {
+ m_compiler_type.DumpTypeDescription(&stream);
+ stream.EOL();
+ return true;
+ }
+ return false;
+ }
+
+ ~Result() override = default;
+
+ private:
+ CompilerType m_compiler_type;
};
- ~Language() override;
-
- static Language*
- FindPlugin (lldb::LanguageType language);
-
- // return false from callback to stop iterating
- static void
- ForEach (std::function<bool(Language*)> callback);
-
- virtual lldb::LanguageType
- GetLanguageType () const = 0;
-
- virtual bool
- IsTopLevelFunction (Function& function);
-
- virtual lldb::TypeCategoryImplSP
- GetFormatters ();
-
- virtual HardcodedFormatters::HardcodedFormatFinder
- GetHardcodedFormats ();
-
- virtual HardcodedFormatters::HardcodedSummaryFinder
- GetHardcodedSummaries ();
-
- virtual HardcodedFormatters::HardcodedSyntheticFinder
- GetHardcodedSynthetics ();
-
- virtual HardcodedFormatters::HardcodedValidatorFinder
- GetHardcodedValidators ();
-
- virtual std::vector<ConstString>
- GetPossibleFormattersMatches (ValueObject& valobj, lldb::DynamicValueType use_dynamic);
-
- virtual lldb_private::formatters::StringPrinter::EscapingHelper
- GetStringPrinterEscapingHelper (lldb_private::formatters::StringPrinter::GetPrintableElementType);
-
- virtual std::unique_ptr<TypeScavenger>
- GetTypeScavenger ();
-
- virtual const char*
- GetLanguageSpecificTypeLookupHelp ();
-
- // if an individual data formatter can apply to several types and cross a language boundary
- // it makes sense for individual languages to want to customize the printing of values of that
- // type by appending proper prefix/suffix information in language-specific ways
- virtual bool
- GetFormatterPrefixSuffix (ValueObject& valobj, ConstString type_hint,
- std::string& prefix, std::string& suffix);
-
- // if a language has a custom format for printing variable declarations that it wants LLDB to honor
- // it should return an appropriate closure here
- virtual DumpValueObjectOptions::DeclPrintingHelper
- GetDeclPrintingHelper ();
-
- virtual LazyBool
- IsLogicalTrue (ValueObject& valobj,
- Error& error);
-
- // for a ValueObject of some "reference type", if the value points to the
- // nil/null object, this method returns true
- virtual bool
- IsNilReference (ValueObject& valobj);
-
- // for a ValueObject of some "reference type", if the language provides a technique
- // to decide whether the reference has ever been assigned to some object, this method
- // will return true if such detection is possible, and if the reference has never been assigned
- virtual bool
- IsUninitializedReference (ValueObject& valobj);
-
- virtual bool
- GetFunctionDisplayName (const SymbolContext *sc,
- const ExecutionContext *exe_ctx,
- FunctionNameRepresentation representation,
- Stream& s);
-
- virtual void
- GetExceptionResolverDescription(bool catch_on, bool throw_on, Stream &s);
-
- static void
- GetDefaultExceptionResolverDescription(bool catch_on, bool throw_on, Stream &s);
-
- // These are accessors for general information about the Languages lldb knows about:
-
- static lldb::LanguageType
- GetLanguageTypeFromString (const char *string);
-
- static const char *
- GetNameForLanguageType (lldb::LanguageType language);
-
- static void
- PrintAllLanguages (Stream &s, const char *prefix, const char *suffix);
-
- // return false from callback to stop iterating
- static void
- ForAllLanguages (std::function<bool(lldb::LanguageType)> callback);
-
- static bool
- LanguageIsCPlusPlus (lldb::LanguageType language);
-
- static bool
- LanguageIsObjC (lldb::LanguageType language);
-
- static bool
- LanguageIsC (lldb::LanguageType language);
-
- static bool
- LanguageIsPascal (lldb::LanguageType language);
-
- // return the primary language, so if LanguageIsC(l), return eLanguageTypeC, etc.
- static lldb::LanguageType
- GetPrimaryLanguage (lldb::LanguageType language);
-
- static void
- GetLanguagesSupportingTypeSystems (std::set<lldb::LanguageType> &languages,
- std::set<lldb::LanguageType> &languages_for_expressions);
-
- static void
- GetLanguagesSupportingREPLs (std::set<lldb::LanguageType> &languages);
-
+ protected:
+ ImageListTypeScavenger() = default;
+
+ ~ImageListTypeScavenger() override = default;
+
+ // is this type something we should accept? it's usually going to be a
+ // filter by language + maybe some sugar tweaking
+ // returning an empty type means rejecting this candidate entirely;
+ // any other result will be accepted as a valid match
+ virtual CompilerType AdjustForInclusion(CompilerType &candidate) = 0;
+
+ bool Find_Impl(ExecutionContextScope *exe_scope, const char *key,
+ ResultSet &results) override;
+ };
+
+ template <typename... ScavengerTypes>
+ class EitherTypeScavenger : public TypeScavenger {
+ public:
+ EitherTypeScavenger() : TypeScavenger(), m_scavengers() {
+ for (std::shared_ptr<TypeScavenger> scavenger : { std::shared_ptr<TypeScavenger>(new ScavengerTypes())... }) {
+ if (scavenger)
+ m_scavengers.push_back(scavenger);
+ }
+ }
+ protected:
+ bool Find_Impl(ExecutionContextScope *exe_scope, const char *key,
+ ResultSet &results) override {
+ const bool append = false;
+ for (auto& scavenger : m_scavengers) {
+ if (scavenger && scavenger->Find(exe_scope, key, results, append))
+ return true;
+ }
+ return false;
+ }
+ private:
+ std::vector<std::shared_ptr<TypeScavenger>> m_scavengers;
+ };
+
+ template <typename... ScavengerTypes>
+ class UnionTypeScavenger : public TypeScavenger {
+ public:
+ UnionTypeScavenger() : TypeScavenger(), m_scavengers() {
+ for (std::shared_ptr<TypeScavenger> scavenger : { std::shared_ptr<TypeScavenger>(new ScavengerTypes())... }) {
+ if (scavenger)
+ m_scavengers.push_back(scavenger);
+ }
+ }
+ protected:
+ bool Find_Impl(ExecutionContextScope *exe_scope, const char *key,
+ ResultSet &results) override {
+ const bool append = true;
+ bool success = false;
+ for (auto& scavenger : m_scavengers) {
+ if (scavenger)
+ success = scavenger->Find(exe_scope, key, results, append) || success;
+ }
+ return success;
+ }
+ private:
+ std::vector<std::shared_ptr<TypeScavenger>> m_scavengers;
+ };
+
+ enum class FunctionNameRepresentation {
+ eName,
+ eNameWithArgs,
+ eNameWithNoArgs
+ };
+
+ ~Language() override;
+
+ static Language *FindPlugin(lldb::LanguageType language);
+
+ // return false from callback to stop iterating
+ static void ForEach(std::function<bool(Language *)> callback);
+
+ virtual lldb::LanguageType GetLanguageType() const = 0;
+
+ virtual bool IsTopLevelFunction(Function &function);
+
+ virtual lldb::TypeCategoryImplSP GetFormatters();
+
+ virtual HardcodedFormatters::HardcodedFormatFinder GetHardcodedFormats();
+
+ virtual HardcodedFormatters::HardcodedSummaryFinder GetHardcodedSummaries();
+
+ virtual HardcodedFormatters::HardcodedSyntheticFinder
+ GetHardcodedSynthetics();
+
+ virtual HardcodedFormatters::HardcodedValidatorFinder
+ GetHardcodedValidators();
+
+ virtual std::vector<ConstString>
+ GetPossibleFormattersMatches(ValueObject &valobj,
+ lldb::DynamicValueType use_dynamic);
+
+ virtual lldb_private::formatters::StringPrinter::EscapingHelper
+ GetStringPrinterEscapingHelper(
+ lldb_private::formatters::StringPrinter::GetPrintableElementType);
+
+ virtual std::unique_ptr<TypeScavenger> GetTypeScavenger();
+
+ virtual const char *GetLanguageSpecificTypeLookupHelp();
+
+ // if an individual data formatter can apply to several types and cross a
+ // language boundary
+ // it makes sense for individual languages to want to customize the printing
+ // of values of that
+ // type by appending proper prefix/suffix information in language-specific
+ // ways
+ virtual bool GetFormatterPrefixSuffix(ValueObject &valobj,
+ ConstString type_hint,
+ std::string &prefix,
+ std::string &suffix);
+
+ // if a language has a custom format for printing variable declarations that
+ // it wants LLDB to honor
+ // it should return an appropriate closure here
+ virtual DumpValueObjectOptions::DeclPrintingHelper GetDeclPrintingHelper();
+
+ virtual LazyBool IsLogicalTrue(ValueObject &valobj, Error &error);
+
+ // for a ValueObject of some "reference type", if the value points to the
+ // nil/null object, this method returns true
+ virtual bool IsNilReference(ValueObject &valobj);
+
+ // for a ValueObject of some "reference type", if the language provides a
+ // technique
+ // to decide whether the reference has ever been assigned to some object, this
+ // method
+ // will return true if such detection is possible, and if the reference has
+ // never been assigned
+ virtual bool IsUninitializedReference(ValueObject &valobj);
+
+ virtual bool GetFunctionDisplayName(const SymbolContext *sc,
+ const ExecutionContext *exe_ctx,
+ FunctionNameRepresentation representation,
+ Stream &s);
+
+ virtual void GetExceptionResolverDescription(bool catch_on, bool throw_on,
+ Stream &s);
+
+ static void GetDefaultExceptionResolverDescription(bool catch_on,
+ bool throw_on, Stream &s);
+
+ // These are accessors for general information about the Languages lldb knows
+ // about:
+
+ static lldb::LanguageType
+ GetLanguageTypeFromString(const char *string) = delete;
+ static lldb::LanguageType GetLanguageTypeFromString(llvm::StringRef string);
+
+ static const char *GetNameForLanguageType(lldb::LanguageType language);
+
+ static void PrintAllLanguages(Stream &s, const char *prefix,
+ const char *suffix);
+
+ // return false from callback to stop iterating
+ static void ForAllLanguages(std::function<bool(lldb::LanguageType)> callback);
+
+ static bool LanguageIsCPlusPlus(lldb::LanguageType language);
+
+ static bool LanguageIsObjC(lldb::LanguageType language);
+
+ static bool LanguageIsC(lldb::LanguageType language);
+
+ static bool LanguageIsPascal(lldb::LanguageType language);
+
+ // return the primary language, so if LanguageIsC(l), return eLanguageTypeC,
+ // etc.
+ static lldb::LanguageType GetPrimaryLanguage(lldb::LanguageType language);
+
+ static void GetLanguagesSupportingTypeSystems(
+ std::set<lldb::LanguageType> &languages,
+ std::set<lldb::LanguageType> &languages_for_expressions);
+
+ static void
+ GetLanguagesSupportingREPLs(std::set<lldb::LanguageType> &languages);
+
protected:
- //------------------------------------------------------------------
- // Classes that inherit from Language can see and modify these
- //------------------------------------------------------------------
-
- Language();
+ //------------------------------------------------------------------
+ // Classes that inherit from Language can see and modify these
+ //------------------------------------------------------------------
+
+ Language();
+
private:
-
- DISALLOW_COPY_AND_ASSIGN (Language);
+ DISALLOW_COPY_AND_ASSIGN(Language);
};
-
+
} // namespace lldb_private
#endif // liblldb_Language_h_
diff --git a/include/lldb/Target/LanguageRuntime.h b/include/lldb/Target/LanguageRuntime.h
index beb7a9e74876..a57216e84794 100644
--- a/include/lldb/Target/LanguageRuntime.h
+++ b/include/lldb/Target/LanguageRuntime.h
@@ -1,4 +1,5 @@
-//===-- LanguageRuntime.h ---------------------------------------------------*- C++ -*-===//
+//===-- LanguageRuntime.h ---------------------------------------------------*-
+// C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,168 +15,161 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
#include "lldb/Breakpoint/BreakpointResolver.h"
#include "lldb/Breakpoint/BreakpointResolverName.h"
#include "lldb/Core/PluginInterface.h"
-#include "lldb/lldb-private.h"
-#include "lldb/Core/ValueObject.h"
#include "lldb/Core/Value.h"
-#include "lldb/Target/ExecutionContextScope.h"
+#include "lldb/Core/ValueObject.h"
#include "lldb/Expression/LLVMUserExpression.h"
+#include "lldb/Target/ExecutionContextScope.h"
+#include "lldb/lldb-private.h"
+#include "lldb/lldb-public.h"
#include "clang/Basic/TargetOptions.h"
namespace lldb_private {
-class LanguageRuntime :
- public PluginInterface
-{
+class ExceptionSearchFilter : public SearchFilter {
public:
+ ExceptionSearchFilter(const lldb::TargetSP &target_sp,
+ lldb::LanguageType language,
+ bool update_module_list = true);
+
+ ~ExceptionSearchFilter() override = default;
+
+ bool ModulePasses(const lldb::ModuleSP &module_sp) override;
+
+ bool ModulePasses(const FileSpec &spec) override;
+
+ void Search(Searcher &searcher) override;
+
+ void GetDescription(Stream *s) override;
+
+ static SearchFilter *
+ CreateFromStructuredData(Target &target,
+ const StructuredData::Dictionary &data_dict,
+ Error &error);
+
+ StructuredData::ObjectSP SerializeToStructuredData() override;
- ~LanguageRuntime() override;
-
- static LanguageRuntime*
- FindPlugin (Process *process, lldb::LanguageType language);
-
- static void
- InitializeCommands (CommandObject* parent);
-
- virtual lldb::LanguageType
- GetLanguageType () const = 0;
-
- virtual bool
- GetObjectDescription (Stream &str, ValueObject &object) = 0;
-
- virtual bool
- GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope) = 0;
-
- // this call should return true if it could set the name and/or the type
- virtual bool
- GetDynamicTypeAndAddress (ValueObject &in_value,
- lldb::DynamicValueType use_dynamic,
- TypeAndOrName &class_type_or_name,
- Address &address,
- Value::ValueType &value_type) = 0;
-
- // This call should return a CompilerType given a generic type name
- // and an ExecutionContextScope in which one can actually fetch
- // any specialization information required.
- virtual CompilerType
- GetConcreteType (ExecutionContextScope *exe_scope,
- ConstString abstract_type_name)
- {
- return CompilerType();
- }
-
- // This should be a fast test to determine whether it is likely that this value would
- // have a dynamic type.
- virtual bool
- CouldHaveDynamicValue (ValueObject &in_value) = 0;
-
- // The contract for GetDynamicTypeAndAddress() is to return a "bare-bones" dynamic type
- // For instance, given a Base* pointer, GetDynamicTypeAndAddress() will return the type of
- // Derived, not Derived*. The job of this API is to correct this misalignment between the
- // static type and the discovered dynamic type
- virtual TypeAndOrName
- FixUpDynamicType (const TypeAndOrName& type_and_or_name,
- ValueObject& static_value) = 0;
-
- virtual void
- SetExceptionBreakpoints ()
- {
- }
-
- virtual void
- ClearExceptionBreakpoints ()
- {
- }
-
- virtual bool
- ExceptionBreakpointsAreSet ()
- {
- return false;
- }
-
- virtual bool
- ExceptionBreakpointsExplainStop (lldb::StopInfoSP stop_reason)
- {
- return false;
- }
-
- static lldb::BreakpointSP
- CreateExceptionBreakpoint (Target &target,
- lldb::LanguageType language,
- bool catch_bp,
- bool throw_bp,
- bool is_internal = false);
-
- static Breakpoint::BreakpointPreconditionSP
- CreateExceptionPrecondition (lldb::LanguageType language,
- bool catch_bp,
- bool throw_bp);
- Process *
- GetProcess()
- {
- return m_process;
- }
-
- Target&
- GetTargetRef()
- {
- return m_process->GetTarget();
- }
-
- virtual lldb::BreakpointResolverSP
- CreateExceptionResolver (Breakpoint *bkpt, bool catch_bp, bool throw_bp) = 0;
-
- virtual lldb::SearchFilterSP
- CreateExceptionSearchFilter ();
-
- virtual bool
- GetTypeBitSize (const CompilerType& compiler_type,
- uint64_t &size)
- {
- return false;
- }
-
- virtual bool
- IsRuntimeSupportValue (ValueObject& valobj)
- {
- return false;
- }
-
- virtual void
- ModulesDidLoad (const ModuleList &module_list)
- {
- }
-
- // Called by the Clang expression evaluation engine to allow runtimes to alter the set of target options provided to
- // the compiler.
- // If the options prototype is modified, runtimes must return true, false otherwise.
- virtual bool
- GetOverrideExprOptions(clang::TargetOptions &prototype)
- {
- return false;
- }
-
- // Called by ClangExpressionParser::PrepareForExecution to query for any custom LLVM IR passes
- // that need to be run before an expression is assembled and run.
- virtual bool
- GetIRPasses(LLVMUserExpression::IRPasses &custom_passes)
- {
- return false;
- }
protected:
- //------------------------------------------------------------------
- // Classes that inherit from LanguageRuntime can see and modify these
- //------------------------------------------------------------------
-
- LanguageRuntime(Process *process);
- Process *m_process;
-private:
+ lldb::LanguageType m_language;
+ LanguageRuntime *m_language_runtime;
+ lldb::SearchFilterSP m_filter_sp;
+
+ lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override;
+
+ void UpdateModuleListIfNeeded();
+};
+
+class LanguageRuntime : public PluginInterface {
+public:
+ ~LanguageRuntime() override;
+
+ static LanguageRuntime *FindPlugin(Process *process,
+ lldb::LanguageType language);
+
+ static void InitializeCommands(CommandObject *parent);
+
+ virtual lldb::LanguageType GetLanguageType() const = 0;
- DISALLOW_COPY_AND_ASSIGN (LanguageRuntime);
+ virtual bool GetObjectDescription(Stream &str, ValueObject &object) = 0;
+
+ virtual bool GetObjectDescription(Stream &str, Value &value,
+ ExecutionContextScope *exe_scope) = 0;
+
+ // this call should return true if it could set the name and/or the type
+ virtual bool GetDynamicTypeAndAddress(ValueObject &in_value,
+ lldb::DynamicValueType use_dynamic,
+ TypeAndOrName &class_type_or_name,
+ Address &address,
+ Value::ValueType &value_type) = 0;
+
+ // This call should return a CompilerType given a generic type name
+ // and an ExecutionContextScope in which one can actually fetch
+ // any specialization information required.
+ virtual CompilerType GetConcreteType(ExecutionContextScope *exe_scope,
+ ConstString abstract_type_name) {
+ return CompilerType();
+ }
+
+ // This should be a fast test to determine whether it is likely that this
+ // value would
+ // have a dynamic type.
+ virtual bool CouldHaveDynamicValue(ValueObject &in_value) = 0;
+
+ // The contract for GetDynamicTypeAndAddress() is to return a "bare-bones"
+ // dynamic type
+ // For instance, given a Base* pointer, GetDynamicTypeAndAddress() will return
+ // the type of
+ // Derived, not Derived*. The job of this API is to correct this misalignment
+ // between the
+ // static type and the discovered dynamic type
+ virtual TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name,
+ ValueObject &static_value) = 0;
+
+ virtual void SetExceptionBreakpoints() {}
+
+ virtual void ClearExceptionBreakpoints() {}
+
+ virtual bool ExceptionBreakpointsAreSet() { return false; }
+
+ virtual bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) {
+ return false;
+ }
+
+ static lldb::BreakpointSP
+ CreateExceptionBreakpoint(Target &target, lldb::LanguageType language,
+ bool catch_bp, bool throw_bp,
+ bool is_internal = false);
+
+ static Breakpoint::BreakpointPreconditionSP
+ CreateExceptionPrecondition(lldb::LanguageType language, bool catch_bp,
+ bool throw_bp);
+ Process *GetProcess() { return m_process; }
+
+ Target &GetTargetRef() { return m_process->GetTarget(); }
+
+ virtual lldb::BreakpointResolverSP
+ CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp, bool throw_bp) = 0;
+
+ virtual lldb::SearchFilterSP CreateExceptionSearchFilter();
+
+ virtual bool GetTypeBitSize(const CompilerType &compiler_type,
+ uint64_t &size) {
+ return false;
+ }
+
+ virtual bool IsRuntimeSupportValue(ValueObject &valobj) { return false; }
+
+ virtual void ModulesDidLoad(const ModuleList &module_list) {}
+
+ // Called by the Clang expression evaluation engine to allow runtimes to alter
+ // the set of target options provided to
+ // the compiler.
+ // If the options prototype is modified, runtimes must return true, false
+ // otherwise.
+ virtual bool GetOverrideExprOptions(clang::TargetOptions &prototype) {
+ return false;
+ }
+
+ // Called by ClangExpressionParser::PrepareForExecution to query for any
+ // custom LLVM IR passes
+ // that need to be run before an expression is assembled and run.
+ virtual bool GetIRPasses(LLVMUserExpression::IRPasses &custom_passes) {
+ return false;
+ }
+
+protected:
+ //------------------------------------------------------------------
+ // Classes that inherit from LanguageRuntime can see and modify these
+ //------------------------------------------------------------------
+
+ LanguageRuntime(Process *process);
+ Process *m_process;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(LanguageRuntime);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/Memory.h b/include/lldb/Target/Memory.h
index f4d776a43c99..57275bbda593 100644
--- a/include/lldb/Target/Memory.h
+++ b/include/lldb/Target/Memory.h
@@ -19,187 +19,140 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/RangeMap.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
- //----------------------------------------------------------------------
- // A class to track memory that was read from a live process between
- // runs.
- //----------------------------------------------------------------------
- class MemoryCache
- {
- public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- MemoryCache (Process &process);
-
- ~MemoryCache ();
-
- void
- Clear(bool clear_invalid_ranges = false);
-
- void
- Flush (lldb::addr_t addr, size_t size);
-
- size_t
- Read (lldb::addr_t addr,
- void *dst,
- size_t dst_len,
- Error &error);
-
- uint32_t
- GetMemoryCacheLineSize() const
- {
- return m_L2_cache_line_byte_size ;
- }
-
- void
- AddInvalidRange (lldb::addr_t base_addr, lldb::addr_t byte_size);
-
- bool
- RemoveInvalidRange (lldb::addr_t base_addr, lldb::addr_t byte_size);
-
- // Allow external sources to populate data into the L1 memory cache
- void
- AddL1CacheData(lldb::addr_t addr, const void *src, size_t src_len);
-
- void
- AddL1CacheData(lldb::addr_t addr, const lldb::DataBufferSP &data_buffer_sp);
-
- protected:
- typedef std::map<lldb::addr_t, lldb::DataBufferSP> BlockMap;
- typedef RangeArray<lldb::addr_t, lldb::addr_t, 4> InvalidRanges;
- typedef Range<lldb::addr_t, lldb::addr_t> AddrRange;
- //------------------------------------------------------------------
- // Classes that inherit from MemoryCache can see and modify these
- //------------------------------------------------------------------
- std::recursive_mutex m_mutex;
- BlockMap m_L1_cache; // A first level memory cache whose chunk sizes vary that will be used only if the memory read fits entirely in a chunk
- BlockMap m_L2_cache; // A memory cache of fixed size chinks (m_L2_cache_line_byte_size bytes in size each)
- InvalidRanges m_invalid_ranges;
- Process &m_process;
- uint32_t m_L2_cache_line_byte_size;
- private:
- DISALLOW_COPY_AND_ASSIGN (MemoryCache);
- };
-
-
- class AllocatedBlock
- {
- public:
- AllocatedBlock (lldb::addr_t addr,
- uint32_t byte_size,
- uint32_t permissions,
- uint32_t chunk_size);
-
- ~AllocatedBlock ();
-
- lldb::addr_t
- ReserveBlock (uint32_t size);
-
- bool
- FreeBlock (lldb::addr_t addr);
-
- lldb::addr_t
- GetBaseAddress () const
- {
- return m_addr;
- }
-
- uint32_t
- GetByteSize () const
- {
- return m_byte_size;
- }
-
- uint32_t
- GetPermissions () const
- {
- return m_permissions;
- }
-
- uint32_t
- GetChunkSize () const
- {
- return m_chunk_size;
- }
-
- bool
- Contains (lldb::addr_t addr) const
- {
- return ((addr >= m_addr) && addr < (m_addr + m_byte_size));
- }
- protected:
- uint32_t
- TotalChunks () const
- {
- return m_byte_size / m_chunk_size;
- }
-
- uint32_t
- CalculateChunksNeededForSize (uint32_t size) const
- {
- return (size + m_chunk_size - 1) / m_chunk_size;
- }
- const lldb::addr_t m_addr; // Base address of this block of memory
- const uint32_t m_byte_size; // 4GB of chunk should be enough...
- const uint32_t m_permissions; // Permissions for this memory (logical OR of lldb::Permissions bits)
- const uint32_t m_chunk_size; // The size of chunks that the memory at m_addr is divied up into
- typedef std::map<uint32_t, uint32_t> OffsetToChunkSize;
- OffsetToChunkSize m_offset_to_chunk_size;
- };
-
-
- //----------------------------------------------------------------------
- // A class that can track allocated memory and give out allocated memory
- // without us having to make an allocate/deallocate call every time we
- // need some memory in a process that is being debugged.
- //----------------------------------------------------------------------
- class AllocatedMemoryCache
- {
- public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- AllocatedMemoryCache (Process &process);
-
- ~AllocatedMemoryCache ();
-
- void
- Clear();
-
- lldb::addr_t
- AllocateMemory (size_t byte_size,
- uint32_t permissions,
- Error &error);
-
- bool
- DeallocateMemory (lldb::addr_t ptr);
-
- protected:
- typedef std::shared_ptr<AllocatedBlock> AllocatedBlockSP;
-
- AllocatedBlockSP
- AllocatePage (uint32_t byte_size,
- uint32_t permissions,
- uint32_t chunk_size,
- Error &error);
-
-
- //------------------------------------------------------------------
- // Classes that inherit from MemoryCache can see and modify these
- //------------------------------------------------------------------
- Process &m_process;
- std::recursive_mutex m_mutex;
- typedef std::multimap<uint32_t, AllocatedBlockSP> PermissionsToBlockMap;
- PermissionsToBlockMap m_memory_map;
-
- private:
- DISALLOW_COPY_AND_ASSIGN (AllocatedMemoryCache);
- };
+//----------------------------------------------------------------------
+// A class to track memory that was read from a live process between
+// runs.
+//----------------------------------------------------------------------
+class MemoryCache {
+public:
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ MemoryCache(Process &process);
+
+ ~MemoryCache();
+
+ void Clear(bool clear_invalid_ranges = false);
+
+ void Flush(lldb::addr_t addr, size_t size);
+
+ size_t Read(lldb::addr_t addr, void *dst, size_t dst_len, Error &error);
+
+ uint32_t GetMemoryCacheLineSize() const { return m_L2_cache_line_byte_size; }
+
+ void AddInvalidRange(lldb::addr_t base_addr, lldb::addr_t byte_size);
+
+ bool RemoveInvalidRange(lldb::addr_t base_addr, lldb::addr_t byte_size);
+
+ // Allow external sources to populate data into the L1 memory cache
+ void AddL1CacheData(lldb::addr_t addr, const void *src, size_t src_len);
+
+ void AddL1CacheData(lldb::addr_t addr,
+ const lldb::DataBufferSP &data_buffer_sp);
+
+protected:
+ typedef std::map<lldb::addr_t, lldb::DataBufferSP> BlockMap;
+ typedef RangeArray<lldb::addr_t, lldb::addr_t, 4> InvalidRanges;
+ typedef Range<lldb::addr_t, lldb::addr_t> AddrRange;
+ //------------------------------------------------------------------
+ // Classes that inherit from MemoryCache can see and modify these
+ //------------------------------------------------------------------
+ std::recursive_mutex m_mutex;
+ BlockMap m_L1_cache; // A first level memory cache whose chunk sizes vary that
+ // will be used only if the memory read fits entirely in
+ // a chunk
+ BlockMap m_L2_cache; // A memory cache of fixed size chinks
+ // (m_L2_cache_line_byte_size bytes in size each)
+ InvalidRanges m_invalid_ranges;
+ Process &m_process;
+ uint32_t m_L2_cache_line_byte_size;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(MemoryCache);
+};
+
+class AllocatedBlock {
+public:
+ AllocatedBlock(lldb::addr_t addr, uint32_t byte_size, uint32_t permissions,
+ uint32_t chunk_size);
+
+ ~AllocatedBlock();
+
+ lldb::addr_t ReserveBlock(uint32_t size);
+
+ bool FreeBlock(lldb::addr_t addr);
+
+ lldb::addr_t GetBaseAddress() const { return m_addr; }
+
+ uint32_t GetByteSize() const { return m_byte_size; }
+
+ uint32_t GetPermissions() const { return m_permissions; }
+
+ uint32_t GetChunkSize() const { return m_chunk_size; }
+
+ bool Contains(lldb::addr_t addr) const {
+ return ((addr >= m_addr) && addr < (m_addr + m_byte_size));
+ }
+
+protected:
+ uint32_t TotalChunks() const { return m_byte_size / m_chunk_size; }
+
+ uint32_t CalculateChunksNeededForSize(uint32_t size) const {
+ return (size + m_chunk_size - 1) / m_chunk_size;
+ }
+ const lldb::addr_t m_addr; // Base address of this block of memory
+ const uint32_t m_byte_size; // 4GB of chunk should be enough...
+ const uint32_t m_permissions; // Permissions for this memory (logical OR of
+ // lldb::Permissions bits)
+ const uint32_t m_chunk_size; // The size of chunks that the memory at m_addr
+ // is divied up into
+ typedef std::map<uint32_t, uint32_t> OffsetToChunkSize;
+ OffsetToChunkSize m_offset_to_chunk_size;
+};
+
+//----------------------------------------------------------------------
+// A class that can track allocated memory and give out allocated memory
+// without us having to make an allocate/deallocate call every time we
+// need some memory in a process that is being debugged.
+//----------------------------------------------------------------------
+class AllocatedMemoryCache {
+public:
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ AllocatedMemoryCache(Process &process);
+
+ ~AllocatedMemoryCache();
+
+ void Clear();
+
+ lldb::addr_t AllocateMemory(size_t byte_size, uint32_t permissions,
+ Error &error);
+
+ bool DeallocateMemory(lldb::addr_t ptr);
+
+protected:
+ typedef std::shared_ptr<AllocatedBlock> AllocatedBlockSP;
+
+ AllocatedBlockSP AllocatePage(uint32_t byte_size, uint32_t permissions,
+ uint32_t chunk_size, Error &error);
+
+ //------------------------------------------------------------------
+ // Classes that inherit from MemoryCache can see and modify these
+ //------------------------------------------------------------------
+ Process &m_process;
+ std::recursive_mutex m_mutex;
+ typedef std::multimap<uint32_t, AllocatedBlockSP> PermissionsToBlockMap;
+ PermissionsToBlockMap m_memory_map;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(AllocatedMemoryCache);
+};
} // namespace lldb_private
-#endif // liblldb_Memory_h_
+#endif // liblldb_Memory_h_
diff --git a/include/lldb/Target/MemoryHistory.h b/include/lldb/Target/MemoryHistory.h
index b3bd62d6547c..acc36ffe2eb4 100644
--- a/include/lldb/Target/MemoryHistory.h
+++ b/include/lldb/Target/MemoryHistory.h
@@ -1,4 +1,5 @@
-//===-- MemoryHistory.h ---------------------------------------------------*- C++ -*-===//
+//===-- MemoryHistory.h ---------------------------------------------------*-
+//C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,27 +17,22 @@
// Other libraries and framework includes
// Project includes
+#include "lldb/Core/PluginInterface.h"
#include "lldb/lldb-private.h"
#include "lldb/lldb-types.h"
-#include "lldb/Core/PluginInterface.h"
namespace lldb_private {
-
+
typedef std::vector<lldb::ThreadSP> HistoryThreads;
-
-class MemoryHistory :
- public std::enable_shared_from_this<MemoryHistory>,
- public PluginInterface
-{
-public:
- static lldb::MemoryHistorySP
- FindPlugin (const lldb::ProcessSP process);
+class MemoryHistory : public std::enable_shared_from_this<MemoryHistory>,
+ public PluginInterface {
+public:
+ static lldb::MemoryHistorySP FindPlugin(const lldb::ProcessSP process);
- virtual HistoryThreads
- GetHistoryThreads(lldb::addr_t address) = 0;
+ virtual HistoryThreads GetHistoryThreads(lldb::addr_t address) = 0;
};
-
+
} // namespace lldb_private
-#endif // liblldb_MemoryHistory_h_
+#endif // liblldb_MemoryHistory_h_
diff --git a/include/lldb/Target/MemoryRegionInfo.h b/include/lldb/Target/MemoryRegionInfo.h
index 5c82a1f294dd..be0cfa429b8f 100644
--- a/include/lldb/Target/MemoryRegionInfo.h
+++ b/include/lldb/Target/MemoryRegionInfo.h
@@ -1,4 +1,5 @@
-//===-- MemoryRegionInfo.h ---------------------------------------*- C++ -*-===//
+//===-- MemoryRegionInfo.h ---------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,154 +11,93 @@
#ifndef lldb_MemoryRegionInfo_h
#define lldb_MemoryRegionInfo_h
+#include "lldb/Core/ConstString.h"
#include "lldb/Core/RangeMap.h"
#include "lldb/Utility/Range.h"
-namespace lldb_private
-{
- class MemoryRegionInfo
- {
- public:
- typedef Range<lldb::addr_t, lldb::addr_t> RangeType;
-
- enum OptionalBool {
- eDontKnow = -1,
- eNo = 0,
- eYes = 1
- };
-
- MemoryRegionInfo () :
- m_range (),
- m_read (eDontKnow),
- m_write (eDontKnow),
- m_execute (eDontKnow),
- m_mapped (eDontKnow)
- {
- }
-
- ~MemoryRegionInfo ()
- {
- }
-
- RangeType &
- GetRange()
- {
- return m_range;
- }
-
- void
- Clear()
- {
- m_range.Clear();
- m_read = m_write = m_execute = eDontKnow;
- }
-
- const RangeType &
- GetRange() const
- {
- return m_range;
- }
-
- OptionalBool
- GetReadable () const
- {
- return m_read;
- }
-
- OptionalBool
- GetWritable () const
- {
- return m_write;
- }
-
- OptionalBool
- GetExecutable () const
- {
- return m_execute;
- }
-
- OptionalBool
- GetMapped () const
- {
- return m_mapped;
- }
-
- void
- SetReadable (OptionalBool val)
- {
- m_read = val;
- }
-
- void
- SetWritable (OptionalBool val)
- {
- m_write = val;
- }
-
- void
- SetExecutable (OptionalBool val)
- {
- m_execute = val;
- }
-
- void
- SetMapped (OptionalBool val)
- {
- m_mapped = val;
- }
-
- //----------------------------------------------------------------------
- // Get permissions as a uint32_t that is a mask of one or more bits from
- // the lldb::Permissions
- //----------------------------------------------------------------------
- uint32_t
- GetLLDBPermissions() const
- {
- uint32_t permissions = 0;
- if (m_read)
- permissions |= lldb::ePermissionsReadable;
- if (m_write)
- permissions |= lldb::ePermissionsWritable;
- if (m_execute)
- permissions |= lldb::ePermissionsExecutable;
- return permissions;
- }
-
- //----------------------------------------------------------------------
- // Set permissions from a uint32_t that contains one or more bits from
- // the lldb::Permissions
- //----------------------------------------------------------------------
- void
- SetLLDBPermissions(uint32_t permissions)
- {
- m_read = (permissions & lldb::ePermissionsReadable) ? eYes : eNo;
- m_write = (permissions & lldb::ePermissionsWritable) ? eYes : eNo;
- m_execute = (permissions & lldb::ePermissionsExecutable) ? eYes : eNo;
- }
-
- bool
- operator == (const MemoryRegionInfo &rhs) const
- {
- return m_range == rhs.m_range &&
- m_read == rhs.m_read &&
- m_write == rhs.m_write &&
- m_execute == rhs.m_execute &&
- m_mapped == rhs.m_mapped;
- }
-
- bool
- operator != (const MemoryRegionInfo &rhs) const
- {
- return !(*this == rhs);
- }
-
- protected:
- RangeType m_range;
- OptionalBool m_read;
- OptionalBool m_write;
- OptionalBool m_execute;
- OptionalBool m_mapped;
- };
+namespace lldb_private {
+class MemoryRegionInfo {
+public:
+ typedef Range<lldb::addr_t, lldb::addr_t> RangeType;
+
+ enum OptionalBool { eDontKnow = -1, eNo = 0, eYes = 1 };
+
+ MemoryRegionInfo()
+ : m_range(), m_read(eDontKnow), m_write(eDontKnow), m_execute(eDontKnow),
+ m_mapped(eDontKnow) {}
+
+ ~MemoryRegionInfo() {}
+
+ RangeType &GetRange() { return m_range; }
+
+ void Clear() {
+ m_range.Clear();
+ m_read = m_write = m_execute = eDontKnow;
+ }
+
+ const RangeType &GetRange() const { return m_range; }
+
+ OptionalBool GetReadable() const { return m_read; }
+
+ OptionalBool GetWritable() const { return m_write; }
+
+ OptionalBool GetExecutable() const { return m_execute; }
+
+ OptionalBool GetMapped() const { return m_mapped; }
+
+ const ConstString &GetName() const { return m_name; }
+
+ void SetReadable(OptionalBool val) { m_read = val; }
+
+ void SetWritable(OptionalBool val) { m_write = val; }
+
+ void SetExecutable(OptionalBool val) { m_execute = val; }
+
+ void SetMapped(OptionalBool val) { m_mapped = val; }
+
+ void SetName(const char *name) { m_name = ConstString(name); }
+
+ //----------------------------------------------------------------------
+ // Get permissions as a uint32_t that is a mask of one or more bits from
+ // the lldb::Permissions
+ //----------------------------------------------------------------------
+ uint32_t GetLLDBPermissions() const {
+ uint32_t permissions = 0;
+ if (m_read)
+ permissions |= lldb::ePermissionsReadable;
+ if (m_write)
+ permissions |= lldb::ePermissionsWritable;
+ if (m_execute)
+ permissions |= lldb::ePermissionsExecutable;
+ return permissions;
+ }
+
+ //----------------------------------------------------------------------
+ // Set permissions from a uint32_t that contains one or more bits from
+ // the lldb::Permissions
+ //----------------------------------------------------------------------
+ void SetLLDBPermissions(uint32_t permissions) {
+ m_read = (permissions & lldb::ePermissionsReadable) ? eYes : eNo;
+ m_write = (permissions & lldb::ePermissionsWritable) ? eYes : eNo;
+ m_execute = (permissions & lldb::ePermissionsExecutable) ? eYes : eNo;
+ }
+
+ bool operator==(const MemoryRegionInfo &rhs) const {
+ return m_range == rhs.m_range && m_read == rhs.m_read &&
+ m_write == rhs.m_write && m_execute == rhs.m_execute &&
+ m_mapped == rhs.m_mapped;
+ }
+
+ bool operator!=(const MemoryRegionInfo &rhs) const { return !(*this == rhs); }
+
+protected:
+ RangeType m_range;
+ OptionalBool m_read;
+ OptionalBool m_write;
+ OptionalBool m_execute;
+ OptionalBool m_mapped;
+ ConstString m_name;
+};
}
#endif // #ifndef lldb_MemoryRegionInfo_h
diff --git a/include/lldb/Target/ObjCLanguageRuntime.h b/include/lldb/Target/ObjCLanguageRuntime.h
index 75f096fdedfe..0a9ffa933bd1 100644
--- a/include/lldb/Target/ObjCLanguageRuntime.h
+++ b/include/lldb/Target/ObjCLanguageRuntime.h
@@ -21,500 +21,404 @@
#include "llvm/Support/Casting.h"
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/ThreadSafeDenseMap.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/DeclVendor.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/lldb-private.h"
class CommandObjectObjC_ClassTable_Dump;
namespace lldb_private {
-
+
class UtilityFunction;
-class ObjCLanguageRuntime :
- public LanguageRuntime
-{
+class ObjCLanguageRuntime : public LanguageRuntime {
public:
- enum class ObjCRuntimeVersions
- {
- eObjC_VersionUnknown = 0,
- eAppleObjC_V1 = 1,
- eAppleObjC_V2 = 2
- };
-
- typedef lldb::addr_t ObjCISA;
-
- class ClassDescriptor;
- typedef std::shared_ptr<ClassDescriptor> ClassDescriptorSP;
-
- // the information that we want to support retrieving from an ObjC class
- // this needs to be pure virtual since there are at least 2 different implementations
- // of the runtime, and more might come
- class ClassDescriptor
- {
- public:
- ClassDescriptor() :
- m_is_kvo (eLazyBoolCalculate),
- m_is_cf (eLazyBoolCalculate),
- m_type_wp ()
- {
- }
-
- virtual
- ~ClassDescriptor() = default;
-
- virtual ConstString
- GetClassName () = 0;
-
- virtual ClassDescriptorSP
- GetSuperclass () = 0;
-
- virtual ClassDescriptorSP
- GetMetaclass () const = 0;
-
- // virtual if any implementation has some other version-specific rules
- // but for the known v1/v2 this is all that needs to be done
- virtual bool
- IsKVO ()
- {
- if (m_is_kvo == eLazyBoolCalculate)
- {
- const char* class_name = GetClassName().AsCString();
- if (class_name && *class_name)
- m_is_kvo = (LazyBool)(strstr(class_name,"NSKVONotifying_") == class_name);
- }
- return (m_is_kvo == eLazyBoolYes);
- }
-
- // virtual if any implementation has some other version-specific rules
- // but for the known v1/v2 this is all that needs to be done
- virtual bool
- IsCFType ()
- {
- if (m_is_cf == eLazyBoolCalculate)
- {
- const char* class_name = GetClassName().AsCString();
- if (class_name && *class_name)
- m_is_cf = (LazyBool)(strcmp(class_name,"__NSCFType") == 0 ||
- strcmp(class_name,"NSCFType") == 0);
- }
- return (m_is_cf == eLazyBoolYes);
- }
-
- virtual bool
- IsValid () = 0;
-
- virtual bool
- GetTaggedPointerInfo(uint64_t* info_bits = nullptr,
- uint64_t* value_bits = nullptr,
- uint64_t* payload = nullptr) = 0;
-
- virtual uint64_t
- GetInstanceSize () = 0;
-
- // use to implement version-specific additional constraints on pointers
- virtual bool
- CheckPointer (lldb::addr_t value,
- uint32_t ptr_size) const
- {
- return true;
- }
-
- virtual ObjCISA
- GetISA () = 0;
-
- // This should return true iff the interface could be completed
- virtual bool
- Describe (std::function <void (ObjCISA)> const &superclass_func,
- std::function <bool (const char*, const char*)> const &instance_method_func,
- std::function <bool (const char*, const char*)> const &class_method_func,
- std::function <bool (const char *, const char *, lldb::addr_t, uint64_t)> const &ivar_func) const
- {
- return false;
- }
-
- lldb::TypeSP
- GetType ()
- {
- return m_type_wp.lock();
- }
-
- void
- SetType (const lldb::TypeSP &type_sp)
- {
- m_type_wp = type_sp;
- }
-
- struct iVarDescriptor {
- ConstString m_name;
- CompilerType m_type;
- uint64_t m_size;
- int32_t m_offset;
- };
-
- virtual size_t
- GetNumIVars ()
- {
- return 0;
- }
-
- virtual iVarDescriptor
- GetIVarAtIndex (size_t idx)
- {
- return iVarDescriptor();
- }
-
- protected:
- bool
- IsPointerValid (lldb::addr_t value,
- uint32_t ptr_size,
- bool allow_NULLs = false,
- bool allow_tagged = false,
- bool check_version_specific = false) const;
-
- private:
- LazyBool m_is_kvo;
- LazyBool m_is_cf;
- lldb::TypeWP m_type_wp;
- };
-
- class EncodingToType
- {
- public:
- virtual ~EncodingToType();
-
- virtual CompilerType RealizeType (ClangASTContext& ast_ctx, const char* name, bool for_expression);
- virtual CompilerType RealizeType (const char* name, bool for_expression);
-
- virtual CompilerType RealizeType (clang::ASTContext& ast_ctx, const char* name, bool for_expression) = 0;
-
- protected:
- std::unique_ptr<ClangASTContext> m_scratch_ast_ctx_ap;
- };
+ enum class ObjCRuntimeVersions {
+ eObjC_VersionUnknown = 0,
+ eAppleObjC_V1 = 1,
+ eAppleObjC_V2 = 2
+ };
+
+ typedef lldb::addr_t ObjCISA;
+
+ class ClassDescriptor;
+ typedef std::shared_ptr<ClassDescriptor> ClassDescriptorSP;
+
+ // the information that we want to support retrieving from an ObjC class
+ // this needs to be pure virtual since there are at least 2 different
+ // implementations
+ // of the runtime, and more might come
+ class ClassDescriptor {
+ public:
+ ClassDescriptor()
+ : m_is_kvo(eLazyBoolCalculate), m_is_cf(eLazyBoolCalculate),
+ m_type_wp() {}
+
+ virtual ~ClassDescriptor() = default;
+
+ virtual ConstString GetClassName() = 0;
+
+ virtual ClassDescriptorSP GetSuperclass() = 0;
+
+ virtual ClassDescriptorSP GetMetaclass() const = 0;
+
+ // virtual if any implementation has some other version-specific rules
+ // but for the known v1/v2 this is all that needs to be done
+ virtual bool IsKVO() {
+ if (m_is_kvo == eLazyBoolCalculate) {
+ const char *class_name = GetClassName().AsCString();
+ if (class_name && *class_name)
+ m_is_kvo =
+ (LazyBool)(strstr(class_name, "NSKVONotifying_") == class_name);
+ }
+ return (m_is_kvo == eLazyBoolYes);
+ }
- class ObjCExceptionPrecondition : public Breakpoint::BreakpointPrecondition
- {
- public:
- ObjCExceptionPrecondition();
+ // virtual if any implementation has some other version-specific rules
+ // but for the known v1/v2 this is all that needs to be done
+ virtual bool IsCFType() {
+ if (m_is_cf == eLazyBoolCalculate) {
+ const char *class_name = GetClassName().AsCString();
+ if (class_name && *class_name)
+ m_is_cf = (LazyBool)(strcmp(class_name, "__NSCFType") == 0 ||
+ strcmp(class_name, "NSCFType") == 0);
+ }
+ return (m_is_cf == eLazyBoolYes);
+ }
- ~ObjCExceptionPrecondition() override = default;
+ virtual bool IsValid() = 0;
- bool EvaluatePrecondition(StoppointCallbackContext &context) override;
- void GetDescription(Stream &stream, lldb::DescriptionLevel level) override;
- Error ConfigurePrecondition(Args &args) override;
+ virtual bool GetTaggedPointerInfo(uint64_t *info_bits = nullptr,
+ uint64_t *value_bits = nullptr,
+ uint64_t *payload = nullptr) = 0;
- protected:
- void AddClassName(const char *class_name);
+ virtual uint64_t GetInstanceSize() = 0;
- private:
- std::unordered_set<std::string> m_class_names;
- };
-
- class TaggedPointerVendor
- {
- public:
- virtual
- ~TaggedPointerVendor() = default;
+ // use to implement version-specific additional constraints on pointers
+ virtual bool CheckPointer(lldb::addr_t value, uint32_t ptr_size) const {
+ return true;
+ }
+
+ virtual ObjCISA GetISA() = 0;
- virtual bool
- IsPossibleTaggedPointer (lldb::addr_t ptr) = 0;
-
- virtual ObjCLanguageRuntime::ClassDescriptorSP
- GetClassDescriptor (lldb::addr_t ptr) = 0;
+ // This should return true iff the interface could be completed
+ virtual bool
+ Describe(std::function<void(ObjCISA)> const &superclass_func,
+ std::function<bool(const char *, const char *)> const
+ &instance_method_func,
+ std::function<bool(const char *, const char *)> const
+ &class_method_func,
+ std::function<bool(const char *, const char *, lldb::addr_t,
+ uint64_t)> const &ivar_func) const {
+ return false;
+ }
- protected:
- TaggedPointerVendor() = default;
+ lldb::TypeSP GetType() { return m_type_wp.lock(); }
- private:
- DISALLOW_COPY_AND_ASSIGN(TaggedPointerVendor);
+ void SetType(const lldb::TypeSP &type_sp) { m_type_wp = type_sp; }
+
+ struct iVarDescriptor {
+ ConstString m_name;
+ CompilerType m_type;
+ uint64_t m_size;
+ int32_t m_offset;
};
-
- ~ObjCLanguageRuntime() override;
- virtual TaggedPointerVendor*
- GetTaggedPointerVendor ()
- {
- return nullptr;
- }
-
- typedef std::shared_ptr<EncodingToType> EncodingToTypeSP;
-
- virtual EncodingToTypeSP
- GetEncodingToType ();
-
- virtual ClassDescriptorSP
- GetClassDescriptor (ValueObject& in_value);
-
- ClassDescriptorSP
- GetNonKVOClassDescriptor (ValueObject& in_value);
-
- virtual ClassDescriptorSP
- GetClassDescriptorFromClassName (const ConstString &class_name);
-
- virtual ClassDescriptorSP
- GetClassDescriptorFromISA (ObjCISA isa);
-
- ClassDescriptorSP
- GetNonKVOClassDescriptor (ObjCISA isa);
-
- lldb::LanguageType
- GetLanguageType () const override
- {
- return lldb::eLanguageTypeObjC;
- }
-
- virtual bool
- IsModuleObjCLibrary (const lldb::ModuleSP &module_sp) = 0;
-
- virtual bool
- ReadObjCLibrary (const lldb::ModuleSP &module_sp) = 0;
-
- virtual bool
- HasReadObjCLibrary () = 0;
-
- virtual lldb::ThreadPlanSP
- GetStepThroughTrampolinePlan (Thread &thread, bool stop_others) = 0;
-
- lldb::addr_t
- LookupInMethodCache (lldb::addr_t class_addr, lldb::addr_t sel);
-
- void
- AddToMethodCache (lldb::addr_t class_addr, lldb::addr_t sel, lldb::addr_t impl_addr);
-
- TypeAndOrName
- LookupInClassNameCache (lldb::addr_t class_addr);
-
- void
- AddToClassNameCache (lldb::addr_t class_addr, const char *name, lldb::TypeSP type_sp);
-
- void
- AddToClassNameCache (lldb::addr_t class_addr, const TypeAndOrName &class_or_type_name);
-
- lldb::TypeSP
- LookupInCompleteClassCache (ConstString &name);
-
- virtual UtilityFunction *
- CreateObjectChecker (const char *) = 0;
-
- virtual ObjCRuntimeVersions
- GetRuntimeVersion () const
- {
- return ObjCRuntimeVersions::eObjC_VersionUnknown;
- }
-
- bool
- IsValidISA(ObjCISA isa)
- {
- UpdateISAToDescriptorMap();
- return m_isa_to_descriptor.count(isa) > 0;
+ virtual size_t GetNumIVars() { return 0; }
+
+ virtual iVarDescriptor GetIVarAtIndex(size_t idx) {
+ return iVarDescriptor();
}
- virtual void
- UpdateISAToDescriptorMapIfNeeded() = 0;
+ protected:
+ bool IsPointerValid(lldb::addr_t value, uint32_t ptr_size,
+ bool allow_NULLs = false, bool allow_tagged = false,
+ bool check_version_specific = false) const;
- void
- UpdateISAToDescriptorMap()
- {
- if (m_process && m_process->GetStopID() != m_isa_to_descriptor_stop_id)
- {
- UpdateISAToDescriptorMapIfNeeded ();
- }
- }
-
- virtual ObjCISA
- GetISA(const ConstString &name);
-
- virtual ConstString
- GetActualTypeName(ObjCISA isa);
-
- virtual ObjCISA
- GetParentClass(ObjCISA isa);
-
- virtual DeclVendor *
- GetDeclVendor()
- {
- return nullptr;
- }
-
- // Finds the byte offset of the child_type ivar in parent_type. If it can't find the
- // offset, returns LLDB_INVALID_IVAR_OFFSET.
-
- virtual size_t
- GetByteOffsetForIvar (CompilerType &parent_qual_type, const char *ivar_name);
-
- // Given the name of an Objective-C runtime symbol (e.g., ivar offset symbol),
- // try to determine from the runtime what the value of that symbol would be.
- // Useful when the underlying binary is stripped.
- virtual lldb::addr_t
- LookupRuntimeSymbol (const ConstString &name)
- {
- return LLDB_INVALID_ADDRESS;
- }
-
- bool
- HasNewLiteralsAndIndexing ()
- {
- if (m_has_new_literals_and_indexing == eLazyBoolCalculate)
- {
- if (CalculateHasNewLiteralsAndIndexing())
- m_has_new_literals_and_indexing = eLazyBoolYes;
- else
- m_has_new_literals_and_indexing = eLazyBoolNo;
- }
-
- return (m_has_new_literals_and_indexing == eLazyBoolYes);
+ private:
+ LazyBool m_is_kvo;
+ LazyBool m_is_cf;
+ lldb::TypeWP m_type_wp;
+ };
+
+ class EncodingToType {
+ public:
+ virtual ~EncodingToType();
+
+ virtual CompilerType RealizeType(ClangASTContext &ast_ctx, const char *name,
+ bool for_expression);
+ virtual CompilerType RealizeType(const char *name, bool for_expression);
+
+ virtual CompilerType RealizeType(clang::ASTContext &ast_ctx,
+ const char *name, bool for_expression) = 0;
+
+ protected:
+ std::unique_ptr<ClangASTContext> m_scratch_ast_ctx_ap;
+ };
+
+ class ObjCExceptionPrecondition : public Breakpoint::BreakpointPrecondition {
+ public:
+ ObjCExceptionPrecondition();
+
+ ~ObjCExceptionPrecondition() override = default;
+
+ bool EvaluatePrecondition(StoppointCallbackContext &context) override;
+ void GetDescription(Stream &stream, lldb::DescriptionLevel level) override;
+ Error ConfigurePrecondition(Args &args) override;
+
+ protected:
+ void AddClassName(const char *class_name);
+
+ private:
+ std::unordered_set<std::string> m_class_names;
+ };
+
+ class TaggedPointerVendor {
+ public:
+ virtual ~TaggedPointerVendor() = default;
+
+ virtual bool IsPossibleTaggedPointer(lldb::addr_t ptr) = 0;
+
+ virtual ObjCLanguageRuntime::ClassDescriptorSP
+ GetClassDescriptor(lldb::addr_t ptr) = 0;
+
+ protected:
+ TaggedPointerVendor() = default;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TaggedPointerVendor);
+ };
+
+ ~ObjCLanguageRuntime() override;
+
+ virtual TaggedPointerVendor *GetTaggedPointerVendor() { return nullptr; }
+
+ typedef std::shared_ptr<EncodingToType> EncodingToTypeSP;
+
+ virtual EncodingToTypeSP GetEncodingToType();
+
+ virtual ClassDescriptorSP GetClassDescriptor(ValueObject &in_value);
+
+ ClassDescriptorSP GetNonKVOClassDescriptor(ValueObject &in_value);
+
+ virtual ClassDescriptorSP
+ GetClassDescriptorFromClassName(const ConstString &class_name);
+
+ virtual ClassDescriptorSP GetClassDescriptorFromISA(ObjCISA isa);
+
+ ClassDescriptorSP GetNonKVOClassDescriptor(ObjCISA isa);
+
+ lldb::LanguageType GetLanguageType() const override {
+ return lldb::eLanguageTypeObjC;
+ }
+
+ virtual bool IsModuleObjCLibrary(const lldb::ModuleSP &module_sp) = 0;
+
+ virtual bool ReadObjCLibrary(const lldb::ModuleSP &module_sp) = 0;
+
+ virtual bool HasReadObjCLibrary() = 0;
+
+ virtual lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
+ bool stop_others) = 0;
+
+ lldb::addr_t LookupInMethodCache(lldb::addr_t class_addr, lldb::addr_t sel);
+
+ void AddToMethodCache(lldb::addr_t class_addr, lldb::addr_t sel,
+ lldb::addr_t impl_addr);
+
+ TypeAndOrName LookupInClassNameCache(lldb::addr_t class_addr);
+
+ void AddToClassNameCache(lldb::addr_t class_addr, const char *name,
+ lldb::TypeSP type_sp);
+
+ void AddToClassNameCache(lldb::addr_t class_addr,
+ const TypeAndOrName &class_or_type_name);
+
+ lldb::TypeSP LookupInCompleteClassCache(ConstString &name);
+
+ virtual UtilityFunction *CreateObjectChecker(const char *) = 0;
+
+ virtual ObjCRuntimeVersions GetRuntimeVersion() const {
+ return ObjCRuntimeVersions::eObjC_VersionUnknown;
+ }
+
+ bool IsValidISA(ObjCISA isa) {
+ UpdateISAToDescriptorMap();
+ return m_isa_to_descriptor.count(isa) > 0;
+ }
+
+ virtual void UpdateISAToDescriptorMapIfNeeded() = 0;
+
+ void UpdateISAToDescriptorMap() {
+ if (m_process && m_process->GetStopID() != m_isa_to_descriptor_stop_id) {
+ UpdateISAToDescriptorMapIfNeeded();
}
-
- virtual void
- SymbolsDidLoad (const ModuleList& module_list)
- {
- m_negative_complete_class_cache.clear();
+ }
+
+ virtual ObjCISA GetISA(const ConstString &name);
+
+ virtual ConstString GetActualTypeName(ObjCISA isa);
+
+ virtual ObjCISA GetParentClass(ObjCISA isa);
+
+ virtual DeclVendor *GetDeclVendor() { return nullptr; }
+
+ // Finds the byte offset of the child_type ivar in parent_type. If it can't
+ // find the
+ // offset, returns LLDB_INVALID_IVAR_OFFSET.
+
+ virtual size_t GetByteOffsetForIvar(CompilerType &parent_qual_type,
+ const char *ivar_name);
+
+ // Given the name of an Objective-C runtime symbol (e.g., ivar offset symbol),
+ // try to determine from the runtime what the value of that symbol would be.
+ // Useful when the underlying binary is stripped.
+ virtual lldb::addr_t LookupRuntimeSymbol(const ConstString &name) {
+ return LLDB_INVALID_ADDRESS;
+ }
+
+ bool HasNewLiteralsAndIndexing() {
+ if (m_has_new_literals_and_indexing == eLazyBoolCalculate) {
+ if (CalculateHasNewLiteralsAndIndexing())
+ m_has_new_literals_and_indexing = eLazyBoolYes;
+ else
+ m_has_new_literals_and_indexing = eLazyBoolNo;
}
-
- bool
- GetTypeBitSize (const CompilerType& compiler_type,
- uint64_t &size) override;
+
+ return (m_has_new_literals_and_indexing == eLazyBoolYes);
+ }
+
+ virtual void SymbolsDidLoad(const ModuleList &module_list) {
+ m_negative_complete_class_cache.clear();
+ }
+
+ bool GetTypeBitSize(const CompilerType &compiler_type,
+ uint64_t &size) override;
protected:
- //------------------------------------------------------------------
- // Classes that inherit from ObjCLanguageRuntime can see and modify these
- //------------------------------------------------------------------
- ObjCLanguageRuntime(Process *process);
+ //------------------------------------------------------------------
+ // Classes that inherit from ObjCLanguageRuntime can see and modify these
+ //------------------------------------------------------------------
+ ObjCLanguageRuntime(Process *process);
- virtual bool CalculateHasNewLiteralsAndIndexing()
- {
- return false;
+ virtual bool CalculateHasNewLiteralsAndIndexing() { return false; }
+
+ bool ISAIsCached(ObjCISA isa) const {
+ return m_isa_to_descriptor.find(isa) != m_isa_to_descriptor.end();
+ }
+
+ bool AddClass(ObjCISA isa, const ClassDescriptorSP &descriptor_sp) {
+ if (isa != 0) {
+ m_isa_to_descriptor[isa] = descriptor_sp;
+ return true;
}
-
- bool
- ISAIsCached (ObjCISA isa) const
- {
- return m_isa_to_descriptor.find(isa) != m_isa_to_descriptor.end();
+ return false;
+ }
+
+ bool AddClass(ObjCISA isa, const ClassDescriptorSP &descriptor_sp,
+ const char *class_name);
+
+ bool AddClass(ObjCISA isa, const ClassDescriptorSP &descriptor_sp,
+ uint32_t class_name_hash) {
+ if (isa != 0) {
+ m_isa_to_descriptor[isa] = descriptor_sp;
+ m_hash_to_isa_map.insert(std::make_pair(class_name_hash, isa));
+ return true;
}
+ return false;
+ }
- bool
- AddClass (ObjCISA isa, const ClassDescriptorSP &descriptor_sp)
- {
- if (isa != 0)
- {
- m_isa_to_descriptor[isa] = descriptor_sp;
- return true;
- }
- return false;
+private:
+ // We keep a map of <Class,Selector>->Implementation so we don't have to call
+ // the resolver
+ // function over and over.
+
+ // FIXME: We need to watch for the loading of Protocols, and flush the cache
+ // for any
+ // class that we see so changed.
+
+ struct ClassAndSel {
+ ClassAndSel() {
+ sel_addr = LLDB_INVALID_ADDRESS;
+ class_addr = LLDB_INVALID_ADDRESS;
}
- bool
- AddClass (ObjCISA isa, const ClassDescriptorSP &descriptor_sp, const char *class_name);
+ ClassAndSel(lldb::addr_t in_sel_addr, lldb::addr_t in_class_addr)
+ : class_addr(in_class_addr), sel_addr(in_sel_addr) {}
- bool
- AddClass (ObjCISA isa, const ClassDescriptorSP &descriptor_sp, uint32_t class_name_hash)
- {
- if (isa != 0)
- {
- m_isa_to_descriptor[isa] = descriptor_sp;
- m_hash_to_isa_map.insert(std::make_pair(class_name_hash, isa));
- return true;
- }
+ bool operator==(const ClassAndSel &rhs) {
+ if (class_addr == rhs.class_addr && sel_addr == rhs.sel_addr)
+ return true;
+ else
return false;
}
-private:
- // We keep a map of <Class,Selector>->Implementation so we don't have to call the resolver
- // function over and over.
-
- // FIXME: We need to watch for the loading of Protocols, and flush the cache for any
- // class that we see so changed.
-
- struct ClassAndSel
- {
- ClassAndSel()
- {
- sel_addr = LLDB_INVALID_ADDRESS;
- class_addr = LLDB_INVALID_ADDRESS;
- }
-
- ClassAndSel (lldb::addr_t in_sel_addr, lldb::addr_t in_class_addr) :
- class_addr (in_class_addr),
- sel_addr(in_sel_addr)
- {
- }
-
- bool operator== (const ClassAndSel &rhs)
- {
- if (class_addr == rhs.class_addr
- && sel_addr == rhs.sel_addr)
- return true;
- else
- return false;
- }
-
- bool operator< (const ClassAndSel &rhs) const
- {
- if (class_addr < rhs.class_addr)
- return true;
- else if (class_addr > rhs.class_addr)
- return false;
- else
- {
- if (sel_addr < rhs.sel_addr)
- return true;
- else
- return false;
- }
- }
-
- lldb::addr_t class_addr;
- lldb::addr_t sel_addr;
- };
+ bool operator<(const ClassAndSel &rhs) const {
+ if (class_addr < rhs.class_addr)
+ return true;
+ else if (class_addr > rhs.class_addr)
+ return false;
+ else {
+ if (sel_addr < rhs.sel_addr)
+ return true;
+ else
+ return false;
+ }
+ }
+
+ lldb::addr_t class_addr;
+ lldb::addr_t sel_addr;
+ };
- typedef std::map<ClassAndSel,lldb::addr_t> MsgImplMap;
- typedef std::map<ObjCISA, ClassDescriptorSP> ISAToDescriptorMap;
- typedef std::multimap<uint32_t, ObjCISA> HashToISAMap;
- typedef ISAToDescriptorMap::iterator ISAToDescriptorIterator;
- typedef HashToISAMap::iterator HashToISAIterator;
- typedef ThreadSafeDenseMap<void*, uint64_t> TypeSizeCache;
+ typedef std::map<ClassAndSel, lldb::addr_t> MsgImplMap;
+ typedef std::map<ObjCISA, ClassDescriptorSP> ISAToDescriptorMap;
+ typedef std::multimap<uint32_t, ObjCISA> HashToISAMap;
+ typedef ISAToDescriptorMap::iterator ISAToDescriptorIterator;
+ typedef HashToISAMap::iterator HashToISAIterator;
+ typedef ThreadSafeDenseMap<void *, uint64_t> TypeSizeCache;
- MsgImplMap m_impl_cache;
- LazyBool m_has_new_literals_and_indexing;
- ISAToDescriptorMap m_isa_to_descriptor;
- HashToISAMap m_hash_to_isa_map;
- TypeSizeCache m_type_size_cache;
+ MsgImplMap m_impl_cache;
+ LazyBool m_has_new_literals_and_indexing;
+ ISAToDescriptorMap m_isa_to_descriptor;
+ HashToISAMap m_hash_to_isa_map;
+ TypeSizeCache m_type_size_cache;
protected:
- uint32_t m_isa_to_descriptor_stop_id;
-
- typedef std::map<ConstString, lldb::TypeWP> CompleteClassMap;
- CompleteClassMap m_complete_class_cache;
-
- struct ConstStringSetHelpers {
- size_t operator () (const ConstString& arg) const // for hashing
- {
- return (size_t)arg.GetCString();
- }
- bool operator () (const ConstString& arg1, const ConstString& arg2) const // for equality
- {
- return arg1.operator==(arg2);
- }
- };
- typedef std::unordered_set<ConstString, ConstStringSetHelpers, ConstStringSetHelpers> CompleteClassSet;
- CompleteClassSet m_negative_complete_class_cache;
+ uint32_t m_isa_to_descriptor_stop_id;
+
+ typedef std::map<ConstString, lldb::TypeWP> CompleteClassMap;
+ CompleteClassMap m_complete_class_cache;
+
+ struct ConstStringSetHelpers {
+ size_t operator()(const ConstString &arg) const // for hashing
+ {
+ return (size_t)arg.GetCString();
+ }
+ bool operator()(const ConstString &arg1,
+ const ConstString &arg2) const // for equality
+ {
+ return arg1.operator==(arg2);
+ }
+ };
+ typedef std::unordered_set<ConstString, ConstStringSetHelpers,
+ ConstStringSetHelpers>
+ CompleteClassSet;
+ CompleteClassSet m_negative_complete_class_cache;
+
+ ISAToDescriptorIterator GetDescriptorIterator(const ConstString &name);
- ISAToDescriptorIterator
- GetDescriptorIterator (const ConstString &name);
+ friend class ::CommandObjectObjC_ClassTable_Dump;
- friend class ::CommandObjectObjC_ClassTable_Dump;
-
- std::pair<ISAToDescriptorIterator,ISAToDescriptorIterator>
- GetDescriptorIteratorPair (bool update_if_needed = true);
+ std::pair<ISAToDescriptorIterator, ISAToDescriptorIterator>
+ GetDescriptorIteratorPair(bool update_if_needed = true);
- void
- ReadObjCLibraryIfNeeded (const ModuleList &module_list);
+ void ReadObjCLibraryIfNeeded(const ModuleList &module_list);
- DISALLOW_COPY_AND_ASSIGN (ObjCLanguageRuntime);
+ DISALLOW_COPY_AND_ASSIGN(ObjCLanguageRuntime);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/OperatingSystem.h b/include/lldb/Target/OperatingSystem.h
index 74de5645da5a..24ded3f69723 100644
--- a/include/lldb/Target/OperatingSystem.h
+++ b/include/lldb/Target/OperatingSystem.h
@@ -1,4 +1,5 @@
-//===-- OperatingSystem.h ----------------------------------------------*- C++ -*-===//
+//===-- OperatingSystem.h ----------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,84 +15,77 @@
// C++ Includes
// Other libraries and framework includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/PluginInterface.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-
+
//----------------------------------------------------------------------
/// @class OperatingSystem OperatingSystem.h "lldb/Target/OperatingSystem.h"
/// @brief A plug-in interface definition class for halted OS helpers.
///
-/// Halted OS plug-ins can be used by any process to locate and create
-/// OS objects, like threads, during the lifetime of a debug session.
+/// Halted OS plug-ins can be used by any process to locate and create
+/// OS objects, like threads, during the lifetime of a debug session.
/// This is commonly used when attaching to an operating system that is
/// halted, such as when debugging over JTAG or connecting to low level
/// kernel debug services.
//----------------------------------------------------------------------
-class OperatingSystem :
- public PluginInterface
-{
+class OperatingSystem : public PluginInterface {
public:
- //------------------------------------------------------------------
- /// Find a halted OS plugin for a given process.
- ///
- /// Scans the installed OperatingSystem plug-ins and tries to find
- /// an instance that matches the current target triple and
- /// executable.
- ///
- /// @param[in] process
- /// The process for which to try and locate a halted OS
- /// plug-in instance.
- ///
- /// @param[in] plugin_name
- /// An optional name of a specific halted OS plug-in that
- /// should be used. If NULL, pick the best plug-in.
- //------------------------------------------------------------------
- static OperatingSystem*
- FindPlugin (Process *process, const char *plugin_name);
-
- //------------------------------------------------------------------
- // Class Methods
- //------------------------------------------------------------------
- OperatingSystem (Process *process);
-
- ~OperatingSystem() override;
-
- //------------------------------------------------------------------
- // Plug-in Methods
- //------------------------------------------------------------------
- virtual bool
- UpdateThreadList (ThreadList &old_thread_list,
- ThreadList &real_thread_list,
- ThreadList &new_thread_list) = 0;
-
- virtual void
- ThreadWasSelected (Thread *thread) = 0;
-
- virtual lldb::RegisterContextSP
- CreateRegisterContextForThread (Thread *thread, lldb::addr_t reg_data_addr) = 0;
-
- virtual lldb::StopInfoSP
- CreateThreadStopReason (Thread *thread) = 0;
-
- virtual lldb::ThreadSP
- CreateThread (lldb::tid_t tid, lldb::addr_t context)
- {
- return lldb::ThreadSP();
- }
-
- virtual bool
- IsOperatingSystemPluginThread (const lldb::ThreadSP &thread_sp);
+ //------------------------------------------------------------------
+ /// Find a halted OS plugin for a given process.
+ ///
+ /// Scans the installed OperatingSystem plug-ins and tries to find
+ /// an instance that matches the current target triple and
+ /// executable.
+ ///
+ /// @param[in] process
+ /// The process for which to try and locate a halted OS
+ /// plug-in instance.
+ ///
+ /// @param[in] plugin_name
+ /// An optional name of a specific halted OS plug-in that
+ /// should be used. If NULL, pick the best plug-in.
+ //------------------------------------------------------------------
+ static OperatingSystem *FindPlugin(Process *process, const char *plugin_name);
+
+ //------------------------------------------------------------------
+ // Class Methods
+ //------------------------------------------------------------------
+ OperatingSystem(Process *process);
+
+ ~OperatingSystem() override;
+
+ //------------------------------------------------------------------
+ // Plug-in Methods
+ //------------------------------------------------------------------
+ virtual bool UpdateThreadList(ThreadList &old_thread_list,
+ ThreadList &real_thread_list,
+ ThreadList &new_thread_list) = 0;
+
+ virtual void ThreadWasSelected(Thread *thread) = 0;
+
+ virtual lldb::RegisterContextSP
+ CreateRegisterContextForThread(Thread *thread,
+ lldb::addr_t reg_data_addr) = 0;
+
+ virtual lldb::StopInfoSP CreateThreadStopReason(Thread *thread) = 0;
+
+ virtual lldb::ThreadSP CreateThread(lldb::tid_t tid, lldb::addr_t context) {
+ return lldb::ThreadSP();
+ }
+
+ virtual bool IsOperatingSystemPluginThread(const lldb::ThreadSP &thread_sp);
protected:
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- Process* m_process; ///< The process that this dynamic loader plug-in is tracking.
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ Process
+ *m_process; ///< The process that this dynamic loader plug-in is tracking.
private:
- DISALLOW_COPY_AND_ASSIGN (OperatingSystem);
+ DISALLOW_COPY_AND_ASSIGN(OperatingSystem);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/PathMappingList.h b/include/lldb/Target/PathMappingList.h
index 1a486c4642dc..4e5a5693235a 100644
--- a/include/lldb/Target/PathMappingList.h
+++ b/include/lldb/Target/PathMappingList.h
@@ -21,153 +21,119 @@
namespace lldb_private {
-class PathMappingList
-{
+class PathMappingList {
public:
+ typedef void (*ChangedCallback)(const PathMappingList &path_list,
+ void *baton);
+
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ PathMappingList();
+
+ PathMappingList(ChangedCallback callback, void *callback_baton);
+
+ PathMappingList(const PathMappingList &rhs);
+
+ ~PathMappingList();
+
+ const PathMappingList &operator=(const PathMappingList &rhs);
+
+ void Append(const ConstString &path, const ConstString &replacement,
+ bool notify);
+
+ void Append(const PathMappingList &rhs, bool notify);
+
+ void Clear(bool notify);
+
+ // By default, dump all pairs.
+ void Dump(Stream *s, int pair_index = -1);
+
+ bool IsEmpty() const { return m_pairs.empty(); }
+
+ size_t GetSize() const { return m_pairs.size(); }
+
+ bool GetPathsAtIndex(uint32_t idx, ConstString &path,
+ ConstString &new_path) const;
+
+ void Insert(const ConstString &path, const ConstString &replacement,
+ uint32_t insert_idx, bool notify);
+
+ bool Remove(size_t index, bool notify);
+
+ bool Remove(const ConstString &path, bool notify);
+
+ bool Replace(const ConstString &path, const ConstString &replacement,
+ bool notify);
+
+ bool Replace(const ConstString &path, const ConstString &replacement,
+ uint32_t index, bool notify);
+ bool RemapPath(const ConstString &path, ConstString &new_path) const;
+
+ //------------------------------------------------------------------
+ /// Remaps a source file given \a path into \a new_path.
+ ///
+ /// Remaps \a path if any source remappings match. This function
+ /// does NOT stat the file system so it can be used in tight loops
+ /// where debug info is being parsed.
+ ///
+ /// @param[in] path
+ /// The original source file path to try and remap.
+ ///
+ /// @param[out] new_path
+ /// The newly remapped filespec that is may or may not exist.
+ ///
+ /// @return
+ /// /b true if \a path was successfully located and \a new_path
+ /// is filled in with a new source path, \b false otherwise.
+ //------------------------------------------------------------------
+ bool RemapPath(llvm::StringRef path, std::string &new_path) const;
+ bool RemapPath(const char *, std::string &) const = delete;
+
+ bool ReverseRemapPath(const ConstString &path, ConstString &new_path) const;
+
+ //------------------------------------------------------------------
+ /// Finds a source file given a file spec using the path remappings.
+ ///
+ /// Tries to resolve \a orig_spec by checking the path remappings.
+ /// It makes sure the file exists by checking with the file system,
+ /// so this call can be expensive if the remappings are on a network
+ /// or are even on the local file system, so use this function
+ /// sparingly (not in a tight debug info parsing loop).
+ ///
+ /// @param[in] orig_spec
+ /// The original source file path to try and remap.
+ ///
+ /// @param[out] new_spec
+ /// The newly remapped filespec that is guaranteed to exist.
+ ///
+ /// @return
+ /// /b true if \a orig_spec was successfully located and
+ /// \a new_spec is filled in with an existing file spec,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool FindFile(const FileSpec &orig_spec, FileSpec &new_spec) const;
+
+ uint32_t FindIndexForPath(const ConstString &path) const;
+
+ uint32_t GetModificationID() const { return m_mod_id; }
- typedef void (*ChangedCallback) (const PathMappingList &path_list,
- void *baton);
-
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- PathMappingList ();
-
- PathMappingList (ChangedCallback callback,
- void *callback_baton);
-
- PathMappingList (const PathMappingList &rhs);
-
- ~PathMappingList ();
-
- const PathMappingList &
- operator =(const PathMappingList &rhs);
-
- void
- Append (const ConstString &path, const ConstString &replacement, bool notify);
-
- void
- Append (const PathMappingList &rhs, bool notify);
-
- void
- Clear (bool notify);
-
- // By default, dump all pairs.
- void
- Dump (Stream *s, int pair_index=-1);
-
- bool
- IsEmpty() const
- {
- return m_pairs.empty();
- }
-
- size_t
- GetSize () const
- {
- return m_pairs.size();
- }
-
- bool
- GetPathsAtIndex (uint32_t idx, ConstString &path, ConstString &new_path) const;
-
- void
- Insert (const ConstString &path,
- const ConstString &replacement,
- uint32_t insert_idx,
- bool notify);
-
- bool
- Remove (size_t index, bool notify);
-
- bool
- Remove (const ConstString &path, bool notify);
-
- bool
- Replace (const ConstString &path,
- const ConstString &replacement,
- bool notify);
-
- bool
- Replace (const ConstString &path,
- const ConstString &replacement,
- uint32_t index,
- bool notify);
- bool
- RemapPath (const ConstString &path, ConstString &new_path) const;
-
- //------------------------------------------------------------------
- /// Remaps a source file given \a path into \a new_path.
- ///
- /// Remaps \a path if any source remappings match. This function
- /// does NOT stat the file system so it can be used in tight loops
- /// where debug info is being parsed.
- ///
- /// @param[in] path
- /// The original source file path to try and remap.
- ///
- /// @param[out] new_path
- /// The newly remapped filespec that is may or may not exist.
- ///
- /// @return
- /// /b true if \a path was successfully located and \a new_path
- /// is filled in with a new source path, \b false otherwise.
- //------------------------------------------------------------------
- bool
- RemapPath (const char *path, std::string &new_path) const;
-
- bool
- ReverseRemapPath (const ConstString &path, ConstString &new_path) const;
-
- //------------------------------------------------------------------
- /// Finds a source file given a file spec using the path remappings.
- ///
- /// Tries to resolve \a orig_spec by checking the path remappings.
- /// It makes sure the file exists by checking with the file system,
- /// so this call can be expensive if the remappings are on a network
- /// or are even on the local file system, so use this function
- /// sparingly (not in a tight debug info parsing loop).
- ///
- /// @param[in] orig_spec
- /// The original source file path to try and remap.
- ///
- /// @param[out] new_spec
- /// The newly remapped filespec that is guaranteed to exist.
- ///
- /// @return
- /// /b true if \a orig_spec was successfully located and
- /// \a new_spec is filled in with an existing file spec,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool
- FindFile (const FileSpec &orig_spec, FileSpec &new_spec) const;
-
- uint32_t
- FindIndexForPath (const ConstString &path) const;
-
- uint32_t
- GetModificationID() const
- {
- return m_mod_id;
- }
protected:
- typedef std::pair <ConstString, ConstString> pair;
- typedef std::vector <pair> collection;
- typedef collection::iterator iterator;
- typedef collection::const_iterator const_iterator;
-
- iterator
- FindIteratorForPath (const ConstString &path);
-
- const_iterator
- FindIteratorForPath (const ConstString &path) const;
-
- collection m_pairs;
- ChangedCallback m_callback;
- void * m_callback_baton;
- uint32_t m_mod_id; // Incremented anytime anything is added or removed.
+ typedef std::pair<ConstString, ConstString> pair;
+ typedef std::vector<pair> collection;
+ typedef collection::iterator iterator;
+ typedef collection::const_iterator const_iterator;
+
+ iterator FindIteratorForPath(const ConstString &path);
+
+ const_iterator FindIteratorForPath(const ConstString &path) const;
+
+ collection m_pairs;
+ ChangedCallback m_callback;
+ void *m_callback_baton;
+ uint32_t m_mod_id; // Incremented anytime anything is added or removed.
};
} // namespace lldb_private
-#endif // liblldb_PathMappingList_h_
+#endif // liblldb_PathMappingList_h_
diff --git a/include/lldb/Target/Platform.h b/include/lldb/Target/Platform.h
index 6fdd92db5680..9707093440a5 100644
--- a/include/lldb/Target/Platform.h
+++ b/include/lldb/Target/Platform.h
@@ -21,14 +21,14 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private-forward.h"
-#include "lldb/lldb-public.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/UserSettingsController.h"
-#include "lldb/Interpreter/Options.h"
#include "lldb/Host/FileSpec.h"
+#include "lldb/Interpreter/Options.h"
+#include "lldb/lldb-private-forward.h"
+#include "lldb/lldb-public.h"
// TODO pull NativeDelegate class out of NativeProcessProtocol so we
// can just forward ref the NativeDelegate rather than include it here.
@@ -37,1390 +37,1133 @@
namespace lldb_private {
class ModuleCache;
- enum MmapFlags {
- eMmapFlagsPrivate = 1,
- eMmapFlagsAnon = 2
- };
+enum MmapFlags { eMmapFlagsPrivate = 1, eMmapFlagsAnon = 2 };
+
+class PlatformProperties : public Properties {
+public:
+ PlatformProperties();
+
+ static ConstString GetSettingName();
+
+ bool GetUseModuleCache() const;
+ bool SetUseModuleCache(bool use_module_cache);
+
+ FileSpec GetModuleCacheDirectory() const;
+ bool SetModuleCacheDirectory(const FileSpec &dir_spec);
+};
+
+typedef std::shared_ptr<PlatformProperties> PlatformPropertiesSP;
+
+//----------------------------------------------------------------------
+/// @class Platform Platform.h "lldb/Target/Platform.h"
+/// @brief A plug-in interface definition class for debug platform that
+/// includes many platform abilities such as:
+/// @li getting platform information such as supported architectures,
+/// supported binary file formats and more
+/// @li launching new processes
+/// @li attaching to existing processes
+/// @li download/upload files
+/// @li execute shell commands
+/// @li listing and getting info for existing processes
+/// @li attaching and possibly debugging the platform's kernel
+//----------------------------------------------------------------------
+class Platform : public PluginInterface {
+public:
+ //------------------------------------------------------------------
+ /// Default Constructor
+ //------------------------------------------------------------------
+ Platform(bool is_host_platform);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ ///
+ /// The destructor is virtual since this class is designed to be
+ /// inherited from by the plug-in instance.
+ //------------------------------------------------------------------
+ ~Platform() override;
+
+ static void Initialize();
+
+ static void Terminate();
+
+ static const PlatformPropertiesSP &GetGlobalPlatformProperties();
+
+ //------------------------------------------------------------------
+ /// Get the native host platform plug-in.
+ ///
+ /// There should only be one of these for each host that LLDB runs
+ /// upon that should be statically compiled in and registered using
+ /// preprocessor macros or other similar build mechanisms in a
+ /// PlatformSubclass::Initialize() function.
+ ///
+ /// This platform will be used as the default platform when launching
+ /// or attaching to processes unless another platform is specified.
+ //------------------------------------------------------------------
+ static lldb::PlatformSP GetHostPlatform();
+
+ static lldb::PlatformSP
+ GetPlatformForArchitecture(const ArchSpec &arch, ArchSpec *platform_arch_ptr);
+
+ static const char *GetHostPlatformName();
+
+ static void SetHostPlatform(const lldb::PlatformSP &platform_sp);
+
+ // Find an existing platform plug-in by name
+ static lldb::PlatformSP Find(const ConstString &name);
+
+ static lldb::PlatformSP Create(const ConstString &name, Error &error);
+
+ static lldb::PlatformSP Create(const ArchSpec &arch,
+ ArchSpec *platform_arch_ptr, Error &error);
+
+ static uint32_t GetNumConnectedRemotePlatforms();
+
+ static lldb::PlatformSP GetConnectedRemotePlatformAtIndex(uint32_t idx);
+
+ //------------------------------------------------------------------
+ /// Find a platform plugin for a given process.
+ ///
+ /// Scans the installed Platform plug-ins and tries to find
+ /// an instance that can be used for \a process
+ ///
+ /// @param[in] process
+ /// The process for which to try and locate a platform
+ /// plug-in instance.
+ ///
+ /// @param[in] plugin_name
+ /// An optional name of a specific platform plug-in that
+ /// should be used. If nullptr, pick the best plug-in.
+ //------------------------------------------------------------------
+ // static lldb::PlatformSP
+ // FindPlugin (Process *process, const ConstString &plugin_name);
+
+ //------------------------------------------------------------------
+ /// Set the target's executable based off of the existing
+ /// architecture information in \a target given a path to an
+ /// executable \a exe_file.
+ ///
+ /// Each platform knows the architectures that it supports and can
+ /// select the correct architecture slice within \a exe_file by
+ /// inspecting the architecture in \a target. If the target had an
+ /// architecture specified, then in can try and obey that request
+ /// and optionally fail if the architecture doesn't match up.
+ /// If no architecture is specified, the platform should select the
+ /// default architecture from \a exe_file. Any application bundles
+ /// or executable wrappers can also be inspected for the actual
+ /// application binary within the bundle that should be used.
+ ///
+ /// @return
+ /// Returns \b true if this Platform plug-in was able to find
+ /// a suitable executable, \b false otherwise.
+ //------------------------------------------------------------------
+ virtual Error ResolveExecutable(const ModuleSpec &module_spec,
+ lldb::ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr);
+
+ //------------------------------------------------------------------
+ /// Find a symbol file given a symbol file module specification.
+ ///
+ /// Each platform might have tricks to find symbol files for an
+ /// executable given information in a symbol file ModuleSpec. Some
+ /// platforms might also support symbol files that are bundles and
+ /// know how to extract the right symbol file given a bundle.
+ ///
+ /// @param[in] target
+ /// The target in which we are trying to resolve the symbol file.
+ /// The target has a list of modules that we might be able to
+ /// use in order to help find the right symbol file. If the
+ /// "m_file" or "m_platform_file" entries in the \a sym_spec
+ /// are filled in, then we might be able to locate a module in
+ /// the target, extract its UUID and locate a symbol file.
+ /// If just the "m_uuid" is specified, then we might be able
+ /// to find the module in the target that matches that UUID
+ /// and pair the symbol file along with it. If just "m_symbol_file"
+ /// is specified, we can use a variety of tricks to locate the
+ /// symbols in an SDK, PDK, or other development kit location.
+ ///
+ /// @param[in] sym_spec
+ /// A module spec that describes some information about the
+ /// symbol file we are trying to resolve. The ModuleSpec might
+ /// contain the following:
+ /// m_file - A full or partial path to an executable from the
+ /// target (might be empty).
+ /// m_platform_file - Another executable hint that contains
+ /// the path to the file as known on the
+ /// local/remote platform.
+ /// m_symbol_file - A full or partial path to a symbol file
+ /// or symbol bundle that should be used when
+ /// trying to resolve the symbol file.
+ /// m_arch - The architecture we are looking for when resolving
+ /// the symbol file.
+ /// m_uuid - The UUID of the executable and symbol file. This
+ /// can often be used to match up an executable with
+ /// a symbol file, or resolve an symbol file in a
+ /// symbol file bundle.
+ ///
+ /// @param[out] sym_file
+ /// The resolved symbol file spec if the returned error
+ /// indicates success.
+ ///
+ /// @return
+ /// Returns an error that describes success or failure.
+ //------------------------------------------------------------------
+ virtual Error ResolveSymbolFile(Target &target, const ModuleSpec &sym_spec,
+ FileSpec &sym_file);
+
+ //------------------------------------------------------------------
+ /// Resolves the FileSpec to a (possibly) remote path. Remote
+ /// platforms must override this to resolve to a path on the remote
+ /// side.
+ //------------------------------------------------------------------
+ virtual bool ResolveRemotePath(const FileSpec &platform_path,
+ FileSpec &resolved_platform_path);
+
+ //------------------------------------------------------------------
+ /// Get the OS version from a connected platform.
+ ///
+ /// Some platforms might not be connected to a remote platform, but
+ /// can figure out the OS version for a process. This is common for
+ /// simulator platforms that will run native programs on the current
+ /// host, but the simulator might be simulating a different OS. The
+ /// \a process parameter might be specified to help to determine
+ /// the OS version.
+ //------------------------------------------------------------------
+ virtual bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update,
+ Process *process = nullptr);
+
+ bool SetOSVersion(uint32_t major, uint32_t minor, uint32_t update);
+
+ bool GetOSBuildString(std::string &s);
+
+ bool GetOSKernelDescription(std::string &s);
+
+ // Returns the name of the platform
+ ConstString GetName();
+
+ virtual const char *GetHostname();
+
+ virtual ConstString GetFullNameForDylib(ConstString basename);
+
+ virtual const char *GetDescription() = 0;
+
+ //------------------------------------------------------------------
+ /// Report the current status for this platform.
+ ///
+ /// The returned string usually involves returning the OS version
+ /// (if available), and any SDK directory that might be being used
+ /// for local file caching, and if connected a quick blurb about
+ /// what this platform is connected to.
+ //------------------------------------------------------------------
+ virtual void GetStatus(Stream &strm);
+
+ //------------------------------------------------------------------
+ // Subclasses must be able to fetch the current OS version
+ //
+ // Remote classes must be connected for this to succeed. Local
+ // subclasses don't need to override this function as it will just
+ // call the HostInfo::GetOSVersion().
+ //------------------------------------------------------------------
+ virtual bool GetRemoteOSVersion() { return false; }
+
+ virtual bool GetRemoteOSBuildString(std::string &s) {
+ s.clear();
+ return false;
+ }
+
+ virtual bool GetRemoteOSKernelDescription(std::string &s) {
+ s.clear();
+ return false;
+ }
+
+ // Remote Platform subclasses need to override this function
+ virtual ArchSpec GetRemoteSystemArchitecture() {
+ return ArchSpec(); // Return an invalid architecture
+ }
+
+ virtual FileSpec GetRemoteWorkingDirectory() { return m_working_dir; }
+
+ virtual bool SetRemoteWorkingDirectory(const FileSpec &working_dir);
+
+ virtual const char *GetUserName(uint32_t uid);
+
+ virtual const char *GetGroupName(uint32_t gid);
+
+ //------------------------------------------------------------------
+ /// Locate a file for a platform.
+ ///
+ /// The default implementation of this function will return the same
+ /// file patch in \a local_file as was in \a platform_file.
+ ///
+ /// @param[in] platform_file
+ /// The platform file path to locate and cache locally.
+ ///
+ /// @param[in] uuid_ptr
+ /// If we know the exact UUID of the file we are looking for, it
+ /// can be specified. If it is not specified, we might now know
+ /// the exact file. The UUID is usually some sort of MD5 checksum
+ /// for the file and is sometimes known by dynamic linkers/loaders.
+ /// If the UUID is known, it is best to supply it to platform
+ /// file queries to ensure we are finding the correct file, not
+ /// just a file at the correct path.
+ ///
+ /// @param[out] local_file
+ /// A locally cached version of the platform file. For platforms
+ /// that describe the current host computer, this will just be
+ /// the same file. For remote platforms, this file might come from
+ /// and SDK directory, or might need to be sync'ed over to the
+ /// current machine for efficient debugging access.
+ ///
+ /// @return
+ /// An error object.
+ //------------------------------------------------------------------
+ virtual Error GetFileWithUUID(const FileSpec &platform_file,
+ const UUID *uuid_ptr, FileSpec &local_file);
+
+ //----------------------------------------------------------------------
+ // Locate the scripting resource given a module specification.
+ //
+ // Locating the file should happen only on the local computer or using
+ // the current computers global settings.
+ //----------------------------------------------------------------------
+ virtual FileSpecList
+ LocateExecutableScriptingResources(Target *target, Module &module,
+ Stream *feedback_stream);
+
+ virtual Error GetSharedModule(const ModuleSpec &module_spec, Process *process,
+ lldb::ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr,
+ lldb::ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr);
+
+ virtual bool GetModuleSpec(const FileSpec &module_file_spec,
+ const ArchSpec &arch, ModuleSpec &module_spec);
+
+ virtual Error ConnectRemote(Args &args);
+
+ virtual Error DisconnectRemote();
+
+ //------------------------------------------------------------------
+ /// Get the platform's supported architectures in the order in which
+ /// they should be searched.
+ ///
+ /// @param[in] idx
+ /// A zero based architecture index
+ ///
+ /// @param[out] arch
+ /// A copy of the architecture at index if the return value is
+ /// \b true.
+ ///
+ /// @return
+ /// \b true if \a arch was filled in and is valid, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ virtual bool GetSupportedArchitectureAtIndex(uint32_t idx,
+ ArchSpec &arch) = 0;
+
+ virtual size_t GetSoftwareBreakpointTrapOpcode(Target &target,
+ BreakpointSite *bp_site);
+
+ //------------------------------------------------------------------
+ /// Launch a new process on a platform, not necessarily for
+ /// debugging, it could be just for running the process.
+ //------------------------------------------------------------------
+ virtual Error LaunchProcess(ProcessLaunchInfo &launch_info);
+
+ //------------------------------------------------------------------
+ /// Perform expansion of the command-line for this launch info
+ /// This can potentially involve wildcard expansion
+ // environment variable replacement, and whatever other
+ // argument magic the platform defines as part of its typical
+ // user experience
+ //------------------------------------------------------------------
+ virtual Error ShellExpandArguments(ProcessLaunchInfo &launch_info);
+
+ //------------------------------------------------------------------
+ /// Kill process on a platform.
+ //------------------------------------------------------------------
+ virtual Error KillProcess(const lldb::pid_t pid);
+
+ //------------------------------------------------------------------
+ /// Lets a platform answer if it is compatible with a given
+ /// architecture and the target triple contained within.
+ //------------------------------------------------------------------
+ virtual bool IsCompatibleArchitecture(const ArchSpec &arch,
+ bool exact_arch_match,
+ ArchSpec *compatible_arch_ptr);
+
+ //------------------------------------------------------------------
+ /// Not all platforms will support debugging a process by spawning
+ /// somehow halted for a debugger (specified using the
+ /// "eLaunchFlagDebug" launch flag) and then attaching. If your
+ /// platform doesn't support this, override this function and return
+ /// false.
+ //------------------------------------------------------------------
+ virtual bool CanDebugProcess() { return true; }
+
+ //------------------------------------------------------------------
+ /// Subclasses do not need to implement this function as it uses
+ /// the Platform::LaunchProcess() followed by Platform::Attach ().
+ /// Remote platforms will want to subclass this function in order
+ /// to be able to intercept STDIO and possibly launch a separate
+ /// process that will debug the debuggee.
+ //------------------------------------------------------------------
+ virtual lldb::ProcessSP
+ DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
+ Target *target, // Can be nullptr, if nullptr create a new
+ // target, else use existing one
+ Error &error);
+
+ virtual lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url,
+ llvm::StringRef plugin_name,
+ lldb_private::Debugger &debugger,
+ lldb_private::Target *target,
+ lldb_private::Error &error);
+
+ //------------------------------------------------------------------
+ /// Attach to an existing process using a process ID.
+ ///
+ /// Each platform subclass needs to implement this function and
+ /// attempt to attach to the process with the process ID of \a pid.
+ /// The platform subclass should return an appropriate ProcessSP
+ /// subclass that is attached to the process, or an empty shared
+ /// pointer with an appropriate error.
+ ///
+ /// @param[in] pid
+ /// The process ID that we should attempt to attach to.
+ ///
+ /// @return
+ /// An appropriate ProcessSP containing a valid shared pointer
+ /// to the default Process subclass for the platform that is
+ /// attached to the process, or an empty shared pointer with an
+ /// appropriate error fill into the \a error object.
+ //------------------------------------------------------------------
+ virtual lldb::ProcessSP Attach(ProcessAttachInfo &attach_info,
+ Debugger &debugger,
+ Target *target, // Can be nullptr, if nullptr
+ // create a new target, else
+ // use existing one
+ Error &error) = 0;
+
+ //------------------------------------------------------------------
+ /// Attach to an existing process by process name.
+ ///
+ /// This function is not meant to be overridden by Process
+ /// subclasses. It will first call
+ /// Process::WillAttach (const char *) and if that returns \b
+ /// true, Process::DoAttach (const char *) will be called to
+ /// actually do the attach. If DoAttach returns \b true, then
+ /// Process::DidAttach() will be called.
+ ///
+ /// @param[in] process_name
+ /// A process name to match against the current process list.
+ ///
+ /// @return
+ /// Returns \a pid if attaching was successful, or
+ /// LLDB_INVALID_PROCESS_ID if attaching fails.
+ //------------------------------------------------------------------
+ // virtual lldb::ProcessSP
+ // Attach (const char *process_name,
+ // bool wait_for_launch,
+ // Error &error) = 0;
+
+ //------------------------------------------------------------------
+ // The base class Platform will take care of the host platform.
+ // Subclasses will need to fill in the remote case.
+ //------------------------------------------------------------------
+ virtual uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &proc_infos);
+
+ virtual bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info);
+
+ //------------------------------------------------------------------
+ // Set a breakpoint on all functions that can end up creating a thread
+ // for this platform. This is needed when running expressions and
+ // also for process control.
+ //------------------------------------------------------------------
+ virtual lldb::BreakpointSP SetThreadCreationBreakpoint(Target &target);
+
+ //------------------------------------------------------------------
+ // Given a target, find the local SDK directory if one exists on the
+ // current host.
+ //------------------------------------------------------------------
+ virtual lldb_private::ConstString
+ GetSDKDirectory(lldb_private::Target &target) {
+ return lldb_private::ConstString();
+ }
+
+ const std::string &GetRemoteURL() const { return m_remote_url; }
+
+ bool IsHost() const {
+ return m_is_host; // Is this the default host platform?
+ }
+
+ bool IsRemote() const { return !m_is_host; }
+
+ virtual bool IsConnected() const {
+ // Remote subclasses should override this function
+ return IsHost();
+ }
+
+ const ArchSpec &GetSystemArchitecture();
+
+ void SetSystemArchitecture(const ArchSpec &arch) {
+ m_system_arch = arch;
+ if (IsHost())
+ m_os_version_set_while_connected = m_system_arch.IsValid();
+ }
+
+ // Used for column widths
+ size_t GetMaxUserIDNameLength() const { return m_max_uid_name_len; }
+
+ // Used for column widths
+ size_t GetMaxGroupIDNameLength() const { return m_max_gid_name_len; }
+
+ const ConstString &GetSDKRootDirectory() const { return m_sdk_sysroot; }
+
+ void SetSDKRootDirectory(const ConstString &dir) { m_sdk_sysroot = dir; }
+
+ const ConstString &GetSDKBuild() const { return m_sdk_build; }
+
+ void SetSDKBuild(const ConstString &sdk_build) { m_sdk_build = sdk_build; }
+
+ // Override this to return true if your platform supports Clang modules.
+ // You may also need to override AddClangModuleCompilationOptions to pass the
+ // right Clang flags for your platform.
+ virtual bool SupportsModules() { return false; }
+
+ // Appends the platform-specific options required to find the modules for the
+ // current platform.
+ virtual void
+ AddClangModuleCompilationOptions(Target *target,
+ std::vector<std::string> &options);
+
+ FileSpec GetWorkingDirectory();
+
+ bool SetWorkingDirectory(const FileSpec &working_dir);
+
+ // There may be modules that we don't want to find by default for operations
+ // like "setting breakpoint by name".
+ // The platform will return "true" from this call if the passed in module
+ // happens to be one of these.
+
+ virtual bool
+ ModuleIsExcludedForUnconstrainedSearches(Target &target,
+ const lldb::ModuleSP &module_sp) {
+ return false;
+ }
+
+ virtual Error MakeDirectory(const FileSpec &file_spec, uint32_t permissions);
+
+ virtual Error GetFilePermissions(const FileSpec &file_spec,
+ uint32_t &file_permissions);
- class PlatformProperties : public Properties
- {
- public:
- PlatformProperties();
-
- static ConstString
- GetSettingName ();
-
- bool
- GetUseModuleCache () const;
- bool
- SetUseModuleCache (bool use_module_cache);
-
- FileSpec
- GetModuleCacheDirectory () const;
- bool
- SetModuleCacheDirectory (const FileSpec& dir_spec);
- };
-
- typedef std::shared_ptr<PlatformProperties> PlatformPropertiesSP;
-
- //----------------------------------------------------------------------
- /// @class Platform Platform.h "lldb/Target/Platform.h"
- /// @brief A plug-in interface definition class for debug platform that
- /// includes many platform abilities such as:
- /// @li getting platform information such as supported architectures,
- /// supported binary file formats and more
- /// @li launching new processes
- /// @li attaching to existing processes
- /// @li download/upload files
- /// @li execute shell commands
- /// @li listing and getting info for existing processes
- /// @li attaching and possibly debugging the platform's kernel
- //----------------------------------------------------------------------
- class Platform :
- public PluginInterface
- {
- public:
- //------------------------------------------------------------------
- /// Default Constructor
- //------------------------------------------------------------------
- Platform (bool is_host_platform);
-
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// The destructor is virtual since this class is designed to be
- /// inherited from by the plug-in instance.
- //------------------------------------------------------------------
- ~Platform() override;
-
- static void
- Initialize ();
-
- static void
- Terminate ();
-
- static const PlatformPropertiesSP &
- GetGlobalPlatformProperties ();
-
- //------------------------------------------------------------------
- /// Get the native host platform plug-in.
- ///
- /// There should only be one of these for each host that LLDB runs
- /// upon that should be statically compiled in and registered using
- /// preprocessor macros or other similar build mechanisms in a
- /// PlatformSubclass::Initialize() function.
- ///
- /// This platform will be used as the default platform when launching
- /// or attaching to processes unless another platform is specified.
- //------------------------------------------------------------------
- static lldb::PlatformSP
- GetHostPlatform ();
-
- static lldb::PlatformSP
- GetPlatformForArchitecture (const ArchSpec &arch,
- ArchSpec *platform_arch_ptr);
-
- static const char *
- GetHostPlatformName ();
-
- static void
- SetHostPlatform (const lldb::PlatformSP &platform_sp);
-
- // Find an existing platform plug-in by name
- static lldb::PlatformSP
- Find (const ConstString &name);
-
- static lldb::PlatformSP
- Create (const ConstString &name, Error &error);
-
- static lldb::PlatformSP
- Create (const ArchSpec &arch, ArchSpec *platform_arch_ptr, Error &error);
-
- static uint32_t
- GetNumConnectedRemotePlatforms ();
-
- static lldb::PlatformSP
- GetConnectedRemotePlatformAtIndex (uint32_t idx);
-
- //------------------------------------------------------------------
- /// Find a platform plugin for a given process.
- ///
- /// Scans the installed Platform plug-ins and tries to find
- /// an instance that can be used for \a process
- ///
- /// @param[in] process
- /// The process for which to try and locate a platform
- /// plug-in instance.
- ///
- /// @param[in] plugin_name
- /// An optional name of a specific platform plug-in that
- /// should be used. If nullptr, pick the best plug-in.
- //------------------------------------------------------------------
-// static lldb::PlatformSP
-// FindPlugin (Process *process, const ConstString &plugin_name);
-
- //------------------------------------------------------------------
- /// Set the target's executable based off of the existing
- /// architecture information in \a target given a path to an
- /// executable \a exe_file.
- ///
- /// Each platform knows the architectures that it supports and can
- /// select the correct architecture slice within \a exe_file by
- /// inspecting the architecture in \a target. If the target had an
- /// architecture specified, then in can try and obey that request
- /// and optionally fail if the architecture doesn't match up.
- /// If no architecture is specified, the platform should select the
- /// default architecture from \a exe_file. Any application bundles
- /// or executable wrappers can also be inspected for the actual
- /// application binary within the bundle that should be used.
- ///
- /// @return
- /// Returns \b true if this Platform plug-in was able to find
- /// a suitable executable, \b false otherwise.
- //------------------------------------------------------------------
- virtual Error
- ResolveExecutable (const ModuleSpec &module_spec,
- lldb::ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr);
-
- //------------------------------------------------------------------
- /// Find a symbol file given a symbol file module specification.
- ///
- /// Each platform might have tricks to find symbol files for an
- /// executable given information in a symbol file ModuleSpec. Some
- /// platforms might also support symbol files that are bundles and
- /// know how to extract the right symbol file given a bundle.
- ///
- /// @param[in] target
- /// The target in which we are trying to resolve the symbol file.
- /// The target has a list of modules that we might be able to
- /// use in order to help find the right symbol file. If the
- /// "m_file" or "m_platform_file" entries in the \a sym_spec
- /// are filled in, then we might be able to locate a module in
- /// the target, extract its UUID and locate a symbol file.
- /// If just the "m_uuid" is specified, then we might be able
- /// to find the module in the target that matches that UUID
- /// and pair the symbol file along with it. If just "m_symbol_file"
- /// is specified, we can use a variety of tricks to locate the
- /// symbols in an SDK, PDK, or other development kit location.
- ///
- /// @param[in] sym_spec
- /// A module spec that describes some information about the
- /// symbol file we are trying to resolve. The ModuleSpec might
- /// contain the following:
- /// m_file - A full or partial path to an executable from the
- /// target (might be empty).
- /// m_platform_file - Another executable hint that contains
- /// the path to the file as known on the
- /// local/remote platform.
- /// m_symbol_file - A full or partial path to a symbol file
- /// or symbol bundle that should be used when
- /// trying to resolve the symbol file.
- /// m_arch - The architecture we are looking for when resolving
- /// the symbol file.
- /// m_uuid - The UUID of the executable and symbol file. This
- /// can often be used to match up an executable with
- /// a symbol file, or resolve an symbol file in a
- /// symbol file bundle.
- ///
- /// @param[out] sym_file
- /// The resolved symbol file spec if the returned error
- /// indicates success.
- ///
- /// @return
- /// Returns an error that describes success or failure.
- //------------------------------------------------------------------
- virtual Error
- ResolveSymbolFile (Target &target,
- const ModuleSpec &sym_spec,
- FileSpec &sym_file);
-
- //------------------------------------------------------------------
- /// Resolves the FileSpec to a (possibly) remote path. Remote
- /// platforms must override this to resolve to a path on the remote
- /// side.
- //------------------------------------------------------------------
- virtual bool
- ResolveRemotePath (const FileSpec &platform_path,
- FileSpec &resolved_platform_path);
-
- //------------------------------------------------------------------
- /// Get the OS version from a connected platform.
- ///
- /// Some platforms might not be connected to a remote platform, but
- /// can figure out the OS version for a process. This is common for
- /// simulator platforms that will run native programs on the current
- /// host, but the simulator might be simulating a different OS. The
- /// \a process parameter might be specified to help to determine
- /// the OS version.
- //------------------------------------------------------------------
- virtual bool
- GetOSVersion (uint32_t &major,
- uint32_t &minor,
- uint32_t &update,
- Process *process = nullptr);
-
- bool
- SetOSVersion (uint32_t major,
- uint32_t minor,
- uint32_t update);
-
- bool
- GetOSBuildString (std::string &s);
-
- bool
- GetOSKernelDescription (std::string &s);
-
- // Returns the name of the platform
- ConstString
- GetName ();
-
- virtual const char *
- GetHostname ();
-
- virtual ConstString
- GetFullNameForDylib (ConstString basename);
-
- virtual const char *
- GetDescription () = 0;
-
- //------------------------------------------------------------------
- /// Report the current status for this platform.
- ///
- /// The returned string usually involves returning the OS version
- /// (if available), and any SDK directory that might be being used
- /// for local file caching, and if connected a quick blurb about
- /// what this platform is connected to.
- //------------------------------------------------------------------
- virtual void
- GetStatus (Stream &strm);
-
- //------------------------------------------------------------------
- // Subclasses must be able to fetch the current OS version
- //
- // Remote classes must be connected for this to succeed. Local
- // subclasses don't need to override this function as it will just
- // call the HostInfo::GetOSVersion().
- //------------------------------------------------------------------
- virtual bool
- GetRemoteOSVersion ()
- {
- return false;
- }
+ virtual Error SetFilePermissions(const FileSpec &file_spec,
+ uint32_t file_permissions);
- virtual bool
- GetRemoteOSBuildString (std::string &s)
- {
- s.clear();
- return false;
- }
-
- virtual bool
- GetRemoteOSKernelDescription (std::string &s)
- {
- s.clear();
- return false;
- }
+ virtual lldb::user_id_t OpenFile(const FileSpec &file_spec, uint32_t flags,
+ uint32_t mode, Error &error) {
+ return UINT64_MAX;
+ }
- // Remote Platform subclasses need to override this function
- virtual ArchSpec
- GetRemoteSystemArchitecture ()
- {
- return ArchSpec(); // Return an invalid architecture
- }
+ virtual bool CloseFile(lldb::user_id_t fd, Error &error) { return false; }
- virtual FileSpec
- GetRemoteWorkingDirectory()
- {
- return m_working_dir;
- }
-
- virtual bool
- SetRemoteWorkingDirectory(const FileSpec &working_dir);
-
- virtual const char *
- GetUserName (uint32_t uid);
-
- virtual const char *
- GetGroupName (uint32_t gid);
-
- //------------------------------------------------------------------
- /// Locate a file for a platform.
- ///
- /// The default implementation of this function will return the same
- /// file patch in \a local_file as was in \a platform_file.
- ///
- /// @param[in] platform_file
- /// The platform file path to locate and cache locally.
- ///
- /// @param[in] uuid_ptr
- /// If we know the exact UUID of the file we are looking for, it
- /// can be specified. If it is not specified, we might now know
- /// the exact file. The UUID is usually some sort of MD5 checksum
- /// for the file and is sometimes known by dynamic linkers/loaders.
- /// If the UUID is known, it is best to supply it to platform
- /// file queries to ensure we are finding the correct file, not
- /// just a file at the correct path.
- ///
- /// @param[out] local_file
- /// A locally cached version of the platform file. For platforms
- /// that describe the current host computer, this will just be
- /// the same file. For remote platforms, this file might come from
- /// and SDK directory, or might need to be sync'ed over to the
- /// current machine for efficient debugging access.
- ///
- /// @return
- /// An error object.
- //------------------------------------------------------------------
- virtual Error
- GetFileWithUUID (const FileSpec &platform_file,
- const UUID *uuid_ptr,
- FileSpec &local_file);
-
- //----------------------------------------------------------------------
- // Locate the scripting resource given a module specification.
- //
- // Locating the file should happen only on the local computer or using
- // the current computers global settings.
- //----------------------------------------------------------------------
- virtual FileSpecList
- LocateExecutableScriptingResources (Target *target,
- Module &module,
- Stream* feedback_stream);
-
- virtual Error
- GetSharedModule (const ModuleSpec &module_spec,
- Process* process,
- lldb::ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr,
- lldb::ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr);
-
- virtual bool
- GetModuleSpec (const FileSpec& module_file_spec,
- const ArchSpec& arch,
- ModuleSpec &module_spec);
-
- virtual Error
- ConnectRemote (Args& args);
-
- virtual Error
- DisconnectRemote ();
-
- //------------------------------------------------------------------
- /// Get the platform's supported architectures in the order in which
- /// they should be searched.
- ///
- /// @param[in] idx
- /// A zero based architecture index
- ///
- /// @param[out] arch
- /// A copy of the architecture at index if the return value is
- /// \b true.
- ///
- /// @return
- /// \b true if \a arch was filled in and is valid, \b false
- /// otherwise.
- //------------------------------------------------------------------
- virtual bool
- GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch) = 0;
-
- virtual size_t
- GetSoftwareBreakpointTrapOpcode (Target &target,
- BreakpointSite *bp_site);
-
- //------------------------------------------------------------------
- /// Launch a new process on a platform, not necessarily for
- /// debugging, it could be just for running the process.
- //------------------------------------------------------------------
- virtual Error
- LaunchProcess (ProcessLaunchInfo &launch_info);
-
- //------------------------------------------------------------------
- /// Perform expansion of the command-line for this launch info
- /// This can potentially involve wildcard expansion
- // environment variable replacement, and whatever other
- // argument magic the platform defines as part of its typical
- // user experience
- //------------------------------------------------------------------
- virtual Error
- ShellExpandArguments (ProcessLaunchInfo &launch_info);
-
- //------------------------------------------------------------------
- /// Kill process on a platform.
- //------------------------------------------------------------------
- virtual Error
- KillProcess (const lldb::pid_t pid);
-
- //------------------------------------------------------------------
- /// Lets a platform answer if it is compatible with a given
- /// architecture and the target triple contained within.
- //------------------------------------------------------------------
- virtual bool
- IsCompatibleArchitecture (const ArchSpec &arch,
- bool exact_arch_match,
- ArchSpec *compatible_arch_ptr);
-
- //------------------------------------------------------------------
- /// Not all platforms will support debugging a process by spawning
- /// somehow halted for a debugger (specified using the
- /// "eLaunchFlagDebug" launch flag) and then attaching. If your
- /// platform doesn't support this, override this function and return
- /// false.
- //------------------------------------------------------------------
- virtual bool
- CanDebugProcess ()
- {
- return true;
- }
+ virtual lldb::user_id_t GetFileSize(const FileSpec &file_spec) {
+ return UINT64_MAX;
+ }
- //------------------------------------------------------------------
- /// Subclasses do not need to implement this function as it uses
- /// the Platform::LaunchProcess() followed by Platform::Attach ().
- /// Remote platforms will want to subclass this function in order
- /// to be able to intercept STDIO and possibly launch a separate
- /// process that will debug the debuggee.
- //------------------------------------------------------------------
- virtual lldb::ProcessSP
- DebugProcess (ProcessLaunchInfo &launch_info,
- Debugger &debugger,
- Target *target, // Can be nullptr, if nullptr create a new target, else use existing one
- Error &error);
-
- virtual lldb::ProcessSP
- ConnectProcess (const char* connect_url,
- const char* plugin_name,
- lldb_private::Debugger &debugger,
- lldb_private::Target *target,
- lldb_private::Error &error);
-
- //------------------------------------------------------------------
- /// Attach to an existing process using a process ID.
- ///
- /// Each platform subclass needs to implement this function and
- /// attempt to attach to the process with the process ID of \a pid.
- /// The platform subclass should return an appropriate ProcessSP
- /// subclass that is attached to the process, or an empty shared
- /// pointer with an appropriate error.
- ///
- /// @param[in] pid
- /// The process ID that we should attempt to attach to.
- ///
- /// @return
- /// An appropriate ProcessSP containing a valid shared pointer
- /// to the default Process subclass for the platform that is
- /// attached to the process, or an empty shared pointer with an
- /// appropriate error fill into the \a error object.
- //------------------------------------------------------------------
- virtual lldb::ProcessSP
- Attach (ProcessAttachInfo &attach_info,
- Debugger &debugger,
- Target *target, // Can be nullptr, if nullptr create a new target, else use existing one
- Error &error) = 0;
-
- //------------------------------------------------------------------
- /// Attach to an existing process by process name.
- ///
- /// This function is not meant to be overridden by Process
- /// subclasses. It will first call
- /// Process::WillAttach (const char *) and if that returns \b
- /// true, Process::DoAttach (const char *) will be called to
- /// actually do the attach. If DoAttach returns \b true, then
- /// Process::DidAttach() will be called.
- ///
- /// @param[in] process_name
- /// A process name to match against the current process list.
- ///
- /// @return
- /// Returns \a pid if attaching was successful, or
- /// LLDB_INVALID_PROCESS_ID if attaching fails.
- //------------------------------------------------------------------
-// virtual lldb::ProcessSP
-// Attach (const char *process_name,
-// bool wait_for_launch,
-// Error &error) = 0;
-
- //------------------------------------------------------------------
- // The base class Platform will take care of the host platform.
- // Subclasses will need to fill in the remote case.
- //------------------------------------------------------------------
- virtual uint32_t
- FindProcesses (const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &proc_infos);
-
- virtual bool
- GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &proc_info);
-
- //------------------------------------------------------------------
- // Set a breakpoint on all functions that can end up creating a thread
- // for this platform. This is needed when running expressions and
- // also for process control.
- //------------------------------------------------------------------
- virtual lldb::BreakpointSP
- SetThreadCreationBreakpoint (Target &target);
-
- //------------------------------------------------------------------
- // Given a target, find the local SDK directory if one exists on the
- // current host.
- //------------------------------------------------------------------
- virtual lldb_private::ConstString
- GetSDKDirectory (lldb_private::Target &target)
- {
- return lldb_private::ConstString();
- }
+ virtual uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
+ uint64_t dst_len, Error &error) {
+ error.SetErrorStringWithFormat(
+ "Platform::ReadFile() is not supported in the %s platform",
+ GetName().GetCString());
+ return -1;
+ }
- const std::string &
- GetRemoteURL () const
- {
- return m_remote_url;
- }
+ virtual uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset,
+ const void *src, uint64_t src_len, Error &error) {
+ error.SetErrorStringWithFormat(
+ "Platform::ReadFile() is not supported in the %s platform",
+ GetName().GetCString());
+ return -1;
+ }
- bool
- IsHost () const
- {
- return m_is_host; // Is this the default host platform?
- }
+ virtual Error GetFile(const FileSpec &source, const FileSpec &destination);
- bool
- IsRemote () const
- {
- return !m_is_host;
- }
-
- virtual bool
- IsConnected () const
- {
- // Remote subclasses should override this function
- return IsHost();
- }
-
- const ArchSpec &
- GetSystemArchitecture();
-
- void
- SetSystemArchitecture (const ArchSpec &arch)
- {
- m_system_arch = arch;
- if (IsHost())
- m_os_version_set_while_connected = m_system_arch.IsValid();
- }
+ virtual Error PutFile(const FileSpec &source, const FileSpec &destination,
+ uint32_t uid = UINT32_MAX, uint32_t gid = UINT32_MAX);
- // Used for column widths
- size_t
- GetMaxUserIDNameLength() const
- {
- return m_max_uid_name_len;
- }
+ virtual Error
+ CreateSymlink(const FileSpec &src, // The name of the link is in src
+ const FileSpec &dst); // The symlink points to dst
- // Used for column widths
- size_t
- GetMaxGroupIDNameLength() const
- {
- return m_max_gid_name_len;
- }
-
- const ConstString &
- GetSDKRootDirectory () const
- {
- return m_sdk_sysroot;
- }
+ //----------------------------------------------------------------------
+ /// Install a file or directory to the remote system.
+ ///
+ /// Install is similar to Platform::PutFile(), but it differs in that if
+ /// an application/framework/shared library is installed on a remote
+ /// platform and the remote platform requires something to be done to
+ /// register the application/framework/shared library, then this extra
+ /// registration can be done.
+ ///
+ /// @param[in] src
+ /// The source file/directory to install on the remote system.
+ ///
+ /// @param[in] dst
+ /// The destination file/directory where \a src will be installed.
+ /// If \a dst has no filename specified, then its filename will
+ /// be set from \a src. It \a dst has no directory specified, it
+ /// will use the platform working directory. If \a dst has a
+ /// directory specified, but the directory path is relative, the
+ /// platform working directory will be prepended to the relative
+ /// directory.
+ ///
+ /// @return
+ /// An error object that describes anything that went wrong.
+ //----------------------------------------------------------------------
+ virtual Error Install(const FileSpec &src, const FileSpec &dst);
+
+ virtual size_t GetEnvironment(StringList &environment);
+
+ virtual bool GetFileExists(const lldb_private::FileSpec &file_spec);
+
+ virtual Error Unlink(const FileSpec &file_spec);
+
+ virtual uint64_t ConvertMmapFlagsToPlatform(const ArchSpec &arch,
+ unsigned flags);
+
+ virtual bool GetSupportsRSync() { return m_supports_rsync; }
+
+ virtual void SetSupportsRSync(bool flag) { m_supports_rsync = flag; }
+
+ virtual const char *GetRSyncOpts() { return m_rsync_opts.c_str(); }
+
+ virtual void SetRSyncOpts(const char *opts) { m_rsync_opts.assign(opts); }
+
+ virtual const char *GetRSyncPrefix() { return m_rsync_prefix.c_str(); }
+
+ virtual void SetRSyncPrefix(const char *prefix) {
+ m_rsync_prefix.assign(prefix);
+ }
+
+ virtual bool GetSupportsSSH() { return m_supports_ssh; }
+
+ virtual void SetSupportsSSH(bool flag) { m_supports_ssh = flag; }
+
+ virtual const char *GetSSHOpts() { return m_ssh_opts.c_str(); }
+
+ virtual void SetSSHOpts(const char *opts) { m_ssh_opts.assign(opts); }
+
+ virtual bool GetIgnoresRemoteHostname() { return m_ignores_remote_hostname; }
+
+ virtual void SetIgnoresRemoteHostname(bool flag) {
+ m_ignores_remote_hostname = flag;
+ }
+
+ virtual lldb_private::OptionGroupOptions *
+ GetConnectionOptions(CommandInterpreter &interpreter) {
+ return nullptr;
+ }
+
+ virtual lldb_private::Error RunShellCommand(
+ const char *command, // Shouldn't be nullptr
+ const FileSpec &working_dir, // Pass empty FileSpec to use the current
+ // working directory
+ int *status_ptr, // Pass nullptr if you don't want the process exit status
+ int *signo_ptr, // Pass nullptr if you don't want the signal that caused
+ // the process to exit
+ std::string
+ *command_output, // Pass nullptr if you don't want the command output
+ uint32_t timeout_sec); // Timeout in seconds to wait for shell program to
+ // finish
+
+ virtual void SetLocalCacheDirectory(const char *local);
+
+ virtual const char *GetLocalCacheDirectory();
+
+ virtual std::string GetPlatformSpecificConnectionInformation() { return ""; }
+
+ virtual bool CalculateMD5(const FileSpec &file_spec, uint64_t &low,
+ uint64_t &high);
+
+ virtual int32_t GetResumeCountForLaunchInfo(ProcessLaunchInfo &launch_info) {
+ return 1;
+ }
+
+ virtual const lldb::UnixSignalsSP &GetRemoteUnixSignals();
+
+ const lldb::UnixSignalsSP &GetUnixSignals();
+
+ //------------------------------------------------------------------
+ /// Locate a queue name given a thread's qaddr
+ ///
+ /// On a system using libdispatch ("Grand Central Dispatch") style
+ /// queues, a thread may be associated with a GCD queue or not,
+ /// and a queue may be associated with multiple threads.
+ /// The process/thread must provide a way to find the "dispatch_qaddr"
+ /// for each thread, and from that dispatch_qaddr this Platform method
+ /// will locate the queue name and provide that.
+ ///
+ /// @param[in] process
+ /// A process is required for reading memory.
+ ///
+ /// @param[in] dispatch_qaddr
+ /// The dispatch_qaddr for this thread.
+ ///
+ /// @return
+ /// The name of the queue, if there is one. An empty string
+ /// means that this thread is not associated with a dispatch
+ /// queue.
+ //------------------------------------------------------------------
+ virtual std::string
+ GetQueueNameForThreadQAddress(Process *process, lldb::addr_t dispatch_qaddr) {
+ return "";
+ }
+
+ //------------------------------------------------------------------
+ /// Locate a queue ID given a thread's qaddr
+ ///
+ /// On a system using libdispatch ("Grand Central Dispatch") style
+ /// queues, a thread may be associated with a GCD queue or not,
+ /// and a queue may be associated with multiple threads.
+ /// The process/thread must provide a way to find the "dispatch_qaddr"
+ /// for each thread, and from that dispatch_qaddr this Platform method
+ /// will locate the queue ID and provide that.
+ ///
+ /// @param[in] process
+ /// A process is required for reading memory.
+ ///
+ /// @param[in] dispatch_qaddr
+ /// The dispatch_qaddr for this thread.
+ ///
+ /// @return
+ /// The queue_id for this thread, if this thread is associated
+ /// with a dispatch queue. Else LLDB_INVALID_QUEUE_ID is returned.
+ //------------------------------------------------------------------
+ virtual lldb::queue_id_t
+ GetQueueIDForThreadQAddress(Process *process, lldb::addr_t dispatch_qaddr) {
+ return LLDB_INVALID_QUEUE_ID;
+ }
+
+ //------------------------------------------------------------------
+ /// Provide a list of trap handler function names for this platform
+ ///
+ /// The unwinder needs to treat trap handlers specially -- the stack
+ /// frame may not be aligned correctly for a trap handler (the kernel
+ /// often won't perturb the stack pointer, or won't re-align it properly,
+ /// in the process of calling the handler) and the frame above the handler
+ /// needs to be treated by the unwinder's "frame 0" rules instead of its
+ /// "middle of the stack frame" rules.
+ ///
+ /// In a user process debugging scenario, the list of trap handlers is
+ /// typically just "_sigtramp".
+ ///
+ /// The Platform base class provides the m_trap_handlers ivar but it does
+ /// not populate it. Subclasses should add the names of the asynchronous
+ /// signal handler routines as needed. For most Unix platforms, add
+ /// _sigtramp.
+ ///
+ /// @return
+ /// A list of symbol names. The list may be empty.
+ //------------------------------------------------------------------
+ virtual const std::vector<ConstString> &GetTrapHandlerSymbolNames();
+
+ //------------------------------------------------------------------
+ /// Find a support executable that may not live within in the
+ /// standard locations related to LLDB.
+ ///
+ /// Executable might exist within the Platform SDK directories, or
+ /// in standard tool directories within the current IDE that is
+ /// running LLDB.
+ ///
+ /// @param[in] basename
+ /// The basename of the executable to locate in the current
+ /// platform.
+ ///
+ /// @return
+ /// A FileSpec pointing to the executable on disk, or an invalid
+ /// FileSpec if the executable cannot be found.
+ //------------------------------------------------------------------
+ virtual FileSpec LocateExecutable(const char *basename) { return FileSpec(); }
+
+ //------------------------------------------------------------------
+ /// Allow the platform to set preferred memory cache line size. If non-zero
+ /// (and the user
+ /// has not set cache line size explicitly), this value will be used as the
+ /// cache line
+ /// size for memory reads.
+ //------------------------------------------------------------------
+ virtual uint32_t GetDefaultMemoryCacheLineSize() { return 0; }
+
+ //------------------------------------------------------------------
+ /// Load a shared library into this process.
+ ///
+ /// Try and load a shared library into the current process. This
+ /// call might fail in the dynamic loader plug-in says it isn't safe
+ /// to try and load shared libraries at the moment.
+ ///
+ /// @param[in] process
+ /// The process to load the image.
+ ///
+ /// @param[in] local_file
+ /// The file spec that points to the shared library that you want
+ /// to load if the library is located on the host. The library will
+ /// be copied over to the location specified by remote_file or into
+ /// the current working directory with the same filename if the
+ /// remote_file isn't specified.
+ ///
+ /// @param[in] remote_file
+ /// If local_file is specified then the location where the library
+ /// should be copied over from the host. If local_file isn't
+ /// specified, then the path for the shared library on the target
+ /// what you want to load.
+ ///
+ /// @param[out] error
+ /// An error object that gets filled in with any errors that
+ /// might occur when trying to load the shared library.
+ ///
+ /// @return
+ /// A token that represents the shared library that can be
+ /// later used to unload the shared library. A value of
+ /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared
+ /// library can't be opened.
+ //------------------------------------------------------------------
+ uint32_t LoadImage(lldb_private::Process *process,
+ const lldb_private::FileSpec &local_file,
+ const lldb_private::FileSpec &remote_file,
+ lldb_private::Error &error);
+
+ virtual uint32_t DoLoadImage(lldb_private::Process *process,
+ const lldb_private::FileSpec &remote_file,
+ lldb_private::Error &error);
+
+ virtual Error UnloadImage(lldb_private::Process *process,
+ uint32_t image_token);
+
+ //------------------------------------------------------------------
+ /// Connect to all processes waiting for a debugger to attach
+ ///
+ /// If the platform have a list of processes waiting for a debugger
+ /// to connect to them then connect to all of these pending processes.
+ ///
+ /// @param[in] debugger
+ /// The debugger used for the connect.
+ ///
+ /// @param[out] error
+ /// If an error occurred during the connect then this object will
+ /// contain the error message.
+ ///
+ /// @return
+ /// The number of processes we are successfully connected to.
+ //------------------------------------------------------------------
+ virtual size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
+ lldb_private::Error &error);
+
+protected:
+ bool m_is_host;
+ // Set to true when we are able to actually set the OS version while
+ // being connected. For remote platforms, we might set the version ahead
+ // of time before we actually connect and this version might change when
+ // we actually connect to a remote platform. For the host platform this
+ // will be set to the once we call HostInfo::GetOSVersion().
+ bool m_os_version_set_while_connected;
+ bool m_system_arch_set_while_connected;
+ ConstString
+ m_sdk_sysroot; // the root location of where the SDK files are all located
+ ConstString m_sdk_build;
+ FileSpec m_working_dir; // The working directory which is used when installing
+ // modules that have no install path set
+ std::string m_remote_url;
+ std::string m_name;
+ uint32_t m_major_os_version;
+ uint32_t m_minor_os_version;
+ uint32_t m_update_os_version;
+ ArchSpec
+ m_system_arch; // The architecture of the kernel or the remote platform
+ typedef std::map<uint32_t, ConstString> IDToNameMap;
+ // Mutex for modifying Platform data structures that should only be used for
+ // non-reentrant code
+ std::mutex m_mutex;
+ IDToNameMap m_uid_map;
+ IDToNameMap m_gid_map;
+ size_t m_max_uid_name_len;
+ size_t m_max_gid_name_len;
+ bool m_supports_rsync;
+ std::string m_rsync_opts;
+ std::string m_rsync_prefix;
+ bool m_supports_ssh;
+ std::string m_ssh_opts;
+ bool m_ignores_remote_hostname;
+ std::string m_local_cache_directory;
+ std::vector<ConstString> m_trap_handlers;
+ bool m_calculated_trap_handlers;
+ const std::unique_ptr<ModuleCache> m_module_cache;
+
+ //------------------------------------------------------------------
+ /// Ask the Platform subclass to fill in the list of trap handler names
+ ///
+ /// For most Unix user process environments, this will be a single
+ /// function name, _sigtramp. More specialized environments may have
+ /// additional handler names. The unwinder code needs to know when a
+ /// trap handler is on the stack because the unwind rules for the frame
+ /// that caused the trap are different.
+ ///
+ /// The base class Platform ivar m_trap_handlers should be updated by
+ /// the Platform subclass when this method is called. If there are no
+ /// predefined trap handlers, this method may be a no-op.
+ //------------------------------------------------------------------
+ virtual void CalculateTrapHandlerSymbolNames() = 0;
+
+ const char *GetCachedUserName(uint32_t uid) {
+ std::lock_guard<std::mutex> guard(m_mutex);
+ // return the empty string if our string is NULL
+ // so we can tell when things were in the negative
+ // cached (didn't find a valid user name, don't keep
+ // trying)
+ const auto pos = m_uid_map.find(uid);
+ return ((pos != m_uid_map.end()) ? pos->second.AsCString("") : nullptr);
+ }
+
+ const char *SetCachedUserName(uint32_t uid, const char *name,
+ size_t name_len) {
+ std::lock_guard<std::mutex> guard(m_mutex);
+ ConstString const_name(name);
+ m_uid_map[uid] = const_name;
+ if (m_max_uid_name_len < name_len)
+ m_max_uid_name_len = name_len;
+ // Const strings lives forever in our const string pool, so we can return
+ // the const char *
+ return const_name.GetCString();
+ }
+
+ void SetUserNameNotFound(uint32_t uid) {
+ std::lock_guard<std::mutex> guard(m_mutex);
+ m_uid_map[uid] = ConstString();
+ }
+
+ void ClearCachedUserNames() {
+ std::lock_guard<std::mutex> guard(m_mutex);
+ m_uid_map.clear();
+ }
+
+ const char *GetCachedGroupName(uint32_t gid) {
+ std::lock_guard<std::mutex> guard(m_mutex);
+ // return the empty string if our string is NULL
+ // so we can tell when things were in the negative
+ // cached (didn't find a valid group name, don't keep
+ // trying)
+ const auto pos = m_gid_map.find(gid);
+ return ((pos != m_gid_map.end()) ? pos->second.AsCString("") : nullptr);
+ }
+
+ const char *SetCachedGroupName(uint32_t gid, const char *name,
+ size_t name_len) {
+ std::lock_guard<std::mutex> guard(m_mutex);
+ ConstString const_name(name);
+ m_gid_map[gid] = const_name;
+ if (m_max_gid_name_len < name_len)
+ m_max_gid_name_len = name_len;
+ // Const strings lives forever in our const string pool, so we can return
+ // the const char *
+ return const_name.GetCString();
+ }
+
+ void SetGroupNameNotFound(uint32_t gid) {
+ std::lock_guard<std::mutex> guard(m_mutex);
+ m_gid_map[gid] = ConstString();
+ }
+
+ void ClearCachedGroupNames() {
+ std::lock_guard<std::mutex> guard(m_mutex);
+ m_gid_map.clear();
+ }
+
+ Error GetCachedExecutable(ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr,
+ Platform &remote_platform);
+
+ virtual Error DownloadModuleSlice(const FileSpec &src_file_spec,
+ const uint64_t src_offset,
+ const uint64_t src_size,
+ const FileSpec &dst_file_spec);
+
+ virtual Error DownloadSymbolFile(const lldb::ModuleSP &module_sp,
+ const FileSpec &dst_file_spec);
+
+ virtual const char *GetCacheHostname();
+
+private:
+ typedef std::function<Error(const ModuleSpec &)> ModuleResolver;
+
+ Error GetRemoteSharedModule(const ModuleSpec &module_spec, Process *process,
+ lldb::ModuleSP &module_sp,
+ const ModuleResolver &module_resolver,
+ bool *did_create_ptr);
- void
- SetSDKRootDirectory (const ConstString &dir)
- {
- m_sdk_sysroot = dir;
- }
+ bool GetCachedSharedModule(const ModuleSpec &module_spec,
+ lldb::ModuleSP &module_sp, bool *did_create_ptr);
- const ConstString &
- GetSDKBuild () const
- {
- return m_sdk_build;
- }
-
- void
- SetSDKBuild (const ConstString &sdk_build)
- {
- m_sdk_build = sdk_build;
- }
-
- // Override this to return true if your platform supports Clang modules.
- // You may also need to override AddClangModuleCompilationOptions to pass the right Clang flags for your platform.
- virtual bool
- SupportsModules () { return false; }
-
- // Appends the platform-specific options required to find the modules for the current platform.
- virtual void
- AddClangModuleCompilationOptions (Target *target, std::vector<std::string> &options);
-
- FileSpec
- GetWorkingDirectory();
-
- bool
- SetWorkingDirectory(const FileSpec &working_dir);
-
- // There may be modules that we don't want to find by default for operations like "setting breakpoint by name".
- // The platform will return "true" from this call if the passed in module happens to be one of these.
-
- virtual bool
- ModuleIsExcludedForUnconstrainedSearches (Target &target, const lldb::ModuleSP &module_sp)
- {
- return false;
- }
-
- virtual Error
- MakeDirectory(const FileSpec &file_spec, uint32_t permissions);
-
- virtual Error
- GetFilePermissions(const FileSpec &file_spec, uint32_t &file_permissions);
-
- virtual Error
- SetFilePermissions(const FileSpec &file_spec, uint32_t file_permissions);
-
- virtual lldb::user_id_t
- OpenFile (const FileSpec& file_spec,
- uint32_t flags,
- uint32_t mode,
- Error &error)
- {
- return UINT64_MAX;
- }
-
- virtual bool
- CloseFile (lldb::user_id_t fd,
- Error &error)
- {
- return false;
- }
-
- virtual lldb::user_id_t
- GetFileSize (const FileSpec& file_spec)
- {
- return UINT64_MAX;
- }
+ Error LoadCachedExecutable(const ModuleSpec &module_spec,
+ lldb::ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr,
+ Platform &remote_platform);
- virtual uint64_t
- ReadFile (lldb::user_id_t fd,
- uint64_t offset,
- void *dst,
- uint64_t dst_len,
- Error &error)
- {
- error.SetErrorStringWithFormat ("Platform::ReadFile() is not supported in the %s platform", GetName().GetCString());
- return -1;
- }
-
- virtual uint64_t
- WriteFile (lldb::user_id_t fd,
- uint64_t offset,
- const void* src,
- uint64_t src_len,
- Error &error)
- {
- error.SetErrorStringWithFormat ("Platform::ReadFile() is not supported in the %s platform", GetName().GetCString());
- return -1;
- }
-
- virtual Error
- GetFile (const FileSpec& source,
- const FileSpec& destination);
-
- virtual Error
- PutFile (const FileSpec& source,
- const FileSpec& destination,
- uint32_t uid = UINT32_MAX,
- uint32_t gid = UINT32_MAX);
-
- virtual Error
- CreateSymlink(const FileSpec &src, // The name of the link is in src
- const FileSpec &dst); // The symlink points to dst
-
- //----------------------------------------------------------------------
- /// Install a file or directory to the remote system.
- ///
- /// Install is similar to Platform::PutFile(), but it differs in that if
- /// an application/framework/shared library is installed on a remote
- /// platform and the remote platform requires something to be done to
- /// register the application/framework/shared library, then this extra
- /// registration can be done.
- ///
- /// @param[in] src
- /// The source file/directory to install on the remote system.
- ///
- /// @param[in] dst
- /// The destination file/directory where \a src will be installed.
- /// If \a dst has no filename specified, then its filename will
- /// be set from \a src. It \a dst has no directory specified, it
- /// will use the platform working directory. If \a dst has a
- /// directory specified, but the directory path is relative, the
- /// platform working directory will be prepended to the relative
- /// directory.
- ///
- /// @return
- /// An error object that describes anything that went wrong.
- //----------------------------------------------------------------------
- virtual Error
- Install (const FileSpec& src, const FileSpec& dst);
-
- virtual size_t
- GetEnvironment (StringList &environment);
-
- virtual bool
- GetFileExists (const lldb_private::FileSpec& file_spec);
-
- virtual Error
- Unlink(const FileSpec &file_spec);
-
- virtual uint64_t
- ConvertMmapFlagsToPlatform(const ArchSpec &arch, unsigned flags);
-
- virtual bool
- GetSupportsRSync ()
- {
- return m_supports_rsync;
- }
-
- virtual void
- SetSupportsRSync(bool flag)
- {
- m_supports_rsync = flag;
- }
-
- virtual const char*
- GetRSyncOpts ()
- {
- return m_rsync_opts.c_str();
- }
-
- virtual void
- SetRSyncOpts (const char* opts)
- {
- m_rsync_opts.assign(opts);
- }
-
- virtual const char*
- GetRSyncPrefix ()
- {
- return m_rsync_prefix.c_str();
- }
-
- virtual void
- SetRSyncPrefix (const char* prefix)
- {
- m_rsync_prefix.assign(prefix);
- }
-
- virtual bool
- GetSupportsSSH ()
- {
- return m_supports_ssh;
- }
-
- virtual void
- SetSupportsSSH(bool flag)
- {
- m_supports_ssh = flag;
- }
-
- virtual const char*
- GetSSHOpts ()
- {
- return m_ssh_opts.c_str();
- }
-
- virtual void
- SetSSHOpts (const char* opts)
- {
- m_ssh_opts.assign(opts);
- }
-
- virtual bool
- GetIgnoresRemoteHostname ()
- {
- return m_ignores_remote_hostname;
- }
-
- virtual void
- SetIgnoresRemoteHostname(bool flag)
- {
- m_ignores_remote_hostname = flag;
- }
-
- virtual lldb_private::OptionGroupOptions *
- GetConnectionOptions (CommandInterpreter& interpreter)
- {
- return nullptr;
- }
-
- virtual lldb_private::Error
- RunShellCommand(const char *command, // Shouldn't be nullptr
- const FileSpec &working_dir, // Pass empty FileSpec to use the current working directory
- int *status_ptr, // Pass nullptr if you don't want the process exit status
- int *signo_ptr, // Pass nullptr if you don't want the signal that caused the process to exit
- std::string *command_output, // Pass nullptr if you don't want the command output
- uint32_t timeout_sec); // Timeout in seconds to wait for shell program to finish
-
- virtual void
- SetLocalCacheDirectory (const char* local);
-
- virtual const char*
- GetLocalCacheDirectory ();
-
- virtual std::string
- GetPlatformSpecificConnectionInformation()
- {
- return "";
- }
-
- virtual bool
- CalculateMD5 (const FileSpec& file_spec,
- uint64_t &low,
- uint64_t &high);
-
- virtual int32_t
- GetResumeCountForLaunchInfo (ProcessLaunchInfo &launch_info)
- {
- return 1;
- }
+ FileSpec GetModuleCacheRoot();
- virtual const lldb::UnixSignalsSP &
- GetRemoteUnixSignals();
-
- const lldb::UnixSignalsSP &
- GetUnixSignals();
-
- //------------------------------------------------------------------
- /// Locate a queue name given a thread's qaddr
- ///
- /// On a system using libdispatch ("Grand Central Dispatch") style
- /// queues, a thread may be associated with a GCD queue or not,
- /// and a queue may be associated with multiple threads.
- /// The process/thread must provide a way to find the "dispatch_qaddr"
- /// for each thread, and from that dispatch_qaddr this Platform method
- /// will locate the queue name and provide that.
- ///
- /// @param[in] process
- /// A process is required for reading memory.
- ///
- /// @param[in] dispatch_qaddr
- /// The dispatch_qaddr for this thread.
- ///
- /// @return
- /// The name of the queue, if there is one. An empty string
- /// means that this thread is not associated with a dispatch
- /// queue.
- //------------------------------------------------------------------
- virtual std::string
- GetQueueNameForThreadQAddress (Process *process, lldb::addr_t dispatch_qaddr)
- {
- return "";
- }
+ DISALLOW_COPY_AND_ASSIGN(Platform);
+};
- //------------------------------------------------------------------
- /// Locate a queue ID given a thread's qaddr
- ///
- /// On a system using libdispatch ("Grand Central Dispatch") style
- /// queues, a thread may be associated with a GCD queue or not,
- /// and a queue may be associated with multiple threads.
- /// The process/thread must provide a way to find the "dispatch_qaddr"
- /// for each thread, and from that dispatch_qaddr this Platform method
- /// will locate the queue ID and provide that.
- ///
- /// @param[in] process
- /// A process is required for reading memory.
- ///
- /// @param[in] dispatch_qaddr
- /// The dispatch_qaddr for this thread.
- ///
- /// @return
- /// The queue_id for this thread, if this thread is associated
- /// with a dispatch queue. Else LLDB_INVALID_QUEUE_ID is returned.
- //------------------------------------------------------------------
- virtual lldb::queue_id_t
- GetQueueIDForThreadQAddress (Process *process, lldb::addr_t dispatch_qaddr)
- {
- return LLDB_INVALID_QUEUE_ID;
- }
+class PlatformList {
+public:
+ PlatformList() : m_mutex(), m_platforms(), m_selected_platform_sp() {}
- //------------------------------------------------------------------
- /// Provide a list of trap handler function names for this platform
- ///
- /// The unwinder needs to treat trap handlers specially -- the stack
- /// frame may not be aligned correctly for a trap handler (the kernel
- /// often won't perturb the stack pointer, or won't re-align it properly,
- /// in the process of calling the handler) and the frame above the handler
- /// needs to be treated by the unwinder's "frame 0" rules instead of its
- /// "middle of the stack frame" rules.
- ///
- /// In a user process debugging scenario, the list of trap handlers is
- /// typically just "_sigtramp".
- ///
- /// The Platform base class provides the m_trap_handlers ivar but it does
- /// not populate it. Subclasses should add the names of the asynchronous
- /// signal handler routines as needed. For most Unix platforms, add _sigtramp.
- ///
- /// @return
- /// A list of symbol names. The list may be empty.
- //------------------------------------------------------------------
- virtual const std::vector<ConstString> &
- GetTrapHandlerSymbolNames ();
-
- //------------------------------------------------------------------
- /// Find a support executable that may not live within in the
- /// standard locations related to LLDB.
- ///
- /// Executable might exist within the Platform SDK directories, or
- /// in standard tool directories within the current IDE that is
- /// running LLDB.
- ///
- /// @param[in] basename
- /// The basename of the executable to locate in the current
- /// platform.
- ///
- /// @return
- /// A FileSpec pointing to the executable on disk, or an invalid
- /// FileSpec if the executable cannot be found.
- //------------------------------------------------------------------
- virtual FileSpec
- LocateExecutable (const char *basename)
- {
- return FileSpec();
- }
+ ~PlatformList() = default;
- //------------------------------------------------------------------
- /// Allow the platform to set preferred memory cache line size. If non-zero (and the user
- /// has not set cache line size explicitly), this value will be used as the cache line
- /// size for memory reads.
- //------------------------------------------------------------------
- virtual uint32_t
- GetDefaultMemoryCacheLineSize() { return 0; }
-
- //------------------------------------------------------------------
- /// Load a shared library into this process.
- ///
- /// Try and load a shared library into the current process. This
- /// call might fail in the dynamic loader plug-in says it isn't safe
- /// to try and load shared libraries at the moment.
- ///
- /// @param[in] process
- /// The process to load the image.
- ///
- /// @param[in] local_file
- /// The file spec that points to the shared library that you want
- /// to load if the library is located on the host. The library will
- /// be copied over to the location specified by remote_file or into
- /// the current working directory with the same filename if the
- /// remote_file isn't specified.
- ///
- /// @param[in] remote_file
- /// If local_file is specified then the location where the library
- /// should be copied over from the host. If local_file isn't
- /// specified, then the path for the shared library on the target
- /// what you want to load.
- ///
- /// @param[out] error
- /// An error object that gets filled in with any errors that
- /// might occur when trying to load the shared library.
- ///
- /// @return
- /// A token that represents the shared library that can be
- /// later used to unload the shared library. A value of
- /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared
- /// library can't be opened.
- //------------------------------------------------------------------
- uint32_t
- LoadImage (lldb_private::Process* process,
- const lldb_private::FileSpec& local_file,
- const lldb_private::FileSpec& remote_file,
- lldb_private::Error& error);
-
- virtual uint32_t
- DoLoadImage (lldb_private::Process* process,
- const lldb_private::FileSpec& remote_file,
- lldb_private::Error& error);
-
- virtual Error
- UnloadImage (lldb_private::Process* process, uint32_t image_token);
-
- //------------------------------------------------------------------
- /// Connect to all processes waiting for a debugger to attach
- ///
- /// If the platform have a list of processes waiting for a debugger
- /// to connect to them then connect to all of these pending processes.
- ///
- /// @param[in] debugger
- /// The debugger used for the connect.
- ///
- /// @param[out] error
- /// If an error occurred during the connect then this object will
- /// contain the error message.
- ///
- /// @return
- /// The number of processes we are succesfully connected to.
- //------------------------------------------------------------------
- virtual size_t
- ConnectToWaitingProcesses(lldb_private::Debugger& debugger, lldb_private::Error& error);
-
- protected:
- bool m_is_host;
- // Set to true when we are able to actually set the OS version while
- // being connected. For remote platforms, we might set the version ahead
- // of time before we actually connect and this version might change when
- // we actually connect to a remote platform. For the host platform this
- // will be set to the once we call HostInfo::GetOSVersion().
- bool m_os_version_set_while_connected;
- bool m_system_arch_set_while_connected;
- ConstString m_sdk_sysroot; // the root location of where the SDK files are all located
- ConstString m_sdk_build;
- FileSpec m_working_dir; // The working directory which is used when installing modules that have no install path set
- std::string m_remote_url;
- std::string m_name;
- uint32_t m_major_os_version;
- uint32_t m_minor_os_version;
- uint32_t m_update_os_version;
- ArchSpec m_system_arch; // The architecture of the kernel or the remote platform
- typedef std::map<uint32_t, ConstString> IDToNameMap;
- // Mutex for modifying Platform data structures that should only be used for non-reentrant code
- std::mutex m_mutex;
- IDToNameMap m_uid_map;
- IDToNameMap m_gid_map;
- size_t m_max_uid_name_len;
- size_t m_max_gid_name_len;
- bool m_supports_rsync;
- std::string m_rsync_opts;
- std::string m_rsync_prefix;
- bool m_supports_ssh;
- std::string m_ssh_opts;
- bool m_ignores_remote_hostname;
- std::string m_local_cache_directory;
- std::vector<ConstString> m_trap_handlers;
- bool m_calculated_trap_handlers;
- const std::unique_ptr<ModuleCache> m_module_cache;
-
- //------------------------------------------------------------------
- /// Ask the Platform subclass to fill in the list of trap handler names
- ///
- /// For most Unix user process environments, this will be a single
- /// function name, _sigtramp. More specialized environments may have
- /// additional handler names. The unwinder code needs to know when a
- /// trap handler is on the stack because the unwind rules for the frame
- /// that caused the trap are different.
- ///
- /// The base class Platform ivar m_trap_handlers should be updated by
- /// the Platform subclass when this method is called. If there are no
- /// predefined trap handlers, this method may be a no-op.
- //------------------------------------------------------------------
- virtual void
- CalculateTrapHandlerSymbolNames () = 0;
-
- const char *
- GetCachedUserName(uint32_t uid)
- {
- std::lock_guard<std::mutex> guard(m_mutex);
- // return the empty string if our string is NULL
- // so we can tell when things were in the negative
- // cached (didn't find a valid user name, don't keep
- // trying)
- const auto pos = m_uid_map.find(uid);
- return ((pos != m_uid_map.end()) ? pos->second.AsCString("") : nullptr);
- }
+ void Append(const lldb::PlatformSP &platform_sp, bool set_selected) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ m_platforms.push_back(platform_sp);
+ if (set_selected)
+ m_selected_platform_sp = m_platforms.back();
+ }
- const char *
- SetCachedUserName(uint32_t uid, const char *name, size_t name_len)
- {
- std::lock_guard<std::mutex> guard(m_mutex);
- ConstString const_name(name);
- m_uid_map[uid] = const_name;
- if (m_max_uid_name_len < name_len)
- m_max_uid_name_len = name_len;
- // Const strings lives forever in our const string pool, so we can return the const char *
- return const_name.GetCString();
- }
+ size_t GetSize() {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_platforms.size();
+ }
- void
- SetUserNameNotFound(uint32_t uid)
- {
- std::lock_guard<std::mutex> guard(m_mutex);
- m_uid_map[uid] = ConstString();
+ lldb::PlatformSP GetAtIndex(uint32_t idx) {
+ lldb::PlatformSP platform_sp;
+ {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ if (idx < m_platforms.size())
+ platform_sp = m_platforms[idx];
+ }
+ return platform_sp;
+ }
+
+ //------------------------------------------------------------------
+ /// Select the active platform.
+ ///
+ /// In order to debug remotely, other platform's can be remotely
+ /// connected to and set as the selected platform for any subsequent
+ /// debugging. This allows connection to remote targets and allows
+ /// the ability to discover process info, launch and attach to remote
+ /// processes.
+ //------------------------------------------------------------------
+ lldb::PlatformSP GetSelectedPlatform() {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ if (!m_selected_platform_sp && !m_platforms.empty())
+ m_selected_platform_sp = m_platforms.front();
+
+ return m_selected_platform_sp;
+ }
+
+ void SetSelectedPlatform(const lldb::PlatformSP &platform_sp) {
+ if (platform_sp) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ const size_t num_platforms = m_platforms.size();
+ for (size_t idx = 0; idx < num_platforms; ++idx) {
+ if (m_platforms[idx].get() == platform_sp.get()) {
+ m_selected_platform_sp = m_platforms[idx];
+ return;
}
+ }
+ m_platforms.push_back(platform_sp);
+ m_selected_platform_sp = m_platforms.back();
+ }
+ }
- void
- ClearCachedUserNames()
- {
- std::lock_guard<std::mutex> guard(m_mutex);
- m_uid_map.clear();
- }
+protected:
+ typedef std::vector<lldb::PlatformSP> collection;
+ mutable std::recursive_mutex m_mutex;
+ collection m_platforms;
+ lldb::PlatformSP m_selected_platform_sp;
- const char *
- GetCachedGroupName(uint32_t gid)
- {
- std::lock_guard<std::mutex> guard(m_mutex);
- // return the empty string if our string is NULL
- // so we can tell when things were in the negative
- // cached (didn't find a valid group name, don't keep
- // trying)
- const auto pos = m_gid_map.find(gid);
- return ((pos != m_gid_map.end()) ? pos->second.AsCString("") : nullptr);
- }
+private:
+ DISALLOW_COPY_AND_ASSIGN(PlatformList);
+};
- const char *
- SetCachedGroupName(uint32_t gid, const char *name, size_t name_len)
- {
- std::lock_guard<std::mutex> guard(m_mutex);
- ConstString const_name(name);
- m_gid_map[gid] = const_name;
- if (m_max_gid_name_len < name_len)
- m_max_gid_name_len = name_len;
- // Const strings lives forever in our const string pool, so we can return the const char *
- return const_name.GetCString();
- }
+class OptionGroupPlatformRSync : public lldb_private::OptionGroup {
+public:
+ OptionGroupPlatformRSync() = default;
- void
- SetGroupNameNotFound(uint32_t gid)
- {
- std::lock_guard<std::mutex> guard(m_mutex);
- m_gid_map[gid] = ConstString();
- }
+ ~OptionGroupPlatformRSync() override = default;
- void
- ClearCachedGroupNames()
- {
- std::lock_guard<std::mutex> guard(m_mutex);
- m_gid_map.clear();
- }
+ lldb_private::Error
+ SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
+ ExecutionContext *execution_context) override;
- Error
- GetCachedExecutable (ModuleSpec &module_spec,
- lldb::ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr,
- Platform &remote_platform);
+ void OptionParsingStarting(ExecutionContext *execution_context) override;
- virtual Error
- DownloadModuleSlice (const FileSpec& src_file_spec,
- const uint64_t src_offset,
- const uint64_t src_size,
- const FileSpec& dst_file_spec);
-
- virtual Error
- DownloadSymbolFile (const lldb::ModuleSP& module_sp,
- const FileSpec& dst_file_spec);
-
- virtual const char *
- GetCacheHostname ();
-
- private:
- typedef std::function<Error (const ModuleSpec &)> ModuleResolver;
-
- Error
- GetRemoteSharedModule (const ModuleSpec &module_spec,
- Process* process,
- lldb::ModuleSP &module_sp,
- const ModuleResolver &module_resolver,
- bool *did_create_ptr);
-
- bool
- GetCachedSharedModule (const ModuleSpec& module_spec,
- lldb::ModuleSP &module_sp,
- bool *did_create_ptr);
-
- Error
- LoadCachedExecutable (const ModuleSpec &module_spec,
- lldb::ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr,
- Platform &remote_platform);
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
- FileSpec
- GetModuleCacheRoot ();
+ // Options table: Required for subclasses of Options.
- DISALLOW_COPY_AND_ASSIGN (Platform);
- };
+ static lldb_private::OptionDefinition g_option_table[];
- class PlatformList
- {
- public:
- PlatformList() : m_mutex(), m_platforms(), m_selected_platform_sp() {}
-
- ~PlatformList() = default;
-
- void
- Append(const lldb::PlatformSP &platform_sp, bool set_selected)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- m_platforms.push_back(platform_sp);
- if (set_selected)
- m_selected_platform_sp = m_platforms.back();
- }
+ // Instance variables to hold the values for command options.
- size_t
- GetSize()
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_platforms.size();
- }
+ bool m_rsync;
+ std::string m_rsync_opts;
+ std::string m_rsync_prefix;
+ bool m_ignores_remote_hostname;
- lldb::PlatformSP
- GetAtIndex(uint32_t idx)
- {
- lldb::PlatformSP platform_sp;
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- if (idx < m_platforms.size())
- platform_sp = m_platforms[idx];
- }
- return platform_sp;
- }
+private:
+ DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformRSync);
+};
- //------------------------------------------------------------------
- /// Select the active platform.
- ///
- /// In order to debug remotely, other platform's can be remotely
- /// connected to and set as the selected platform for any subsequent
- /// debugging. This allows connection to remote targets and allows
- /// the ability to discover process info, launch and attach to remote
- /// processes.
- //------------------------------------------------------------------
- lldb::PlatformSP
- GetSelectedPlatform()
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- if (!m_selected_platform_sp && !m_platforms.empty())
- m_selected_platform_sp = m_platforms.front();
-
- return m_selected_platform_sp;
- }
+class OptionGroupPlatformSSH : public lldb_private::OptionGroup {
+public:
+ OptionGroupPlatformSSH() = default;
- void
- SetSelectedPlatform(const lldb::PlatformSP &platform_sp)
- {
- if (platform_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- const size_t num_platforms = m_platforms.size();
- for (size_t idx = 0; idx < num_platforms; ++idx)
- {
- if (m_platforms[idx].get() == platform_sp.get())
- {
- m_selected_platform_sp = m_platforms[idx];
- return;
- }
- }
- m_platforms.push_back(platform_sp);
- m_selected_platform_sp = m_platforms.back();
- }
- }
+ ~OptionGroupPlatformSSH() override = default;
- protected:
- typedef std::vector<lldb::PlatformSP> collection;
- mutable std::recursive_mutex m_mutex;
- collection m_platforms;
- lldb::PlatformSP m_selected_platform_sp;
+ lldb_private::Error
+ SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
+ ExecutionContext *execution_context) override;
- private:
- DISALLOW_COPY_AND_ASSIGN (PlatformList);
- };
+ void OptionParsingStarting(ExecutionContext *execution_context) override;
+
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
+
+ // Options table: Required for subclasses of Options.
+
+ static lldb_private::OptionDefinition g_option_table[];
+
+ // Instance variables to hold the values for command options.
+
+ bool m_ssh;
+ std::string m_ssh_opts;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformSSH);
+};
+
+class OptionGroupPlatformCaching : public lldb_private::OptionGroup {
+public:
+ OptionGroupPlatformCaching() = default;
+
+ ~OptionGroupPlatformCaching() override = default;
+
+ lldb_private::Error
+ SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
+ ExecutionContext *execution_context) override;
+
+ void OptionParsingStarting(ExecutionContext *execution_context) override;
+
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
+
+ // Options table: Required for subclasses of Options.
+
+ static lldb_private::OptionDefinition g_option_table[];
+
+ // Instance variables to hold the values for command options.
+
+ std::string m_cache_dir;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformCaching);
+};
- class OptionGroupPlatformRSync : public lldb_private::OptionGroup
- {
- public:
- OptionGroupPlatformRSync() = default;
-
- ~OptionGroupPlatformRSync() override = default;
-
- lldb_private::Error
- SetOptionValue(CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value) override;
-
- void
- OptionParsingStarting(CommandInterpreter &interpreter) override;
-
- const lldb_private::OptionDefinition*
- GetDefinitions() override;
-
- uint32_t
- GetNumDefinitions() override;
-
- // Options table: Required for subclasses of Options.
-
- static lldb_private::OptionDefinition g_option_table[];
-
- // Instance variables to hold the values for command options.
-
- bool m_rsync;
- std::string m_rsync_opts;
- std::string m_rsync_prefix;
- bool m_ignores_remote_hostname;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformRSync);
- };
-
- class OptionGroupPlatformSSH : public lldb_private::OptionGroup
- {
- public:
- OptionGroupPlatformSSH() = default;
-
- ~OptionGroupPlatformSSH() override = default;
-
- lldb_private::Error
- SetOptionValue(CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value) override;
-
- void
- OptionParsingStarting(CommandInterpreter &interpreter) override;
-
- uint32_t
- GetNumDefinitions() override;
-
- const lldb_private::OptionDefinition*
- GetDefinitions() override;
-
- // Options table: Required for subclasses of Options.
-
- static lldb_private::OptionDefinition g_option_table[];
-
- // Instance variables to hold the values for command options.
-
- bool m_ssh;
- std::string m_ssh_opts;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformSSH);
- };
-
- class OptionGroupPlatformCaching : public lldb_private::OptionGroup
- {
- public:
- OptionGroupPlatformCaching() = default;
-
- ~OptionGroupPlatformCaching() override = default;
-
- lldb_private::Error
- SetOptionValue(CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value) override;
-
- void
- OptionParsingStarting(CommandInterpreter &interpreter) override;
-
- uint32_t
- GetNumDefinitions() override;
-
- const lldb_private::OptionDefinition*
- GetDefinitions() override;
-
- // Options table: Required for subclasses of Options.
-
- static lldb_private::OptionDefinition g_option_table[];
-
- // Instance variables to hold the values for command options.
-
- std::string m_cache_dir;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformCaching);
- };
-
} // namespace lldb_private
#endif // liblldb_Platform_h_
diff --git a/include/lldb/Target/Process.h b/include/lldb/Target/Process.h
index 57787f2f8f39..251dfe6a17c0 100644
--- a/include/lldb/Target/Process.h
+++ b/include/lldb/Target/Process.h
@@ -16,16 +16,17 @@
#include <limits.h>
// C++ Includes
+#include <chrono>
#include <list>
#include <memory>
#include <mutex>
#include <string>
-#include <vector>
#include <unordered_set>
+#include <vector>
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
+#include "lldb/Breakpoint/BreakpointSiteList.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Communication.h"
@@ -33,88 +34,74 @@
#include "lldb/Core/Event.h"
#include "lldb/Core/Listener.h"
#include "lldb/Core/LoadedModuleInfoList.h"
-#include "lldb/Core/ThreadSafeValue.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/StructuredData.h"
+#include "lldb/Core/ThreadSafeValue.h"
#include "lldb/Core/UserSettingsController.h"
-#include "lldb/Breakpoint/BreakpointSiteList.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/ProcessRunLock.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Target/ExecutionContextScope.h"
+#include "lldb/Target/InstrumentationRuntime.h"
#include "lldb/Target/Memory.h"
#include "lldb/Target/ProcessInfo.h"
#include "lldb/Target/ProcessLaunchInfo.h"
#include "lldb/Target/QueueList.h"
#include "lldb/Target/ThreadList.h"
-#include "lldb/Target/InstrumentationRuntime.h"
+#include "lldb/lldb-private.h"
+
+#include "llvm/ADT/ArrayRef.h"
namespace lldb_private {
-template <typename B, typename S>
-struct Range;
+template <typename B, typename S> struct Range;
//----------------------------------------------------------------------
// ProcessProperties
//----------------------------------------------------------------------
-class ProcessProperties : public Properties
-{
+class ProcessProperties : public Properties {
public:
- // Pass nullptr for "process" if the ProcessProperties are to be the global copy
- ProcessProperties (lldb_private::Process *process);
-
- ~ProcessProperties() override;
-
- bool
- GetDisableMemoryCache() const;
-
- uint64_t
- GetMemoryCacheLineSize () const;
-
- Args
- GetExtraStartupCommands () const;
-
- void
- SetExtraStartupCommands (const Args &args);
-
- FileSpec
- GetPythonOSPluginPath () const;
-
- void
- SetPythonOSPluginPath (const FileSpec &file);
-
- bool
- GetIgnoreBreakpointsInExpressions () const;
-
- void
- SetIgnoreBreakpointsInExpressions (bool ignore);
-
- bool
- GetUnwindOnErrorInExpressions () const;
-
- void
- SetUnwindOnErrorInExpressions (bool ignore);
-
- bool
- GetStopOnSharedLibraryEvents () const;
-
- void
- SetStopOnSharedLibraryEvents (bool stop);
-
- bool
- GetDetachKeepsStopped () const;
-
- void
- SetDetachKeepsStopped (bool keep_stopped);
-
- bool
- GetWarningsOptimization () const;
+ // Pass nullptr for "process" if the ProcessProperties are to be the global
+ // copy
+ ProcessProperties(lldb_private::Process *process);
+
+ ~ProcessProperties() override;
+
+ bool GetDisableMemoryCache() const;
+
+ uint64_t GetMemoryCacheLineSize() const;
+
+ Args GetExtraStartupCommands() const;
+
+ void SetExtraStartupCommands(const Args &args);
+
+ FileSpec GetPythonOSPluginPath() const;
+
+ void SetPythonOSPluginPath(const FileSpec &file);
+
+ bool GetIgnoreBreakpointsInExpressions() const;
+
+ void SetIgnoreBreakpointsInExpressions(bool ignore);
+
+ bool GetUnwindOnErrorInExpressions() const;
+
+ void SetUnwindOnErrorInExpressions(bool ignore);
+
+ bool GetStopOnSharedLibraryEvents() const;
+
+ void SetStopOnSharedLibraryEvents(bool stop);
+
+ bool GetDetachKeepsStopped() const;
+
+ void SetDetachKeepsStopped(bool keep_stopped);
+
+ bool GetWarningsOptimization() const;
protected:
- static void
- OptionValueChangedCallback (void *baton, OptionValue *option_value);
+ static void OptionValueChangedCallback(void *baton,
+ OptionValue *option_value);
- Process * m_process; // Can be nullptr for global ProcessProperties
+ Process *m_process; // Can be nullptr for global ProcessProperties
};
typedef std::shared_ptr<ProcessProperties> ProcessPropertiesSP;
@@ -125,103 +112,55 @@ typedef std::shared_ptr<ProcessProperties> ProcessPropertiesSP;
// Describes an existing process and any discoverable information that
// pertains to that process.
//----------------------------------------------------------------------
-class ProcessInstanceInfo : public ProcessInfo
-{
+class ProcessInstanceInfo : public ProcessInfo {
public:
- ProcessInstanceInfo () :
- ProcessInfo (),
- m_euid (UINT32_MAX),
- m_egid (UINT32_MAX),
- m_parent_pid (LLDB_INVALID_PROCESS_ID)
- {
- }
+ ProcessInstanceInfo()
+ : ProcessInfo(), m_euid(UINT32_MAX), m_egid(UINT32_MAX),
+ m_parent_pid(LLDB_INVALID_PROCESS_ID) {}
- ProcessInstanceInfo (const char *name,
- const ArchSpec &arch,
- lldb::pid_t pid) :
- ProcessInfo (name, arch, pid),
- m_euid (UINT32_MAX),
- m_egid (UINT32_MAX),
- m_parent_pid (LLDB_INVALID_PROCESS_ID)
- {
- }
-
- void
- Clear ()
- {
- ProcessInfo::Clear();
- m_euid = UINT32_MAX;
- m_egid = UINT32_MAX;
- m_parent_pid = LLDB_INVALID_PROCESS_ID;
- }
-
- uint32_t
- GetEffectiveUserID() const
- {
- return m_euid;
- }
+ ProcessInstanceInfo(const char *name, const ArchSpec &arch, lldb::pid_t pid)
+ : ProcessInfo(name, arch, pid), m_euid(UINT32_MAX), m_egid(UINT32_MAX),
+ m_parent_pid(LLDB_INVALID_PROCESS_ID) {}
- uint32_t
- GetEffectiveGroupID() const
- {
- return m_egid;
- }
-
- bool
- EffectiveUserIDIsValid () const
- {
- return m_euid != UINT32_MAX;
- }
+ void Clear() {
+ ProcessInfo::Clear();
+ m_euid = UINT32_MAX;
+ m_egid = UINT32_MAX;
+ m_parent_pid = LLDB_INVALID_PROCESS_ID;
+ }
- bool
- EffectiveGroupIDIsValid () const
- {
- return m_egid != UINT32_MAX;
- }
+ uint32_t GetEffectiveUserID() const { return m_euid; }
- void
- SetEffectiveUserID (uint32_t uid)
- {
- m_euid = uid;
- }
-
- void
- SetEffectiveGroupID (uint32_t gid)
- {
- m_egid = gid;
- }
+ uint32_t GetEffectiveGroupID() const { return m_egid; }
- lldb::pid_t
- GetParentProcessID () const
- {
- return m_parent_pid;
- }
-
- void
- SetParentProcessID (lldb::pid_t pid)
- {
- m_parent_pid = pid;
- }
-
- bool
- ParentProcessIDIsValid() const
- {
- return m_parent_pid != LLDB_INVALID_PROCESS_ID;
- }
-
- void
- Dump (Stream &s, Platform *platform) const;
+ bool EffectiveUserIDIsValid() const { return m_euid != UINT32_MAX; }
+
+ bool EffectiveGroupIDIsValid() const { return m_egid != UINT32_MAX; }
+
+ void SetEffectiveUserID(uint32_t uid) { m_euid = uid; }
+
+ void SetEffectiveGroupID(uint32_t gid) { m_egid = gid; }
+
+ lldb::pid_t GetParentProcessID() const { return m_parent_pid; }
+
+ void SetParentProcessID(lldb::pid_t pid) { m_parent_pid = pid; }
- static void
- DumpTableHeader (Stream &s, Platform *platform, bool show_args, bool verbose);
+ bool ParentProcessIDIsValid() const {
+ return m_parent_pid != LLDB_INVALID_PROCESS_ID;
+ }
+
+ void Dump(Stream &s, Platform *platform) const;
+
+ static void DumpTableHeader(Stream &s, Platform *platform, bool show_args,
+ bool verbose);
+
+ void DumpAsTableRow(Stream &s, Platform *platform, bool show_args,
+ bool verbose) const;
- void
- DumpAsTableRow (Stream &s, Platform *platform, bool show_args, bool verbose) const;
-
protected:
- uint32_t m_euid;
- uint32_t m_egid;
- lldb::pid_t m_parent_pid;
+ uint32_t m_euid;
+ uint32_t m_egid;
+ lldb::pid_t m_parent_pid;
};
//----------------------------------------------------------------------
@@ -229,230 +168,132 @@ protected:
//
// Describes any information that is required to attach to a process.
//----------------------------------------------------------------------
-
-class ProcessAttachInfo : public ProcessInstanceInfo
-{
+
+class ProcessAttachInfo : public ProcessInstanceInfo {
public:
- ProcessAttachInfo() :
- ProcessInstanceInfo(),
- m_listener_sp(),
- m_hijack_listener_sp(),
- m_plugin_name (),
- m_resume_count (0),
- m_wait_for_launch (false),
- m_ignore_existing (true),
- m_continue_once_attached (false),
- m_detach_on_error (true),
- m_async (false)
- {
- }
+ ProcessAttachInfo()
+ : ProcessInstanceInfo(), m_listener_sp(), m_hijack_listener_sp(),
+ m_plugin_name(), m_resume_count(0), m_wait_for_launch(false),
+ m_ignore_existing(true), m_continue_once_attached(false),
+ m_detach_on_error(true), m_async(false) {}
- ProcessAttachInfo (const ProcessLaunchInfo &launch_info) :
- ProcessInstanceInfo(),
- m_listener_sp(),
- m_hijack_listener_sp(),
- m_plugin_name (),
- m_resume_count (0),
- m_wait_for_launch (false),
- m_ignore_existing (true),
- m_continue_once_attached (false),
- m_detach_on_error (true),
- m_async (false)
- {
- ProcessInfo::operator= (launch_info);
- SetProcessPluginName (launch_info.GetProcessPluginName());
- SetResumeCount (launch_info.GetResumeCount());
- SetListener(launch_info.GetListener());
- SetHijackListener(launch_info.GetHijackListener());
- m_detach_on_error = launch_info.GetDetachOnError();
- }
-
- bool
- GetWaitForLaunch () const
- {
- return m_wait_for_launch;
- }
-
- void
- SetWaitForLaunch (bool b)
- {
- m_wait_for_launch = b;
- }
+ ProcessAttachInfo(const ProcessLaunchInfo &launch_info)
+ : ProcessInstanceInfo(), m_listener_sp(), m_hijack_listener_sp(),
+ m_plugin_name(), m_resume_count(0), m_wait_for_launch(false),
+ m_ignore_existing(true), m_continue_once_attached(false),
+ m_detach_on_error(true), m_async(false) {
+ ProcessInfo::operator=(launch_info);
+ SetProcessPluginName(launch_info.GetProcessPluginName());
+ SetResumeCount(launch_info.GetResumeCount());
+ SetListener(launch_info.GetListener());
+ SetHijackListener(launch_info.GetHijackListener());
+ m_detach_on_error = launch_info.GetDetachOnError();
+ }
- bool
- GetAsync () const
- {
- return m_async;
- }
+ bool GetWaitForLaunch() const { return m_wait_for_launch; }
- void
- SetAsync (bool b)
- {
- m_async = b;
- }
+ void SetWaitForLaunch(bool b) { m_wait_for_launch = b; }
- bool
- GetIgnoreExisting () const
- {
- return m_ignore_existing;
- }
-
- void
- SetIgnoreExisting (bool b)
- {
- m_ignore_existing = b;
- }
+ bool GetAsync() const { return m_async; }
- bool
- GetContinueOnceAttached () const
- {
- return m_continue_once_attached;
- }
-
- void
- SetContinueOnceAttached (bool b)
- {
- m_continue_once_attached = b;
- }
+ void SetAsync(bool b) { m_async = b; }
- uint32_t
- GetResumeCount () const
- {
- return m_resume_count;
- }
-
- void
- SetResumeCount (uint32_t c)
- {
- m_resume_count = c;
- }
-
- const char *
- GetProcessPluginName () const
- {
- return (m_plugin_name.empty() ? nullptr : m_plugin_name.c_str());
- }
-
- void
- SetProcessPluginName (const char *plugin)
- {
- if (plugin && plugin[0])
- m_plugin_name.assign (plugin);
- else
- m_plugin_name.clear();
- }
+ bool GetIgnoreExisting() const { return m_ignore_existing; }
- void
- Clear ()
- {
- ProcessInstanceInfo::Clear();
- m_plugin_name.clear();
- m_resume_count = 0;
- m_wait_for_launch = false;
- m_ignore_existing = true;
- m_continue_once_attached = false;
- }
+ void SetIgnoreExisting(bool b) { m_ignore_existing = b; }
- bool
- ProcessInfoSpecified () const
- {
- if (GetExecutableFile())
- return true;
- if (GetProcessID() != LLDB_INVALID_PROCESS_ID)
- return true;
- if (GetParentProcessID() != LLDB_INVALID_PROCESS_ID)
- return true;
- return false;
- }
-
- lldb::ListenerSP
- GetHijackListener () const
- {
- return m_hijack_listener_sp;
- }
-
- void
- SetHijackListener (const lldb::ListenerSP &listener_sp)
- {
- m_hijack_listener_sp = listener_sp;
- }
-
- bool
- GetDetachOnError () const
- {
- return m_detach_on_error;
- }
-
- void
- SetDetachOnError (bool enable)
- {
- m_detach_on_error = enable;
- }
+ bool GetContinueOnceAttached() const { return m_continue_once_attached; }
- // Get and set the actual listener that will be used for the process events
- lldb::ListenerSP
- GetListener () const
- {
- return m_listener_sp;
- }
+ void SetContinueOnceAttached(bool b) { m_continue_once_attached = b; }
- void
- SetListener (const lldb::ListenerSP &listener_sp)
- {
- m_listener_sp = listener_sp;
- }
+ uint32_t GetResumeCount() const { return m_resume_count; }
+
+ void SetResumeCount(uint32_t c) { m_resume_count = c; }
+
+ const char *GetProcessPluginName() const {
+ return (m_plugin_name.empty() ? nullptr : m_plugin_name.c_str());
+ }
+
+ void SetProcessPluginName(llvm::StringRef plugin) { m_plugin_name = plugin; }
- lldb::ListenerSP
- GetListenerForProcess (Debugger &debugger);
+ void Clear() {
+ ProcessInstanceInfo::Clear();
+ m_plugin_name.clear();
+ m_resume_count = 0;
+ m_wait_for_launch = false;
+ m_ignore_existing = true;
+ m_continue_once_attached = false;
+ }
+
+ bool ProcessInfoSpecified() const {
+ if (GetExecutableFile())
+ return true;
+ if (GetProcessID() != LLDB_INVALID_PROCESS_ID)
+ return true;
+ if (GetParentProcessID() != LLDB_INVALID_PROCESS_ID)
+ return true;
+ return false;
+ }
+
+ lldb::ListenerSP GetHijackListener() const { return m_hijack_listener_sp; }
+
+ void SetHijackListener(const lldb::ListenerSP &listener_sp) {
+ m_hijack_listener_sp = listener_sp;
+ }
+
+ bool GetDetachOnError() const { return m_detach_on_error; }
+
+ void SetDetachOnError(bool enable) { m_detach_on_error = enable; }
+
+ // Get and set the actual listener that will be used for the process events
+ lldb::ListenerSP GetListener() const { return m_listener_sp; }
+
+ void SetListener(const lldb::ListenerSP &listener_sp) {
+ m_listener_sp = listener_sp;
+ }
+
+ lldb::ListenerSP GetListenerForProcess(Debugger &debugger);
protected:
- lldb::ListenerSP m_listener_sp;
- lldb::ListenerSP m_hijack_listener_sp;
- std::string m_plugin_name;
- uint32_t m_resume_count; // How many times do we resume after launching
- bool m_wait_for_launch;
- bool m_ignore_existing;
- bool m_continue_once_attached; // Supports the use-case scenario of immediately continuing the process once attached.
- bool m_detach_on_error; // If we are debugging remotely, instruct the stub to detach rather than killing the target on error.
- bool m_async; // Use an async attach where we start the attach and return immediately (used by GUI programs with --waitfor so they can call SBProcess::Stop() to cancel attach)
+ lldb::ListenerSP m_listener_sp;
+ lldb::ListenerSP m_hijack_listener_sp;
+ std::string m_plugin_name;
+ uint32_t m_resume_count; // How many times do we resume after launching
+ bool m_wait_for_launch;
+ bool m_ignore_existing;
+ bool m_continue_once_attached; // Supports the use-case scenario of
+ // immediately continuing the process once
+ // attached.
+ bool m_detach_on_error; // If we are debugging remotely, instruct the stub to
+ // detach rather than killing the target on error.
+ bool m_async; // Use an async attach where we start the attach and return
+ // immediately (used by GUI programs with --waitfor so they can
+ // call SBProcess::Stop() to cancel attach)
};
-class ProcessLaunchCommandOptions : public Options
-{
+class ProcessLaunchCommandOptions : public Options {
public:
- ProcessLaunchCommandOptions (CommandInterpreter &interpreter) :
- Options(interpreter)
- {
- // Keep default values of all options in one place: OptionParsingStarting ()
- OptionParsingStarting ();
- }
+ ProcessLaunchCommandOptions() : Options() {
+ // Keep default values of all options in one place: OptionParsingStarting ()
+ OptionParsingStarting(nullptr);
+ }
- ~ProcessLaunchCommandOptions() override = default;
+ ~ProcessLaunchCommandOptions() override = default;
- Error
- SetOptionValue (uint32_t option_idx, const char *option_arg) override;
-
- void
- OptionParsingStarting() override
- {
- launch_info.Clear();
- disable_aslr = eLazyBoolCalculate;
- }
-
- const OptionDefinition*
- GetDefinitions() override
- {
- return g_option_table;
- }
-
- // Options table: Required for subclasses of Options.
-
- static OptionDefinition g_option_table[];
-
- // Instance variables to hold the values for command options.
-
- ProcessLaunchInfo launch_info;
- lldb_private::LazyBool disable_aslr;
+ Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+ ExecutionContext *execution_context) override;
+
+ void OptionParsingStarting(ExecutionContext *execution_context) override {
+ launch_info.Clear();
+ disable_aslr = eLazyBoolCalculate;
+ }
+
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
+
+ // Instance variables to hold the values for command options.
+
+ ProcessLaunchInfo launch_info;
+ lldb_private::LazyBool disable_aslr;
};
//----------------------------------------------------------------------
@@ -461,3129 +302,2874 @@ public:
// A class to help matching one ProcessInstanceInfo to another.
//----------------------------------------------------------------------
-class ProcessInstanceInfoMatch
-{
+class ProcessInstanceInfoMatch {
public:
- ProcessInstanceInfoMatch () :
- m_match_info (),
- m_name_match_type (eNameMatchIgnore),
- m_match_all_users (false)
- {
- }
+ ProcessInstanceInfoMatch()
+ : m_match_info(), m_name_match_type(eNameMatchIgnore),
+ m_match_all_users(false) {}
- ProcessInstanceInfoMatch (const char *process_name,
- NameMatchType process_name_match_type) :
- m_match_info (),
- m_name_match_type (process_name_match_type),
- m_match_all_users (false)
- {
- m_match_info.GetExecutableFile().SetFile(process_name, false);
- }
+ ProcessInstanceInfoMatch(const char *process_name,
+ NameMatchType process_name_match_type)
+ : m_match_info(), m_name_match_type(process_name_match_type),
+ m_match_all_users(false) {
+ m_match_info.GetExecutableFile().SetFile(process_name, false);
+ }
- ProcessInstanceInfo &
- GetProcessInfo ()
- {
- return m_match_info;
- }
+ ProcessInstanceInfo &GetProcessInfo() { return m_match_info; }
- const ProcessInstanceInfo &
- GetProcessInfo () const
- {
- return m_match_info;
- }
-
- bool
- GetMatchAllUsers () const
- {
- return m_match_all_users;
- }
+ const ProcessInstanceInfo &GetProcessInfo() const { return m_match_info; }
- void
- SetMatchAllUsers (bool b)
- {
- m_match_all_users = b;
- }
+ bool GetMatchAllUsers() const { return m_match_all_users; }
- NameMatchType
- GetNameMatchType () const
- {
- return m_name_match_type;
- }
+ void SetMatchAllUsers(bool b) { m_match_all_users = b; }
- void
- SetNameMatchType (NameMatchType name_match_type)
- {
- m_name_match_type = name_match_type;
- }
-
- bool
- NameMatches (const char *process_name) const;
+ NameMatchType GetNameMatchType() const { return m_name_match_type; }
+
+ void SetNameMatchType(NameMatchType name_match_type) {
+ m_name_match_type = name_match_type;
+ }
- bool
- Matches (const ProcessInstanceInfo &proc_info) const;
+ bool NameMatches(const char *process_name) const;
- bool
- MatchAllProcesses () const;
- void
- Clear ();
+ bool Matches(const ProcessInstanceInfo &proc_info) const;
+
+ bool MatchAllProcesses() const;
+ void Clear();
protected:
- ProcessInstanceInfo m_match_info;
- NameMatchType m_name_match_type;
- bool m_match_all_users;
+ ProcessInstanceInfo m_match_info;
+ NameMatchType m_name_match_type;
+ bool m_match_all_users;
};
-class ProcessInstanceInfoList
-{
+class ProcessInstanceInfoList {
public:
- ProcessInstanceInfoList() = default;
+ ProcessInstanceInfoList() = default;
- void
- Clear()
- {
- m_infos.clear();
- }
-
- size_t
- GetSize()
- {
- return m_infos.size();
- }
-
- void
- Append (const ProcessInstanceInfo &info)
- {
- m_infos.push_back (info);
- }
+ void Clear() { m_infos.clear(); }
- const char *
- GetProcessNameAtIndex (size_t idx)
- {
- return ((idx < m_infos.size()) ? m_infos[idx].GetName() : nullptr);
- }
+ size_t GetSize() { return m_infos.size(); }
- size_t
- GetProcessNameLengthAtIndex (size_t idx)
- {
- return ((idx < m_infos.size()) ? m_infos[idx].GetNameLength() : 0);
- }
+ void Append(const ProcessInstanceInfo &info) { m_infos.push_back(info); }
- lldb::pid_t
- GetProcessIDAtIndex (size_t idx)
- {
- return ((idx < m_infos.size()) ? m_infos[idx].GetProcessID() : 0);
- }
+ const char *GetProcessNameAtIndex(size_t idx) {
+ return ((idx < m_infos.size()) ? m_infos[idx].GetName() : nullptr);
+ }
- bool
- GetInfoAtIndex (size_t idx, ProcessInstanceInfo &info)
- {
- if (idx < m_infos.size())
- {
- info = m_infos[idx];
- return true;
- }
- return false;
- }
-
- // You must ensure "idx" is valid before calling this function
- const ProcessInstanceInfo &
- GetProcessInfoAtIndex (size_t idx) const
- {
- assert (idx < m_infos.size());
- return m_infos[idx];
+ size_t GetProcessNameLengthAtIndex(size_t idx) {
+ return ((idx < m_infos.size()) ? m_infos[idx].GetNameLength() : 0);
+ }
+
+ lldb::pid_t GetProcessIDAtIndex(size_t idx) {
+ return ((idx < m_infos.size()) ? m_infos[idx].GetProcessID() : 0);
+ }
+
+ bool GetInfoAtIndex(size_t idx, ProcessInstanceInfo &info) {
+ if (idx < m_infos.size()) {
+ info = m_infos[idx];
+ return true;
}
-
+ return false;
+ }
+
+ // You must ensure "idx" is valid before calling this function
+ const ProcessInstanceInfo &GetProcessInfoAtIndex(size_t idx) const {
+ assert(idx < m_infos.size());
+ return m_infos[idx];
+ }
+
protected:
- typedef std::vector<ProcessInstanceInfo> collection;
- collection m_infos;
+ typedef std::vector<ProcessInstanceInfo> collection;
+ collection m_infos;
};
-// This class tracks the Modification state of the process. Things that can currently modify
-// the program are running the program (which will up the StopID) and writing memory (which
-// will up the MemoryID.)
+// This class tracks the Modification state of the process. Things that can
+// currently modify
+// the program are running the program (which will up the StopID) and writing
+// memory (which
+// will up the MemoryID.)
// FIXME: Should we also include modification of register states?
-class ProcessModID
-{
- friend bool operator== (const ProcessModID &lhs, const ProcessModID &rhs);
+class ProcessModID {
+ friend bool operator==(const ProcessModID &lhs, const ProcessModID &rhs);
+
public:
- ProcessModID () :
- m_stop_id (0),
- m_last_natural_stop_id(0),
- m_resume_id (0),
- m_memory_id (0),
- m_last_user_expression_resume (0),
- m_running_user_expression (false)
- {}
-
- ProcessModID (const ProcessModID &rhs) :
- m_stop_id (rhs.m_stop_id),
- m_memory_id (rhs.m_memory_id)
- {}
-
- const ProcessModID & operator= (const ProcessModID &rhs)
- {
- if (this != &rhs)
- {
- m_stop_id = rhs.m_stop_id;
- m_memory_id = rhs.m_memory_id;
- }
- return *this;
- }
-
- ~ProcessModID() = default;
-
- void BumpStopID () {
- m_stop_id++;
- if (!IsLastResumeForUserExpression())
- m_last_natural_stop_id++;
- }
-
- void BumpMemoryID () { m_memory_id++; }
-
- void BumpResumeID () {
- m_resume_id++;
- if (m_running_user_expression > 0)
- m_last_user_expression_resume = m_resume_id;
- }
-
- uint32_t GetStopID() const { return m_stop_id; }
- uint32_t GetLastNaturalStopID() const { return m_last_natural_stop_id; }
- uint32_t GetMemoryID () const { return m_memory_id; }
- uint32_t GetResumeID () const { return m_resume_id; }
- uint32_t GetLastUserExpressionResumeID () const { return m_last_user_expression_resume; }
-
- bool MemoryIDEqual (const ProcessModID &compare) const
- {
- return m_memory_id == compare.m_memory_id;
- }
-
- bool StopIDEqual (const ProcessModID &compare) const
- {
- return m_stop_id == compare.m_stop_id;
- }
-
- void SetInvalid ()
- {
- m_stop_id = UINT32_MAX;
- }
-
- bool IsValid () const
- {
- return m_stop_id != UINT32_MAX;
- }
-
- bool
- IsLastResumeForUserExpression () const
- {
- // If we haven't yet resumed the target, then it can't be for a user expression...
- if (m_resume_id == 0)
- return false;
-
- return m_resume_id == m_last_user_expression_resume;
- }
-
- void
- SetRunningUserExpression (bool on)
- {
- if (on)
- m_running_user_expression++;
- else
- m_running_user_expression--;
- }
+ ProcessModID()
+ : m_stop_id(0), m_last_natural_stop_id(0), m_resume_id(0), m_memory_id(0),
+ m_last_user_expression_resume(0), m_running_user_expression(false) {}
- void
- SetStopEventForLastNaturalStopID (lldb::EventSP event_sp)
- {
- m_last_natural_stop_event = event_sp;
- }
+ ProcessModID(const ProcessModID &rhs)
+ : m_stop_id(rhs.m_stop_id), m_memory_id(rhs.m_memory_id) {}
- lldb::EventSP GetStopEventForStopID (uint32_t stop_id) const
- {
- if (stop_id == m_last_natural_stop_id)
- return m_last_natural_stop_event;
- return lldb::EventSP();
+ const ProcessModID &operator=(const ProcessModID &rhs) {
+ if (this != &rhs) {
+ m_stop_id = rhs.m_stop_id;
+ m_memory_id = rhs.m_memory_id;
}
+ return *this;
+ }
+
+ ~ProcessModID() = default;
+
+ void BumpStopID() {
+ m_stop_id++;
+ if (!IsLastResumeForUserExpression())
+ m_last_natural_stop_id++;
+ }
+
+ void BumpMemoryID() { m_memory_id++; }
+
+ void BumpResumeID() {
+ m_resume_id++;
+ if (m_running_user_expression > 0)
+ m_last_user_expression_resume = m_resume_id;
+ }
+
+ uint32_t GetStopID() const { return m_stop_id; }
+ uint32_t GetLastNaturalStopID() const { return m_last_natural_stop_id; }
+ uint32_t GetMemoryID() const { return m_memory_id; }
+ uint32_t GetResumeID() const { return m_resume_id; }
+ uint32_t GetLastUserExpressionResumeID() const {
+ return m_last_user_expression_resume;
+ }
+
+ bool MemoryIDEqual(const ProcessModID &compare) const {
+ return m_memory_id == compare.m_memory_id;
+ }
+
+ bool StopIDEqual(const ProcessModID &compare) const {
+ return m_stop_id == compare.m_stop_id;
+ }
+
+ void SetInvalid() { m_stop_id = UINT32_MAX; }
+
+ bool IsValid() const { return m_stop_id != UINT32_MAX; }
+
+ bool IsLastResumeForUserExpression() const {
+ // If we haven't yet resumed the target, then it can't be for a user
+ // expression...
+ if (m_resume_id == 0)
+ return false;
+
+ return m_resume_id == m_last_user_expression_resume;
+ }
+
+ void SetRunningUserExpression(bool on) {
+ if (on)
+ m_running_user_expression++;
+ else
+ m_running_user_expression--;
+ }
+
+ void SetStopEventForLastNaturalStopID(lldb::EventSP event_sp) {
+ m_last_natural_stop_event = event_sp;
+ }
+
+ lldb::EventSP GetStopEventForStopID(uint32_t stop_id) const {
+ if (stop_id == m_last_natural_stop_id)
+ return m_last_natural_stop_event;
+ return lldb::EventSP();
+ }
private:
- uint32_t m_stop_id;
- uint32_t m_last_natural_stop_id;
- uint32_t m_resume_id;
- uint32_t m_memory_id;
- uint32_t m_last_user_expression_resume;
- uint32_t m_running_user_expression;
- lldb::EventSP m_last_natural_stop_event;
+ uint32_t m_stop_id;
+ uint32_t m_last_natural_stop_id;
+ uint32_t m_resume_id;
+ uint32_t m_memory_id;
+ uint32_t m_last_user_expression_resume;
+ uint32_t m_running_user_expression;
+ lldb::EventSP m_last_natural_stop_event;
};
-inline bool operator== (const ProcessModID &lhs, const ProcessModID &rhs)
-{
- if (lhs.StopIDEqual (rhs)
- && lhs.MemoryIDEqual (rhs))
- return true;
- else
- return false;
+inline bool operator==(const ProcessModID &lhs, const ProcessModID &rhs) {
+ if (lhs.StopIDEqual(rhs) && lhs.MemoryIDEqual(rhs))
+ return true;
+ else
+ return false;
}
-inline bool operator!= (const ProcessModID &lhs, const ProcessModID &rhs)
-{
- return (!lhs.StopIDEqual (rhs) || !lhs.MemoryIDEqual (rhs));
+inline bool operator!=(const ProcessModID &lhs, const ProcessModID &rhs) {
+ return (!lhs.StopIDEqual(rhs) || !lhs.MemoryIDEqual(rhs));
}
-
+
//----------------------------------------------------------------------
/// @class Process Process.h "lldb/Target/Process.h"
/// @brief A plug-in interface definition class for debugging a process.
//----------------------------------------------------------------------
-class Process :
- public std::enable_shared_from_this<Process>,
- public ProcessProperties,
- public UserID,
- public Broadcaster,
- public ExecutionContextScope,
- public PluginInterface
-{
- friend class FunctionCaller; // For WaitForStateChangeEventsPrivate
- friend class Debugger; // For PopProcessIOHandler and ProcessIOHandlerIsActive
- friend class ProcessEventData;
- friend class StopInfo;
- friend class Target;
- friend class ThreadList;
+class Process : public std::enable_shared_from_this<Process>,
+ public ProcessProperties,
+ public UserID,
+ public Broadcaster,
+ public ExecutionContextScope,
+ public PluginInterface {
+ friend class FunctionCaller; // For WaitForStateChangeEventsPrivate
+ friend class Debugger; // For PopProcessIOHandler and ProcessIOHandlerIsActive
+ friend class ProcessEventData;
+ friend class StopInfo;
+ friend class Target;
+ friend class ThreadList;
public:
- //------------------------------------------------------------------
- /// Broadcaster event bits definitions.
- //------------------------------------------------------------------
- enum
- {
- eBroadcastBitStateChanged = (1 << 0),
- eBroadcastBitInterrupt = (1 << 1),
- eBroadcastBitSTDOUT = (1 << 2),
- eBroadcastBitSTDERR = (1 << 3),
- eBroadcastBitProfileData = (1 << 4)
- };
-
- enum
- {
- eBroadcastInternalStateControlStop = (1<<0),
- eBroadcastInternalStateControlPause = (1<<1),
- eBroadcastInternalStateControlResume = (1<<2)
- };
-
- //------------------------------------------------------------------
- /// Process warning types.
- //------------------------------------------------------------------
- enum Warnings
- {
- eWarningsOptimization = 1
- };
-
- typedef Range<lldb::addr_t, lldb::addr_t> LoadRange;
- // We use a read/write lock to allow on or more clients to
- // access the process state while the process is stopped (reader).
- // We lock the write lock to control access to the process
- // while it is running (readers, or clients that want the process
- // stopped can block waiting for the process to stop, or just
- // try to lock it to see if they can immediately access the stopped
- // process. If the try read lock fails, then the process is running.
- typedef ProcessRunLock::ProcessRunLocker StopLocker;
-
- // These two functions fill out the Broadcaster interface:
-
- static ConstString &GetStaticBroadcasterClass ();
-
- ConstString &GetBroadcasterClass() const override
- {
- return GetStaticBroadcasterClass();
- }
-
- //------------------------------------------------------------------
- /// A notification structure that can be used by clients to listen
- /// for changes in a process's lifetime.
- ///
- /// @see RegisterNotificationCallbacks (const Notifications&)
- /// @see UnregisterNotificationCallbacks (const Notifications&)
- //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ /// Broadcaster event bits definitions.
+ //------------------------------------------------------------------
+ enum {
+ eBroadcastBitStateChanged = (1 << 0),
+ eBroadcastBitInterrupt = (1 << 1),
+ eBroadcastBitSTDOUT = (1 << 2),
+ eBroadcastBitSTDERR = (1 << 3),
+ eBroadcastBitProfileData = (1 << 4),
+ eBroadcastBitStructuredData = (1 << 5),
+ };
+
+ enum {
+ eBroadcastInternalStateControlStop = (1 << 0),
+ eBroadcastInternalStateControlPause = (1 << 1),
+ eBroadcastInternalStateControlResume = (1 << 2)
+ };
+
+ //------------------------------------------------------------------
+ /// Process warning types.
+ //------------------------------------------------------------------
+ enum Warnings { eWarningsOptimization = 1 };
+
+ typedef Range<lldb::addr_t, lldb::addr_t> LoadRange;
+ // We use a read/write lock to allow on or more clients to
+ // access the process state while the process is stopped (reader).
+ // We lock the write lock to control access to the process
+ // while it is running (readers, or clients that want the process
+ // stopped can block waiting for the process to stop, or just
+ // try to lock it to see if they can immediately access the stopped
+ // process. If the try read lock fails, then the process is running.
+ typedef ProcessRunLock::ProcessRunLocker StopLocker;
+
+ // These two functions fill out the Broadcaster interface:
+
+ static ConstString &GetStaticBroadcasterClass();
+
+ ConstString &GetBroadcasterClass() const override {
+ return GetStaticBroadcasterClass();
+ }
+
+//------------------------------------------------------------------
+/// A notification structure that can be used by clients to listen
+/// for changes in a process's lifetime.
+///
+/// @see RegisterNotificationCallbacks (const Notifications&)
+/// @see UnregisterNotificationCallbacks (const Notifications&)
+//------------------------------------------------------------------
#ifndef SWIG
- typedef struct
- {
- void *baton;
- void (*initialize)(void *baton, Process *process);
- void (*process_state_changed) (void *baton, Process *process, lldb::StateType state);
- } Notifications;
-
- class ProcessEventData :
- public EventData
- {
- friend class Process;
-
- public:
- ProcessEventData ();
- ProcessEventData (const lldb::ProcessSP &process, lldb::StateType state);
-
- ~ProcessEventData() override;
-
- static const ConstString &
- GetFlavorString ();
-
- const ConstString &
- GetFlavor() const override;
-
- lldb::ProcessSP
- GetProcessSP() const
- {
- return m_process_wp.lock();
- }
-
- lldb::StateType
- GetState() const
- {
- return m_state;
- }
- bool
- GetRestarted () const
- {
- return m_restarted;
- }
-
- size_t
- GetNumRestartedReasons ()
- {
- return m_restarted_reasons.size();
- }
-
- const char *
- GetRestartedReasonAtIndex(size_t idx)
- {
- return ((idx < m_restarted_reasons.size()) ? m_restarted_reasons[idx].c_str() : nullptr);
- }
-
- bool
- GetInterrupted () const
- {
- return m_interrupted;
- }
-
- void
- Dump(Stream *s) const override;
-
- void
- DoOnRemoval(Event *event_ptr) override;
-
- static const Process::ProcessEventData *
- GetEventDataFromEvent (const Event *event_ptr);
-
- static lldb::ProcessSP
- GetProcessFromEvent (const Event *event_ptr);
-
- static lldb::StateType
- GetStateFromEvent (const Event *event_ptr);
-
- static bool
- GetRestartedFromEvent (const Event *event_ptr);
-
- static size_t
- GetNumRestartedReasons(const Event *event_ptr);
-
- static const char *
- GetRestartedReasonAtIndex(const Event *event_ptr, size_t idx);
-
- static void
- AddRestartedReason (Event *event_ptr, const char *reason);
-
- static void
- SetRestartedInEvent (Event *event_ptr, bool new_value);
-
- static bool
- GetInterruptedFromEvent (const Event *event_ptr);
-
- static void
- SetInterruptedInEvent (Event *event_ptr, bool new_value);
-
- static bool
- SetUpdateStateOnRemoval (Event *event_ptr);
-
- private:
- void
- SetUpdateStateOnRemoval()
- {
- m_update_state++;
- }
-
- void
- SetRestarted (bool new_value)
- {
- m_restarted = new_value;
- }
-
- void
- SetInterrupted (bool new_value)
- {
- m_interrupted = new_value;
- }
-
- void
- AddRestartedReason (const char *reason)
- {
- m_restarted_reasons.push_back(reason);
- }
-
- lldb::ProcessWP m_process_wp;
- lldb::StateType m_state;
- std::vector<std::string> m_restarted_reasons;
- bool m_restarted; // For "eStateStopped" events, this is true if the target was automatically restarted.
- int m_update_state;
- bool m_interrupted;
-
- DISALLOW_COPY_AND_ASSIGN (ProcessEventData);
- };
-#endif // SWIG
+ typedef struct {
+ void *baton;
+ void (*initialize)(void *baton, Process *process);
+ void (*process_state_changed)(void *baton, Process *process,
+ lldb::StateType state);
+ } Notifications;
- //------------------------------------------------------------------
- /// Construct with a shared pointer to a target, and the Process listener.
- /// Uses the Host UnixSignalsSP by default.
- //------------------------------------------------------------------
- Process(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp);
-
- //------------------------------------------------------------------
- /// Construct with a shared pointer to a target, the Process listener,
- /// and the appropriate UnixSignalsSP for the process.
- //------------------------------------------------------------------
- Process(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const lldb::UnixSignalsSP &unix_signals_sp);
-
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// The destructor is virtual since this class is designed to be
- /// inherited from by the plug-in instance.
- //------------------------------------------------------------------
- ~Process() override;
-
- static void
- SettingsInitialize ();
-
- static void
- SettingsTerminate ();
-
- static const ProcessPropertiesSP &
- GetGlobalProperties();
-
- //------------------------------------------------------------------
- /// Find a Process plug-in that can debug \a module using the
- /// currently selected architecture.
- ///
- /// Scans all loaded plug-in interfaces that implement versions of
- /// the Process plug-in interface and returns the first instance
- /// that can debug the file.
- ///
- /// @param[in] module_sp
- /// The module shared pointer that this process will debug.
- ///
- /// @param[in] plugin_name
- /// If nullptr, select the best plug-in for the binary. If non-nullptr
- /// then look for a plugin whose PluginInfo's name matches
- /// this string.
- ///
- /// @see Process::CanDebug ()
- //------------------------------------------------------------------
- static lldb::ProcessSP
- FindPlugin (lldb::TargetSP target_sp,
- const char *plugin_name,
- lldb::ListenerSP listener_sp,
- const FileSpec *crash_file_path);
-
- //------------------------------------------------------------------
- /// Static function that can be used with the \b host function
- /// Host::StartMonitoringChildProcess ().
- ///
- /// This function can be used by lldb_private::Process subclasses
- /// when they want to watch for a local process and have its exit
- /// status automatically set when the host child process exits.
- /// Subclasses should call Host::StartMonitoringChildProcess ()
- /// with:
- /// callback = Process::SetHostProcessExitStatus
- /// pid = Process::GetID()
- /// monitor_signals = false
- //------------------------------------------------------------------
- static bool
- SetProcessExitStatus(lldb::pid_t pid, // The process ID we want to monitor
- bool exited,
- int signo, // Zero for no signal
- int status); // Exit value of process if signal is zero
-
- lldb::ByteOrder
- GetByteOrder () const;
-
- uint32_t
- GetAddressByteSize () const;
-
- uint32_t
- GetUniqueID() const
- {
- return m_process_unique_id;
- }
+ class ProcessEventData : public EventData {
+ friend class Process;
- //------------------------------------------------------------------
- /// Check if a plug-in instance can debug the file in \a module.
- ///
- /// Each plug-in is given a chance to say whether it can debug
- /// the file in \a module. If the Process plug-in instance can
- /// debug a file on the current system, it should return \b true.
- ///
- /// @return
- /// Returns \b true if this Process plug-in instance can
- /// debug the executable, \b false otherwise.
- //------------------------------------------------------------------
- virtual bool
- CanDebug (lldb::TargetSP target,
- bool plugin_specified_by_name) = 0;
-
- //------------------------------------------------------------------
- /// This object is about to be destroyed, do any necessary cleanup.
- ///
- /// Subclasses that override this method should always call this
- /// superclass method.
- //------------------------------------------------------------------
- virtual void
- Finalize();
-
- //------------------------------------------------------------------
- /// Return whether this object is valid (i.e. has not been finalized.)
- ///
- /// @return
- /// Returns \b true if this Process has not been finalized
- /// and \b false otherwise.
- //------------------------------------------------------------------
- bool
- IsValid() const
- {
- return !m_finalize_called;
- }
+ public:
+ ProcessEventData();
+ ProcessEventData(const lldb::ProcessSP &process, lldb::StateType state);
- //------------------------------------------------------------------
- /// Return a multi-word command object that can be used to expose
- /// plug-in specific commands.
- ///
- /// This object will be used to resolve plug-in commands and can be
- /// triggered by a call to:
- ///
- /// (lldb) process commmand <args>
- ///
- /// @return
- /// A CommandObject which can be one of the concrete subclasses
- /// of CommandObject like CommandObjectRaw, CommandObjectParsed,
- /// or CommandObjectMultiword.
- //------------------------------------------------------------------
- virtual CommandObject *
- GetPluginCommandObject()
- {
- return nullptr;
- }
+ ~ProcessEventData() override;
- //------------------------------------------------------------------
- /// Launch a new process.
- ///
- /// Launch a new process by spawning a new process using the
- /// target object's executable module's file as the file to launch.
- ///
- /// This function is not meant to be overridden by Process
- /// subclasses. It will first call Process::WillLaunch (Module *)
- /// and if that returns \b true, Process::DoLaunch (Module*,
- /// char const *[],char const *[],const char *,const char *,
- /// const char *) will be called to actually do the launching. If
- /// DoLaunch returns \b true, then Process::DidLaunch() will be
- /// called.
- ///
- /// @param[in] launch_info
- /// Details regarding the environment, STDIN/STDOUT/STDERR
- /// redirection, working path, etc. related to the requested launch.
- ///
- /// @return
- /// An error object. Call GetID() to get the process ID if
- /// the error object is success.
- //------------------------------------------------------------------
- virtual Error
- Launch (ProcessLaunchInfo &launch_info);
-
- virtual Error
- LoadCore ();
-
- virtual Error
- DoLoadCore ()
- {
- Error error;
- error.SetErrorStringWithFormat("error: %s does not support loading core files.", GetPluginName().GetCString());
- return error;
- }
+ static const ConstString &GetFlavorString();
- //------------------------------------------------------------------
- /// Get the dynamic loader plug-in for this process.
- ///
- /// The default action is to let the DynamicLoader plug-ins check
- /// the main executable and the DynamicLoader will select itself
- /// automatically. Subclasses can override this if inspecting the
- /// executable is not desired, or if Process subclasses can only
- /// use a specific DynamicLoader plug-in.
- //------------------------------------------------------------------
- virtual DynamicLoader *
- GetDynamicLoader ();
-
- //------------------------------------------------------------------
- // Returns AUXV structure found in many ELF-based environments.
- //
- // The default action is to return an empty data buffer.
- //
- // @return
- // A data buffer containing the contents of the AUXV data.
- //------------------------------------------------------------------
- virtual const lldb::DataBufferSP
- GetAuxvData();
-
- //------------------------------------------------------------------
- /// Sometimes processes know how to retrieve and load shared libraries.
- /// This is normally done by DynamicLoader plug-ins, but sometimes the
- /// connection to the process allows retrieving this information. The
- /// dynamic loader plug-ins can use this function if they can't
- /// determine the current shared library load state.
- ///
- /// @return
- /// The number of shared libraries that were loaded
- //------------------------------------------------------------------
- virtual size_t
- LoadModules ()
- {
- return 0;
- }
+ const ConstString &GetFlavor() const override;
- virtual size_t
- LoadModules (LoadedModuleInfoList &)
- {
- return 0;
- }
+ lldb::ProcessSP GetProcessSP() const { return m_process_wp.lock(); }
-protected:
- virtual JITLoaderList &
- GetJITLoaders ();
+ lldb::StateType GetState() const { return m_state; }
+ bool GetRestarted() const { return m_restarted; }
-public:
- //------------------------------------------------------------------
- /// Get the system runtime plug-in for this process.
- ///
- /// @return
- /// Returns a pointer to the SystemRuntime plugin for this Process
- /// if one is available. Else returns nullptr.
- //------------------------------------------------------------------
- virtual SystemRuntime *
- GetSystemRuntime ();
-
- //------------------------------------------------------------------
- /// Attach to an existing process using the process attach info.
- ///
- /// This function is not meant to be overridden by Process
- /// subclasses. It will first call WillAttach (lldb::pid_t)
- /// or WillAttach (const char *), and if that returns \b
- /// true, DoAttach (lldb::pid_t) or DoAttach (const char *) will
- /// be called to actually do the attach. If DoAttach returns \b
- /// true, then Process::DidAttach() will be called.
- ///
- /// @param[in] pid
- /// The process ID that we should attempt to attach to.
- ///
- /// @return
- /// Returns \a pid if attaching was successful, or
- /// LLDB_INVALID_PROCESS_ID if attaching fails.
- //------------------------------------------------------------------
- virtual Error
- Attach (ProcessAttachInfo &attach_info);
-
- //------------------------------------------------------------------
- /// Attach to a remote system via a URL
- ///
- /// @param[in] strm
- /// A stream where output intended for the user
- /// (if the driver has a way to display that) generated during
- /// the connection. This may be nullptr if no output is needed.A
- ///
- /// @param[in] remote_url
- /// The URL format that we are connecting to.
- ///
- /// @return
- /// Returns an error object.
- //------------------------------------------------------------------
- virtual Error
- ConnectRemote (Stream *strm, const char *remote_url);
-
- bool
- GetShouldDetach () const
- {
- return m_should_detach;
- }
+ size_t GetNumRestartedReasons() { return m_restarted_reasons.size(); }
- void
- SetShouldDetach (bool b)
- {
- m_should_detach = b;
+ const char *GetRestartedReasonAtIndex(size_t idx) {
+ return ((idx < m_restarted_reasons.size())
+ ? m_restarted_reasons[idx].c_str()
+ : nullptr);
}
- //------------------------------------------------------------------
- /// Get the image information address for the current process.
- ///
- /// Some runtimes have system functions that can help dynamic
- /// loaders locate the dynamic loader information needed to observe
- /// shared libraries being loaded or unloaded. This function is
- /// in the Process interface (as opposed to the DynamicLoader
- /// interface) to ensure that remote debugging can take advantage of
- /// this functionality.
- ///
- /// @return
- /// The address of the dynamic loader information, or
- /// LLDB_INVALID_ADDRESS if this is not supported by this
- /// interface.
- //------------------------------------------------------------------
- virtual lldb::addr_t
- GetImageInfoAddress ();
-
- //------------------------------------------------------------------
- /// Called when the process is about to broadcast a public stop.
- ///
- /// There are public and private stops. Private stops are when the
- /// process is doing things like stepping and the client doesn't
- /// need to know about starts and stop that implement a thread plan.
- /// Single stepping over a source line in code might end up being
- /// implemented by one or more process starts and stops. Public stops
- /// are when clients will be notified that the process is stopped.
- /// These events typically trigger UI updates (thread stack frames to
- /// be displayed, variables to be displayed, and more). This function
- /// can be overriden and allows process subclasses to do something
- /// before the eBroadcastBitStateChanged event is sent to public
- /// clients.
- //------------------------------------------------------------------
- virtual void
- WillPublicStop ()
- {
- }
+ bool GetInterrupted() const { return m_interrupted; }
- //------------------------------------------------------------------
- /// Register for process and thread notifications.
- ///
- /// Clients can register notification callbacks by filling out a
- /// Process::Notifications structure and calling this function.
- ///
- /// @param[in] callbacks
- /// A structure that contains the notification baton and
- /// callback functions.
- ///
- /// @see Process::Notifications
- //------------------------------------------------------------------
-#ifndef SWIG
- void
- RegisterNotificationCallbacks (const Process::Notifications& callbacks);
-#endif
+ void Dump(Stream *s) const override;
- //------------------------------------------------------------------
- /// Unregister for process and thread notifications.
- ///
- /// Clients can unregister notification callbacks by passing a copy of
- /// the original baton and callbacks in \a callbacks.
- ///
- /// @param[in] callbacks
- /// A structure that contains the notification baton and
- /// callback functions.
- ///
- /// @return
- /// Returns \b true if the notification callbacks were
- /// successfully removed from the process, \b false otherwise.
- ///
- /// @see Process::Notifications
- //------------------------------------------------------------------
-#ifndef SWIG
- bool
- UnregisterNotificationCallbacks (const Process::Notifications& callbacks);
-#endif
+ void DoOnRemoval(Event *event_ptr) override;
- //==================================================================
- // Built in Process Control functions
- //==================================================================
- //------------------------------------------------------------------
- /// Resumes all of a process's threads as configured using the
- /// Thread run control functions.
- ///
- /// Threads for a process should be updated with one of the run
- /// control actions (resume, step, or suspend) that they should take
- /// when the process is resumed. If no run control action is given
- /// to a thread it will be resumed by default.
- ///
- /// This function is not meant to be overridden by Process
- /// subclasses. This function will take care of disabling any
- /// breakpoints that threads may be stopped at, single stepping, and
- /// re-enabling breakpoints, and enabling the basic flow control
- /// that the plug-in instances need not worry about.
- ///
- /// N.B. This function also sets the Write side of the Run Lock,
- /// which is unset when the corresponding stop event is pulled off
- /// the Public Event Queue. If you need to resume the process without
- /// setting the Run Lock, use PrivateResume (though you should only do
- /// that from inside the Process class.
- ///
- /// @return
- /// Returns an error object.
- ///
- /// @see Thread:Resume()
- /// @see Thread:Step()
- /// @see Thread:Suspend()
- //------------------------------------------------------------------
- Error
- Resume();
-
- Error
- ResumeSynchronous (Stream *stream);
-
- //------------------------------------------------------------------
- /// Halts a running process.
- ///
- /// This function is not meant to be overridden by Process
- /// subclasses.
- /// If the process is successfully halted, a eStateStopped
- /// process event with GetInterrupted will be broadcast. If false, we will
- /// halt the process with no events generated by the halt.
- ///
- /// @param[in] clear_thread_plans
- /// If true, when the process stops, clear all thread plans.
- ///
- /// @param[in] use_run_lock
- /// Whether to release the run lock after the stop.
- ///
- /// @return
- /// Returns an error object. If the error is empty, the process is halted.
- /// otherwise the halt has failed.
- //------------------------------------------------------------------
- Error
- Halt (bool clear_thread_plans = false, bool use_run_lock = true);
-
- //------------------------------------------------------------------
- /// Detaches from a running or stopped process.
- ///
- /// This function is not meant to be overridden by Process
- /// subclasses.
- ///
- /// @param[in] keep_stopped
- /// If true, don't resume the process on detach.
- ///
- /// @return
- /// Returns an error object.
- //------------------------------------------------------------------
- Error
- Detach (bool keep_stopped);
-
- //------------------------------------------------------------------
- /// Kills the process and shuts down all threads that were spawned
- /// to track and monitor the process.
- ///
- /// This function is not meant to be overridden by Process
- /// subclasses.
- ///
- /// @param[in] force_kill
- /// Whether lldb should force a kill (instead of a detach) from
- /// the inferior process. Normally if lldb launched a binary and
- /// Destory is called, lldb kills it. If lldb attached to a
- /// running process and Destory is called, lldb detaches. If
- /// this behavior needs to be over-ridden, this is the bool that
- /// can be used.
- ///
- /// @return
- /// Returns an error object.
- //------------------------------------------------------------------
- Error
- Destroy(bool force_kill);
-
- //------------------------------------------------------------------
- /// Sends a process a UNIX signal \a signal.
- ///
- /// This function is not meant to be overridden by Process
- /// subclasses.
- ///
- /// @return
- /// Returns an error object.
- //------------------------------------------------------------------
- Error
- Signal (int signal);
-
- void
- SetUnixSignals(lldb::UnixSignalsSP &&signals_sp);
-
- const lldb::UnixSignalsSP &
- GetUnixSignals();
-
- //==================================================================
- // Plug-in Process Control Overrides
- //==================================================================
-
- //------------------------------------------------------------------
- /// Called before attaching to a process.
- ///
- /// Allow Process plug-ins to execute some code before attaching a
- /// process.
- ///
- /// @return
- /// Returns an error object.
- //------------------------------------------------------------------
- virtual Error
- WillAttachToProcessWithID (lldb::pid_t pid)
- {
- return Error();
- }
+ static const Process::ProcessEventData *
+ GetEventDataFromEvent(const Event *event_ptr);
- //------------------------------------------------------------------
- /// Called before attaching to a process.
- ///
- /// Allow Process plug-ins to execute some code before attaching a
- /// process.
- ///
- /// @return
- /// Returns an error object.
- //------------------------------------------------------------------
- virtual Error
- WillAttachToProcessWithName (const char *process_name, bool wait_for_launch)
- {
- return Error();
- }
+ static lldb::ProcessSP GetProcessFromEvent(const Event *event_ptr);
- //------------------------------------------------------------------
- /// Attach to a remote system via a URL
- ///
- /// @param[in] strm
- /// A stream where output intended for the user
- /// (if the driver has a way to display that) generated during
- /// the connection. This may be nullptr if no output is needed.A
- ///
- /// @param[in] remote_url
- /// The URL format that we are connecting to.
- ///
- /// @return
- /// Returns an error object.
- //------------------------------------------------------------------
- virtual Error
- DoConnectRemote (Stream *strm, const char *remote_url)
- {
- Error error;
- error.SetErrorString ("remote connections are not supported");
- return error;
- }
+ static lldb::StateType GetStateFromEvent(const Event *event_ptr);
- //------------------------------------------------------------------
- /// Attach to an existing process using a process ID.
- ///
- /// @param[in] pid
- /// The process ID that we should attempt to attach to.
- ///
- /// @param[in] attach_info
- /// Information on how to do the attach. For example, GetUserID()
- /// will return the uid to attach as.
- ///
- /// @return
- /// Returns a successful Error attaching was successful, or
- /// an appropriate (possibly platform-specific) error code if
- /// attaching fails.
- /// hanming : need flag
- //------------------------------------------------------------------
- virtual Error
- DoAttachToProcessWithID (lldb::pid_t pid, const ProcessAttachInfo &attach_info)
- {
- Error error;
- error.SetErrorStringWithFormat("error: %s does not support attaching to a process by pid", GetPluginName().GetCString());
- return error;
- }
+ static bool GetRestartedFromEvent(const Event *event_ptr);
- //------------------------------------------------------------------
- /// Attach to an existing process using a partial process name.
- ///
- /// @param[in] process_name
- /// The name of the process to attach to.
- ///
- /// @param[in] attach_info
- /// Information on how to do the attach. For example, GetUserID()
- /// will return the uid to attach as.
- ///
- /// @return
- /// Returns a successful Error attaching was successful, or
- /// an appropriate (possibly platform-specific) error code if
- /// attaching fails.
- //------------------------------------------------------------------
- virtual Error
- DoAttachToProcessWithName (const char *process_name, const ProcessAttachInfo &attach_info)
- {
- Error error;
- error.SetErrorString("attach by name is not supported");
- return error;
- }
+ static size_t GetNumRestartedReasons(const Event *event_ptr);
- //------------------------------------------------------------------
- /// Called after attaching a process.
- ///
- /// @param[in] process_arch
- /// If you can figure out the process architecture after attach, fill it in here.
- ///
- /// Allow Process plug-ins to execute some code after attaching to
- /// a process.
- //------------------------------------------------------------------
- virtual void
- DidAttach (ArchSpec &process_arch)
- {
- process_arch.Clear();
- }
+ static const char *GetRestartedReasonAtIndex(const Event *event_ptr,
+ size_t idx);
- //------------------------------------------------------------------
- /// Called after a process re-execs itself.
- ///
- /// Allow Process plug-ins to execute some code after a process has
- /// exec'ed itself. Subclasses typically should override DoDidExec()
- /// as the lldb_private::Process class needs to remove its dynamic
- /// loader, runtime, ABI and other plug-ins, as well as unload all
- /// shared libraries.
- //------------------------------------------------------------------
- virtual void
- DidExec ();
-
- //------------------------------------------------------------------
- /// Subclasses of Process should implement this function if they
- /// need to do anything after a process exec's itself.
- //------------------------------------------------------------------
- virtual void
- DoDidExec ()
- {
- }
+ static void AddRestartedReason(Event *event_ptr, const char *reason);
- //------------------------------------------------------------------
- /// Called before launching to a process.
- ///
- /// Allow Process plug-ins to execute some code before launching a
- /// process.
- ///
- /// @return
- /// Returns an error object.
- //------------------------------------------------------------------
- virtual Error
- WillLaunch (Module* module)
- {
- return Error();
- }
+ static void SetRestartedInEvent(Event *event_ptr, bool new_value);
- //------------------------------------------------------------------
- /// Launch a new process.
- ///
- /// Launch a new process by spawning a new process using
- /// \a exe_module's file as the file to launch. Launch details are
- /// provided in \a launch_info.
- ///
- /// @param[in] exe_module
- /// The module from which to extract the file specification and
- /// launch.
- ///
- /// @param[in] launch_info
- /// Details (e.g. arguments, stdio redirection, etc.) for the
- /// requested launch.
- ///
- /// @return
- /// An Error instance indicating success or failure of the
- /// operation.
- //------------------------------------------------------------------
- virtual Error
- DoLaunch (Module *exe_module,
- ProcessLaunchInfo &launch_info)
- {
- Error error;
- error.SetErrorStringWithFormat("error: %s does not support launching processes", GetPluginName().GetCString());
- return error;
- }
+ static bool GetInterruptedFromEvent(const Event *event_ptr);
- //------------------------------------------------------------------
- /// Called after launching a process.
- ///
- /// Allow Process plug-ins to execute some code after launching
- /// a process.
- //------------------------------------------------------------------
- virtual void
- DidLaunch () {}
-
- //------------------------------------------------------------------
- /// Called before resuming to a process.
- ///
- /// Allow Process plug-ins to execute some code before resuming a
- /// process.
- ///
- /// @return
- /// Returns an error object.
- //------------------------------------------------------------------
- virtual Error
- WillResume () { return Error(); }
-
- //------------------------------------------------------------------
- /// Resumes all of a process's threads as configured using the
- /// Thread run control functions.
- ///
- /// Threads for a process should be updated with one of the run
- /// control actions (resume, step, or suspend) that they should take
- /// when the process is resumed. If no run control action is given
- /// to a thread it will be resumed by default.
- ///
- /// @return
- /// Returns \b true if the process successfully resumes using
- /// the thread run control actions, \b false otherwise.
- ///
- /// @see Thread:Resume()
- /// @see Thread:Step()
- /// @see Thread:Suspend()
- //------------------------------------------------------------------
- virtual Error
- DoResume ()
- {
- Error error;
- error.SetErrorStringWithFormat("error: %s does not support resuming processes", GetPluginName().GetCString());
- return error;
- }
+ static void SetInterruptedInEvent(Event *event_ptr, bool new_value);
- //------------------------------------------------------------------
- /// Called after resuming a process.
- ///
- /// Allow Process plug-ins to execute some code after resuming
- /// a process.
- //------------------------------------------------------------------
- virtual void
- DidResume () {}
-
- //------------------------------------------------------------------
- /// Called before halting to a process.
- ///
- /// Allow Process plug-ins to execute some code before halting a
- /// process.
- ///
- /// @return
- /// Returns an error object.
- //------------------------------------------------------------------
- virtual Error
- WillHalt () { return Error(); }
-
- //------------------------------------------------------------------
- /// Halts a running process.
- ///
- /// DoHalt must produce one and only one stop StateChanged event if it actually
- /// stops the process. If the stop happens through some natural event (for
- /// instance a SIGSTOP), then forwarding that event will do. Otherwise, you must
- /// generate the event manually. This function is called from the context of the
- /// private state thread.
- ///
- /// @param[out] caused_stop
- /// If true, then this Halt caused the stop, otherwise, the
- /// process was already stopped.
- ///
- /// @return
- /// Returns \b true if the process successfully halts, \b false
- /// otherwise.
- //------------------------------------------------------------------
- virtual Error
- DoHalt (bool &caused_stop)
- {
- Error error;
- error.SetErrorStringWithFormat("error: %s does not support halting processes", GetPluginName().GetCString());
- return error;
- }
+ static bool SetUpdateStateOnRemoval(Event *event_ptr);
- //------------------------------------------------------------------
- /// Called after halting a process.
- ///
- /// Allow Process plug-ins to execute some code after halting
- /// a process.
- //------------------------------------------------------------------
- virtual void
- DidHalt () {}
-
- //------------------------------------------------------------------
- /// Called before detaching from a process.
- ///
- /// Allow Process plug-ins to execute some code before detaching
- /// from a process.
- ///
- /// @return
- /// Returns an error object.
- //------------------------------------------------------------------
- virtual Error
- WillDetach ()
- {
- return Error();
- }
+ private:
+ void SetUpdateStateOnRemoval() { m_update_state++; }
- //------------------------------------------------------------------
- /// Detaches from a running or stopped process.
- ///
- /// @return
- /// Returns \b true if the process successfully detaches, \b
- /// false otherwise.
- //------------------------------------------------------------------
- virtual Error
- DoDetach (bool keep_stopped)
- {
- Error error;
- error.SetErrorStringWithFormat("error: %s does not support detaching from processes", GetPluginName().GetCString());
- return error;
- }
+ void SetRestarted(bool new_value) { m_restarted = new_value; }
- //------------------------------------------------------------------
- /// Called after detaching from a process.
- ///
- /// Allow Process plug-ins to execute some code after detaching
- /// from a process.
- //------------------------------------------------------------------
- virtual void
- DidDetach () {}
-
- virtual bool
- DetachRequiresHalt() { return false; }
-
- //------------------------------------------------------------------
- /// Called before sending a signal to a process.
- ///
- /// Allow Process plug-ins to execute some code before sending a
- /// signal to a process.
- ///
- /// @return
- /// Returns no error if it is safe to proceed with a call to
- /// Process::DoSignal(int), otherwise an error describing what
- /// prevents the signal from being sent.
- //------------------------------------------------------------------
- virtual Error
- WillSignal () { return Error(); }
-
- //------------------------------------------------------------------
- /// Sends a process a UNIX signal \a signal.
- ///
- /// @return
- /// Returns an error object.
- //------------------------------------------------------------------
- virtual Error
- DoSignal (int signal)
- {
- Error error;
- error.SetErrorStringWithFormat("error: %s does not support sending signals to processes", GetPluginName().GetCString());
- return error;
- }
+ void SetInterrupted(bool new_value) { m_interrupted = new_value; }
- virtual Error
- WillDestroy () { return Error(); }
-
- virtual Error
- DoDestroy () = 0;
-
- virtual void
- DidDestroy () { }
-
- virtual bool
- DestroyRequiresHalt() { return true; }
-
- //------------------------------------------------------------------
- /// Called after sending a signal to a process.
- ///
- /// Allow Process plug-ins to execute some code after sending a
- /// signal to a process.
- //------------------------------------------------------------------
- virtual void
- DidSignal () {}
-
- //------------------------------------------------------------------
- /// Currently called as part of ShouldStop.
- /// FIXME: Should really happen when the target stops before the
- /// event is taken from the queue...
- ///
- /// This callback is called as the event
- /// is about to be queued up to allow Process plug-ins to execute
- /// some code prior to clients being notified that a process was
- /// stopped. Common operations include updating the thread list,
- /// invalidating any thread state (registers, stack, etc) prior to
- /// letting the notification go out.
- ///
- //------------------------------------------------------------------
- virtual void
- RefreshStateAfterStop () = 0;
-
- //------------------------------------------------------------------
- /// Sometimes the connection to a process can detect the host OS
- /// version that the process is running on. The current platform
- /// should be checked first in case the platform is connected, but
- /// clients can fall back onto this function if the platform fails
- /// to identify the host OS version. The platform should be checked
- /// first in case you are running a simulator platform that might
- /// itself be running natively, but have different heuristics for
- /// figuring out which OS is is emulating.
- ///
- /// @param[out] major
- /// The major OS version, or UINT32_MAX if it can't be determined
- ///
- /// @param[out] minor
- /// The minor OS version, or UINT32_MAX if it can't be determined
- ///
- /// @param[out] update
- /// The update OS version, or UINT32_MAX if it can't be determined
- ///
- /// @return
- /// Returns \b true if the host OS version info was filled in
- /// and \b false otherwise.
- //------------------------------------------------------------------
- virtual bool
- GetHostOSVersion(uint32_t &major,
- uint32_t &minor,
- uint32_t &update)
- {
- major = UINT32_MAX;
- minor = UINT32_MAX;
- update = UINT32_MAX;
- return false;
+ void AddRestartedReason(const char *reason) {
+ m_restarted_reasons.push_back(reason);
}
+ lldb::ProcessWP m_process_wp;
+ lldb::StateType m_state;
+ std::vector<std::string> m_restarted_reasons;
+ bool m_restarted; // For "eStateStopped" events, this is true if the target
+ // was automatically restarted.
+ int m_update_state;
+ bool m_interrupted;
- //------------------------------------------------------------------
- /// Get the target object pointer for this module.
- ///
- /// @return
- /// A Target object pointer to the target that owns this
- /// module.
- //------------------------------------------------------------------
- Target &
- GetTarget ()
- {
- return *m_target_sp.lock();
- }
-
- //------------------------------------------------------------------
- /// Get the const target object pointer for this module.
- ///
- /// @return
- /// A const Target object pointer to the target that owns this
- /// module.
- //------------------------------------------------------------------
- const Target &
- GetTarget () const
- {
- return *m_target_sp.lock();
- }
+ DISALLOW_COPY_AND_ASSIGN(ProcessEventData);
+ };
+#endif // SWIG
- //------------------------------------------------------------------
- /// Flush all data in the process.
- ///
- /// Flush the memory caches, all threads, and any other cached data
- /// in the process.
- ///
- /// This function can be called after a world changing event like
- /// adding a new symbol file, or after the process makes a large
- /// context switch (from boot ROM to booted into an OS).
- //------------------------------------------------------------------
- void
- Flush ();
-
- //------------------------------------------------------------------
- /// Get accessor for the current process state.
- ///
- /// @return
- /// The current state of the process.
- ///
- /// @see lldb::StateType
- //------------------------------------------------------------------
- lldb::StateType
- GetState ();
-
- lldb::ExpressionResults
- RunThreadPlan(ExecutionContext &exe_ctx, lldb::ThreadPlanSP &thread_plan_sp,
- const EvaluateExpressionOptions &options, DiagnosticManager &diagnostic_manager);
-
- static const char *
- ExecutionResultAsCString(lldb::ExpressionResults result);
-
- void
- GetStatus (Stream &ostrm);
-
- size_t
- GetThreadStatus (Stream &ostrm,
- bool only_threads_with_stop_reason,
- uint32_t start_frame,
- uint32_t num_frames,
- uint32_t num_frames_with_source);
-
- void
- SendAsyncInterrupt ();
-
- //------------------------------------------------------------------
- // Notify this process class that modules got loaded.
- //
- // If subclasses override this method, they must call this version
- // before doing anything in the subclass version of the function.
- //------------------------------------------------------------------
- virtual void
- ModulesDidLoad (ModuleList &module_list);
-
- //------------------------------------------------------------------
- /// Retrieve the list of shared libraries that are loaded for this process
- ///
- /// For certain platforms, the time it takes for the DynamicLoader plugin to
- /// read all of the shared libraries out of memory over a slow communication
- /// channel may be too long. In that instance, the gdb-remote stub may be
- /// able to retrieve the necessary information about the solibs out of memory
- /// and return a concise summary sufficient for the DynamicLoader plugin.
- ///
- /// @param [in] image_list_address
- /// The address where the table of shared libraries is stored in memory,
- /// if that is appropriate for this platform. Else this may be
- /// passed as LLDB_INVALID_ADDRESS.
- ///
- /// @param [in] image_count
- /// The number of shared libraries that are present in this process, if
- /// that is appropriate for this platofrm Else this may be passed as
- /// LLDB_INVALID_ADDRESS.
- ///
- /// @return
- /// A StructureDataSP object which, if non-empty, will contain the
- /// information the DynamicLoader needs to get the initial scan of
- /// solibs resolved.
- //------------------------------------------------------------------
- virtual lldb_private::StructuredData::ObjectSP
- GetLoadedDynamicLibrariesInfos (lldb::addr_t image_list_address, lldb::addr_t image_count)
- {
- return StructuredData::ObjectSP();
- }
+ //------------------------------------------------------------------
+ /// Construct with a shared pointer to a target, and the Process listener.
+ /// Uses the Host UnixSignalsSP by default.
+ //------------------------------------------------------------------
+ Process(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp);
+
+ //------------------------------------------------------------------
+ /// Construct with a shared pointer to a target, the Process listener,
+ /// and the appropriate UnixSignalsSP for the process.
+ //------------------------------------------------------------------
+ Process(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
+ const lldb::UnixSignalsSP &unix_signals_sp);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ ///
+ /// The destructor is virtual since this class is designed to be
+ /// inherited from by the plug-in instance.
+ //------------------------------------------------------------------
+ ~Process() override;
+
+ static void SettingsInitialize();
+
+ static void SettingsTerminate();
+
+ static const ProcessPropertiesSP &GetGlobalProperties();
+
+ //------------------------------------------------------------------
+ /// Find a Process plug-in that can debug \a module using the
+ /// currently selected architecture.
+ ///
+ /// Scans all loaded plug-in interfaces that implement versions of
+ /// the Process plug-in interface and returns the first instance
+ /// that can debug the file.
+ ///
+ /// @param[in] module_sp
+ /// The module shared pointer that this process will debug.
+ ///
+ /// @param[in] plugin_name
+ /// If nullptr, select the best plug-in for the binary. If non-nullptr
+ /// then look for a plugin whose PluginInfo's name matches
+ /// this string.
+ ///
+ /// @see Process::CanDebug ()
+ //------------------------------------------------------------------
+ static lldb::ProcessSP FindPlugin(lldb::TargetSP target_sp,
+ llvm::StringRef plugin_name,
+ lldb::ListenerSP listener_sp,
+ const FileSpec *crash_file_path);
+
+ //------------------------------------------------------------------
+ /// Static function that can be used with the \b host function
+ /// Host::StartMonitoringChildProcess ().
+ ///
+ /// This function can be used by lldb_private::Process subclasses
+ /// when they want to watch for a local process and have its exit
+ /// status automatically set when the host child process exits.
+ /// Subclasses should call Host::StartMonitoringChildProcess ()
+ /// with:
+ /// callback = Process::SetHostProcessExitStatus
+ /// pid = Process::GetID()
+ /// monitor_signals = false
+ //------------------------------------------------------------------
+ static bool
+ SetProcessExitStatus(lldb::pid_t pid, // The process ID we want to monitor
+ bool exited,
+ int signo, // Zero for no signal
+ int status); // Exit value of process if signal is zero
+
+ lldb::ByteOrder GetByteOrder() const;
+
+ uint32_t GetAddressByteSize() const;
+
+ uint32_t GetUniqueID() const { return m_process_unique_id; }
+
+ //------------------------------------------------------------------
+ /// Check if a plug-in instance can debug the file in \a module.
+ ///
+ /// Each plug-in is given a chance to say whether it can debug
+ /// the file in \a module. If the Process plug-in instance can
+ /// debug a file on the current system, it should return \b true.
+ ///
+ /// @return
+ /// Returns \b true if this Process plug-in instance can
+ /// debug the executable, \b false otherwise.
+ //------------------------------------------------------------------
+ virtual bool CanDebug(lldb::TargetSP target,
+ bool plugin_specified_by_name) = 0;
+
+ //------------------------------------------------------------------
+ /// This object is about to be destroyed, do any necessary cleanup.
+ ///
+ /// Subclasses that override this method should always call this
+ /// superclass method.
+ //------------------------------------------------------------------
+ virtual void Finalize();
+
+ //------------------------------------------------------------------
+ /// Return whether this object is valid (i.e. has not been finalized.)
+ ///
+ /// @return
+ /// Returns \b true if this Process has not been finalized
+ /// and \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsValid() const { return !m_finalize_called; }
+
+ //------------------------------------------------------------------
+ /// Return a multi-word command object that can be used to expose
+ /// plug-in specific commands.
+ ///
+ /// This object will be used to resolve plug-in commands and can be
+ /// triggered by a call to:
+ ///
+ /// (lldb) process commmand <args>
+ ///
+ /// @return
+ /// A CommandObject which can be one of the concrete subclasses
+ /// of CommandObject like CommandObjectRaw, CommandObjectParsed,
+ /// or CommandObjectMultiword.
+ //------------------------------------------------------------------
+ virtual CommandObject *GetPluginCommandObject() { return nullptr; }
+
+ //------------------------------------------------------------------
+ /// Launch a new process.
+ ///
+ /// Launch a new process by spawning a new process using the
+ /// target object's executable module's file as the file to launch.
+ ///
+ /// This function is not meant to be overridden by Process
+ /// subclasses. It will first call Process::WillLaunch (Module *)
+ /// and if that returns \b true, Process::DoLaunch (Module*,
+ /// char const *[],char const *[],const char *,const char *,
+ /// const char *) will be called to actually do the launching. If
+ /// DoLaunch returns \b true, then Process::DidLaunch() will be
+ /// called.
+ ///
+ /// @param[in] launch_info
+ /// Details regarding the environment, STDIN/STDOUT/STDERR
+ /// redirection, working path, etc. related to the requested launch.
+ ///
+ /// @return
+ /// An error object. Call GetID() to get the process ID if
+ /// the error object is success.
+ //------------------------------------------------------------------
+ virtual Error Launch(ProcessLaunchInfo &launch_info);
+
+ virtual Error LoadCore();
+
+ virtual Error DoLoadCore() {
+ Error error;
+ error.SetErrorStringWithFormat(
+ "error: %s does not support loading core files.",
+ GetPluginName().GetCString());
+ return error;
+ }
+
+ //------------------------------------------------------------------
+ /// Get the dynamic loader plug-in for this process.
+ ///
+ /// The default action is to let the DynamicLoader plug-ins check
+ /// the main executable and the DynamicLoader will select itself
+ /// automatically. Subclasses can override this if inspecting the
+ /// executable is not desired, or if Process subclasses can only
+ /// use a specific DynamicLoader plug-in.
+ //------------------------------------------------------------------
+ virtual DynamicLoader *GetDynamicLoader();
+
+ //------------------------------------------------------------------
+ // Returns AUXV structure found in many ELF-based environments.
+ //
+ // The default action is to return an empty data buffer.
+ //
+ // @return
+ // A data buffer containing the contents of the AUXV data.
+ //------------------------------------------------------------------
+ virtual const lldb::DataBufferSP GetAuxvData();
+
+ //------------------------------------------------------------------
+ /// Sometimes processes know how to retrieve and load shared libraries.
+ /// This is normally done by DynamicLoader plug-ins, but sometimes the
+ /// connection to the process allows retrieving this information. The
+ /// dynamic loader plug-ins can use this function if they can't
+ /// determine the current shared library load state.
+ ///
+ /// @return
+ /// The number of shared libraries that were loaded
+ //------------------------------------------------------------------
+ virtual size_t LoadModules() { return 0; }
+
+ virtual size_t LoadModules(LoadedModuleInfoList &) { return 0; }
- //------------------------------------------------------------------
- /// Print a user-visible warning about a module being built with optimization
- ///
- /// Prints a async warning message to the user one time per Module
- /// where a function is found that was compiled with optimization, per
- /// Process.
- ///
- /// @param [in] sc
- /// A SymbolContext with eSymbolContextFunction and eSymbolContextModule
- /// pre-computed.
- //------------------------------------------------------------------
- void
- PrintWarningOptimization (const SymbolContext &sc);
-
- virtual bool
- GetProcessInfo(ProcessInstanceInfo &info);
+protected:
+ virtual JITLoaderList &GetJITLoaders();
public:
- //------------------------------------------------------------------
- /// Get the exit status for a process.
- ///
- /// @return
- /// The process's return code, or -1 if the current process
- /// state is not eStateExited.
- //------------------------------------------------------------------
- int
- GetExitStatus ();
-
- //------------------------------------------------------------------
- /// Get a textual description of what the process exited.
- ///
- /// @return
- /// The textual description of why the process exited, or nullptr
- /// if there is no description available.
- //------------------------------------------------------------------
- const char *
- GetExitDescription ();
-
- virtual void
- DidExit ()
- {
- }
-
- //------------------------------------------------------------------
- /// Get the Modification ID of the process.
- ///
- /// @return
- /// The modification ID of the process.
- //------------------------------------------------------------------
- ProcessModID
- GetModID () const
- {
- return m_mod_id;
- }
-
- const ProcessModID &
- GetModIDRef () const
- {
- return m_mod_id;
- }
-
- uint32_t
- GetStopID () const
- {
- return m_mod_id.GetStopID();
- }
-
- uint32_t
- GetResumeID () const
- {
- return m_mod_id.GetResumeID();
- }
-
- uint32_t
- GetLastUserExpressionResumeID () const
- {
- return m_mod_id.GetLastUserExpressionResumeID();
- }
-
- uint32_t
- GetLastNaturalStopID() const
- {
- return m_mod_id.GetLastNaturalStopID();
- }
+ //------------------------------------------------------------------
+ /// Get the system runtime plug-in for this process.
+ ///
+ /// @return
+ /// Returns a pointer to the SystemRuntime plugin for this Process
+ /// if one is available. Else returns nullptr.
+ //------------------------------------------------------------------
+ virtual SystemRuntime *GetSystemRuntime();
+
+ //------------------------------------------------------------------
+ /// Attach to an existing process using the process attach info.
+ ///
+ /// This function is not meant to be overridden by Process
+ /// subclasses. It will first call WillAttach (lldb::pid_t)
+ /// or WillAttach (const char *), and if that returns \b
+ /// true, DoAttach (lldb::pid_t) or DoAttach (const char *) will
+ /// be called to actually do the attach. If DoAttach returns \b
+ /// true, then Process::DidAttach() will be called.
+ ///
+ /// @param[in] pid
+ /// The process ID that we should attempt to attach to.
+ ///
+ /// @return
+ /// Returns \a pid if attaching was successful, or
+ /// LLDB_INVALID_PROCESS_ID if attaching fails.
+ //------------------------------------------------------------------
+ virtual Error Attach(ProcessAttachInfo &attach_info);
+
+ //------------------------------------------------------------------
+ /// Attach to a remote system via a URL
+ ///
+ /// @param[in] strm
+ /// A stream where output intended for the user
+ /// (if the driver has a way to display that) generated during
+ /// the connection. This may be nullptr if no output is needed.A
+ ///
+ /// @param[in] remote_url
+ /// The URL format that we are connecting to.
+ ///
+ /// @return
+ /// Returns an error object.
+ //------------------------------------------------------------------
+ virtual Error ConnectRemote(Stream *strm, llvm::StringRef remote_url);
+
+ bool GetShouldDetach() const { return m_should_detach; }
+
+ void SetShouldDetach(bool b) { m_should_detach = b; }
+
+ //------------------------------------------------------------------
+ /// Get the image information address for the current process.
+ ///
+ /// Some runtimes have system functions that can help dynamic
+ /// loaders locate the dynamic loader information needed to observe
+ /// shared libraries being loaded or unloaded. This function is
+ /// in the Process interface (as opposed to the DynamicLoader
+ /// interface) to ensure that remote debugging can take advantage of
+ /// this functionality.
+ ///
+ /// @return
+ /// The address of the dynamic loader information, or
+ /// LLDB_INVALID_ADDRESS if this is not supported by this
+ /// interface.
+ //------------------------------------------------------------------
+ virtual lldb::addr_t GetImageInfoAddress();
+
+ //------------------------------------------------------------------
+ /// Called when the process is about to broadcast a public stop.
+ ///
+ /// There are public and private stops. Private stops are when the
+ /// process is doing things like stepping and the client doesn't
+ /// need to know about starts and stop that implement a thread plan.
+ /// Single stepping over a source line in code might end up being
+ /// implemented by one or more process starts and stops. Public stops
+ /// are when clients will be notified that the process is stopped.
+ /// These events typically trigger UI updates (thread stack frames to
+ /// be displayed, variables to be displayed, and more). This function
+ /// can be overriden and allows process subclasses to do something
+ /// before the eBroadcastBitStateChanged event is sent to public
+ /// clients.
+ //------------------------------------------------------------------
+ virtual void WillPublicStop() {}
+
+//------------------------------------------------------------------
+/// Register for process and thread notifications.
+///
+/// Clients can register notification callbacks by filling out a
+/// Process::Notifications structure and calling this function.
+///
+/// @param[in] callbacks
+/// A structure that contains the notification baton and
+/// callback functions.
+///
+/// @see Process::Notifications
+//------------------------------------------------------------------
+#ifndef SWIG
+ void RegisterNotificationCallbacks(const Process::Notifications &callbacks);
+#endif
- lldb::EventSP
- GetStopEventForStopID (uint32_t stop_id) const
- {
- return m_mod_id.GetStopEventForStopID(stop_id);
- }
+//------------------------------------------------------------------
+/// Unregister for process and thread notifications.
+///
+/// Clients can unregister notification callbacks by passing a copy of
+/// the original baton and callbacks in \a callbacks.
+///
+/// @param[in] callbacks
+/// A structure that contains the notification baton and
+/// callback functions.
+///
+/// @return
+/// Returns \b true if the notification callbacks were
+/// successfully removed from the process, \b false otherwise.
+///
+/// @see Process::Notifications
+//------------------------------------------------------------------
+#ifndef SWIG
+ bool UnregisterNotificationCallbacks(const Process::Notifications &callbacks);
+#endif
- //------------------------------------------------------------------
- /// Set accessor for the process exit status (return code).
- ///
- /// Sometimes a child exits and the exit can be detected by global
- /// functions (signal handler for SIGCHLD for example). This
- /// accessor allows the exit status to be set from an external
- /// source.
- ///
- /// Setting this will cause a eStateExited event to be posted to
- /// the process event queue.
- ///
- /// @param[in] exit_status
- /// The value for the process's return code.
- ///
- /// @see lldb::StateType
- //------------------------------------------------------------------
- virtual bool
- SetExitStatus (int exit_status, const char *cstr);
-
- //------------------------------------------------------------------
- /// Check if a process is still alive.
- ///
- /// @return
- /// Returns \b true if the process is still valid, \b false
- /// otherwise.
- //------------------------------------------------------------------
- virtual bool
- IsAlive ();
-
- //------------------------------------------------------------------
- /// Before lldb detaches from a process, it warns the user that they are about to lose their debug session.
- /// In some cases, this warning doesn't need to be emitted -- for instance, with core file debugging where
- /// the user can reconstruct the "state" by simply re-running the debugger on the core file.
- ///
- /// @return
- // true if the user should be warned about detaching from this process.
- //------------------------------------------------------------------
- virtual bool
- WarnBeforeDetach () const
- {
- return true;
- }
+ //==================================================================
+ // Built in Process Control functions
+ //==================================================================
+ //------------------------------------------------------------------
+ /// Resumes all of a process's threads as configured using the
+ /// Thread run control functions.
+ ///
+ /// Threads for a process should be updated with one of the run
+ /// control actions (resume, step, or suspend) that they should take
+ /// when the process is resumed. If no run control action is given
+ /// to a thread it will be resumed by default.
+ ///
+ /// This function is not meant to be overridden by Process
+ /// subclasses. This function will take care of disabling any
+ /// breakpoints that threads may be stopped at, single stepping, and
+ /// re-enabling breakpoints, and enabling the basic flow control
+ /// that the plug-in instances need not worry about.
+ ///
+ /// N.B. This function also sets the Write side of the Run Lock,
+ /// which is unset when the corresponding stop event is pulled off
+ /// the Public Event Queue. If you need to resume the process without
+ /// setting the Run Lock, use PrivateResume (though you should only do
+ /// that from inside the Process class.
+ ///
+ /// @return
+ /// Returns an error object.
+ ///
+ /// @see Thread:Resume()
+ /// @see Thread:Step()
+ /// @see Thread:Suspend()
+ //------------------------------------------------------------------
+ Error Resume();
+
+ Error ResumeSynchronous(Stream *stream);
+
+ //------------------------------------------------------------------
+ /// Halts a running process.
+ ///
+ /// This function is not meant to be overridden by Process
+ /// subclasses.
+ /// If the process is successfully halted, a eStateStopped
+ /// process event with GetInterrupted will be broadcast. If false, we will
+ /// halt the process with no events generated by the halt.
+ ///
+ /// @param[in] clear_thread_plans
+ /// If true, when the process stops, clear all thread plans.
+ ///
+ /// @param[in] use_run_lock
+ /// Whether to release the run lock after the stop.
+ ///
+ /// @return
+ /// Returns an error object. If the error is empty, the process is
+ /// halted.
+ /// otherwise the halt has failed.
+ //------------------------------------------------------------------
+ Error Halt(bool clear_thread_plans = false, bool use_run_lock = true);
+
+ //------------------------------------------------------------------
+ /// Detaches from a running or stopped process.
+ ///
+ /// This function is not meant to be overridden by Process
+ /// subclasses.
+ ///
+ /// @param[in] keep_stopped
+ /// If true, don't resume the process on detach.
+ ///
+ /// @return
+ /// Returns an error object.
+ //------------------------------------------------------------------
+ Error Detach(bool keep_stopped);
+
+ //------------------------------------------------------------------
+ /// Kills the process and shuts down all threads that were spawned
+ /// to track and monitor the process.
+ ///
+ /// This function is not meant to be overridden by Process
+ /// subclasses.
+ ///
+ /// @param[in] force_kill
+ /// Whether lldb should force a kill (instead of a detach) from
+ /// the inferior process. Normally if lldb launched a binary and
+ /// Destory is called, lldb kills it. If lldb attached to a
+ /// running process and Destory is called, lldb detaches. If
+ /// this behavior needs to be over-ridden, this is the bool that
+ /// can be used.
+ ///
+ /// @return
+ /// Returns an error object.
+ //------------------------------------------------------------------
+ Error Destroy(bool force_kill);
+
+ //------------------------------------------------------------------
+ /// Sends a process a UNIX signal \a signal.
+ ///
+ /// This function is not meant to be overridden by Process
+ /// subclasses.
+ ///
+ /// @return
+ /// Returns an error object.
+ //------------------------------------------------------------------
+ Error Signal(int signal);
+
+ void SetUnixSignals(lldb::UnixSignalsSP &&signals_sp);
+
+ const lldb::UnixSignalsSP &GetUnixSignals();
+
+ //==================================================================
+ // Plug-in Process Control Overrides
+ //==================================================================
+
+ //------------------------------------------------------------------
+ /// Called before attaching to a process.
+ ///
+ /// Allow Process plug-ins to execute some code before attaching a
+ /// process.
+ ///
+ /// @return
+ /// Returns an error object.
+ //------------------------------------------------------------------
+ virtual Error WillAttachToProcessWithID(lldb::pid_t pid) { return Error(); }
+
+ //------------------------------------------------------------------
+ /// Called before attaching to a process.
+ ///
+ /// Allow Process plug-ins to execute some code before attaching a
+ /// process.
+ ///
+ /// @return
+ /// Returns an error object.
+ //------------------------------------------------------------------
+ virtual Error WillAttachToProcessWithName(const char *process_name,
+ bool wait_for_launch) {
+ return Error();
+ }
+
+ //------------------------------------------------------------------
+ /// Attach to a remote system via a URL
+ ///
+ /// @param[in] strm
+ /// A stream where output intended for the user
+ /// (if the driver has a way to display that) generated during
+ /// the connection. This may be nullptr if no output is needed.A
+ ///
+ /// @param[in] remote_url
+ /// The URL format that we are connecting to.
+ ///
+ /// @return
+ /// Returns an error object.
+ //------------------------------------------------------------------
+ virtual Error DoConnectRemote(Stream *strm, llvm::StringRef remote_url) {
+ Error error;
+ error.SetErrorString("remote connections are not supported");
+ return error;
+ }
+
+ //------------------------------------------------------------------
+ /// Attach to an existing process using a process ID.
+ ///
+ /// @param[in] pid
+ /// The process ID that we should attempt to attach to.
+ ///
+ /// @param[in] attach_info
+ /// Information on how to do the attach. For example, GetUserID()
+ /// will return the uid to attach as.
+ ///
+ /// @return
+ /// Returns a successful Error attaching was successful, or
+ /// an appropriate (possibly platform-specific) error code if
+ /// attaching fails.
+ /// hanming : need flag
+ //------------------------------------------------------------------
+ virtual Error DoAttachToProcessWithID(lldb::pid_t pid,
+ const ProcessAttachInfo &attach_info) {
+ Error error;
+ error.SetErrorStringWithFormat(
+ "error: %s does not support attaching to a process by pid",
+ GetPluginName().GetCString());
+ return error;
+ }
+
+ //------------------------------------------------------------------
+ /// Attach to an existing process using a partial process name.
+ ///
+ /// @param[in] process_name
+ /// The name of the process to attach to.
+ ///
+ /// @param[in] attach_info
+ /// Information on how to do the attach. For example, GetUserID()
+ /// will return the uid to attach as.
+ ///
+ /// @return
+ /// Returns a successful Error attaching was successful, or
+ /// an appropriate (possibly platform-specific) error code if
+ /// attaching fails.
+ //------------------------------------------------------------------
+ virtual Error
+ DoAttachToProcessWithName(const char *process_name,
+ const ProcessAttachInfo &attach_info) {
+ Error error;
+ error.SetErrorString("attach by name is not supported");
+ return error;
+ }
+
+ //------------------------------------------------------------------
+ /// Called after attaching a process.
+ ///
+ /// @param[in] process_arch
+ /// If you can figure out the process architecture after attach, fill it
+ /// in here.
+ ///
+ /// Allow Process plug-ins to execute some code after attaching to
+ /// a process.
+ //------------------------------------------------------------------
+ virtual void DidAttach(ArchSpec &process_arch) { process_arch.Clear(); }
+
+ //------------------------------------------------------------------
+ /// Called after a process re-execs itself.
+ ///
+ /// Allow Process plug-ins to execute some code after a process has
+ /// exec'ed itself. Subclasses typically should override DoDidExec()
+ /// as the lldb_private::Process class needs to remove its dynamic
+ /// loader, runtime, ABI and other plug-ins, as well as unload all
+ /// shared libraries.
+ //------------------------------------------------------------------
+ virtual void DidExec();
+
+ //------------------------------------------------------------------
+ /// Subclasses of Process should implement this function if they
+ /// need to do anything after a process exec's itself.
+ //------------------------------------------------------------------
+ virtual void DoDidExec() {}
+
+ //------------------------------------------------------------------
+ /// Called before launching to a process.
+ ///
+ /// Allow Process plug-ins to execute some code before launching a
+ /// process.
+ ///
+ /// @return
+ /// Returns an error object.
+ //------------------------------------------------------------------
+ virtual Error WillLaunch(Module *module) { return Error(); }
+
+ //------------------------------------------------------------------
+ /// Launch a new process.
+ ///
+ /// Launch a new process by spawning a new process using
+ /// \a exe_module's file as the file to launch. Launch details are
+ /// provided in \a launch_info.
+ ///
+ /// @param[in] exe_module
+ /// The module from which to extract the file specification and
+ /// launch.
+ ///
+ /// @param[in] launch_info
+ /// Details (e.g. arguments, stdio redirection, etc.) for the
+ /// requested launch.
+ ///
+ /// @return
+ /// An Error instance indicating success or failure of the
+ /// operation.
+ //------------------------------------------------------------------
+ virtual Error DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) {
+ Error error;
+ error.SetErrorStringWithFormat(
+ "error: %s does not support launching processes",
+ GetPluginName().GetCString());
+ return error;
+ }
+
+ //------------------------------------------------------------------
+ /// Called after launching a process.
+ ///
+ /// Allow Process plug-ins to execute some code after launching
+ /// a process.
+ //------------------------------------------------------------------
+ virtual void DidLaunch() {}
+
+ //------------------------------------------------------------------
+ /// Called before resuming to a process.
+ ///
+ /// Allow Process plug-ins to execute some code before resuming a
+ /// process.
+ ///
+ /// @return
+ /// Returns an error object.
+ //------------------------------------------------------------------
+ virtual Error WillResume() { return Error(); }
+
+ //------------------------------------------------------------------
+ /// Resumes all of a process's threads as configured using the
+ /// Thread run control functions.
+ ///
+ /// Threads for a process should be updated with one of the run
+ /// control actions (resume, step, or suspend) that they should take
+ /// when the process is resumed. If no run control action is given
+ /// to a thread it will be resumed by default.
+ ///
+ /// @return
+ /// Returns \b true if the process successfully resumes using
+ /// the thread run control actions, \b false otherwise.
+ ///
+ /// @see Thread:Resume()
+ /// @see Thread:Step()
+ /// @see Thread:Suspend()
+ //------------------------------------------------------------------
+ virtual Error DoResume() {
+ Error error;
+ error.SetErrorStringWithFormat(
+ "error: %s does not support resuming processes",
+ GetPluginName().GetCString());
+ return error;
+ }
+
+ //------------------------------------------------------------------
+ /// Called after resuming a process.
+ ///
+ /// Allow Process plug-ins to execute some code after resuming
+ /// a process.
+ //------------------------------------------------------------------
+ virtual void DidResume() {}
+
+ //------------------------------------------------------------------
+ /// Called before halting to a process.
+ ///
+ /// Allow Process plug-ins to execute some code before halting a
+ /// process.
+ ///
+ /// @return
+ /// Returns an error object.
+ //------------------------------------------------------------------
+ virtual Error WillHalt() { return Error(); }
+
+ //------------------------------------------------------------------
+ /// Halts a running process.
+ ///
+ /// DoHalt must produce one and only one stop StateChanged event if it
+ /// actually
+ /// stops the process. If the stop happens through some natural event (for
+ /// instance a SIGSTOP), then forwarding that event will do. Otherwise, you
+ /// must
+ /// generate the event manually. This function is called from the context of
+ /// the
+ /// private state thread.
+ ///
+ /// @param[out] caused_stop
+ /// If true, then this Halt caused the stop, otherwise, the
+ /// process was already stopped.
+ ///
+ /// @return
+ /// Returns \b true if the process successfully halts, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ virtual Error DoHalt(bool &caused_stop) {
+ Error error;
+ error.SetErrorStringWithFormat(
+ "error: %s does not support halting processes",
+ GetPluginName().GetCString());
+ return error;
+ }
+
+ //------------------------------------------------------------------
+ /// Called after halting a process.
+ ///
+ /// Allow Process plug-ins to execute some code after halting
+ /// a process.
+ //------------------------------------------------------------------
+ virtual void DidHalt() {}
+
+ //------------------------------------------------------------------
+ /// Called before detaching from a process.
+ ///
+ /// Allow Process plug-ins to execute some code before detaching
+ /// from a process.
+ ///
+ /// @return
+ /// Returns an error object.
+ //------------------------------------------------------------------
+ virtual Error WillDetach() { return Error(); }
+
+ //------------------------------------------------------------------
+ /// Detaches from a running or stopped process.
+ ///
+ /// @return
+ /// Returns \b true if the process successfully detaches, \b
+ /// false otherwise.
+ //------------------------------------------------------------------
+ virtual Error DoDetach(bool keep_stopped) {
+ Error error;
+ error.SetErrorStringWithFormat(
+ "error: %s does not support detaching from processes",
+ GetPluginName().GetCString());
+ return error;
+ }
+
+ //------------------------------------------------------------------
+ /// Called after detaching from a process.
+ ///
+ /// Allow Process plug-ins to execute some code after detaching
+ /// from a process.
+ //------------------------------------------------------------------
+ virtual void DidDetach() {}
+
+ virtual bool DetachRequiresHalt() { return false; }
+
+ //------------------------------------------------------------------
+ /// Called before sending a signal to a process.
+ ///
+ /// Allow Process plug-ins to execute some code before sending a
+ /// signal to a process.
+ ///
+ /// @return
+ /// Returns no error if it is safe to proceed with a call to
+ /// Process::DoSignal(int), otherwise an error describing what
+ /// prevents the signal from being sent.
+ //------------------------------------------------------------------
+ virtual Error WillSignal() { return Error(); }
+
+ //------------------------------------------------------------------
+ /// Sends a process a UNIX signal \a signal.
+ ///
+ /// @return
+ /// Returns an error object.
+ //------------------------------------------------------------------
+ virtual Error DoSignal(int signal) {
+ Error error;
+ error.SetErrorStringWithFormat(
+ "error: %s does not support sending signals to processes",
+ GetPluginName().GetCString());
+ return error;
+ }
+
+ virtual Error WillDestroy() { return Error(); }
+
+ virtual Error DoDestroy() = 0;
+
+ virtual void DidDestroy() {}
+
+ virtual bool DestroyRequiresHalt() { return true; }
+
+ //------------------------------------------------------------------
+ /// Called after sending a signal to a process.
+ ///
+ /// Allow Process plug-ins to execute some code after sending a
+ /// signal to a process.
+ //------------------------------------------------------------------
+ virtual void DidSignal() {}
+
+ //------------------------------------------------------------------
+ /// Currently called as part of ShouldStop.
+ /// FIXME: Should really happen when the target stops before the
+ /// event is taken from the queue...
+ ///
+ /// This callback is called as the event
+ /// is about to be queued up to allow Process plug-ins to execute
+ /// some code prior to clients being notified that a process was
+ /// stopped. Common operations include updating the thread list,
+ /// invalidating any thread state (registers, stack, etc) prior to
+ /// letting the notification go out.
+ ///
+ //------------------------------------------------------------------
+ virtual void RefreshStateAfterStop() = 0;
+
+ //------------------------------------------------------------------
+ /// Sometimes the connection to a process can detect the host OS
+ /// version that the process is running on. The current platform
+ /// should be checked first in case the platform is connected, but
+ /// clients can fall back onto this function if the platform fails
+ /// to identify the host OS version. The platform should be checked
+ /// first in case you are running a simulator platform that might
+ /// itself be running natively, but have different heuristics for
+ /// figuring out which OS is is emulating.
+ ///
+ /// @param[out] major
+ /// The major OS version, or UINT32_MAX if it can't be determined
+ ///
+ /// @param[out] minor
+ /// The minor OS version, or UINT32_MAX if it can't be determined
+ ///
+ /// @param[out] update
+ /// The update OS version, or UINT32_MAX if it can't be determined
+ ///
+ /// @return
+ /// Returns \b true if the host OS version info was filled in
+ /// and \b false otherwise.
+ //------------------------------------------------------------------
+ virtual bool GetHostOSVersion(uint32_t &major, uint32_t &minor,
+ uint32_t &update) {
+ major = UINT32_MAX;
+ minor = UINT32_MAX;
+ update = UINT32_MAX;
+ return false;
+ }
+
+ //------------------------------------------------------------------
+ /// Get the target object pointer for this module.
+ ///
+ /// @return
+ /// A Target object pointer to the target that owns this
+ /// module.
+ //------------------------------------------------------------------
+ Target &GetTarget() { return *m_target_sp.lock(); }
+
+ //------------------------------------------------------------------
+ /// Get the const target object pointer for this module.
+ ///
+ /// @return
+ /// A const Target object pointer to the target that owns this
+ /// module.
+ //------------------------------------------------------------------
+ const Target &GetTarget() const { return *m_target_sp.lock(); }
+
+ //------------------------------------------------------------------
+ /// Flush all data in the process.
+ ///
+ /// Flush the memory caches, all threads, and any other cached data
+ /// in the process.
+ ///
+ /// This function can be called after a world changing event like
+ /// adding a new symbol file, or after the process makes a large
+ /// context switch (from boot ROM to booted into an OS).
+ //------------------------------------------------------------------
+ void Flush();
+
+ //------------------------------------------------------------------
+ /// Get accessor for the current process state.
+ ///
+ /// @return
+ /// The current state of the process.
+ ///
+ /// @see lldb::StateType
+ //------------------------------------------------------------------
+ lldb::StateType GetState();
+
+ lldb::ExpressionResults
+ RunThreadPlan(ExecutionContext &exe_ctx, lldb::ThreadPlanSP &thread_plan_sp,
+ const EvaluateExpressionOptions &options,
+ DiagnosticManager &diagnostic_manager);
+
+ static const char *ExecutionResultAsCString(lldb::ExpressionResults result);
+
+ void GetStatus(Stream &ostrm);
+
+ size_t GetThreadStatus(Stream &ostrm, bool only_threads_with_stop_reason,
+ uint32_t start_frame, uint32_t num_frames,
+ uint32_t num_frames_with_source,
+ bool stop_format);
+
+ void SendAsyncInterrupt();
+
+ //------------------------------------------------------------------
+ // Notify this process class that modules got loaded.
+ //
+ // If subclasses override this method, they must call this version
+ // before doing anything in the subclass version of the function.
+ //------------------------------------------------------------------
+ virtual void ModulesDidLoad(ModuleList &module_list);
+
+ //------------------------------------------------------------------
+ /// Retrieve the list of shared libraries that are loaded for this process
+ /// This method is used on pre-macOS 10.12, pre-iOS 10, pre-tvOS 10,
+ /// pre-watchOS 3 systems. The following two methods are for newer versions
+ /// of those OSes.
+ ///
+ /// For certain platforms, the time it takes for the DynamicLoader plugin to
+ /// read all of the shared libraries out of memory over a slow communication
+ /// channel may be too long. In that instance, the gdb-remote stub may be
+ /// able to retrieve the necessary information about the solibs out of memory
+ /// and return a concise summary sufficient for the DynamicLoader plugin.
+ ///
+ /// @param [in] image_list_address
+ /// The address where the table of shared libraries is stored in memory,
+ /// if that is appropriate for this platform. Else this may be
+ /// passed as LLDB_INVALID_ADDRESS.
+ ///
+ /// @param [in] image_count
+ /// The number of shared libraries that are present in this process, if
+ /// that is appropriate for this platofrm Else this may be passed as
+ /// LLDB_INVALID_ADDRESS.
+ ///
+ /// @return
+ /// A StructureDataSP object which, if non-empty, will contain the
+ /// information the DynamicLoader needs to get the initial scan of
+ /// solibs resolved.
+ //------------------------------------------------------------------
+ virtual lldb_private::StructuredData::ObjectSP
+ GetLoadedDynamicLibrariesInfos(lldb::addr_t image_list_address,
+ lldb::addr_t image_count) {
+ return StructuredData::ObjectSP();
+ }
+
+ // On macOS 10.12, tvOS 10, iOS 10, watchOS 3 and newer, debugserver can
+ // return
+ // the full list of loaded shared libraries without needing any input.
+ virtual lldb_private::StructuredData::ObjectSP
+ GetLoadedDynamicLibrariesInfos() {
+ return StructuredData::ObjectSP();
+ }
+
+ // On macOS 10.12, tvOS 10, iOS 10, watchOS 3 and newer, debugserver can
+ // return
+ // information about binaries given their load addresses.
+ virtual lldb_private::StructuredData::ObjectSP GetLoadedDynamicLibrariesInfos(
+ const std::vector<lldb::addr_t> &load_addresses) {
+ return StructuredData::ObjectSP();
+ }
+
+ //------------------------------------------------------------------
+ // Get information about the library shared cache, if that exists
+ //
+ // On macOS 10.12, tvOS 10, iOS 10, watchOS 3 and newer, debugserver can
+ // return
+ // information about the library shared cache (a set of standard libraries
+ // that are
+ // loaded at the same location for all processes on a system) in use.
+ //------------------------------------------------------------------
+ virtual lldb_private::StructuredData::ObjectSP GetSharedCacheInfo() {
+ return StructuredData::ObjectSP();
+ }
+
+ //------------------------------------------------------------------
+ /// Print a user-visible warning about a module being built with optimization
+ ///
+ /// Prints a async warning message to the user one time per Module
+ /// where a function is found that was compiled with optimization, per
+ /// Process.
+ ///
+ /// @param [in] sc
+ /// A SymbolContext with eSymbolContextFunction and eSymbolContextModule
+ /// pre-computed.
+ //------------------------------------------------------------------
+ void PrintWarningOptimization(const SymbolContext &sc);
+
+ virtual bool GetProcessInfo(ProcessInstanceInfo &info);
- //------------------------------------------------------------------
- /// Actually do the reading of memory from a process.
- ///
- /// Subclasses must override this function and can return fewer
- /// bytes than requested when memory requests are too large. This
- /// class will break up the memory requests and keep advancing the
- /// arguments along as needed.
- ///
- /// @param[in] vm_addr
- /// A virtual load address that indicates where to start reading
- /// memory from.
- ///
- /// @param[in] size
- /// The number of bytes to read.
- ///
- /// @param[out] buf
- /// A byte buffer that is at least \a size bytes long that
- /// will receive the memory bytes.
- ///
- /// @return
- /// The number of bytes that were actually read into \a buf.
- //------------------------------------------------------------------
- virtual size_t
- DoReadMemory (lldb::addr_t vm_addr,
- void *buf,
- size_t size,
- Error &error) = 0;
-
- //------------------------------------------------------------------
- /// Read of memory from a process.
- ///
- /// This function will read memory from the current process's
- /// address space and remove any traps that may have been inserted
- /// into the memory.
- ///
- /// This function is not meant to be overridden by Process
- /// subclasses, the subclasses should implement
- /// Process::DoReadMemory (lldb::addr_t, size_t, void *).
- ///
- /// @param[in] vm_addr
- /// A virtual load address that indicates where to start reading
- /// memory from.
- ///
- /// @param[out] buf
- /// A byte buffer that is at least \a size bytes long that
- /// will receive the memory bytes.
- ///
- /// @param[in] size
- /// The number of bytes to read.
- ///
- /// @return
- /// The number of bytes that were actually read into \a buf. If
- /// the returned number is greater than zero, yet less than \a
- /// size, then this function will get called again with \a
- /// vm_addr, \a buf, and \a size updated appropriately. Zero is
- /// returned to indicate an error.
- //------------------------------------------------------------------
- virtual size_t
- ReadMemory (lldb::addr_t vm_addr,
- void *buf,
- size_t size,
- Error &error);
-
- //------------------------------------------------------------------
- /// Read a NULL terminated string from memory
- ///
- /// This function will read a cache page at a time until a NULL
- /// string terminator is found. It will stop reading if an aligned
- /// sequence of NULL termination \a type_width bytes is not found
- /// before reading \a cstr_max_len bytes. The results are always
- /// guaranteed to be NULL terminated, and that no more than
- /// (max_bytes - type_width) bytes will be read.
- ///
- /// @param[in] vm_addr
- /// The virtual load address to start the memory read.
- ///
- /// @param[in] str
- /// A character buffer containing at least max_bytes.
- ///
- /// @param[in] max_bytes
- /// The maximum number of bytes to read.
- ///
- /// @param[in] error
- /// The error status of the read operation.
- ///
- /// @param[in] type_width
- /// The size of the null terminator (1 to 4 bytes per
- /// character). Defaults to 1.
- ///
- /// @return
- /// The error status or the number of bytes prior to the null terminator.
- //------------------------------------------------------------------
- size_t
- ReadStringFromMemory (lldb::addr_t vm_addr,
- char *str,
- size_t max_bytes,
- Error &error,
- size_t type_width = 1);
-
- //------------------------------------------------------------------
- /// Read a NULL terminated C string from memory
- ///
- /// This function will read a cache page at a time until the NULL
- /// C string terminator is found. It will stop reading if the NULL
- /// termination byte isn't found before reading \a cstr_max_len
- /// bytes, and the results are always guaranteed to be NULL
- /// terminated (at most cstr_max_len - 1 bytes will be read).
- //------------------------------------------------------------------
- size_t
- ReadCStringFromMemory (lldb::addr_t vm_addr,
- char *cstr,
- size_t cstr_max_len,
- Error &error);
-
- size_t
- ReadCStringFromMemory (lldb::addr_t vm_addr,
- std::string &out_str,
- Error &error);
-
- size_t
- ReadMemoryFromInferior (lldb::addr_t vm_addr,
- void *buf,
- size_t size,
+public:
+ //------------------------------------------------------------------
+ /// Get the exit status for a process.
+ ///
+ /// @return
+ /// The process's return code, or -1 if the current process
+ /// state is not eStateExited.
+ //------------------------------------------------------------------
+ int GetExitStatus();
+
+ //------------------------------------------------------------------
+ /// Get a textual description of what the process exited.
+ ///
+ /// @return
+ /// The textual description of why the process exited, or nullptr
+ /// if there is no description available.
+ //------------------------------------------------------------------
+ const char *GetExitDescription();
+
+ virtual void DidExit() {}
+
+ //------------------------------------------------------------------
+ /// Get the Modification ID of the process.
+ ///
+ /// @return
+ /// The modification ID of the process.
+ //------------------------------------------------------------------
+ ProcessModID GetModID() const { return m_mod_id; }
+
+ const ProcessModID &GetModIDRef() const { return m_mod_id; }
+
+ uint32_t GetStopID() const { return m_mod_id.GetStopID(); }
+
+ uint32_t GetResumeID() const { return m_mod_id.GetResumeID(); }
+
+ uint32_t GetLastUserExpressionResumeID() const {
+ return m_mod_id.GetLastUserExpressionResumeID();
+ }
+
+ uint32_t GetLastNaturalStopID() const {
+ return m_mod_id.GetLastNaturalStopID();
+ }
+
+ lldb::EventSP GetStopEventForStopID(uint32_t stop_id) const {
+ return m_mod_id.GetStopEventForStopID(stop_id);
+ }
+
+ //------------------------------------------------------------------
+ /// Set accessor for the process exit status (return code).
+ ///
+ /// Sometimes a child exits and the exit can be detected by global
+ /// functions (signal handler for SIGCHLD for example). This
+ /// accessor allows the exit status to be set from an external
+ /// source.
+ ///
+ /// Setting this will cause a eStateExited event to be posted to
+ /// the process event queue.
+ ///
+ /// @param[in] exit_status
+ /// The value for the process's return code.
+ ///
+ /// @see lldb::StateType
+ //------------------------------------------------------------------
+ virtual bool SetExitStatus(int exit_status, const char *cstr);
+
+ //------------------------------------------------------------------
+ /// Check if a process is still alive.
+ ///
+ /// @return
+ /// Returns \b true if the process is still valid, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ virtual bool IsAlive();
+
+ //------------------------------------------------------------------
+ /// Before lldb detaches from a process, it warns the user that they are about
+ /// to lose their debug session.
+ /// In some cases, this warning doesn't need to be emitted -- for instance,
+ /// with core file debugging where
+ /// the user can reconstruct the "state" by simply re-running the debugger on
+ /// the core file.
+ ///
+ /// @return
+ // true if the user should be warned about detaching from this process.
+ //------------------------------------------------------------------
+ virtual bool WarnBeforeDetach() const { return true; }
+
+ //------------------------------------------------------------------
+ /// Actually do the reading of memory from a process.
+ ///
+ /// Subclasses must override this function and can return fewer
+ /// bytes than requested when memory requests are too large. This
+ /// class will break up the memory requests and keep advancing the
+ /// arguments along as needed.
+ ///
+ /// @param[in] vm_addr
+ /// A virtual load address that indicates where to start reading
+ /// memory from.
+ ///
+ /// @param[in] size
+ /// The number of bytes to read.
+ ///
+ /// @param[out] buf
+ /// A byte buffer that is at least \a size bytes long that
+ /// will receive the memory bytes.
+ ///
+ /// @return
+ /// The number of bytes that were actually read into \a buf.
+ //------------------------------------------------------------------
+ virtual size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
+ Error &error) = 0;
+
+ //------------------------------------------------------------------
+ /// Read of memory from a process.
+ ///
+ /// This function will read memory from the current process's
+ /// address space and remove any traps that may have been inserted
+ /// into the memory.
+ ///
+ /// This function is not meant to be overridden by Process
+ /// subclasses, the subclasses should implement
+ /// Process::DoReadMemory (lldb::addr_t, size_t, void *).
+ ///
+ /// @param[in] vm_addr
+ /// A virtual load address that indicates where to start reading
+ /// memory from.
+ ///
+ /// @param[out] buf
+ /// A byte buffer that is at least \a size bytes long that
+ /// will receive the memory bytes.
+ ///
+ /// @param[in] size
+ /// The number of bytes to read.
+ ///
+ /// @return
+ /// The number of bytes that were actually read into \a buf. If
+ /// the returned number is greater than zero, yet less than \a
+ /// size, then this function will get called again with \a
+ /// vm_addr, \a buf, and \a size updated appropriately. Zero is
+ /// returned to indicate an error.
+ //------------------------------------------------------------------
+ virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
Error &error);
-
- //------------------------------------------------------------------
- /// Reads an unsigned integer of the specified byte size from
- /// process memory.
- ///
- /// @param[in] load_addr
- /// A load address of the integer to read.
- ///
- /// @param[in] byte_size
- /// The size in byte of the integer to read.
- ///
- /// @param[in] fail_value
- /// The value to return if we fail to read an integer.
- ///
- /// @param[out] error
- /// An error that indicates the success or failure of this
- /// operation. If error indicates success (error.Success()),
- /// then the value returned can be trusted, otherwise zero
- /// will be returned.
- ///
- /// @return
- /// The unsigned integer that was read from the process memory
- /// space. If the integer was smaller than a uint64_t, any
- /// unused upper bytes will be zero filled. If the process
- /// byte order differs from the host byte order, the integer
- /// value will be appropriately byte swapped into host byte
- /// order.
- //------------------------------------------------------------------
- uint64_t
- ReadUnsignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, uint64_t fail_value, Error &error);
-
- int64_t
- ReadSignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, int64_t fail_value, Error &error);
-
- lldb::addr_t
- ReadPointerFromMemory (lldb::addr_t vm_addr,
- Error &error);
-
- bool
- WritePointerToMemory (lldb::addr_t vm_addr,
- lldb::addr_t ptr_value,
- Error &error);
-
- //------------------------------------------------------------------
- /// Actually do the writing of memory to a process.
- ///
- /// @param[in] vm_addr
- /// A virtual load address that indicates where to start writing
- /// memory to.
- ///
- /// @param[in] buf
- /// A byte buffer that is at least \a size bytes long that
- /// contains the data to write.
- ///
- /// @param[in] size
- /// The number of bytes to write.
- ///
- /// @param[out] error
- /// An error value in case the memory write fails.
- ///
- /// @return
- /// The number of bytes that were actually written.
- //------------------------------------------------------------------
- virtual size_t
- DoWriteMemory (lldb::addr_t vm_addr, const void *buf, size_t size, Error &error)
- {
- error.SetErrorStringWithFormat("error: %s does not support writing to processes", GetPluginName().GetCString());
- return 0;
- }
-
- //------------------------------------------------------------------
- /// Write all or part of a scalar value to memory.
- ///
- /// The value contained in \a scalar will be swapped to match the
- /// byte order of the process that is being debugged. If \a size is
- /// less than the size of scalar, the least significant \a size bytes
- /// from scalar will be written. If \a size is larger than the byte
- /// size of scalar, then the extra space will be padded with zeros
- /// and the scalar value will be placed in the least significant
- /// bytes in memory.
- ///
- /// @param[in] vm_addr
- /// A virtual load address that indicates where to start writing
- /// memory to.
- ///
- /// @param[in] scalar
- /// The scalar to write to the debugged process.
- ///
- /// @param[in] size
- /// This value can be smaller or larger than the scalar value
- /// itself. If \a size is smaller than the size of \a scalar,
- /// the least significant bytes in \a scalar will be used. If
- /// \a size is larger than the byte size of \a scalar, then
- /// the extra space will be padded with zeros. If \a size is
- /// set to UINT32_MAX, then the size of \a scalar will be used.
- ///
- /// @param[out] error
- /// An error value in case the memory write fails.
- ///
- /// @return
- /// The number of bytes that were actually written.
- //------------------------------------------------------------------
- size_t
- WriteScalarToMemory (lldb::addr_t vm_addr,
- const Scalar &scalar,
- size_t size,
- Error &error);
-
- size_t
- ReadScalarIntegerFromMemory (lldb::addr_t addr,
- uint32_t byte_size,
- bool is_signed,
- Scalar &scalar,
- Error &error);
-
- //------------------------------------------------------------------
- /// Write memory to a process.
- ///
- /// This function will write memory to the current process's
- /// address space and maintain any traps that might be present due
- /// to software breakpoints.
- ///
- /// This function is not meant to be overridden by Process
- /// subclasses, the subclasses should implement
- /// Process::DoWriteMemory (lldb::addr_t, size_t, void *).
- ///
- /// @param[in] vm_addr
- /// A virtual load address that indicates where to start writing
- /// memory to.
- ///
- /// @param[in] buf
- /// A byte buffer that is at least \a size bytes long that
- /// contains the data to write.
- ///
- /// @param[in] size
- /// The number of bytes to write.
- ///
- /// @return
- /// The number of bytes that were actually written.
- //------------------------------------------------------------------
- size_t
- WriteMemory (lldb::addr_t vm_addr, const void *buf, size_t size, Error &error);
-
- //------------------------------------------------------------------
- /// Actually allocate memory in the process.
- ///
- /// This function will allocate memory in the process's address
- /// space. This can't rely on the generic function calling mechanism,
- /// since that requires this function.
- ///
- /// @param[in] size
- /// The size of the allocation requested.
- ///
- /// @return
- /// The address of the allocated buffer in the process, or
- /// LLDB_INVALID_ADDRESS if the allocation failed.
- //------------------------------------------------------------------
-
- virtual lldb::addr_t
- DoAllocateMemory (size_t size, uint32_t permissions, Error &error)
- {
- error.SetErrorStringWithFormat("error: %s does not support allocating in the debug process", GetPluginName().GetCString());
- return LLDB_INVALID_ADDRESS;
- }
-
- //------------------------------------------------------------------
- /// The public interface to allocating memory in the process.
- ///
- /// This function will allocate memory in the process's address
- /// space. This can't rely on the generic function calling mechanism,
- /// since that requires this function.
- ///
- /// @param[in] size
- /// The size of the allocation requested.
- ///
- /// @param[in] permissions
- /// Or together any of the lldb::Permissions bits. The permissions on
- /// a given memory allocation can't be changed after allocation. Note
- /// that a block that isn't set writable can still be written on from lldb,
- /// just not by the process itself.
- ///
- /// @param[in,out] error
- /// An error object to fill in if things go wrong.
- /// @return
- /// The address of the allocated buffer in the process, or
- /// LLDB_INVALID_ADDRESS if the allocation failed.
- //------------------------------------------------------------------
- lldb::addr_t
- AllocateMemory (size_t size, uint32_t permissions, Error &error);
-
- //------------------------------------------------------------------
- /// The public interface to allocating memory in the process, this also
- /// clears the allocated memory.
- ///
- /// This function will allocate memory in the process's address
- /// space. This can't rely on the generic function calling mechanism,
- /// since that requires this function.
- ///
- /// @param[in] size
- /// The size of the allocation requested.
- ///
- /// @param[in] permissions
- /// Or together any of the lldb::Permissions bits. The permissions on
- /// a given memory allocation can't be changed after allocation. Note
- /// that a block that isn't set writable can still be written on from lldb,
- /// just not by the process itself.
- ///
- /// @param[in/out] error
- /// An error object to fill in if things go wrong.
- /// @return
- /// The address of the allocated buffer in the process, or
- /// LLDB_INVALID_ADDRESS if the allocation failed.
- //------------------------------------------------------------------
-
- lldb::addr_t
- CallocateMemory (size_t size, uint32_t permissions, Error &error);
-
- //------------------------------------------------------------------
- /// Resolve dynamically loaded indirect functions.
- ///
- /// @param[in] address
- /// The load address of the indirect function to resolve.
- ///
- /// @param[out] error
- /// An error value in case the resolve fails.
- ///
- /// @return
- /// The address of the resolved function.
- /// LLDB_INVALID_ADDRESS if the resolution failed.
- //------------------------------------------------------------------
- virtual lldb::addr_t
- ResolveIndirectFunction(const Address *address, Error &error);
-
- //------------------------------------------------------------------
- /// Locate the memory region that contains load_addr.
- ///
- /// If load_addr is within the address space the process has mapped
- /// range_info will be filled in with the start and end of that range
- /// as well as the permissions for that range and range_info.GetMapped
- /// will return true.
- ///
- /// If load_addr is outside any mapped region then range_info will
- /// have its start address set to load_addr and the end of the
- /// range will indicate the start of the next mapped range or be
- /// set to LLDB_INVALID_ADDRESS if there are no valid mapped ranges
- /// between load_addr and the end of the process address space.
- ///
- /// GetMemoryRegionInfo will only return an error if it is
- /// unimplemented for the current process.
- ///
- /// @param[in] load_addr
- /// The load address to query the range_info for.
- ///
- /// @param[out] range_info
- /// An range_info value containing the details of the range.
- ///
- /// @return
- /// An error value.
- //------------------------------------------------------------------
- virtual Error
- GetMemoryRegionInfo (lldb::addr_t load_addr,
- MemoryRegionInfo &range_info)
- {
- Error error;
- error.SetErrorString ("Process::GetMemoryRegionInfo() not supported");
- return error;
- }
-
- //------------------------------------------------------------------
- /// Obtain all the mapped memory regions within this process.
- ///
- /// @param[out] region_list
- /// A vector to contain MemoryRegionInfo objects for all mapped
- /// ranges.
- ///
- /// @return
- /// An error value.
- //------------------------------------------------------------------
- virtual Error
- GetMemoryRegions (std::vector<lldb::MemoryRegionInfoSP>& region_list);
-
- virtual Error
- GetWatchpointSupportInfo (uint32_t &num)
- {
- Error error;
- num = 0;
- error.SetErrorString ("Process::GetWatchpointSupportInfo() not supported");
- return error;
- }
- virtual Error
- GetWatchpointSupportInfo (uint32_t &num, bool& after)
- {
- Error error;
- num = 0;
- after = true;
- error.SetErrorString ("Process::GetWatchpointSupportInfo() not supported");
- return error;
- }
-
- lldb::ModuleSP
- ReadModuleFromMemory (const FileSpec& file_spec,
- lldb::addr_t header_addr,
- size_t size_to_read = 512);
-
- //------------------------------------------------------------------
- /// Attempt to get the attributes for a region of memory in the process.
- ///
- /// It may be possible for the remote debug server to inspect attributes
- /// for a region of memory in the process, such as whether there is a
- /// valid page of memory at a given address or whether that page is
- /// readable/writable/executable by the process.
- ///
- /// @param[in] load_addr
- /// The address of interest in the process.
- ///
- /// @param[out] permissions
- /// If this call returns successfully, this bitmask will have
- /// its Permissions bits set to indicate whether the region is
- /// readable/writable/executable. If this call fails, the
- /// bitmask values are undefined.
- ///
- /// @return
- /// Returns true if it was able to determine the attributes of the
- /// memory region. False if not.
- //------------------------------------------------------------------
- virtual bool
- GetLoadAddressPermissions (lldb::addr_t load_addr, uint32_t &permissions);
-
- //------------------------------------------------------------------
- /// Determines whether executing JIT-compiled code in this process
- /// is possible.
- ///
- /// @return
- /// True if execution of JIT code is possible; false otherwise.
- //------------------------------------------------------------------
- bool CanJIT ();
-
- //------------------------------------------------------------------
- /// Sets whether executing JIT-compiled code in this process
- /// is possible.
- ///
- /// @param[in] can_jit
- /// True if execution of JIT code is possible; false otherwise.
- //------------------------------------------------------------------
- void SetCanJIT (bool can_jit);
-
- //------------------------------------------------------------------
- /// Determines whether executing function calls using the interpreter
- /// is possible for this process.
- ///
- /// @return
- /// True if possible; false otherwise.
- //------------------------------------------------------------------
- bool CanInterpretFunctionCalls ()
- {
- return m_can_interpret_function_calls;
- }
-
- //------------------------------------------------------------------
- /// Sets whether executing function calls using the interpreter
- /// is possible for this process.
- ///
- /// @param[in] can_interpret_function_calls
- /// True if possible; false otherwise.
- //------------------------------------------------------------------
- void SetCanInterpretFunctionCalls (bool can_interpret_function_calls)
- {
- m_can_interpret_function_calls = can_interpret_function_calls;
- }
-
- //------------------------------------------------------------------
- /// Sets whether executing code in this process is possible.
- /// This could be either through JIT or interpreting.
- ///
- /// @param[in] can_run_code
- /// True if execution of code is possible; false otherwise.
- //------------------------------------------------------------------
- void SetCanRunCode (bool can_run_code);
-
- //------------------------------------------------------------------
- /// Actually deallocate memory in the process.
- ///
- /// This function will deallocate memory in the process's address
- /// space that was allocated with AllocateMemory.
- ///
- /// @param[in] ptr
- /// A return value from AllocateMemory, pointing to the memory you
- /// want to deallocate.
- ///
- /// @return
- /// \btrue if the memory was deallocated, \bfalse otherwise.
- //------------------------------------------------------------------
- virtual Error
- DoDeallocateMemory (lldb::addr_t ptr)
- {
- Error error;
- error.SetErrorStringWithFormat("error: %s does not support deallocating in the debug process", GetPluginName().GetCString());
- return error;
- }
+ //------------------------------------------------------------------
+ /// Read a NULL terminated string from memory
+ ///
+ /// This function will read a cache page at a time until a NULL
+ /// string terminator is found. It will stop reading if an aligned
+ /// sequence of NULL termination \a type_width bytes is not found
+ /// before reading \a cstr_max_len bytes. The results are always
+ /// guaranteed to be NULL terminated, and that no more than
+ /// (max_bytes - type_width) bytes will be read.
+ ///
+ /// @param[in] vm_addr
+ /// The virtual load address to start the memory read.
+ ///
+ /// @param[in] str
+ /// A character buffer containing at least max_bytes.
+ ///
+ /// @param[in] max_bytes
+ /// The maximum number of bytes to read.
+ ///
+ /// @param[in] error
+ /// The error status of the read operation.
+ ///
+ /// @param[in] type_width
+ /// The size of the null terminator (1 to 4 bytes per
+ /// character). Defaults to 1.
+ ///
+ /// @return
+ /// The error status or the number of bytes prior to the null terminator.
+ //------------------------------------------------------------------
+ size_t ReadStringFromMemory(lldb::addr_t vm_addr, char *str, size_t max_bytes,
+ Error &error, size_t type_width = 1);
+
+ //------------------------------------------------------------------
+ /// Read a NULL terminated C string from memory
+ ///
+ /// This function will read a cache page at a time until the NULL
+ /// C string terminator is found. It will stop reading if the NULL
+ /// termination byte isn't found before reading \a cstr_max_len
+ /// bytes, and the results are always guaranteed to be NULL
+ /// terminated (at most cstr_max_len - 1 bytes will be read).
+ //------------------------------------------------------------------
+ size_t ReadCStringFromMemory(lldb::addr_t vm_addr, char *cstr,
+ size_t cstr_max_len, Error &error);
+
+ size_t ReadCStringFromMemory(lldb::addr_t vm_addr, std::string &out_str,
+ Error &error);
+
+ size_t ReadMemoryFromInferior(lldb::addr_t vm_addr, void *buf, size_t size,
+ Error &error);
+
+ //------------------------------------------------------------------
+ /// Reads an unsigned integer of the specified byte size from
+ /// process memory.
+ ///
+ /// @param[in] load_addr
+ /// A load address of the integer to read.
+ ///
+ /// @param[in] byte_size
+ /// The size in byte of the integer to read.
+ ///
+ /// @param[in] fail_value
+ /// The value to return if we fail to read an integer.
+ ///
+ /// @param[out] error
+ /// An error that indicates the success or failure of this
+ /// operation. If error indicates success (error.Success()),
+ /// then the value returned can be trusted, otherwise zero
+ /// will be returned.
+ ///
+ /// @return
+ /// The unsigned integer that was read from the process memory
+ /// space. If the integer was smaller than a uint64_t, any
+ /// unused upper bytes will be zero filled. If the process
+ /// byte order differs from the host byte order, the integer
+ /// value will be appropriately byte swapped into host byte
+ /// order.
+ //------------------------------------------------------------------
+ uint64_t ReadUnsignedIntegerFromMemory(lldb::addr_t load_addr,
+ size_t byte_size, uint64_t fail_value,
+ Error &error);
+
+ int64_t ReadSignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size,
+ int64_t fail_value, Error &error);
+
+ lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Error &error);
+
+ bool WritePointerToMemory(lldb::addr_t vm_addr, lldb::addr_t ptr_value,
+ Error &error);
- //------------------------------------------------------------------
- /// The public interface to deallocating memory in the process.
- ///
- /// This function will deallocate memory in the process's address
- /// space that was allocated with AllocateMemory.
- ///
- /// @param[in] ptr
- /// A return value from AllocateMemory, pointing to the memory you
- /// want to deallocate.
- ///
- /// @return
- /// \btrue if the memory was deallocated, \bfalse otherwise.
- //------------------------------------------------------------------
- Error
- DeallocateMemory (lldb::addr_t ptr);
-
- //------------------------------------------------------------------
- /// Get any available STDOUT.
- ///
- /// Calling this method is a valid operation only if all of the
- /// following conditions are true:
- /// 1) The process was launched, and not attached to.
- /// 2) The process was not launched with eLaunchFlagDisableSTDIO.
- /// 3) The process was launched without supplying a valid file path
- /// for STDOUT.
- ///
- /// Note that the implementation will probably need to start a read
- /// thread in the background to make sure that the pipe is drained
- /// and the STDOUT buffered appropriately, to prevent the process
- /// from deadlocking trying to write to a full buffer.
- ///
- /// Events will be queued indicating that there is STDOUT available
- /// that can be retrieved using this function.
- ///
- /// @param[out] buf
- /// A buffer that will receive any STDOUT bytes that are
- /// currently available.
- ///
- /// @param[in] buf_size
- /// The size in bytes for the buffer \a buf.
- ///
- /// @return
- /// The number of bytes written into \a buf. If this value is
- /// equal to \a buf_size, another call to this function should
- /// be made to retrieve more STDOUT data.
- //------------------------------------------------------------------
- virtual size_t
- GetSTDOUT (char *buf, size_t buf_size, Error &error);
-
- //------------------------------------------------------------------
- /// Get any available STDERR.
- ///
- /// Calling this method is a valid operation only if all of the
- /// following conditions are true:
- /// 1) The process was launched, and not attached to.
- /// 2) The process was not launched with eLaunchFlagDisableSTDIO.
- /// 3) The process was launched without supplying a valid file path
- /// for STDERR.
- ///
- /// Note that the implementation will probably need to start a read
- /// thread in the background to make sure that the pipe is drained
- /// and the STDERR buffered appropriately, to prevent the process
- /// from deadlocking trying to write to a full buffer.
- ///
- /// Events will be queued indicating that there is STDERR available
- /// that can be retrieved using this function.
- ///
- /// @param[in] buf
- /// A buffer that will receive any STDERR bytes that are
- /// currently available.
- ///
- /// @param[out] buf_size
- /// The size in bytes for the buffer \a buf.
- ///
- /// @return
- /// The number of bytes written into \a buf. If this value is
- /// equal to \a buf_size, another call to this function should
- /// be made to retrieve more STDERR data.
- //------------------------------------------------------------------
- virtual size_t
- GetSTDERR (char *buf, size_t buf_size, Error &error);
-
- //------------------------------------------------------------------
- /// Puts data into this process's STDIN.
- ///
- /// Calling this method is a valid operation only if all of the
- /// following conditions are true:
- /// 1) The process was launched, and not attached to.
- /// 2) The process was not launched with eLaunchFlagDisableSTDIO.
- /// 3) The process was launched without supplying a valid file path
- /// for STDIN.
- ///
- /// @param[in] buf
- /// A buffer that contains the data to write to the process's STDIN.
- ///
- /// @param[in] buf_size
- /// The size in bytes for the buffer \a buf.
- ///
- /// @return
- /// The number of bytes written into \a buf. If this value is
- /// less than \a buf_size, another call to this function should
- /// be made to write the rest of the data.
- //------------------------------------------------------------------
- virtual size_t
- PutSTDIN (const char *buf, size_t buf_size, Error &error)
- {
- error.SetErrorString("stdin unsupported");
- return 0;
- }
+ //------------------------------------------------------------------
+ /// Actually do the writing of memory to a process.
+ ///
+ /// @param[in] vm_addr
+ /// A virtual load address that indicates where to start writing
+ /// memory to.
+ ///
+ /// @param[in] buf
+ /// A byte buffer that is at least \a size bytes long that
+ /// contains the data to write.
+ ///
+ /// @param[in] size
+ /// The number of bytes to write.
+ ///
+ /// @param[out] error
+ /// An error value in case the memory write fails.
+ ///
+ /// @return
+ /// The number of bytes that were actually written.
+ //------------------------------------------------------------------
+ virtual size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf,
+ size_t size, Error &error) {
+ error.SetErrorStringWithFormat(
+ "error: %s does not support writing to processes",
+ GetPluginName().GetCString());
+ return 0;
+ }
+
+ //------------------------------------------------------------------
+ /// Write all or part of a scalar value to memory.
+ ///
+ /// The value contained in \a scalar will be swapped to match the
+ /// byte order of the process that is being debugged. If \a size is
+ /// less than the size of scalar, the least significant \a size bytes
+ /// from scalar will be written. If \a size is larger than the byte
+ /// size of scalar, then the extra space will be padded with zeros
+ /// and the scalar value will be placed in the least significant
+ /// bytes in memory.
+ ///
+ /// @param[in] vm_addr
+ /// A virtual load address that indicates where to start writing
+ /// memory to.
+ ///
+ /// @param[in] scalar
+ /// The scalar to write to the debugged process.
+ ///
+ /// @param[in] size
+ /// This value can be smaller or larger than the scalar value
+ /// itself. If \a size is smaller than the size of \a scalar,
+ /// the least significant bytes in \a scalar will be used. If
+ /// \a size is larger than the byte size of \a scalar, then
+ /// the extra space will be padded with zeros. If \a size is
+ /// set to UINT32_MAX, then the size of \a scalar will be used.
+ ///
+ /// @param[out] error
+ /// An error value in case the memory write fails.
+ ///
+ /// @return
+ /// The number of bytes that were actually written.
+ //------------------------------------------------------------------
+ size_t WriteScalarToMemory(lldb::addr_t vm_addr, const Scalar &scalar,
+ size_t size, Error &error);
+
+ size_t ReadScalarIntegerFromMemory(lldb::addr_t addr, uint32_t byte_size,
+ bool is_signed, Scalar &scalar,
+ Error &error);
+
+ //------------------------------------------------------------------
+ /// Write memory to a process.
+ ///
+ /// This function will write memory to the current process's
+ /// address space and maintain any traps that might be present due
+ /// to software breakpoints.
+ ///
+ /// This function is not meant to be overridden by Process
+ /// subclasses, the subclasses should implement
+ /// Process::DoWriteMemory (lldb::addr_t, size_t, void *).
+ ///
+ /// @param[in] vm_addr
+ /// A virtual load address that indicates where to start writing
+ /// memory to.
+ ///
+ /// @param[in] buf
+ /// A byte buffer that is at least \a size bytes long that
+ /// contains the data to write.
+ ///
+ /// @param[in] size
+ /// The number of bytes to write.
+ ///
+ /// @return
+ /// The number of bytes that were actually written.
+ //------------------------------------------------------------------
+ // TODO: change this to take an ArrayRef<uint8_t>
+ size_t WriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size,
+ Error &error);
+
+ //------------------------------------------------------------------
+ /// Actually allocate memory in the process.
+ ///
+ /// This function will allocate memory in the process's address
+ /// space. This can't rely on the generic function calling mechanism,
+ /// since that requires this function.
+ ///
+ /// @param[in] size
+ /// The size of the allocation requested.
+ ///
+ /// @return
+ /// The address of the allocated buffer in the process, or
+ /// LLDB_INVALID_ADDRESS if the allocation failed.
+ //------------------------------------------------------------------
+
+ virtual lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions,
+ Error &error) {
+ error.SetErrorStringWithFormat(
+ "error: %s does not support allocating in the debug process",
+ GetPluginName().GetCString());
+ return LLDB_INVALID_ADDRESS;
+ }
+
+ //------------------------------------------------------------------
+ /// The public interface to allocating memory in the process.
+ ///
+ /// This function will allocate memory in the process's address
+ /// space. This can't rely on the generic function calling mechanism,
+ /// since that requires this function.
+ ///
+ /// @param[in] size
+ /// The size of the allocation requested.
+ ///
+ /// @param[in] permissions
+ /// Or together any of the lldb::Permissions bits. The permissions on
+ /// a given memory allocation can't be changed after allocation. Note
+ /// that a block that isn't set writable can still be written on from
+ /// lldb,
+ /// just not by the process itself.
+ ///
+ /// @param[in,out] error
+ /// An error object to fill in if things go wrong.
+ /// @return
+ /// The address of the allocated buffer in the process, or
+ /// LLDB_INVALID_ADDRESS if the allocation failed.
+ //------------------------------------------------------------------
+ lldb::addr_t AllocateMemory(size_t size, uint32_t permissions, Error &error);
+
+ //------------------------------------------------------------------
+ /// The public interface to allocating memory in the process, this also
+ /// clears the allocated memory.
+ ///
+ /// This function will allocate memory in the process's address
+ /// space. This can't rely on the generic function calling mechanism,
+ /// since that requires this function.
+ ///
+ /// @param[in] size
+ /// The size of the allocation requested.
+ ///
+ /// @param[in] permissions
+ /// Or together any of the lldb::Permissions bits. The permissions on
+ /// a given memory allocation can't be changed after allocation. Note
+ /// that a block that isn't set writable can still be written on from
+ /// lldb,
+ /// just not by the process itself.
+ ///
+ /// @param[in/out] error
+ /// An error object to fill in if things go wrong.
+ /// @return
+ /// The address of the allocated buffer in the process, or
+ /// LLDB_INVALID_ADDRESS if the allocation failed.
+ //------------------------------------------------------------------
+
+ lldb::addr_t CallocateMemory(size_t size, uint32_t permissions, Error &error);
+
+ //------------------------------------------------------------------
+ /// Resolve dynamically loaded indirect functions.
+ ///
+ /// @param[in] address
+ /// The load address of the indirect function to resolve.
+ ///
+ /// @param[out] error
+ /// An error value in case the resolve fails.
+ ///
+ /// @return
+ /// The address of the resolved function.
+ /// LLDB_INVALID_ADDRESS if the resolution failed.
+ //------------------------------------------------------------------
+ virtual lldb::addr_t ResolveIndirectFunction(const Address *address,
+ Error &error);
+
+ //------------------------------------------------------------------
+ /// Locate the memory region that contains load_addr.
+ ///
+ /// If load_addr is within the address space the process has mapped
+ /// range_info will be filled in with the start and end of that range
+ /// as well as the permissions for that range and range_info.GetMapped
+ /// will return true.
+ ///
+ /// If load_addr is outside any mapped region then range_info will
+ /// have its start address set to load_addr and the end of the
+ /// range will indicate the start of the next mapped range or be
+ /// set to LLDB_INVALID_ADDRESS if there are no valid mapped ranges
+ /// between load_addr and the end of the process address space.
+ ///
+ /// GetMemoryRegionInfo will only return an error if it is
+ /// unimplemented for the current process.
+ ///
+ /// @param[in] load_addr
+ /// The load address to query the range_info for.
+ ///
+ /// @param[out] range_info
+ /// An range_info value containing the details of the range.
+ ///
+ /// @return
+ /// An error value.
+ //------------------------------------------------------------------
+ virtual Error GetMemoryRegionInfo(lldb::addr_t load_addr,
+ MemoryRegionInfo &range_info) {
+ Error error;
+ error.SetErrorString("Process::GetMemoryRegionInfo() not supported");
+ return error;
+ }
+
+ //------------------------------------------------------------------
+ /// Obtain all the mapped memory regions within this process.
+ ///
+ /// @param[out] region_list
+ /// A vector to contain MemoryRegionInfo objects for all mapped
+ /// ranges.
+ ///
+ /// @return
+ /// An error value.
+ //------------------------------------------------------------------
+ virtual Error
+ GetMemoryRegions(std::vector<lldb::MemoryRegionInfoSP> &region_list);
+
+ virtual Error GetWatchpointSupportInfo(uint32_t &num) {
+ Error error;
+ num = 0;
+ error.SetErrorString("Process::GetWatchpointSupportInfo() not supported");
+ return error;
+ }
+
+ virtual Error GetWatchpointSupportInfo(uint32_t &num, bool &after) {
+ Error error;
+ num = 0;
+ after = true;
+ error.SetErrorString("Process::GetWatchpointSupportInfo() not supported");
+ return error;
+ }
+
+ lldb::ModuleSP ReadModuleFromMemory(const FileSpec &file_spec,
+ lldb::addr_t header_addr,
+ size_t size_to_read = 512);
+
+ //------------------------------------------------------------------
+ /// Attempt to get the attributes for a region of memory in the process.
+ ///
+ /// It may be possible for the remote debug server to inspect attributes
+ /// for a region of memory in the process, such as whether there is a
+ /// valid page of memory at a given address or whether that page is
+ /// readable/writable/executable by the process.
+ ///
+ /// @param[in] load_addr
+ /// The address of interest in the process.
+ ///
+ /// @param[out] permissions
+ /// If this call returns successfully, this bitmask will have
+ /// its Permissions bits set to indicate whether the region is
+ /// readable/writable/executable. If this call fails, the
+ /// bitmask values are undefined.
+ ///
+ /// @return
+ /// Returns true if it was able to determine the attributes of the
+ /// memory region. False if not.
+ //------------------------------------------------------------------
+ virtual bool GetLoadAddressPermissions(lldb::addr_t load_addr,
+ uint32_t &permissions);
+
+ //------------------------------------------------------------------
+ /// Determines whether executing JIT-compiled code in this process
+ /// is possible.
+ ///
+ /// @return
+ /// True if execution of JIT code is possible; false otherwise.
+ //------------------------------------------------------------------
+ bool CanJIT();
+
+ //------------------------------------------------------------------
+ /// Sets whether executing JIT-compiled code in this process
+ /// is possible.
+ ///
+ /// @param[in] can_jit
+ /// True if execution of JIT code is possible; false otherwise.
+ //------------------------------------------------------------------
+ void SetCanJIT(bool can_jit);
+
+ //------------------------------------------------------------------
+ /// Determines whether executing function calls using the interpreter
+ /// is possible for this process.
+ ///
+ /// @return
+ /// True if possible; false otherwise.
+ //------------------------------------------------------------------
+ bool CanInterpretFunctionCalls() { return m_can_interpret_function_calls; }
+
+ //------------------------------------------------------------------
+ /// Sets whether executing function calls using the interpreter
+ /// is possible for this process.
+ ///
+ /// @param[in] can_interpret_function_calls
+ /// True if possible; false otherwise.
+ //------------------------------------------------------------------
+ void SetCanInterpretFunctionCalls(bool can_interpret_function_calls) {
+ m_can_interpret_function_calls = can_interpret_function_calls;
+ }
+
+ //------------------------------------------------------------------
+ /// Sets whether executing code in this process is possible.
+ /// This could be either through JIT or interpreting.
+ ///
+ /// @param[in] can_run_code
+ /// True if execution of code is possible; false otherwise.
+ //------------------------------------------------------------------
+ void SetCanRunCode(bool can_run_code);
+
+ //------------------------------------------------------------------
+ /// Actually deallocate memory in the process.
+ ///
+ /// This function will deallocate memory in the process's address
+ /// space that was allocated with AllocateMemory.
+ ///
+ /// @param[in] ptr
+ /// A return value from AllocateMemory, pointing to the memory you
+ /// want to deallocate.
+ ///
+ /// @return
+ /// \btrue if the memory was deallocated, \bfalse otherwise.
+ //------------------------------------------------------------------
+ virtual Error DoDeallocateMemory(lldb::addr_t ptr) {
+ Error error;
+ error.SetErrorStringWithFormat(
+ "error: %s does not support deallocating in the debug process",
+ GetPluginName().GetCString());
+ return error;
+ }
+
+ //------------------------------------------------------------------
+ /// The public interface to deallocating memory in the process.
+ ///
+ /// This function will deallocate memory in the process's address
+ /// space that was allocated with AllocateMemory.
+ ///
+ /// @param[in] ptr
+ /// A return value from AllocateMemory, pointing to the memory you
+ /// want to deallocate.
+ ///
+ /// @return
+ /// \btrue if the memory was deallocated, \bfalse otherwise.
+ //------------------------------------------------------------------
+ Error DeallocateMemory(lldb::addr_t ptr);
+
+ //------------------------------------------------------------------
+ /// Get any available STDOUT.
+ ///
+ /// Calling this method is a valid operation only if all of the
+ /// following conditions are true:
+ /// 1) The process was launched, and not attached to.
+ /// 2) The process was not launched with eLaunchFlagDisableSTDIO.
+ /// 3) The process was launched without supplying a valid file path
+ /// for STDOUT.
+ ///
+ /// Note that the implementation will probably need to start a read
+ /// thread in the background to make sure that the pipe is drained
+ /// and the STDOUT buffered appropriately, to prevent the process
+ /// from deadlocking trying to write to a full buffer.
+ ///
+ /// Events will be queued indicating that there is STDOUT available
+ /// that can be retrieved using this function.
+ ///
+ /// @param[out] buf
+ /// A buffer that will receive any STDOUT bytes that are
+ /// currently available.
+ ///
+ /// @param[in] buf_size
+ /// The size in bytes for the buffer \a buf.
+ ///
+ /// @return
+ /// The number of bytes written into \a buf. If this value is
+ /// equal to \a buf_size, another call to this function should
+ /// be made to retrieve more STDOUT data.
+ //------------------------------------------------------------------
+ virtual size_t GetSTDOUT(char *buf, size_t buf_size, Error &error);
+
+ //------------------------------------------------------------------
+ /// Get any available STDERR.
+ ///
+ /// Calling this method is a valid operation only if all of the
+ /// following conditions are true:
+ /// 1) The process was launched, and not attached to.
+ /// 2) The process was not launched with eLaunchFlagDisableSTDIO.
+ /// 3) The process was launched without supplying a valid file path
+ /// for STDERR.
+ ///
+ /// Note that the implementation will probably need to start a read
+ /// thread in the background to make sure that the pipe is drained
+ /// and the STDERR buffered appropriately, to prevent the process
+ /// from deadlocking trying to write to a full buffer.
+ ///
+ /// Events will be queued indicating that there is STDERR available
+ /// that can be retrieved using this function.
+ ///
+ /// @param[in] buf
+ /// A buffer that will receive any STDERR bytes that are
+ /// currently available.
+ ///
+ /// @param[out] buf_size
+ /// The size in bytes for the buffer \a buf.
+ ///
+ /// @return
+ /// The number of bytes written into \a buf. If this value is
+ /// equal to \a buf_size, another call to this function should
+ /// be made to retrieve more STDERR data.
+ //------------------------------------------------------------------
+ virtual size_t GetSTDERR(char *buf, size_t buf_size, Error &error);
+
+ //------------------------------------------------------------------
+ /// Puts data into this process's STDIN.
+ ///
+ /// Calling this method is a valid operation only if all of the
+ /// following conditions are true:
+ /// 1) The process was launched, and not attached to.
+ /// 2) The process was not launched with eLaunchFlagDisableSTDIO.
+ /// 3) The process was launched without supplying a valid file path
+ /// for STDIN.
+ ///
+ /// @param[in] buf
+ /// A buffer that contains the data to write to the process's STDIN.
+ ///
+ /// @param[in] buf_size
+ /// The size in bytes for the buffer \a buf.
+ ///
+ /// @return
+ /// The number of bytes written into \a buf. If this value is
+ /// less than \a buf_size, another call to this function should
+ /// be made to write the rest of the data.
+ //------------------------------------------------------------------
+ virtual size_t PutSTDIN(const char *buf, size_t buf_size, Error &error) {
+ error.SetErrorString("stdin unsupported");
+ return 0;
+ }
+
+ //------------------------------------------------------------------
+ /// Get any available profile data.
+ ///
+ /// @param[out] buf
+ /// A buffer that will receive any profile data bytes that are
+ /// currently available.
+ ///
+ /// @param[out] buf_size
+ /// The size in bytes for the buffer \a buf.
+ ///
+ /// @return
+ /// The number of bytes written into \a buf. If this value is
+ /// equal to \a buf_size, another call to this function should
+ /// be made to retrieve more profile data.
+ //------------------------------------------------------------------
+ virtual size_t GetAsyncProfileData(char *buf, size_t buf_size, Error &error);
+
+ //----------------------------------------------------------------------
+ // Process Breakpoints
+ //----------------------------------------------------------------------
+ size_t GetSoftwareBreakpointTrapOpcode(BreakpointSite *bp_site);
+
+ virtual Error EnableBreakpointSite(BreakpointSite *bp_site) {
+ Error error;
+ error.SetErrorStringWithFormat(
+ "error: %s does not support enabling breakpoints",
+ GetPluginName().GetCString());
+ return error;
+ }
+
+ virtual Error DisableBreakpointSite(BreakpointSite *bp_site) {
+ Error error;
+ error.SetErrorStringWithFormat(
+ "error: %s does not support disabling breakpoints",
+ GetPluginName().GetCString());
+ return error;
+ }
+
+ // This is implemented completely using the lldb::Process API. Subclasses
+ // don't need to implement this function unless the standard flow of
+ // read existing opcode, write breakpoint opcode, verify breakpoint opcode
+ // doesn't work for a specific process plug-in.
+ virtual Error EnableSoftwareBreakpoint(BreakpointSite *bp_site);
+
+ // This is implemented completely using the lldb::Process API. Subclasses
+ // don't need to implement this function unless the standard flow of
+ // restoring original opcode in memory and verifying the restored opcode
+ // doesn't work for a specific process plug-in.
+ virtual Error DisableSoftwareBreakpoint(BreakpointSite *bp_site);
+
+ BreakpointSiteList &GetBreakpointSiteList();
+
+ const BreakpointSiteList &GetBreakpointSiteList() const;
+
+ void DisableAllBreakpointSites();
+
+ Error ClearBreakpointSiteByID(lldb::user_id_t break_id);
+
+ lldb::break_id_t CreateBreakpointSite(const lldb::BreakpointLocationSP &owner,
+ bool use_hardware);
+
+ Error DisableBreakpointSiteByID(lldb::user_id_t break_id);
+
+ Error EnableBreakpointSiteByID(lldb::user_id_t break_id);
+
+ // BreakpointLocations use RemoveOwnerFromBreakpointSite to remove
+ // themselves from the owner's list of this breakpoint sites.
+ void RemoveOwnerFromBreakpointSite(lldb::user_id_t owner_id,
+ lldb::user_id_t owner_loc_id,
+ lldb::BreakpointSiteSP &bp_site_sp);
+
+ //----------------------------------------------------------------------
+ // Process Watchpoints (optional)
+ //----------------------------------------------------------------------
+ virtual Error EnableWatchpoint(Watchpoint *wp, bool notify = true);
+
+ virtual Error DisableWatchpoint(Watchpoint *wp, bool notify = true);
+
+ //------------------------------------------------------------------
+ // Thread Queries
+ //------------------------------------------------------------------
+ virtual bool UpdateThreadList(ThreadList &old_thread_list,
+ ThreadList &new_thread_list) = 0;
+
+ void UpdateThreadListIfNeeded();
+
+ ThreadList &GetThreadList() { return m_thread_list; }
+
+ // When ExtendedBacktraces are requested, the HistoryThreads that are
+ // created need an owner -- they're saved here in the Process. The
+ // threads in this list are not iterated over - driver programs need to
+ // request the extended backtrace calls starting from a root concrete
+ // thread one by one.
+ ThreadList &GetExtendedThreadList() { return m_extended_thread_list; }
+
+ ThreadList::ThreadIterable Threads() { return m_thread_list.Threads(); }
+
+ uint32_t GetNextThreadIndexID(uint64_t thread_id);
+
+ lldb::ThreadSP CreateOSPluginThread(lldb::tid_t tid, lldb::addr_t context);
+
+ // Returns true if an index id has been assigned to a thread.
+ bool HasAssignedIndexIDToThread(uint64_t sb_thread_id);
+
+ // Given a thread_id, it will assign a more reasonable index id for display to
+ // the user.
+ // If the thread_id has previously been assigned, the same index id will be
+ // used.
+ uint32_t AssignIndexIDToThread(uint64_t thread_id);
+
+ //------------------------------------------------------------------
+ // Queue Queries
+ //------------------------------------------------------------------
+
+ void UpdateQueueListIfNeeded();
+
+ QueueList &GetQueueList() {
+ UpdateQueueListIfNeeded();
+ return m_queue_list;
+ }
+
+ QueueList::QueueIterable Queues() {
+ UpdateQueueListIfNeeded();
+ return m_queue_list.Queues();
+ }
+
+ //------------------------------------------------------------------
+ // Event Handling
+ //------------------------------------------------------------------
+ lldb::StateType GetNextEvent(lldb::EventSP &event_sp);
+
+ // Returns the process state when it is stopped. If specified, event_sp_ptr
+ // is set to the event which triggered the stop. If wait_always = false,
+ // and the process is already stopped, this function returns immediately.
+ // If the process is hijacked and use_run_lock is true (the default), then
+ // this
+ // function releases the run lock after the stop. Setting use_run_lock to
+ // false
+ // will avoid this behavior.
+ lldb::StateType
+ WaitForProcessToStop(const Timeout<std::micro> &timeout,
+ lldb::EventSP *event_sp_ptr = nullptr,
+ bool wait_always = true,
+ lldb::ListenerSP hijack_listener = lldb::ListenerSP(),
+ Stream *stream = nullptr, bool use_run_lock = true);
+
+ uint32_t GetIOHandlerID() const { return m_iohandler_sync.GetValue(); }
+
+ //--------------------------------------------------------------------------------------
+ /// Waits for the process state to be running within a given msec timeout.
+ ///
+ /// The main purpose of this is to implement an interlock waiting for
+ /// HandlePrivateEvent
+ /// to push an IOHandler.
+ ///
+ /// @param[in] timeout_msec
+ /// The maximum time length to wait for the process to transition to the
+ /// eStateRunning state, specified in milliseconds.
+ //--------------------------------------------------------------------------------------
+ void SyncIOHandler(uint32_t iohandler_id, uint64_t timeout_msec);
+
+ lldb::StateType GetStateChangedEvents(
+ lldb::EventSP &event_sp, const Timeout<std::micro> &timeout,
+ lldb::ListenerSP
+ hijack_listener); // Pass an empty ListenerSP to use builtin listener
+
+ //--------------------------------------------------------------------------------------
+ /// Centralize the code that handles and prints descriptions for process state
+ /// changes.
+ ///
+ /// @param[in] event_sp
+ /// The process state changed event
+ ///
+ /// @param[in] stream
+ /// The output stream to get the state change description
+ ///
+ /// @param[in,out] pop_process_io_handler
+ /// If this value comes in set to \b true, then pop the Process IOHandler
+ /// if needed.
+ /// Else this variable will be set to \b true or \b false to indicate if
+ /// the process
+ /// needs to have its process IOHandler popped.
+ ///
+ /// @return
+ /// \b true if the event describes a process state changed event, \b false
+ /// otherwise.
+ //--------------------------------------------------------------------------------------
+ static bool HandleProcessStateChangedEvent(const lldb::EventSP &event_sp,
+ Stream *stream,
+ bool &pop_process_io_handler);
+
+ Event *PeekAtStateChangedEvents();
+
+ class ProcessEventHijacker {
+ public:
+ ProcessEventHijacker(Process &process, lldb::ListenerSP listener_sp)
+ : m_process(process) {
+ m_process.HijackProcessEvents(listener_sp);
+ }
+
+ ~ProcessEventHijacker() { m_process.RestoreProcessEvents(); }
+
+ private:
+ Process &m_process;
+ };
+
+ friend class ProcessEventHijacker;
+ friend class ProcessProperties;
+ //------------------------------------------------------------------
+ /// If you need to ensure that you and only you will hear about some public
+ /// event, then make a new listener, set to listen to process events, and
+ /// then call this with that listener. Then you will have to wait on that
+ /// listener explicitly for events (rather than using the GetNextEvent &
+ /// WaitFor*
+ /// calls above. Be sure to call RestoreProcessEvents when you are done.
+ ///
+ /// @param[in] listener
+ /// This is the new listener to whom all process events will be delivered.
+ ///
+ /// @return
+ /// Returns \b true if the new listener could be installed,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool HijackProcessEvents(lldb::ListenerSP listener_sp);
+
+ //------------------------------------------------------------------
+ /// Restores the process event broadcasting to its normal state.
+ ///
+ //------------------------------------------------------------------
+ void RestoreProcessEvents();
+
+ const lldb::ABISP &GetABI();
+
+ OperatingSystem *GetOperatingSystem() { return m_os_ap.get(); }
+
+ ArchSpec::StopInfoOverrideCallbackType GetStopInfoOverrideCallback() const {
+ return m_stop_info_override_callback;
+ }
+
+ virtual LanguageRuntime *GetLanguageRuntime(lldb::LanguageType language,
+ bool retry_if_null = true);
+
+ virtual CPPLanguageRuntime *GetCPPLanguageRuntime(bool retry_if_null = true);
+
+ virtual ObjCLanguageRuntime *
+ GetObjCLanguageRuntime(bool retry_if_null = true);
+
+ bool IsPossibleDynamicValue(ValueObject &in_value);
+
+ bool IsRunning() const;
+
+ DynamicCheckerFunctions *GetDynamicCheckers() {
+ return m_dynamic_checkers_ap.get();
+ }
+
+ void SetDynamicCheckers(DynamicCheckerFunctions *dynamic_checkers);
+
+ //------------------------------------------------------------------
+ /// Call this to set the lldb in the mode where it breaks on new thread
+ /// creations, and then auto-restarts. This is useful when you are trying
+ /// to run only one thread, but either that thread or the kernel is creating
+ /// new threads in the process. If you stop when the thread is created, you
+ /// can immediately suspend it, and keep executing only the one thread you
+ /// intend.
+ ///
+ /// @return
+ /// Returns \b true if we were able to start up the notification
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ virtual bool StartNoticingNewThreads() { return true; }
+
+ //------------------------------------------------------------------
+ /// Call this to turn off the stop & notice new threads mode.
+ ///
+ /// @return
+ /// Returns \b true if we were able to start up the notification
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ virtual bool StopNoticingNewThreads() { return true; }
+
+ void SetRunningUserExpression(bool on);
+
+ //------------------------------------------------------------------
+ // lldb::ExecutionContextScope pure virtual functions
+ //------------------------------------------------------------------
+ lldb::TargetSP CalculateTarget() override;
+
+ lldb::ProcessSP CalculateProcess() override { return shared_from_this(); }
+
+ lldb::ThreadSP CalculateThread() override { return lldb::ThreadSP(); }
+
+ lldb::StackFrameSP CalculateStackFrame() override {
+ return lldb::StackFrameSP();
+ }
+
+ void CalculateExecutionContext(ExecutionContext &exe_ctx) override;
+
+ void SetSTDIOFileDescriptor(int file_descriptor);
+
+ //------------------------------------------------------------------
+ // Add a permanent region of memory that should never be read or
+ // written to. This can be used to ensure that memory reads or writes
+ // to certain areas of memory never end up being sent to the
+ // DoReadMemory or DoWriteMemory functions which can improve
+ // performance.
+ //------------------------------------------------------------------
+ void AddInvalidMemoryRegion(const LoadRange &region);
+
+ //------------------------------------------------------------------
+ // Remove a permanent region of memory that should never be read or
+ // written to that was previously added with AddInvalidMemoryRegion.
+ //------------------------------------------------------------------
+ bool RemoveInvalidMemoryRange(const LoadRange &region);
+
+ //------------------------------------------------------------------
+ // If the setup code of a thread plan needs to do work that might involve
+ // calling a function in the target, it should not do that work directly
+ // in one of the thread plan functions (DidPush/WillResume) because
+ // such work needs to be handled carefully. Instead, put that work in
+ // a PreResumeAction callback, and register it with the process. It will
+ // get done before the actual "DoResume" gets called.
+ //------------------------------------------------------------------
+
+ typedef bool(PreResumeActionCallback)(void *);
+
+ void AddPreResumeAction(PreResumeActionCallback callback, void *baton);
+
+ bool RunPreResumeActions();
+
+ void ClearPreResumeActions();
+
+ void ClearPreResumeAction(PreResumeActionCallback callback, void *baton);
+
+ ProcessRunLock &GetRunLock();
+
+ virtual Error SendEventData(const char *data) {
+ Error return_error("Sending an event is not supported for this process.");
+ return return_error;
+ }
+
+ lldb::ThreadCollectionSP GetHistoryThreads(lldb::addr_t addr);
+
+ lldb::InstrumentationRuntimeSP
+ GetInstrumentationRuntime(lldb::InstrumentationRuntimeType type);
+
+ //------------------------------------------------------------------
+ /// Try to fetch the module specification for a module with the
+ /// given file name and architecture. Process sub-classes have to
+ /// override this method if they support platforms where the
+ /// Platform object can't get the module spec for all module.
+ ///
+ /// @param[in] module_file_spec
+ /// The file name of the module to get specification for.
+ ///
+ /// @param[in] arch
+ /// The architecture of the module to get specification for.
+ ///
+ /// @param[out] module_spec
+ /// The fetched module specification if the return value is
+ /// \b true, unchanged otherwise.
+ ///
+ /// @return
+ /// Returns \b true if the module spec fetched successfully,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ virtual bool GetModuleSpec(const FileSpec &module_file_spec,
+ const ArchSpec &arch, ModuleSpec &module_spec);
+
+ virtual void PrefetchModuleSpecs(llvm::ArrayRef<FileSpec> module_file_specs,
+ const llvm::Triple &triple) {}
+
+ //------------------------------------------------------------------
+ /// Try to find the load address of a file.
+ /// The load address is defined as the address of the first memory
+ /// region what contains data mapped from the specified file.
+ ///
+ /// @param[in] file
+ /// The name of the file whose load address we are looking for
+ ///
+ /// @param[out] is_loaded
+ /// \b True if the file is loaded into the memory and false
+ /// otherwise.
+ ///
+ /// @param[out] load_addr
+ /// The load address of the file if it is loaded into the
+ /// processes address space, LLDB_INVALID_ADDRESS otherwise.
+ //------------------------------------------------------------------
+ virtual Error GetFileLoadAddress(const FileSpec &file, bool &is_loaded,
+ lldb::addr_t &load_addr) {
+ return Error("Not supported");
+ }
+
+ size_t AddImageToken(lldb::addr_t image_ptr);
+
+ lldb::addr_t GetImagePtrFromToken(size_t token) const;
+
+ void ResetImageToken(size_t token);
+
+ //------------------------------------------------------------------
+ /// Find the next branch instruction to set a breakpoint on
+ ///
+ /// When instruction stepping through a source line, instead of
+ /// stepping through each instruction, we can put a breakpoint on
+ /// the next branch instruction (within the range of instructions
+ /// we are stepping through) and continue the process to there,
+ /// yielding significant performance benefits over instruction
+ /// stepping.
+ ///
+ /// @param[in] default_stop_addr
+ /// The address of the instruction where lldb would put a
+ /// breakpoint normally.
+ ///
+ /// @param[in] range_bounds
+ /// The range which the breakpoint must be contained within.
+ /// Typically a source line.
+ ///
+ /// @return
+ /// The address of the next branch instruction, or the end of
+ /// the range provided in range_bounds. If there are any
+ /// problems with the disassembly or getting the instructions,
+ /// the original default_stop_addr will be returned.
+ //------------------------------------------------------------------
+ Address AdvanceAddressToNextBranchInstruction(Address default_stop_addr,
+ AddressRange range_bounds);
+
+ //------------------------------------------------------------------
+ /// Configure asynchronous structured data feature.
+ ///
+ /// Each Process type that supports using an asynchronous StructuredData
+ /// feature should implement this to enable/disable/configure the feature.
+ /// The default implementation here will always return an error indiciating
+ /// the feature is unsupported.
+ ///
+ /// StructuredDataPlugin implementations will call this to configure
+ /// a feature that has been reported as being supported.
+ ///
+ /// @param[in] type_name
+ /// The StructuredData type name as previously discovered by
+ /// the Process-derived instance.
+ ///
+ /// @param[in] config
+ /// Configuration data for the feature being enabled. This config
+ /// data, which may be null, will be passed along to the feature
+ /// to process. The feature will dictate whether this is a dictionary,
+ /// an array or some other object. If the feature needs to be
+ /// set up properly before it can be enabled, then the config should
+ /// also take an enable/disable flag.
+ ///
+ /// @return
+ /// Returns the result of attempting to configure the feature.
+ //------------------------------------------------------------------
+ virtual Error
+ ConfigureStructuredData(const ConstString &type_name,
+ const StructuredData::ObjectSP &config_sp);
+
+ //------------------------------------------------------------------
+ /// Broadcasts the given structured data object from the given
+ /// plugin.
+ ///
+ /// StructuredDataPlugin instances can use this to optionally
+ /// broadcast any of their data if they want to make it available
+ /// for clients. The data will come in on the structured data
+ /// event bit (eBroadcastBitStructuredData).
+ ///
+ /// @param[in] object_sp
+ /// The structured data object to broadcast.
+ ///
+ /// @param[in] plugin_sp
+ /// The plugin that will be reported in the event's plugin
+ /// parameter.
+ //------------------------------------------------------------------
+ void BroadcastStructuredData(const StructuredData::ObjectSP &object_sp,
+ const lldb::StructuredDataPluginSP &plugin_sp);
+
+ //------------------------------------------------------------------
+ /// Returns the StructuredDataPlugin associated with a given type
+ /// name, if there is one.
+ ///
+ /// There will only be a plugin for a given StructuredDataType if the
+ /// debugged process monitor claims that the feature is supported.
+ /// This is one way to tell whether a feature is available.
+ ///
+ /// @return
+ /// The plugin if one is available for the specified feature;
+ /// otherwise, returns an empty shared pointer.
+ //------------------------------------------------------------------
+ lldb::StructuredDataPluginSP
+ GetStructuredDataPlugin(const ConstString &type_name) const;
- //------------------------------------------------------------------
- /// Get any available profile data.
- ///
- /// @param[out] buf
- /// A buffer that will receive any profile data bytes that are
- /// currently available.
- ///
- /// @param[out] buf_size
- /// The size in bytes for the buffer \a buf.
- ///
- /// @return
- /// The number of bytes written into \a buf. If this value is
- /// equal to \a buf_size, another call to this function should
- /// be made to retrieve more profile data.
- //------------------------------------------------------------------
- virtual size_t
- GetAsyncProfileData (char *buf, size_t buf_size, Error &error);
-
- //----------------------------------------------------------------------
- // Process Breakpoints
- //----------------------------------------------------------------------
- size_t
- GetSoftwareBreakpointTrapOpcode (BreakpointSite* bp_site);
-
- virtual Error
- EnableBreakpointSite (BreakpointSite *bp_site)
- {
- Error error;
- error.SetErrorStringWithFormat("error: %s does not support enabling breakpoints", GetPluginName().GetCString());
- return error;
- }
+protected:
+ void SetState(lldb::EventSP &event_sp);
+
+ lldb::StateType GetPrivateState();
+
+ //------------------------------------------------------------------
+ /// The "private" side of resuming a process. This doesn't alter the
+ /// state of m_run_lock, but just causes the process to resume.
+ ///
+ /// @return
+ /// An Error object describing the success or failure of the resume.
+ //------------------------------------------------------------------
+ Error PrivateResume();
+
+ //------------------------------------------------------------------
+ // Called internally
+ //------------------------------------------------------------------
+ void CompleteAttach();
+
+ //------------------------------------------------------------------
+ /// Print a user-visible warning one time per Process
+ ///
+ /// A facility for printing a warning to the user once per repeat_key.
+ ///
+ /// warning_type is from the Process::Warnings enums.
+ /// repeat_key is a pointer value that will be used to ensure that the
+ /// warning message is not printed multiple times. For instance, with a
+ /// warning about a function being optimized, you can pass the CompileUnit
+ /// pointer to have the warning issued for only the first function in a
+ /// CU, or the Function pointer to have it issued once for every function,
+ /// or a Module pointer to have it issued once per Module.
+ ///
+ /// Classes outside Process should call a specific PrintWarning method
+ /// so that the warning strings are all centralized in Process, instead of
+ /// calling PrintWarning() directly.
+ ///
+ /// @param [in] warning_type
+ /// One of the types defined in Process::Warnings.
+ ///
+ /// @param [in] repeat_key
+ /// A pointer value used to ensure that the warning is only printed once.
+ /// May be nullptr, indicating that the warning is printed unconditionally
+ /// every time.
+ ///
+ /// @param [in] fmt
+ /// printf style format string
+ //------------------------------------------------------------------
+ void PrintWarning(uint64_t warning_type, const void *repeat_key,
+ const char *fmt, ...) __attribute__((format(printf, 4, 5)));
+
+ //------------------------------------------------------------------
+ // NextEventAction provides a way to register an action on the next
+ // event that is delivered to this process. There is currently only
+ // one next event action allowed in the process at one time. If a
+ // new "NextEventAction" is added while one is already present, the
+ // old action will be discarded (with HandleBeingUnshipped called
+ // after it is discarded.)
+ //
+ // If you want to resume the process as a result of a resume action,
+ // call RequestResume, don't call Resume directly.
+ //------------------------------------------------------------------
+ class NextEventAction {
+ public:
+ typedef enum EventActionResult {
+ eEventActionSuccess,
+ eEventActionRetry,
+ eEventActionExit
+ } EventActionResult;
+
+ NextEventAction(Process *process) : m_process(process) {}
+
+ virtual ~NextEventAction() = default;
+
+ virtual EventActionResult PerformAction(lldb::EventSP &event_sp) = 0;
+ virtual void HandleBeingUnshipped() {}
+ virtual EventActionResult HandleBeingInterrupted() = 0;
+ virtual const char *GetExitString() = 0;
+ void RequestResume() { m_process->m_resume_requested = true; }
+
+ protected:
+ Process *m_process;
+ };
+
+ void SetNextEventAction(Process::NextEventAction *next_event_action) {
+ if (m_next_event_action_ap.get())
+ m_next_event_action_ap->HandleBeingUnshipped();
+
+ m_next_event_action_ap.reset(next_event_action);
+ }
+
+ // This is the completer for Attaching:
+ class AttachCompletionHandler : public NextEventAction {
+ public:
+ AttachCompletionHandler(Process *process, uint32_t exec_count);
+
+ ~AttachCompletionHandler() override = default;
+
+ EventActionResult PerformAction(lldb::EventSP &event_sp) override;
+ EventActionResult HandleBeingInterrupted() override;
+ const char *GetExitString() override;
+
+ private:
+ uint32_t m_exec_count;
+ std::string m_exit_string;
+ };
+
+ bool PrivateStateThreadIsValid() const {
+ lldb::StateType state = m_private_state.GetValue();
+ return state != lldb::eStateInvalid && state != lldb::eStateDetached &&
+ state != lldb::eStateExited && m_private_state_thread.IsJoinable();
+ }
+
+ void ForceNextEventDelivery() { m_force_next_event_delivery = true; }
+
+ //------------------------------------------------------------------
+ /// Loads any plugins associated with asynchronous structured data
+ /// and maps the relevant supported type name to the plugin.
+ ///
+ /// Processes can receive asynchronous structured data from the
+ /// process monitor. This method will load and map any structured
+ /// data plugins that support the given set of supported type names.
+ /// Later, if any of these features are enabled, the process monitor
+ /// is free to generate asynchronous structured data. The data must
+ /// come in as a single \b StructuredData::Dictionary. That dictionary
+ /// must have a string field named 'type', with a value that equals
+ /// the relevant type name string (one of the values in
+ /// \b supported_type_names).
+ ///
+ /// @param[in] supported_type_names
+ /// An array of zero or more type names. Each must be unique.
+ /// For each entry in the list, a StructuredDataPlugin will be
+ /// searched for that supports the structured data type name.
+ //------------------------------------------------------------------
+ void MapSupportedStructuredDataPlugins(
+ const StructuredData::Array &supported_type_names);
+
+ //------------------------------------------------------------------
+ /// Route the incoming structured data dictionary to the right plugin.
+ ///
+ /// The incoming structured data must be a dictionary, and it must
+ /// have a key named 'type' that stores a string value. The string
+ /// value must be the name of the structured data feature that
+ /// knows how to handle it.
+ ///
+ /// @param[in] object_sp
+ /// When non-null and pointing to a dictionary, the 'type'
+ /// key's string value is used to look up the plugin that
+ /// was registered for that structured data type. It then
+ /// calls the following method on the StructuredDataPlugin
+ /// instance:
+ ///
+ /// virtual void
+ /// HandleArrivalOfStructuredData(Process &process,
+ /// const ConstString &type_name,
+ /// const StructuredData::ObjectSP
+ /// &object_sp)
+ ///
+ /// @return
+ /// True if the structured data was routed to a plugin; otherwise,
+ /// false.
+ //------------------------------------------------------------------
+ bool RouteAsyncStructuredData(const StructuredData::ObjectSP object_sp);
+
+ //------------------------------------------------------------------
+ // Type definitions
+ //------------------------------------------------------------------
+ typedef std::map<lldb::LanguageType, lldb::LanguageRuntimeSP>
+ LanguageRuntimeCollection;
+ typedef std::unordered_set<const void *> WarningsPointerSet;
+ typedef std::map<uint64_t, WarningsPointerSet> WarningsCollection;
+
+ struct PreResumeCallbackAndBaton {
+ bool (*callback)(void *);
+ void *baton;
+ PreResumeCallbackAndBaton(PreResumeActionCallback in_callback,
+ void *in_baton)
+ : callback(in_callback), baton(in_baton) {}
+ bool operator== (const PreResumeCallbackAndBaton &rhs) {
+ return callback == rhs.callback && baton == rhs.baton;
+ }
+ };
+
+ using StructuredDataPluginMap =
+ std::map<ConstString, lldb::StructuredDataPluginSP>;
+
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ std::weak_ptr<Target> m_target_sp; ///< The target that owns this process.
+ ThreadSafeValue<lldb::StateType> m_public_state;
+ ThreadSafeValue<lldb::StateType>
+ m_private_state; // The actual state of our process
+ Broadcaster m_private_state_broadcaster; // This broadcaster feeds state
+ // changed events into the private
+ // state thread's listener.
+ Broadcaster m_private_state_control_broadcaster; // This is the control
+ // broadcaster, used to
+ // pause, resume & stop the
+ // private state thread.
+ lldb::ListenerSP m_private_state_listener_sp; // This is the listener for the
+ // private state thread.
+ HostThread m_private_state_thread; ///< Thread ID for the thread that watches
+ ///internal state events
+ ProcessModID m_mod_id; ///< Tracks the state of the process over stops and
+ ///other alterations.
+ uint32_t m_process_unique_id; ///< Each lldb_private::Process class that is
+ ///created gets a unique integer ID that
+ ///increments with each new instance
+ uint32_t m_thread_index_id; ///< Each thread is created with a 1 based index
+ ///that won't get re-used.
+ std::map<uint64_t, uint32_t> m_thread_id_to_index_id_map;
+ int m_exit_status; ///< The exit status of the process, or -1 if not set.
+ std::string m_exit_string; ///< A textual description of why a process exited.
+ std::mutex m_exit_status_mutex; ///< Mutex so m_exit_status m_exit_string can
+ ///be safely accessed from multiple threads
+ std::recursive_mutex m_thread_mutex;
+ ThreadList m_thread_list_real; ///< The threads for this process as are known
+ ///to the protocol we are debugging with
+ ThreadList m_thread_list; ///< The threads for this process as the user will
+ ///see them. This is usually the same as
+ ///< m_thread_list_real, but might be different if there is an OS plug-in
+ ///creating memory threads
+ ThreadList m_extended_thread_list; ///< Owner for extended threads that may be
+ ///generated, cleared on natural stops
+ uint32_t m_extended_thread_stop_id; ///< The natural stop id when
+ ///extended_thread_list was last updated
+ QueueList
+ m_queue_list; ///< The list of libdispatch queues at a given stop point
+ uint32_t m_queue_list_stop_id; ///< The natural stop id when queue list was
+ ///last fetched
+ std::vector<Notifications> m_notifications; ///< The list of notifications
+ ///that this process can deliver.
+ std::vector<lldb::addr_t> m_image_tokens;
+ lldb::ListenerSP m_listener_sp; ///< Shared pointer to the listener used for
+ ///public events. Can not be empty.
+ BreakpointSiteList m_breakpoint_site_list; ///< This is the list of breakpoint
+ ///locations we intend to insert in
+ ///the target.
+ lldb::DynamicLoaderUP m_dyld_ap;
+ lldb::JITLoaderListUP m_jit_loaders_ap;
+ lldb::DynamicCheckerFunctionsUP m_dynamic_checkers_ap; ///< The functions used
+ ///by the expression
+ ///parser to validate
+ ///data that
+ ///expressions use.
+ lldb::OperatingSystemUP m_os_ap;
+ lldb::SystemRuntimeUP m_system_runtime_ap;
+ lldb::UnixSignalsSP
+ m_unix_signals_sp; /// This is the current signal set for this process.
+ lldb::ABISP m_abi_sp;
+ lldb::IOHandlerSP m_process_input_reader;
+ Communication m_stdio_communication;
+ std::recursive_mutex m_stdio_communication_mutex;
+ bool m_stdin_forward; /// Remember if stdin must be forwarded to remote debug
+ /// server
+ std::string m_stdout_data;
+ std::string m_stderr_data;
+ std::recursive_mutex m_profile_data_comm_mutex;
+ std::vector<std::string> m_profile_data;
+ Predicate<uint32_t> m_iohandler_sync;
+ MemoryCache m_memory_cache;
+ AllocatedMemoryCache m_allocated_memory_cache;
+ bool m_should_detach; /// Should we detach if the process object goes away
+ /// with an explicit call to Kill or Detach?
+ LanguageRuntimeCollection m_language_runtimes;
+ InstrumentationRuntimeCollection m_instrumentation_runtimes;
+ std::unique_ptr<NextEventAction> m_next_event_action_ap;
+ std::vector<PreResumeCallbackAndBaton> m_pre_resume_actions;
+ ProcessRunLock m_public_run_lock;
+ ProcessRunLock m_private_run_lock;
+ ArchSpec::StopInfoOverrideCallbackType m_stop_info_override_callback;
+ bool m_currently_handling_do_on_removals;
+ bool m_resume_requested; // If m_currently_handling_event or
+ // m_currently_handling_do_on_removals are true,
+ // Resume will only request a resume, using this flag
+ // to check.
+ bool m_finalizing; // This is set at the beginning of Process::Finalize() to
+ // stop functions from looking up or creating things during
+ // a finalize call
+ bool m_finalize_called; // This is set at the end of Process::Finalize()
+ bool m_clear_thread_plans_on_stop;
+ bool m_force_next_event_delivery;
+ lldb::StateType m_last_broadcast_state; /// This helps with the Public event
+ /// coalescing in
+ /// ShouldBroadcastEvent.
+ std::map<lldb::addr_t, lldb::addr_t> m_resolved_indirect_addresses;
+ bool m_destroy_in_process;
+ bool m_can_interpret_function_calls; // Some targets, e.g the OSX kernel,
+ // don't support the ability to modify
+ // the stack.
+ WarningsCollection m_warnings_issued; // A set of object pointers which have
+ // already had warnings printed
+ std::mutex m_run_thread_plan_lock;
+ StructuredDataPluginMap m_structured_data_plugin_map;
+
+ enum { eCanJITDontKnow = 0, eCanJITYes, eCanJITNo } m_can_jit;
+
+ size_t RemoveBreakpointOpcodesFromBuffer(lldb::addr_t addr, size_t size,
+ uint8_t *buf) const;
+
+ void SynchronouslyNotifyStateChanged(lldb::StateType state);
+
+ void SetPublicState(lldb::StateType new_state, bool restarted);
+
+ void SetPrivateState(lldb::StateType state);
+
+ bool StartPrivateStateThread(bool is_secondary_thread = false);
+
+ void StopPrivateStateThread();
+
+ void PausePrivateStateThread();
+
+ void ResumePrivateStateThread();
- virtual Error
- DisableBreakpointSite (BreakpointSite *bp_site)
- {
- Error error;
- error.SetErrorStringWithFormat("error: %s does not support disabling breakpoints", GetPluginName().GetCString());
- return error;
- }
+private:
+ struct PrivateStateThreadArgs {
+ PrivateStateThreadArgs(Process *p, bool s)
+ : process(p), is_secondary_thread(s){};
+ Process *process;
+ bool is_secondary_thread;
+ };
+
+ // arg is a pointer to a new'ed PrivateStateThreadArgs structure.
+ // PrivateStateThread will free it for you.
+ static lldb::thread_result_t PrivateStateThread(void *arg);
+
+ // The starts up the private state thread that will watch for events from the
+ // debugee.
+ // Pass true for is_secondary_thread in the case where you have to temporarily
+ // spin up a
+ // secondary state thread to handle events from a hand-called function on the
+ // primary
+ // private state thread.
+
+ lldb::thread_result_t RunPrivateStateThread(bool is_secondary_thread);
- // This is implemented completely using the lldb::Process API. Subclasses
- // don't need to implement this function unless the standard flow of
- // read existing opcode, write breakpoint opcode, verify breakpoint opcode
- // doesn't work for a specific process plug-in.
- virtual Error
- EnableSoftwareBreakpoint (BreakpointSite *bp_site);
-
- // This is implemented completely using the lldb::Process API. Subclasses
- // don't need to implement this function unless the standard flow of
- // restoring original opcode in memory and verifying the restored opcode
- // doesn't work for a specific process plug-in.
- virtual Error
- DisableSoftwareBreakpoint (BreakpointSite *bp_site);
-
- BreakpointSiteList &
- GetBreakpointSiteList();
-
- const BreakpointSiteList &
- GetBreakpointSiteList() const;
-
- void
- DisableAllBreakpointSites ();
-
- Error
- ClearBreakpointSiteByID (lldb::user_id_t break_id);
-
- lldb::break_id_t
- CreateBreakpointSite (const lldb::BreakpointLocationSP &owner,
- bool use_hardware);
-
- Error
- DisableBreakpointSiteByID (lldb::user_id_t break_id);
-
- Error
- EnableBreakpointSiteByID (lldb::user_id_t break_id);
-
- // BreakpointLocations use RemoveOwnerFromBreakpointSite to remove
- // themselves from the owner's list of this breakpoint sites.
- void
- RemoveOwnerFromBreakpointSite (lldb::user_id_t owner_id,
- lldb::user_id_t owner_loc_id,
- lldb::BreakpointSiteSP &bp_site_sp);
-
- //----------------------------------------------------------------------
- // Process Watchpoints (optional)
- //----------------------------------------------------------------------
- virtual Error
- EnableWatchpoint (Watchpoint *wp, bool notify = true);
-
- virtual Error
- DisableWatchpoint (Watchpoint *wp, bool notify = true);
-
- //------------------------------------------------------------------
- // Thread Queries
- //------------------------------------------------------------------
- virtual bool
- UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_thread_list) = 0;
-
- void
- UpdateThreadListIfNeeded ();
-
- ThreadList &
- GetThreadList ()
- {
- return m_thread_list;
- }
+protected:
+ void HandlePrivateEvent(lldb::EventSP &event_sp);
- // When ExtendedBacktraces are requested, the HistoryThreads that are
- // created need an owner -- they're saved here in the Process. The
- // threads in this list are not iterated over - driver programs need to
- // request the extended backtrace calls starting from a root concrete
- // thread one by one.
- ThreadList &
- GetExtendedThreadList ()
- {
- return m_extended_thread_list;
- }
+ Error HaltPrivate();
- ThreadList::ThreadIterable
- Threads ()
- {
- return m_thread_list.Threads();
- }
+ lldb::StateType WaitForProcessStopPrivate(lldb::EventSP &event_sp,
+ const Timeout<std::micro> &timeout);
- uint32_t
- GetNextThreadIndexID (uint64_t thread_id);
-
- lldb::ThreadSP
- CreateOSPluginThread (lldb::tid_t tid, lldb::addr_t context);
-
- // Returns true if an index id has been assigned to a thread.
- bool
- HasAssignedIndexIDToThread(uint64_t sb_thread_id);
-
- // Given a thread_id, it will assign a more reasonable index id for display to the user.
- // If the thread_id has previously been assigned, the same index id will be used.
- uint32_t
- AssignIndexIDToThread(uint64_t thread_id);
-
- //------------------------------------------------------------------
- // Queue Queries
- //------------------------------------------------------------------
-
- void
- UpdateQueueListIfNeeded ();
-
- QueueList &
- GetQueueList ()
- {
- UpdateQueueListIfNeeded();
- return m_queue_list;
- }
+ // This waits for both the state change broadcaster, and the control
+ // broadcaster.
+ // If control_only, it only waits for the control broadcaster.
- QueueList::QueueIterable
- Queues ()
- {
- UpdateQueueListIfNeeded();
- return m_queue_list.Queues();
- }
+ bool GetEventsPrivate(lldb::EventSP &event_sp,
+ const Timeout<std::micro> &timeout, bool control_only);
- //------------------------------------------------------------------
- // Event Handling
- //------------------------------------------------------------------
- lldb::StateType
- GetNextEvent (lldb::EventSP &event_sp);
-
- // Returns the process state when it is stopped. If specified, event_sp_ptr
- // is set to the event which triggered the stop. If wait_always = false,
- // and the process is already stopped, this function returns immediately.
- // If the process is hijacked and use_run_lock is true (the default), then this
- // function releases the run lock after the stop. Setting use_run_lock to false
- // will avoid this behavior.
- lldb::StateType
- WaitForProcessToStop(const TimeValue *timeout,
- lldb::EventSP *event_sp_ptr = nullptr,
- bool wait_always = true,
- lldb::ListenerSP hijack_listener = lldb::ListenerSP(),
- Stream *stream = nullptr,
- bool use_run_lock = true);
-
- uint32_t
- GetIOHandlerID () const
- {
- return m_iohandler_sync.GetValue();
- }
+ lldb::StateType
+ GetStateChangedEventsPrivate(lldb::EventSP &event_sp,
+ const Timeout<std::micro> &timeout);
- //--------------------------------------------------------------------------------------
- /// Waits for the process state to be running within a given msec timeout.
- ///
- /// The main purpose of this is to implement an interlock waiting for HandlePrivateEvent
- /// to push an IOHandler.
- ///
- /// @param[in] timeout_msec
- /// The maximum time length to wait for the process to transition to the
- /// eStateRunning state, specified in milliseconds.
- //--------------------------------------------------------------------------------------
- void
- SyncIOHandler (uint32_t iohandler_id, uint64_t timeout_msec);
-
- lldb::StateType
- WaitForStateChangedEvents(const TimeValue *timeout,
- lldb::EventSP &event_sp,
- lldb::ListenerSP hijack_listener); // Pass an empty ListenerSP to use builtin listener
-
- //--------------------------------------------------------------------------------------
- /// Centralize the code that handles and prints descriptions for process state changes.
- ///
- /// @param[in] event_sp
- /// The process state changed event
- ///
- /// @param[in] stream
- /// The output stream to get the state change description
- ///
- /// @param[in,out] pop_process_io_handler
- /// If this value comes in set to \b true, then pop the Process IOHandler if needed.
- /// Else this variable will be set to \b true or \b false to indicate if the process
- /// needs to have its process IOHandler popped.
- ///
- /// @return
- /// \b true if the event describes a process state changed event, \b false otherwise.
- //--------------------------------------------------------------------------------------
- static bool
- HandleProcessStateChangedEvent (const lldb::EventSP &event_sp,
- Stream *stream,
- bool &pop_process_io_handler);
-
- Event *
- PeekAtStateChangedEvents ();
-
- class
- ProcessEventHijacker
- {
- public:
- ProcessEventHijacker (Process &process, lldb::ListenerSP listener_sp) :
- m_process (process)
- {
- m_process.HijackProcessEvents (listener_sp);
- }
-
- ~ProcessEventHijacker ()
- {
- m_process.RestoreProcessEvents();
- }
-
- private:
- Process &m_process;
- };
-
- friend class ProcessEventHijacker;
- friend class ProcessProperties;
- //------------------------------------------------------------------
- /// If you need to ensure that you and only you will hear about some public
- /// event, then make a new listener, set to listen to process events, and
- /// then call this with that listener. Then you will have to wait on that
- /// listener explicitly for events (rather than using the GetNextEvent & WaitFor*
- /// calls above. Be sure to call RestoreProcessEvents when you are done.
- ///
- /// @param[in] listener
- /// This is the new listener to whom all process events will be delivered.
- ///
- /// @return
- /// Returns \b true if the new listener could be installed,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool
- HijackProcessEvents (lldb::ListenerSP listener_sp);
-
- //------------------------------------------------------------------
- /// Restores the process event broadcasting to its normal state.
- ///
- //------------------------------------------------------------------
- void
- RestoreProcessEvents ();
-
- const lldb::ABISP &
- GetABI ();
-
- OperatingSystem *
- GetOperatingSystem ()
- {
- return m_os_ap.get();
- }
+ size_t WriteMemoryPrivate(lldb::addr_t addr, const void *buf, size_t size,
+ Error &error);
- ArchSpec::StopInfoOverrideCallbackType
- GetStopInfoOverrideCallback () const
- {
- return m_stop_info_override_callback;
- }
+ void AppendSTDOUT(const char *s, size_t len);
- virtual LanguageRuntime *
- GetLanguageRuntime (lldb::LanguageType language, bool retry_if_null = true);
-
- virtual CPPLanguageRuntime *
- GetCPPLanguageRuntime (bool retry_if_null = true);
-
- virtual ObjCLanguageRuntime *
- GetObjCLanguageRuntime (bool retry_if_null = true);
-
- bool
- IsPossibleDynamicValue (ValueObject& in_value);
-
- bool
- IsRunning () const;
-
- DynamicCheckerFunctions *GetDynamicCheckers()
- {
- return m_dynamic_checkers_ap.get();
- }
-
- void SetDynamicCheckers(DynamicCheckerFunctions *dynamic_checkers);
-
- //------------------------------------------------------------------
- /// Call this to set the lldb in the mode where it breaks on new thread
- /// creations, and then auto-restarts. This is useful when you are trying
- /// to run only one thread, but either that thread or the kernel is creating
- /// new threads in the process. If you stop when the thread is created, you
- /// can immediately suspend it, and keep executing only the one thread you intend.
- ///
- /// @return
- /// Returns \b true if we were able to start up the notification
- /// \b false otherwise.
- //------------------------------------------------------------------
- virtual bool
- StartNoticingNewThreads()
- {
- return true;
- }
-
- //------------------------------------------------------------------
- /// Call this to turn off the stop & notice new threads mode.
- ///
- /// @return
- /// Returns \b true if we were able to start up the notification
- /// \b false otherwise.
- //------------------------------------------------------------------
- virtual bool
- StopNoticingNewThreads()
- {
- return true;
- }
-
- void
- SetRunningUserExpression (bool on);
-
- //------------------------------------------------------------------
- // lldb::ExecutionContextScope pure virtual functions
- //------------------------------------------------------------------
- lldb::TargetSP
- CalculateTarget() override;
-
- lldb::ProcessSP
- CalculateProcess() override
- {
- return shared_from_this();
- }
-
- lldb::ThreadSP
- CalculateThread() override
- {
- return lldb::ThreadSP();
- }
-
- lldb::StackFrameSP
- CalculateStackFrame() override
- {
- return lldb::StackFrameSP();
- }
+ void AppendSTDERR(const char *s, size_t len);
- void
- CalculateExecutionContext(ExecutionContext &exe_ctx) override;
-
- void
- SetSTDIOFileDescriptor (int file_descriptor);
-
- //------------------------------------------------------------------
- // Add a permanent region of memory that should never be read or
- // written to. This can be used to ensure that memory reads or writes
- // to certain areas of memory never end up being sent to the
- // DoReadMemory or DoWriteMemory functions which can improve
- // performance.
- //------------------------------------------------------------------
- void
- AddInvalidMemoryRegion (const LoadRange &region);
-
- //------------------------------------------------------------------
- // Remove a permanent region of memory that should never be read or
- // written to that was previously added with AddInvalidMemoryRegion.
- //------------------------------------------------------------------
- bool
- RemoveInvalidMemoryRange (const LoadRange &region);
-
- //------------------------------------------------------------------
- // If the setup code of a thread plan needs to do work that might involve
- // calling a function in the target, it should not do that work directly
- // in one of the thread plan functions (DidPush/WillResume) because
- // such work needs to be handled carefully. Instead, put that work in
- // a PreResumeAction callback, and register it with the process. It will
- // get done before the actual "DoResume" gets called.
- //------------------------------------------------------------------
-
- typedef bool (PreResumeActionCallback)(void *);
-
- void
- AddPreResumeAction (PreResumeActionCallback callback, void *baton);
-
- bool
- RunPreResumeActions ();
-
- void
- ClearPreResumeActions ();
-
- ProcessRunLock &
- GetRunLock ();
-
- virtual Error
- SendEventData(const char *data)
- {
- Error return_error ("Sending an event is not supported for this process.");
- return return_error;
- }
-
- lldb::ThreadCollectionSP
- GetHistoryThreads(lldb::addr_t addr);
-
- lldb::InstrumentationRuntimeSP
- GetInstrumentationRuntime(lldb::InstrumentationRuntimeType type);
-
- //------------------------------------------------------------------
- /// Try to fetch the module specification for a module with the
- /// given file name and architecture. Process sub-classes have to
- /// override this method if they support platforms where the
- /// Platform object can't get the module spec for all module.
- ///
- /// @param[in] module_file_spec
- /// The file name of the module to get specification for.
- ///
- /// @param[in] arch
- /// The architecture of the module to get specification for.
- ///
- /// @param[out] module_spec
- /// The fetched module specification if the return value is
- /// \b true, unchanged otherwise.
- ///
- /// @return
- /// Returns \b true if the module spec fetched successfully,
- /// \b false otherwise.
- //------------------------------------------------------------------
- virtual bool
- GetModuleSpec(const FileSpec& module_file_spec, const ArchSpec& arch, ModuleSpec &module_spec);
-
- //------------------------------------------------------------------
- /// Try to find the load address of a file.
- /// The load address is defined as the address of the first memory
- /// region what contains data mapped from the specified file.
- ///
- /// @param[in] file
- /// The name of the file whose load address we are looking for
- ///
- /// @param[out] is_loaded
- /// \b True if the file is loaded into the memory and false
- /// otherwise.
- ///
- /// @param[out] load_addr
- /// The load address of the file if it is loaded into the
- /// processes address space, LLDB_INVALID_ADDRESS otherwise.
- //------------------------------------------------------------------
- virtual Error
- GetFileLoadAddress(const FileSpec& file, bool& is_loaded, lldb::addr_t& load_addr)
- {
- return Error("Not supported");
- }
+ void BroadcastAsyncProfileData(const std::string &one_profile_data);
- size_t
- AddImageToken(lldb::addr_t image_ptr);
-
- lldb::addr_t
- GetImagePtrFromToken(size_t token) const;
-
- void
- ResetImageToken(size_t token);
-
- //------------------------------------------------------------------
- /// Find the next branch instruction to set a breakpoint on
- ///
- /// When instruction stepping through a source line, instead of
- /// stepping through each instruction, we can put a breakpoint on
- /// the next branch instruction (within the range of instructions
- /// we are stepping through) and continue the process to there,
- /// yielding significant performance benefits over instruction
- /// stepping.
- ///
- /// @param[in] default_stop_addr
- /// The address of the instruction where lldb would put a
- /// breakpoint normally.
- ///
- /// @param[in] range_bounds
- /// The range which the breakpoint must be contained within.
- /// Typically a source line.
- ///
- /// @return
- /// The address of the next branch instruction, or the end of
- /// the range provided in range_bounds. If there are any
- /// problems with the disassembly or getting the instructions,
- /// the original default_stop_addr will be returned.
- //------------------------------------------------------------------
- Address
- AdvanceAddressToNextBranchInstruction (Address default_stop_addr,
- AddressRange range_bounds);
+ static void STDIOReadThreadBytesReceived(void *baton, const void *src,
+ size_t src_len);
-protected:
- void
- SetState (lldb::EventSP &event_sp);
-
- lldb::StateType
- GetPrivateState ();
-
- //------------------------------------------------------------------
- /// The "private" side of resuming a process. This doesn't alter the
- /// state of m_run_lock, but just causes the process to resume.
- ///
- /// @return
- /// An Error object describing the success or failure of the resume.
- //------------------------------------------------------------------
- Error
- PrivateResume ();
-
- //------------------------------------------------------------------
- // Called internally
- //------------------------------------------------------------------
- void
- CompleteAttach ();
-
- //------------------------------------------------------------------
- /// Print a user-visible warning one time per Process
- ///
- /// A facility for printing a warning to the user once per repeat_key.
- ///
- /// warning_type is from the Process::Warnings enums.
- /// repeat_key is a pointer value that will be used to ensure that the
- /// warning message is not printed multiple times. For instance, with a
- /// warning about a function being optimized, you can pass the CompileUnit
- /// pointer to have the warning issued for only the first function in a
- /// CU, or the Function pointer to have it issued once for every function,
- /// or a Module pointer to have it issued once per Module.
- ///
- /// Classes outside Process should call a specific PrintWarning method
- /// so that the warning strings are all centralized in Process, instead of
- /// calling PrintWarning() directly.
- ///
- /// @param [in] warning_type
- /// One of the types defined in Process::Warnings.
- ///
- /// @param [in] repeat_key
- /// A pointer value used to ensure that the warning is only printed once.
- /// May be nullptr, indicating that the warning is printed unconditionally
- /// every time.
- ///
- /// @param [in] fmt
- /// printf style format string
- //------------------------------------------------------------------
- void
- PrintWarning (uint64_t warning_type, const void *repeat_key, const char *fmt, ...) __attribute__((format(printf, 4, 5)));
-
- //------------------------------------------------------------------
- // NextEventAction provides a way to register an action on the next
- // event that is delivered to this process. There is currently only
- // one next event action allowed in the process at one time. If a
- // new "NextEventAction" is added while one is already present, the
- // old action will be discarded (with HandleBeingUnshipped called
- // after it is discarded.)
- //
- // If you want to resume the process as a result of a resume action,
- // call RequestResume, don't call Resume directly.
- //------------------------------------------------------------------
- class NextEventAction
- {
- public:
- typedef enum EventActionResult
- {
- eEventActionSuccess,
- eEventActionRetry,
- eEventActionExit
- } EventActionResult;
-
- NextEventAction (Process *process) :
- m_process(process)
- {
- }
-
- virtual
- ~NextEventAction() = default;
-
- virtual EventActionResult PerformAction (lldb::EventSP &event_sp) = 0;
- virtual void HandleBeingUnshipped () {}
- virtual EventActionResult HandleBeingInterrupted () = 0;
- virtual const char *GetExitString() = 0;
- void RequestResume()
- {
- m_process->m_resume_requested = true;
- }
-
- protected:
- Process *m_process;
- };
-
- void SetNextEventAction (Process::NextEventAction *next_event_action)
- {
- if (m_next_event_action_ap.get())
- m_next_event_action_ap->HandleBeingUnshipped();
-
- m_next_event_action_ap.reset(next_event_action);
- }
-
- // This is the completer for Attaching:
- class AttachCompletionHandler : public NextEventAction
- {
- public:
- AttachCompletionHandler (Process *process, uint32_t exec_count);
-
- ~AttachCompletionHandler() override = default;
-
- EventActionResult PerformAction(lldb::EventSP &event_sp) override;
- EventActionResult HandleBeingInterrupted() override;
- const char *GetExitString() override;
-
- private:
- uint32_t m_exec_count;
- std::string m_exit_string;
- };
-
- bool
- PrivateStateThreadIsValid () const
- {
- lldb::StateType state = m_private_state.GetValue();
- return state != lldb::eStateInvalid &&
- state != lldb::eStateDetached &&
- state != lldb::eStateExited &&
- m_private_state_thread.IsJoinable();
- }
+ bool PushProcessIOHandler();
- void
- ForceNextEventDelivery()
- {
- m_force_next_event_delivery = true;
- }
+ bool PopProcessIOHandler();
- //------------------------------------------------------------------
- // Type definitions
- //------------------------------------------------------------------
- typedef std::map<lldb::LanguageType, lldb::LanguageRuntimeSP> LanguageRuntimeCollection;
- typedef std::unordered_set<const void *> WarningsPointerSet;
- typedef std::map<uint64_t, WarningsPointerSet> WarningsCollection;
-
- struct PreResumeCallbackAndBaton
- {
- bool (*callback) (void *);
- void *baton;
- PreResumeCallbackAndBaton (PreResumeActionCallback in_callback, void *in_baton) :
- callback (in_callback),
- baton (in_baton)
- {
- }
- };
-
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- std::weak_ptr<Target> m_target_sp; ///< The target that owns this process.
- ThreadSafeValue<lldb::StateType> m_public_state;
- ThreadSafeValue<lldb::StateType> m_private_state; // The actual state of our process
- Broadcaster m_private_state_broadcaster; // This broadcaster feeds state changed events into the private state thread's listener.
- Broadcaster m_private_state_control_broadcaster; // This is the control broadcaster, used to pause, resume & stop the private state thread.
- lldb::ListenerSP m_private_state_listener_sp; // This is the listener for the private state thread.
- HostThread m_private_state_thread; ///< Thread ID for the thread that watches internal state events
- ProcessModID m_mod_id; ///< Tracks the state of the process over stops and other alterations.
- uint32_t m_process_unique_id; ///< Each lldb_private::Process class that is created gets a unique integer ID that increments with each new instance
- uint32_t m_thread_index_id; ///< Each thread is created with a 1 based index that won't get re-used.
- std::map<uint64_t, uint32_t> m_thread_id_to_index_id_map;
- int m_exit_status; ///< The exit status of the process, or -1 if not set.
- std::string m_exit_string; ///< A textual description of why a process exited.
- std::mutex
- m_exit_status_mutex; ///< Mutex so m_exit_status m_exit_string can be safely accessed from multiple threads
- std::recursive_mutex m_thread_mutex;
- ThreadList m_thread_list_real; ///< The threads for this process as are known to the protocol we are debugging with
- ThreadList m_thread_list; ///< The threads for this process as the user will see them. This is usually the same as
- ///< m_thread_list_real, but might be different if there is an OS plug-in creating memory threads
- ThreadList m_extended_thread_list; ///< Owner for extended threads that may be generated, cleared on natural stops
- uint32_t m_extended_thread_stop_id; ///< The natural stop id when extended_thread_list was last updated
- QueueList m_queue_list; ///< The list of libdispatch queues at a given stop point
- uint32_t m_queue_list_stop_id; ///< The natural stop id when queue list was last fetched
- std::vector<Notifications> m_notifications; ///< The list of notifications that this process can deliver.
- std::vector<lldb::addr_t> m_image_tokens;
- lldb::ListenerSP m_listener_sp; ///< Shared pointer to the listener used for public events. Can not be empty.
- BreakpointSiteList m_breakpoint_site_list; ///< This is the list of breakpoint locations we intend to insert in the target.
- lldb::DynamicLoaderUP m_dyld_ap;
- lldb::JITLoaderListUP m_jit_loaders_ap;
- lldb::DynamicCheckerFunctionsUP m_dynamic_checkers_ap; ///< The functions used by the expression parser to validate data that expressions use.
- lldb::OperatingSystemUP m_os_ap;
- lldb::SystemRuntimeUP m_system_runtime_ap;
- lldb::UnixSignalsSP m_unix_signals_sp; /// This is the current signal set for this process.
- lldb::ABISP m_abi_sp;
- lldb::IOHandlerSP m_process_input_reader;
- Communication m_stdio_communication;
- std::recursive_mutex m_stdio_communication_mutex;
- bool m_stdin_forward; /// Remember if stdin must be forwarded to remote debug server
- std::string m_stdout_data;
- std::string m_stderr_data;
- std::recursive_mutex m_profile_data_comm_mutex;
- std::vector<std::string> m_profile_data;
- Predicate<uint32_t> m_iohandler_sync;
- MemoryCache m_memory_cache;
- AllocatedMemoryCache m_allocated_memory_cache;
- bool m_should_detach; /// Should we detach if the process object goes away with an explicit call to Kill or Detach?
- LanguageRuntimeCollection m_language_runtimes;
- InstrumentationRuntimeCollection m_instrumentation_runtimes;
- std::unique_ptr<NextEventAction> m_next_event_action_ap;
- std::vector<PreResumeCallbackAndBaton> m_pre_resume_actions;
- ProcessRunLock m_public_run_lock;
- ProcessRunLock m_private_run_lock;
- ArchSpec::StopInfoOverrideCallbackType m_stop_info_override_callback;
- bool m_currently_handling_do_on_removals;
- bool m_resume_requested; // If m_currently_handling_event or m_currently_handling_do_on_removals are true, Resume will only request a resume, using this flag to check.
- bool m_finalizing; // This is set at the beginning of Process::Finalize() to stop functions from looking up or creating things during a finalize call
- bool m_finalize_called; // This is set at the end of Process::Finalize()
- bool m_clear_thread_plans_on_stop;
- bool m_force_next_event_delivery;
- lldb::StateType m_last_broadcast_state; /// This helps with the Public event coalescing in ShouldBroadcastEvent.
- std::map<lldb::addr_t,lldb::addr_t> m_resolved_indirect_addresses;
- bool m_destroy_in_process;
- bool m_can_interpret_function_calls; // Some targets, e.g the OSX kernel, don't support the ability to modify the stack.
- WarningsCollection m_warnings_issued; // A set of object pointers which have already had warnings printed
- std::mutex m_run_thread_plan_lock;
-
- enum {
- eCanJITDontKnow= 0,
- eCanJITYes,
- eCanJITNo
- } m_can_jit;
-
- size_t
- RemoveBreakpointOpcodesFromBuffer (lldb::addr_t addr, size_t size, uint8_t *buf) const;
-
- void
- SynchronouslyNotifyStateChanged (lldb::StateType state);
-
- void
- SetPublicState (lldb::StateType new_state, bool restarted);
-
- void
- SetPrivateState (lldb::StateType state);
-
- bool
- StartPrivateStateThread (bool is_secondary_thread = false);
-
- void
- StopPrivateStateThread ();
-
- void
- PausePrivateStateThread ();
-
- void
- ResumePrivateStateThread ();
+ bool ProcessIOHandlerIsActive();
-private:
- struct PrivateStateThreadArgs
- {
- PrivateStateThreadArgs(Process *p, bool s) : process(p), is_secondary_thread(s) {};
- Process *process;
- bool is_secondary_thread;
- };
-
- // arg is a pointer to a new'ed PrivateStateThreadArgs structure. PrivateStateThread will free it for you.
- static lldb::thread_result_t
- PrivateStateThread (void *arg);
-
- // The starts up the private state thread that will watch for events from the debugee.
- // Pass true for is_secondary_thread in the case where you have to temporarily spin up a
- // secondary state thread to handle events from a hand-called function on the primary
- // private state thread.
-
- lldb::thread_result_t
- RunPrivateStateThread (bool is_secondary_thread);
+ bool ProcessIOHandlerExists() const {
+ return static_cast<bool>(m_process_input_reader);
+ }
-protected:
- void
- HandlePrivateEvent (lldb::EventSP &event_sp);
-
- Error
- HaltPrivate();
-
- lldb::StateType
- WaitForProcessStopPrivate (const TimeValue *timeout, lldb::EventSP &event_sp);
-
- // This waits for both the state change broadcaster, and the control broadcaster.
- // If control_only, it only waits for the control broadcaster.
-
- bool
- WaitForEventsPrivate (const TimeValue *timeout, lldb::EventSP &event_sp, bool control_only);
-
- lldb::StateType
- WaitForStateChangedEventsPrivate (const TimeValue *timeout, lldb::EventSP &event_sp);
-
- lldb::StateType
- WaitForState (const TimeValue *timeout,
- const lldb::StateType *match_states,
- const uint32_t num_match_states);
-
- size_t
- WriteMemoryPrivate (lldb::addr_t addr, const void *buf, size_t size, Error &error);
-
- void
- AppendSTDOUT (const char *s, size_t len);
-
- void
- AppendSTDERR (const char *s, size_t len);
-
- void
- BroadcastAsyncProfileData(const std::string &one_profile_data);
-
- static void
- STDIOReadThreadBytesReceived (void *baton, const void *src, size_t src_len);
-
- bool
- PushProcessIOHandler ();
-
- bool
- PopProcessIOHandler ();
-
- bool
- ProcessIOHandlerIsActive ();
-
- bool
- ProcessIOHandlerExists () const
- {
- return static_cast<bool>(m_process_input_reader);
- }
-
- Error
- StopForDestroyOrDetach(lldb::EventSP &exit_event_sp);
+ Error StopForDestroyOrDetach(lldb::EventSP &exit_event_sp);
- bool
- StateChangedIsExternallyHijacked();
+ bool StateChangedIsExternallyHijacked();
- void
- LoadOperatingSystemPlugin(bool flush);
+ void LoadOperatingSystemPlugin(bool flush);
private:
- //------------------------------------------------------------------
- /// This is the part of the event handling that for a process event.
- /// It decides what to do with the event and returns true if the
- /// event needs to be propagated to the user, and false otherwise.
- /// If the event is not propagated, this call will most likely set
- /// the target to executing again.
- /// There is only one place where this call should be called, HandlePrivateEvent.
- /// Don't call it from anywhere else...
- ///
- /// @param[in] event_ptr
- /// This is the event we are handling.
- ///
- /// @return
- /// Returns \b true if the event should be reported to the
- /// user, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ShouldBroadcastEvent (Event *event_ptr);
-
- void ControlPrivateStateThread (uint32_t signal);
-
- DISALLOW_COPY_AND_ASSIGN (Process);
+ //------------------------------------------------------------------
+ /// This is the part of the event handling that for a process event.
+ /// It decides what to do with the event and returns true if the
+ /// event needs to be propagated to the user, and false otherwise.
+ /// If the event is not propagated, this call will most likely set
+ /// the target to executing again.
+ /// There is only one place where this call should be called,
+ /// HandlePrivateEvent.
+ /// Don't call it from anywhere else...
+ ///
+ /// @param[in] event_ptr
+ /// This is the event we are handling.
+ ///
+ /// @return
+ /// Returns \b true if the event should be reported to the
+ /// user, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ShouldBroadcastEvent(Event *event_ptr);
+
+ void ControlPrivateStateThread(uint32_t signal);
+
+ DISALLOW_COPY_AND_ASSIGN(Process);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/ProcessInfo.h b/include/lldb/Target/ProcessInfo.h
index 1539e043d6fc..f8d37fa4ebb4 100644
--- a/include/lldb/Target/ProcessInfo.h
+++ b/include/lldb/Target/ProcessInfo.h
@@ -15,174 +15,89 @@
#include "lldb/Host/FileSpec.h"
#include "lldb/Interpreter/Args.h"
-namespace lldb_private
-{
- //----------------------------------------------------------------------
- // ProcessInfo
- //
- // A base class for information for a process. This can be used to fill
- // out information for a process prior to launching it, or it can be
- // used for an instance of a process and can be filled in with the
- // existing values for that process.
- //----------------------------------------------------------------------
- class ProcessInfo
- {
- public:
- ProcessInfo ();
-
- ProcessInfo (const char *name,
- const ArchSpec &arch,
- lldb::pid_t pid);
-
- void
- Clear ();
-
- const char *
- GetName() const;
-
- size_t
- GetNameLength() const;
-
- FileSpec &
- GetExecutableFile ()
- {
- return m_executable;
- }
-
- void
- SetExecutableFile (const FileSpec &exe_file, bool add_exe_file_as_first_arg);
-
- const FileSpec &
- GetExecutableFile () const
- {
- return m_executable;
- }
-
- uint32_t
- GetUserID() const
- {
- return m_uid;
- }
-
- uint32_t
- GetGroupID() const
- {
- return m_gid;
- }
-
- bool
- UserIDIsValid () const
- {
- return m_uid != UINT32_MAX;
- }
-
- bool
- GroupIDIsValid () const
- {
- return m_gid != UINT32_MAX;
- }
-
- void
- SetUserID (uint32_t uid)
- {
- m_uid = uid;
- }
-
- void
- SetGroupID (uint32_t gid)
- {
- m_gid = gid;
- }
-
- ArchSpec &
- GetArchitecture ()
- {
- return m_arch;
- }
-
- const ArchSpec &
- GetArchitecture () const
- {
- return m_arch;
- }
-
- void
- SetArchitecture (const ArchSpec& arch)
- {
- m_arch = arch;
- }
-
- lldb::pid_t
- GetProcessID () const
- {
- return m_pid;
- }
-
- void
- SetProcessID (lldb::pid_t pid)
- {
- m_pid = pid;
- }
-
- bool
- ProcessIDIsValid() const
- {
- return m_pid != LLDB_INVALID_PROCESS_ID;
- }
-
- void
- Dump (Stream &s, Platform *platform) const;
-
- Args &
- GetArguments ()
- {
- return m_arguments;
- }
-
- const Args &
- GetArguments () const
- {
- return m_arguments;
- }
-
- const char *
- GetArg0 () const;
-
- void
- SetArg0 (const char *arg);
-
- void
- SetArguments (const Args& args, bool first_arg_is_executable);
-
- void
- SetArguments (char const **argv, bool first_arg_is_executable);
-
- Args &
- GetEnvironmentEntries ()
- {
- return m_environment;
- }
-
- const Args &
- GetEnvironmentEntries () const
- {
- return m_environment;
- }
-
- protected:
- FileSpec m_executable;
- std::string m_arg0; // argv[0] if supported. If empty, then use m_executable.
- // Not all process plug-ins support specifying an argv[0]
- // that differs from the resolved platform executable
- // (which is in m_executable)
- Args m_arguments; // All program arguments except argv[0]
- Args m_environment;
- uint32_t m_uid;
- uint32_t m_gid;
- ArchSpec m_arch;
- lldb::pid_t m_pid;
- };
+namespace lldb_private {
+//----------------------------------------------------------------------
+// ProcessInfo
+//
+// A base class for information for a process. This can be used to fill
+// out information for a process prior to launching it, or it can be
+// used for an instance of a process and can be filled in with the
+// existing values for that process.
+//----------------------------------------------------------------------
+class ProcessInfo {
+public:
+ ProcessInfo();
+
+ ProcessInfo(const char *name, const ArchSpec &arch, lldb::pid_t pid);
+
+ void Clear();
+
+ const char *GetName() const;
+
+ size_t GetNameLength() const;
+
+ FileSpec &GetExecutableFile() { return m_executable; }
+
+ void SetExecutableFile(const FileSpec &exe_file,
+ bool add_exe_file_as_first_arg);
+
+ const FileSpec &GetExecutableFile() const { return m_executable; }
+
+ uint32_t GetUserID() const { return m_uid; }
+
+ uint32_t GetGroupID() const { return m_gid; }
+
+ bool UserIDIsValid() const { return m_uid != UINT32_MAX; }
+
+ bool GroupIDIsValid() const { return m_gid != UINT32_MAX; }
+
+ void SetUserID(uint32_t uid) { m_uid = uid; }
+
+ void SetGroupID(uint32_t gid) { m_gid = gid; }
+
+ ArchSpec &GetArchitecture() { return m_arch; }
+
+ const ArchSpec &GetArchitecture() const { return m_arch; }
+
+ void SetArchitecture(const ArchSpec &arch) { m_arch = arch; }
+
+ lldb::pid_t GetProcessID() const { return m_pid; }
+
+ void SetProcessID(lldb::pid_t pid) { m_pid = pid; }
+
+ bool ProcessIDIsValid() const { return m_pid != LLDB_INVALID_PROCESS_ID; }
+
+ void Dump(Stream &s, Platform *platform) const;
+
+ Args &GetArguments() { return m_arguments; }
+
+ const Args &GetArguments() const { return m_arguments; }
+
+ llvm::StringRef GetArg0() const;
+
+ void SetArg0(llvm::StringRef arg);
+
+ void SetArguments(const Args &args, bool first_arg_is_executable);
+
+ void SetArguments(char const **argv, bool first_arg_is_executable);
+
+ Args &GetEnvironmentEntries() { return m_environment; }
+
+ const Args &GetEnvironmentEntries() const { return m_environment; }
+
+protected:
+ FileSpec m_executable;
+ std::string m_arg0; // argv[0] if supported. If empty, then use m_executable.
+ // Not all process plug-ins support specifying an argv[0]
+ // that differs from the resolved platform executable
+ // (which is in m_executable)
+ Args m_arguments; // All program arguments except argv[0]
+ Args m_environment;
+ uint32_t m_uid;
+ uint32_t m_gid;
+ ArchSpec m_arch;
+ lldb::pid_t m_pid;
+};
}
#endif // #ifndef liblldb_ProcessInfo_h_
-
diff --git a/include/lldb/Target/ProcessLaunchInfo.h b/include/lldb/Target/ProcessLaunchInfo.h
index d1a45794b551..2c192c24da87 100644
--- a/include/lldb/Target/ProcessLaunchInfo.h
+++ b/include/lldb/Target/ProcessLaunchInfo.h
@@ -21,224 +21,144 @@
#include "lldb/Target/ProcessInfo.h"
#include "lldb/Utility/PseudoTerminal.h"
-namespace lldb_private
-{
-
- //----------------------------------------------------------------------
- // ProcessLaunchInfo
- //
- // Describes any information that is required to launch a process.
- //----------------------------------------------------------------------
-
- class ProcessLaunchInfo : public ProcessInfo
- {
- public:
-
- ProcessLaunchInfo ();
-
- ProcessLaunchInfo(const FileSpec &stdin_file_spec,
- const FileSpec &stdout_file_spec,
- const FileSpec &stderr_file_spec,
- const FileSpec &working_dir,
- uint32_t launch_flags);
-
- void
- AppendFileAction (const FileAction &info)
- {
- m_file_actions.push_back(info);
- }
-
- bool
- AppendCloseFileAction (int fd);
-
- bool
- AppendDuplicateFileAction (int fd, int dup_fd);
-
- bool
- AppendOpenFileAction(int fd, const FileSpec &file_spec,
- bool read, bool write);
-
- bool
- AppendSuppressFileAction (int fd, bool read, bool write);
-
- void
- FinalizeFileActions (Target *target,
- bool default_to_use_pty);
-
- size_t
- GetNumFileActions () const
- {
- return m_file_actions.size();
- }
-
- const FileAction *
- GetFileActionAtIndex (size_t idx) const;
-
- const FileAction *
- GetFileActionForFD (int fd) const;
-
- Flags &
- GetFlags ()
- {
- return m_flags;
- }
-
- const Flags &
- GetFlags () const
- {
- return m_flags;
- }
-
- const FileSpec &
- GetWorkingDirectory() const;
-
- void
- SetWorkingDirectory(const FileSpec &working_dir);
-
- const char *
- GetProcessPluginName () const;
-
- void
- SetProcessPluginName (const char *plugin);
-
- const FileSpec &
- GetShell () const;
-
- void
- SetShell (const FileSpec &shell);
-
- uint32_t
- GetResumeCount () const
- {
- return m_resume_count;
- }
-
- void
- SetResumeCount (uint32_t c)
- {
- m_resume_count = c;
- }
-
- bool
- GetLaunchInSeparateProcessGroup() const
- {
- return m_flags.Test(lldb::eLaunchFlagLaunchInSeparateProcessGroup);
- }
-
- void
- SetLaunchInSeparateProcessGroup (bool separate);
-
- bool
- GetShellExpandArguments () const
- {
- return m_flags.Test(lldb::eLaunchFlagShellExpandArguments);
- }
-
- void
- SetShellExpandArguments (bool expand);
-
- void
- Clear ();
-
- bool
- ConvertArgumentsForLaunchingInShell (Error &error,
- bool localhost,
- bool will_debug,
- bool first_arg_is_full_shell_command,
- int32_t num_resumes);
-
- void
- SetMonitorProcessCallback(const Host::MonitorChildProcessCallback &callback, bool monitor_signals);
-
- Host::MonitorChildProcessCallback
- GetMonitorProcessCallback() const
- {
- return m_monitor_callback;
- }
-
- bool
- GetMonitorSignals() const
- {
- return m_monitor_signals;
- }
-
- // If the LaunchInfo has a monitor callback, then arrange to monitor the process.
- // Return true if the LaunchInfo has taken care of monitoring the process, and false if the
- // caller might want to monitor the process themselves.
-
- bool
- MonitorProcess () const;
-
- lldb_utility::PseudoTerminal &
- GetPTY ()
- {
- return *m_pty;
- }
-
- // Get and set the actual listener that will be used for the process events
- lldb::ListenerSP
- GetListener () const
- {
- return m_listener_sp;
- }
-
- void
- SetListener (const lldb::ListenerSP &listener_sp)
- {
- m_listener_sp = listener_sp;
- }
-
- lldb::ListenerSP
- GetListenerForProcess (Debugger &debugger);
-
- lldb::ListenerSP
- GetHijackListener () const
- {
- return m_hijack_listener_sp;
- }
-
- void
- SetHijackListener (const lldb::ListenerSP &listener_sp)
- {
- m_hijack_listener_sp = listener_sp;
- }
-
- void
- SetLaunchEventData (const char *data)
- {
- m_event_data.assign (data);
- }
-
- const char *
- GetLaunchEventData () const
- {
- return m_event_data.c_str();
- }
-
- void
- SetDetachOnError (bool enable);
-
- bool
- GetDetachOnError () const
- {
- return m_flags.Test(lldb::eLaunchFlagDetachOnError);
- }
-
- protected:
- FileSpec m_working_dir;
- std::string m_plugin_name;
- FileSpec m_shell;
- Flags m_flags; // Bitwise OR of bits from lldb::LaunchFlags
- std::vector<FileAction> m_file_actions; // File actions for any other files
- std::shared_ptr<lldb_utility::PseudoTerminal> m_pty;
- uint32_t m_resume_count; // How many times do we resume after launching
- Host::MonitorChildProcessCallback m_monitor_callback;
- void *m_monitor_callback_baton;
- bool m_monitor_signals;
- std::string m_event_data; // A string passed to the plugin launch, having no meaning to the upper levels of lldb.
- lldb::ListenerSP m_listener_sp;
- lldb::ListenerSP m_hijack_listener_sp;
- };
+namespace lldb_private {
+
+//----------------------------------------------------------------------
+// ProcessLaunchInfo
+//
+// Describes any information that is required to launch a process.
+//----------------------------------------------------------------------
+
+class ProcessLaunchInfo : public ProcessInfo {
+public:
+ ProcessLaunchInfo();
+
+ ProcessLaunchInfo(const FileSpec &stdin_file_spec,
+ const FileSpec &stdout_file_spec,
+ const FileSpec &stderr_file_spec,
+ const FileSpec &working_dir, uint32_t launch_flags);
+
+ void AppendFileAction(const FileAction &info) {
+ m_file_actions.push_back(info);
+ }
+
+ bool AppendCloseFileAction(int fd);
+
+ bool AppendDuplicateFileAction(int fd, int dup_fd);
+
+ bool AppendOpenFileAction(int fd, const FileSpec &file_spec, bool read,
+ bool write);
+
+ bool AppendSuppressFileAction(int fd, bool read, bool write);
+
+ void FinalizeFileActions(Target *target, bool default_to_use_pty);
+
+ size_t GetNumFileActions() const { return m_file_actions.size(); }
+
+ const FileAction *GetFileActionAtIndex(size_t idx) const;
+
+ const FileAction *GetFileActionForFD(int fd) const;
+
+ Flags &GetFlags() { return m_flags; }
+
+ const Flags &GetFlags() const { return m_flags; }
+
+ const FileSpec &GetWorkingDirectory() const;
+
+ void SetWorkingDirectory(const FileSpec &working_dir);
+
+ const char *GetProcessPluginName() const;
+
+ void SetProcessPluginName(llvm::StringRef plugin);
+
+ const FileSpec &GetShell() const;
+
+ void SetShell(const FileSpec &shell);
+
+ uint32_t GetResumeCount() const { return m_resume_count; }
+
+ void SetResumeCount(uint32_t c) { m_resume_count = c; }
+
+ bool GetLaunchInSeparateProcessGroup() const {
+ return m_flags.Test(lldb::eLaunchFlagLaunchInSeparateProcessGroup);
+ }
+
+ void SetLaunchInSeparateProcessGroup(bool separate);
+
+ bool GetShellExpandArguments() const {
+ return m_flags.Test(lldb::eLaunchFlagShellExpandArguments);
+ }
+
+ void SetShellExpandArguments(bool expand);
+
+ void Clear();
+
+ bool ConvertArgumentsForLaunchingInShell(Error &error, bool localhost,
+ bool will_debug,
+ bool first_arg_is_full_shell_command,
+ int32_t num_resumes);
+
+ void
+ SetMonitorProcessCallback(const Host::MonitorChildProcessCallback &callback,
+ bool monitor_signals);
+
+ Host::MonitorChildProcessCallback GetMonitorProcessCallback() const {
+ return m_monitor_callback;
+ }
+
+ bool GetMonitorSignals() const { return m_monitor_signals; }
+
+ // If the LaunchInfo has a monitor callback, then arrange to monitor the
+ // process.
+ // Return true if the LaunchInfo has taken care of monitoring the process, and
+ // false if the
+ // caller might want to monitor the process themselves.
+
+ bool MonitorProcess() const;
+
+ lldb_utility::PseudoTerminal &GetPTY() { return *m_pty; }
+
+ // Get and set the actual listener that will be used for the process events
+ lldb::ListenerSP GetListener() const { return m_listener_sp; }
+
+ void SetListener(const lldb::ListenerSP &listener_sp) {
+ m_listener_sp = listener_sp;
+ }
+
+ lldb::ListenerSP GetListenerForProcess(Debugger &debugger);
+
+ lldb::ListenerSP GetHijackListener() const { return m_hijack_listener_sp; }
+
+ void SetHijackListener(const lldb::ListenerSP &listener_sp) {
+ m_hijack_listener_sp = listener_sp;
+ }
+
+ void SetLaunchEventData(const char *data) { m_event_data.assign(data); }
+
+ const char *GetLaunchEventData() const { return m_event_data.c_str(); }
+
+ void SetDetachOnError(bool enable);
+
+ bool GetDetachOnError() const {
+ return m_flags.Test(lldb::eLaunchFlagDetachOnError);
+ }
+
+protected:
+ FileSpec m_working_dir;
+ std::string m_plugin_name;
+ FileSpec m_shell;
+ Flags m_flags; // Bitwise OR of bits from lldb::LaunchFlags
+ std::vector<FileAction> m_file_actions; // File actions for any other files
+ std::shared_ptr<lldb_utility::PseudoTerminal> m_pty;
+ uint32_t m_resume_count; // How many times do we resume after launching
+ Host::MonitorChildProcessCallback m_monitor_callback;
+ void *m_monitor_callback_baton;
+ bool m_monitor_signals;
+ std::string m_event_data; // A string passed to the plugin launch, having no
+ // meaning to the upper levels of lldb.
+ lldb::ListenerSP m_listener_sp;
+ lldb::ListenerSP m_hijack_listener_sp;
+};
}
#endif // liblldb_ProcessLaunch_Info_h
diff --git a/include/lldb/Target/Queue.h b/include/lldb/Target/Queue.h
index 514481fe8c9d..2df4d54a89b6 100644
--- a/include/lldb/Target/Queue.h
+++ b/include/lldb/Target/Queue.h
@@ -10,21 +10,20 @@
#ifndef liblldb_Queue_h_
#define liblldb_Queue_h_
-#include <vector>
#include <string>
+#include <vector>
-#include "lldb/lldb-forward.h"
+#include "lldb/Target/QueueItem.h"
#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-forward.h"
#include "lldb/lldb-private.h"
-#include "lldb/Target/QueueItem.h"
-
namespace lldb_private {
//------------------------------------------------------------------
// Queue:
// This class represents a libdispatch aka Grand Central Dispatch
-// queue in the process.
+// queue in the process.
//
// A program using libdispatch will create queues, put work items
// (functions, blocks) on the queues. The system will create /
@@ -34,169 +33,147 @@ namespace lldb_private {
// be associated with multiple threads.
//------------------------------------------------------------------
-
-class Queue :
- public std::enable_shared_from_this<Queue>
-{
+class Queue : public std::enable_shared_from_this<Queue> {
public:
-
- Queue (lldb::ProcessSP process_sp, lldb::queue_id_t queue_id, const char *queue_name);
-
- ~Queue ();
-
- //------------------------------------------------------------------
- /// Get the QueueID for this Queue
- ///
- /// A 64-bit ID number that uniquely identifies a queue at this particular
- /// stop_id. Currently the libdispatch serialnum is used for the QueueID;
- /// it is a number that starts at 1 for each process and increments with
- /// each queue. A serialnum is not reused for a different queue in the
- /// lifetime of that process execution.
- ///
- /// @return
- /// The QueueID for this Queue.
- //------------------------------------------------------------------
- lldb::queue_id_t
- GetID ();
-
- //------------------------------------------------------------------
- /// Get the name of this Queue
- ///
- /// @return
- /// The name of the queue, if one is available.
- /// A NULL pointer is returned if none is available.
- //------------------------------------------------------------------
- const char *
- GetName ();
-
- //------------------------------------------------------------------
- /// Get the IndexID for this Queue
- ///
- /// This is currently the same as GetID(). If it changes in the future,
- /// it will be a small integer value (starting with 1) assigned to
- /// each queue that is seen during a Process lifetime.
- ///
- /// Both the GetID and GetIndexID are being retained for Queues to
- /// maintain similar API to the Thread class, and allow for the
- /// possibility of GetID changing to a different source in the future.
- ///
- /// @return
- /// The IndexID for this queue.
- //------------------------------------------------------------------
- uint32_t
- GetIndexID ();
-
- //------------------------------------------------------------------
- /// Return the threads currently associated with this queue
- ///
- /// Zero, one, or many threads may be executing code for a queue at
- /// a given point in time. This call returns the list of threads
- /// that are currently executing work for this queue.
- ///
- /// @return
- /// The threads currently performing work for this queue
- //------------------------------------------------------------------
- std::vector<lldb::ThreadSP>
- GetThreads ();
-
- //------------------------------------------------------------------
- /// Return the items that are currently enqueued
- ///
- /// "Enqueued" means that the item has been added to the queue to
- /// be done, but has not yet been done. When the item is going to
- /// be processed it is "dequeued".
- ///
- /// @return
- /// The vector of enqueued items for this queue
- //------------------------------------------------------------------
- const std::vector<lldb::QueueItemSP> &
- GetPendingItems();
-
- lldb::ProcessSP
- GetProcess() const
- {
- return m_process_wp.lock();
- }
-
- //------------------------------------------------------------------
- /// Get the number of work items that this queue is currently running
- ///
- /// @return
- /// The number of work items currently executing. For a serial
- /// queue, this will be 0 or 1. For a concurrent queue, this
- /// may be any number.
- //------------------------------------------------------------------
- uint32_t
- GetNumRunningWorkItems () const;
-
- //------------------------------------------------------------------
- /// Get the number of work items enqueued on this queue
- ///
- /// @return
- /// The number of work items currently enqueued, waiting to
- /// execute.
- //------------------------------------------------------------------
- uint32_t
- GetNumPendingWorkItems () const;
-
- //------------------------------------------------------------------
- /// Get the dispatch_queue_t structure address for this Queue
- ///
- /// Get the address in the inferior process' memory of this Queue's
- /// dispatch_queue_t structure.
- ///
- /// @return
- /// The address of the dispatch_queue_t structure, if known.
- /// LLDB_INVALID_ADDRESS will be returned if it is unavailable.
- //------------------------------------------------------------------
- lldb::addr_t
- GetLibdispatchQueueAddress () const;
-
-
- void
- SetNumRunningWorkItems (uint32_t count);
-
- void
- SetNumPendingWorkItems (uint32_t count);
-
- void
- SetLibdispatchQueueAddress (lldb::addr_t dispatch_queue_t_addr);
-
- void
- PushPendingQueueItem (lldb::QueueItemSP item)
- {
- m_pending_items.push_back (item);
- }
-
- //------------------------------------------------------------------
- /// Return the kind (serial, concurrent) of this queue
- ///
- /// @return
- // Whether this is a serial or a concurrent queue
- //------------------------------------------------------------------
- lldb::QueueKind
- GetKind ();
-
- void
- SetKind (lldb::QueueKind kind);
+ Queue(lldb::ProcessSP process_sp, lldb::queue_id_t queue_id,
+ const char *queue_name);
+
+ ~Queue();
+
+ //------------------------------------------------------------------
+ /// Get the QueueID for this Queue
+ ///
+ /// A 64-bit ID number that uniquely identifies a queue at this particular
+ /// stop_id. Currently the libdispatch serialnum is used for the QueueID;
+ /// it is a number that starts at 1 for each process and increments with
+ /// each queue. A serialnum is not reused for a different queue in the
+ /// lifetime of that process execution.
+ ///
+ /// @return
+ /// The QueueID for this Queue.
+ //------------------------------------------------------------------
+ lldb::queue_id_t GetID();
+
+ //------------------------------------------------------------------
+ /// Get the name of this Queue
+ ///
+ /// @return
+ /// The name of the queue, if one is available.
+ /// A NULL pointer is returned if none is available.
+ //------------------------------------------------------------------
+ const char *GetName();
+
+ //------------------------------------------------------------------
+ /// Get the IndexID for this Queue
+ ///
+ /// This is currently the same as GetID(). If it changes in the future,
+ /// it will be a small integer value (starting with 1) assigned to
+ /// each queue that is seen during a Process lifetime.
+ ///
+ /// Both the GetID and GetIndexID are being retained for Queues to
+ /// maintain similar API to the Thread class, and allow for the
+ /// possibility of GetID changing to a different source in the future.
+ ///
+ /// @return
+ /// The IndexID for this queue.
+ //------------------------------------------------------------------
+ uint32_t GetIndexID();
+
+ //------------------------------------------------------------------
+ /// Return the threads currently associated with this queue
+ ///
+ /// Zero, one, or many threads may be executing code for a queue at
+ /// a given point in time. This call returns the list of threads
+ /// that are currently executing work for this queue.
+ ///
+ /// @return
+ /// The threads currently performing work for this queue
+ //------------------------------------------------------------------
+ std::vector<lldb::ThreadSP> GetThreads();
+
+ //------------------------------------------------------------------
+ /// Return the items that are currently enqueued
+ ///
+ /// "Enqueued" means that the item has been added to the queue to
+ /// be done, but has not yet been done. When the item is going to
+ /// be processed it is "dequeued".
+ ///
+ /// @return
+ /// The vector of enqueued items for this queue
+ //------------------------------------------------------------------
+ const std::vector<lldb::QueueItemSP> &GetPendingItems();
+
+ lldb::ProcessSP GetProcess() const { return m_process_wp.lock(); }
+
+ //------------------------------------------------------------------
+ /// Get the number of work items that this queue is currently running
+ ///
+ /// @return
+ /// The number of work items currently executing. For a serial
+ /// queue, this will be 0 or 1. For a concurrent queue, this
+ /// may be any number.
+ //------------------------------------------------------------------
+ uint32_t GetNumRunningWorkItems() const;
+
+ //------------------------------------------------------------------
+ /// Get the number of work items enqueued on this queue
+ ///
+ /// @return
+ /// The number of work items currently enqueued, waiting to
+ /// execute.
+ //------------------------------------------------------------------
+ uint32_t GetNumPendingWorkItems() const;
+
+ //------------------------------------------------------------------
+ /// Get the dispatch_queue_t structure address for this Queue
+ ///
+ /// Get the address in the inferior process' memory of this Queue's
+ /// dispatch_queue_t structure.
+ ///
+ /// @return
+ /// The address of the dispatch_queue_t structure, if known.
+ /// LLDB_INVALID_ADDRESS will be returned if it is unavailable.
+ //------------------------------------------------------------------
+ lldb::addr_t GetLibdispatchQueueAddress() const;
+
+ void SetNumRunningWorkItems(uint32_t count);
+
+ void SetNumPendingWorkItems(uint32_t count);
+
+ void SetLibdispatchQueueAddress(lldb::addr_t dispatch_queue_t_addr);
+
+ void PushPendingQueueItem(lldb::QueueItemSP item) {
+ m_pending_items.push_back(item);
+ }
+
+ //------------------------------------------------------------------
+ /// Return the kind (serial, concurrent) of this queue
+ ///
+ /// @return
+ // Whether this is a serial or a concurrent queue
+ //------------------------------------------------------------------
+ lldb::QueueKind GetKind();
+
+ void SetKind(lldb::QueueKind kind);
private:
- //------------------------------------------------------------------
- // For Queue only
- //------------------------------------------------------------------
-
- lldb::ProcessWP m_process_wp;
- lldb::queue_id_t m_queue_id;
- std::string m_queue_name;
- uint32_t m_running_work_items_count;
- uint32_t m_pending_work_items_count;
- std::vector<lldb::QueueItemSP> m_pending_items;
- lldb::addr_t m_dispatch_queue_t_addr; // address of libdispatch dispatch_queue_t for this Queue
- lldb::QueueKind m_kind;
-
- DISALLOW_COPY_AND_ASSIGN (Queue);
+ //------------------------------------------------------------------
+ // For Queue only
+ //------------------------------------------------------------------
+
+ lldb::ProcessWP m_process_wp;
+ lldb::queue_id_t m_queue_id;
+ std::string m_queue_name;
+ uint32_t m_running_work_items_count;
+ uint32_t m_pending_work_items_count;
+ std::vector<lldb::QueueItemSP> m_pending_items;
+ lldb::addr_t m_dispatch_queue_t_addr; // address of libdispatch
+ // dispatch_queue_t for this Queue
+ lldb::QueueKind m_kind;
+
+ DISALLOW_COPY_AND_ASSIGN(Queue);
};
} // namespace lldb_private
-#endif // liblldb_Queue_h_
+#endif // liblldb_Queue_h_
diff --git a/include/lldb/Target/QueueItem.h b/include/lldb/Target/QueueItem.h
index aea506644c37..f6378502c19c 100644
--- a/include/lldb/Target/QueueItem.h
+++ b/include/lldb/Target/QueueItem.h
@@ -18,9 +18,9 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-forward.h"
+#include "lldb/lldb-private.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/ConstString.h"
@@ -33,197 +33,153 @@ namespace lldb_private {
// Grand Central Dispatch (GCD) queue. Most often, this will be a
// function or block.
// "enqueued" here means that the work item has been added to a queue
-// but it has not yet started executing. When it is "dequeued",
+// but it has not yet started executing. When it is "dequeued",
// execution of the item begins.
//------------------------------------------------------------------
-class QueueItem :
- public std::enable_shared_from_this<QueueItem>
-{
+class QueueItem : public std::enable_shared_from_this<QueueItem> {
public:
- QueueItem (lldb::QueueSP queue_sp, lldb::ProcessSP process_sp, lldb::addr_t item_ref, lldb_private::Address address);
-
- ~QueueItem ();
-
- //------------------------------------------------------------------
- /// Get the kind of work item this is
- ///
- /// @return
- /// The type of work item that this QueueItem object
- /// represents. eQueueItemKindUnknown may be returned.
- //------------------------------------------------------------------
- lldb::QueueItemKind
- GetKind ();
-
- //------------------------------------------------------------------
- /// Set the type of work item this is
- ///
- /// @param [in] item_kind
- /// Set the kind of this work item object.
- //------------------------------------------------------------------
- void
- SetKind (lldb::QueueItemKind item_kind);
-
- //------------------------------------------------------------------
- /// Get the code address that will be executed when this work item
- /// is executed.
- ///
- /// @return
- /// The address that will be invoked when this work item is
- /// executed. Not all types of QueueItems will have an
- /// address associated with them; check that the returned
- /// Address is valid, or check that the WorkItemKind is a
- /// kind that involves an address, such as eQueueItemKindFunction
- /// or eQueueItemKindBlock.
- //------------------------------------------------------------------
- lldb_private::Address &
- GetAddress ();
-
- //------------------------------------------------------------------
- /// Set the work item address for this object
- ///
- /// @param [in] addr
- /// The address that will be invoked when this work item
- /// is executed.
- //------------------------------------------------------------------
- void
- SetAddress (lldb_private::Address addr);
-
- //------------------------------------------------------------------
- /// Check if this QueueItem object is valid
- ///
- /// If the weak pointer to the parent Queue cannot be revivified,
- /// it is invalid.
- ///
- /// @return
- /// True if this object is valid.
- //------------------------------------------------------------------
- bool
- IsValid ()
- {
- return m_queue_wp.lock() != nullptr;
- }
-
- //------------------------------------------------------------------
- /// Get an extended backtrace thread for this queue item, if available
- ///
- /// If the backtrace/thread information was collected when this item
- /// was enqueued, this call will provide it.
- ///
- /// @param [in] type
- /// The type of extended backtrace being requested, e.g. "libdispatch"
- /// or "pthread".
- ///
- /// @return
- /// A thread shared pointer which will have a reference to an extended
- /// thread if one was available.
- //------------------------------------------------------------------
- lldb::ThreadSP
- GetExtendedBacktraceThread (ConstString type);
-
- void
- SetItemThatEnqueuedThis (lldb::addr_t address_of_item)
- {
- m_item_that_enqueued_this_ref = address_of_item;
- }
-
- lldb::addr_t
- GetItemThatEnqueuedThis ();
-
- void
- SetEnqueueingThreadID (lldb::tid_t tid)
- {
- m_enqueueing_thread_id = tid;
- }
-
- lldb::tid_t
- GetEnqueueingThreadID ();
-
- void
- SetEnqueueingQueueID (lldb::queue_id_t qid)
- {
- m_enqueueing_queue_id = qid;
- }
-
- lldb::queue_id_t
- GetEnqueueingQueueID ();
-
- void
- SetTargetQueueID (lldb::queue_id_t qid)
- {
- m_target_queue_id = qid;
- }
-
- void
- SetStopID (uint32_t stop_id)
- {
- m_stop_id = stop_id;
- }
-
- uint32_t
- GetStopID ();
-
- void
- SetEnqueueingBacktrace (std::vector<lldb::addr_t> backtrace)
- {
- m_backtrace = backtrace;
- }
-
- std::vector<lldb::addr_t> &
- GetEnqueueingBacktrace ();
-
- void
- SetThreadLabel (std::string thread_name)
- {
- m_thread_label = thread_name;
- }
-
- std::string
- GetThreadLabel ();
-
- void
- SetQueueLabel (std::string queue_name)
- {
- m_queue_label = queue_name;
- }
-
- std::string
- GetQueueLabel ();
-
- void
- SetTargetQueueLabel (std::string queue_name)
- {
- m_target_queue_label = queue_name;
- }
-
- lldb::ProcessSP
- GetProcessSP ();
+ QueueItem(lldb::QueueSP queue_sp, lldb::ProcessSP process_sp,
+ lldb::addr_t item_ref, lldb_private::Address address);
+
+ ~QueueItem();
+
+ //------------------------------------------------------------------
+ /// Get the kind of work item this is
+ ///
+ /// @return
+ /// The type of work item that this QueueItem object
+ /// represents. eQueueItemKindUnknown may be returned.
+ //------------------------------------------------------------------
+ lldb::QueueItemKind GetKind();
+
+ //------------------------------------------------------------------
+ /// Set the type of work item this is
+ ///
+ /// @param [in] item_kind
+ /// Set the kind of this work item object.
+ //------------------------------------------------------------------
+ void SetKind(lldb::QueueItemKind item_kind);
+
+ //------------------------------------------------------------------
+ /// Get the code address that will be executed when this work item
+ /// is executed.
+ ///
+ /// @return
+ /// The address that will be invoked when this work item is
+ /// executed. Not all types of QueueItems will have an
+ /// address associated with them; check that the returned
+ /// Address is valid, or check that the WorkItemKind is a
+ /// kind that involves an address, such as eQueueItemKindFunction
+ /// or eQueueItemKindBlock.
+ //------------------------------------------------------------------
+ lldb_private::Address &GetAddress();
+
+ //------------------------------------------------------------------
+ /// Set the work item address for this object
+ ///
+ /// @param [in] addr
+ /// The address that will be invoked when this work item
+ /// is executed.
+ //------------------------------------------------------------------
+ void SetAddress(lldb_private::Address addr);
+
+ //------------------------------------------------------------------
+ /// Check if this QueueItem object is valid
+ ///
+ /// If the weak pointer to the parent Queue cannot be revivified,
+ /// it is invalid.
+ ///
+ /// @return
+ /// True if this object is valid.
+ //------------------------------------------------------------------
+ bool IsValid() { return m_queue_wp.lock() != nullptr; }
+
+ //------------------------------------------------------------------
+ /// Get an extended backtrace thread for this queue item, if available
+ ///
+ /// If the backtrace/thread information was collected when this item
+ /// was enqueued, this call will provide it.
+ ///
+ /// @param [in] type
+ /// The type of extended backtrace being requested, e.g. "libdispatch"
+ /// or "pthread".
+ ///
+ /// @return
+ /// A thread shared pointer which will have a reference to an extended
+ /// thread if one was available.
+ //------------------------------------------------------------------
+ lldb::ThreadSP GetExtendedBacktraceThread(ConstString type);
+
+ void SetItemThatEnqueuedThis(lldb::addr_t address_of_item) {
+ m_item_that_enqueued_this_ref = address_of_item;
+ }
+
+ lldb::addr_t GetItemThatEnqueuedThis();
+
+ void SetEnqueueingThreadID(lldb::tid_t tid) { m_enqueueing_thread_id = tid; }
+
+ lldb::tid_t GetEnqueueingThreadID();
+
+ void SetEnqueueingQueueID(lldb::queue_id_t qid) {
+ m_enqueueing_queue_id = qid;
+ }
+
+ lldb::queue_id_t GetEnqueueingQueueID();
+
+ void SetTargetQueueID(lldb::queue_id_t qid) { m_target_queue_id = qid; }
+
+ void SetStopID(uint32_t stop_id) { m_stop_id = stop_id; }
+
+ uint32_t GetStopID();
+
+ void SetEnqueueingBacktrace(std::vector<lldb::addr_t> backtrace) {
+ m_backtrace = backtrace;
+ }
+
+ std::vector<lldb::addr_t> &GetEnqueueingBacktrace();
+
+ void SetThreadLabel(std::string thread_name) { m_thread_label = thread_name; }
+
+ std::string GetThreadLabel();
+
+ void SetQueueLabel(std::string queue_name) { m_queue_label = queue_name; }
+
+ std::string GetQueueLabel();
+
+ void SetTargetQueueLabel(std::string queue_name) {
+ m_target_queue_label = queue_name;
+ }
+
+ lldb::ProcessSP GetProcessSP();
protected:
- void
- FetchEntireItem ();
-
- lldb::QueueWP m_queue_wp;
- lldb::ProcessWP m_process_wp;
-
- lldb::addr_t m_item_ref; // the token we can be used to fetch more information about this queue item
- lldb_private::Address m_address;
- bool m_have_fetched_entire_item;
-
- lldb::QueueItemKind m_kind;
- lldb::addr_t m_item_that_enqueued_this_ref; // a handle that we can pass into libBacktraceRecording
- // to get the QueueItem that enqueued this item
- lldb::tid_t m_enqueueing_thread_id; // thread that enqueued this item
- lldb::queue_id_t m_enqueueing_queue_id; // Queue that enqueued this item, if it was a queue
- lldb::queue_id_t m_target_queue_id;
- uint32_t m_stop_id; // indicates when this backtrace was recorded in time
- std::vector<lldb::addr_t> m_backtrace;
- std::string m_thread_label;
- std::string m_queue_label;
- std::string m_target_queue_label;
+ void FetchEntireItem();
+
+ lldb::QueueWP m_queue_wp;
+ lldb::ProcessWP m_process_wp;
+
+ lldb::addr_t m_item_ref; // the token we can be used to fetch more information
+ // about this queue item
+ lldb_private::Address m_address;
+ bool m_have_fetched_entire_item;
+
+ lldb::QueueItemKind m_kind;
+ lldb::addr_t m_item_that_enqueued_this_ref; // a handle that we can pass into
+ // libBacktraceRecording
+ // to get the QueueItem that enqueued this item
+ lldb::tid_t m_enqueueing_thread_id; // thread that enqueued this item
+ lldb::queue_id_t
+ m_enqueueing_queue_id; // Queue that enqueued this item, if it was a queue
+ lldb::queue_id_t m_target_queue_id;
+ uint32_t m_stop_id; // indicates when this backtrace was recorded in time
+ std::vector<lldb::addr_t> m_backtrace;
+ std::string m_thread_label;
+ std::string m_queue_label;
+ std::string m_target_queue_label;
private:
- DISALLOW_COPY_AND_ASSIGN (QueueItem);
+ DISALLOW_COPY_AND_ASSIGN(QueueItem);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/QueueList.h b/include/lldb/Target/QueueList.h
index 265145db2696..038463d9ab02 100644
--- a/include/lldb/Target/QueueList.h
+++ b/include/lldb/Target/QueueList.h
@@ -13,130 +13,118 @@
#include <mutex>
#include <vector>
-#include "lldb/lldb-private.h"
#include "lldb/Core/UserID.h"
#include "lldb/Utility/Iterable.h"
-
+#include "lldb/lldb-private.h"
namespace lldb_private {
//------------------------------------------------------------------
// QueueList:
-// This is the container for libdispatch aka Grand Central Dispatch
+// This is the container for libdispatch aka Grand Central Dispatch
// Queue objects.
//
// Each Process will have a QueueList. When the process execution is
-// paused, the QueueList may be populated with Queues by the
+// paused, the QueueList may be populated with Queues by the
// SystemRuntime.
//------------------------------------------------------------------
-class QueueList
-{
-friend class Process;
+class QueueList {
+ friend class Process;
public:
-
- QueueList (Process *process);
-
- ~QueueList ();
-
- //------------------------------------------------------------------
- /// Get the number of libdispatch queues that are available
- ///
- /// @return
- /// The number of queues that are stored in the QueueList.
- //------------------------------------------------------------------
- uint32_t
- GetSize();
-
- //------------------------------------------------------------------
- /// Get the Queue at a given index number
- ///
- /// @param [in] idx
- /// The index number (0-based) of the queue.
- /// @return
- /// The Queue at that index number.
- //------------------------------------------------------------------
- lldb::QueueSP
- GetQueueAtIndex (uint32_t idx);
-
- typedef std::vector<lldb::QueueSP> collection;
- typedef LockingAdaptedIterable<collection, lldb::QueueSP, vector_adapter, std::mutex> QueueIterable;
-
- //------------------------------------------------------------------
- /// Iterate over the list of queues
- ///
- /// @return
- /// An Iterable object which can be used to loop over the queues
- /// that exist.
- //------------------------------------------------------------------
- QueueIterable
- Queues ()
- {
- return QueueIterable(m_queues, m_mutex);
- }
-
- //------------------------------------------------------------------
- /// Clear out the list of queues from the QueueList
- //------------------------------------------------------------------
- void
- Clear();
-
- //------------------------------------------------------------------
- /// Add a Queue to the QueueList
- ///
- /// @param [in] queue
- /// Used by the SystemRuntime to populate the QueueList
- //------------------------------------------------------------------
- void
- AddQueue (lldb::QueueSP queue);
-
- //------------------------------------------------------------------
- /// Find a queue in the QueueList by QueueID
- ///
- /// @param [in] qid
- /// The QueueID (same as returned by Thread::GetQueueID()) to find.
- ///
- /// @return
- /// A QueueSP to the queue requested, if it is present in the QueueList.
- /// An empty QueueSP will be returned if this queue was not found.
- //------------------------------------------------------------------
- lldb::QueueSP
- FindQueueByID (lldb::queue_id_t qid);
-
- //------------------------------------------------------------------
- /// Find a queue in the QueueList by IndexID
- ///
- /// @param [in] index_id
- /// Find a queue by IndexID. This is an integer associated with each
- /// unique queue seen during a debug session and will not be reused
- /// for a different queue. Unlike the QueueID, a 64-bit value, this
- /// will tend to be an integral value like 1 or 7.
- ///
- /// @return
- /// A QueueSP to the queue requested, if it is present in the QueueList.
- /// An empty QueueSP will be returned if this queue was not found.
- //------------------------------------------------------------------
- lldb::QueueSP
- FindQueueByIndexID (uint32_t index_id);
-
- std::mutex &
- GetMutex();
+ QueueList(Process *process);
+
+ ~QueueList();
+
+ //------------------------------------------------------------------
+ /// Get the number of libdispatch queues that are available
+ ///
+ /// @return
+ /// The number of queues that are stored in the QueueList.
+ //------------------------------------------------------------------
+ uint32_t GetSize();
+
+ //------------------------------------------------------------------
+ /// Get the Queue at a given index number
+ ///
+ /// @param [in] idx
+ /// The index number (0-based) of the queue.
+ /// @return
+ /// The Queue at that index number.
+ //------------------------------------------------------------------
+ lldb::QueueSP GetQueueAtIndex(uint32_t idx);
+
+ typedef std::vector<lldb::QueueSP> collection;
+ typedef LockingAdaptedIterable<collection, lldb::QueueSP, vector_adapter,
+ std::mutex>
+ QueueIterable;
+
+ //------------------------------------------------------------------
+ /// Iterate over the list of queues
+ ///
+ /// @return
+ /// An Iterable object which can be used to loop over the queues
+ /// that exist.
+ //------------------------------------------------------------------
+ QueueIterable Queues() { return QueueIterable(m_queues, m_mutex); }
+
+ //------------------------------------------------------------------
+ /// Clear out the list of queues from the QueueList
+ //------------------------------------------------------------------
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Add a Queue to the QueueList
+ ///
+ /// @param [in] queue
+ /// Used by the SystemRuntime to populate the QueueList
+ //------------------------------------------------------------------
+ void AddQueue(lldb::QueueSP queue);
+
+ //------------------------------------------------------------------
+ /// Find a queue in the QueueList by QueueID
+ ///
+ /// @param [in] qid
+ /// The QueueID (same as returned by Thread::GetQueueID()) to find.
+ ///
+ /// @return
+ /// A QueueSP to the queue requested, if it is present in the QueueList.
+ /// An empty QueueSP will be returned if this queue was not found.
+ //------------------------------------------------------------------
+ lldb::QueueSP FindQueueByID(lldb::queue_id_t qid);
+
+ //------------------------------------------------------------------
+ /// Find a queue in the QueueList by IndexID
+ ///
+ /// @param [in] index_id
+ /// Find a queue by IndexID. This is an integer associated with each
+ /// unique queue seen during a debug session and will not be reused
+ /// for a different queue. Unlike the QueueID, a 64-bit value, this
+ /// will tend to be an integral value like 1 or 7.
+ ///
+ /// @return
+ /// A QueueSP to the queue requested, if it is present in the QueueList.
+ /// An empty QueueSP will be returned if this queue was not found.
+ //------------------------------------------------------------------
+ lldb::QueueSP FindQueueByIndexID(uint32_t index_id);
+
+ std::mutex &GetMutex();
protected:
-
- //------------------------------------------------------------------
- // Classes that inherit from Process can see and modify these
- //------------------------------------------------------------------
- Process *m_process; ///< The process that manages this queue list.
- uint32_t m_stop_id; ///< The process stop ID that this queue list is valid for.
- collection m_queues; ///< The queues for this process.
- std::mutex m_mutex;
+ //------------------------------------------------------------------
+ // Classes that inherit from Process can see and modify these
+ //------------------------------------------------------------------
+ Process *m_process; ///< The process that manages this queue list.
+ uint32_t
+ m_stop_id; ///< The process stop ID that this queue list is valid for.
+ collection m_queues; ///< The queues for this process.
+ std::mutex m_mutex;
private:
- QueueList ();
+ QueueList();
};
} // namespace lldb_private
-#endif // liblldb_QueueList_h_
+#endif // liblldb_QueueList_h_
diff --git a/include/lldb/Target/RegisterCheckpoint.h b/include/lldb/Target/RegisterCheckpoint.h
index 3e61e1490d4b..8391cadcdf66 100644
--- a/include/lldb/Target/RegisterCheckpoint.h
+++ b/include/lldb/Target/RegisterCheckpoint.h
@@ -10,62 +10,46 @@
#ifndef liblldb_RegisterCheckpoint_h_
#define liblldb_RegisterCheckpoint_h_
-#include "lldb/lldb-private.h"
#include "lldb/Core/UserID.h"
#include "lldb/Target/StackID.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
- // Inherit from UserID in case pushing/popping all register values can be
- // done using a 64 bit integer that holds a baton/cookie instead of actually
- // having to read all register values into a buffer
- class RegisterCheckpoint : public UserID
- {
- public:
-
- enum class Reason {
- // An expression is about to be run on the thread if the protocol that
- // talks to the debuggee supports checkpointing the registers using a
- // push/pop then the UserID base class in the RegisterCheckpoint can
- // be used to store the baton/cookie that refers to the remote saved
- // state.
- eExpression,
- // The register checkpoint wants the raw register bytes, so they must
- // be read into m_data_sp, or the save/restore checkpoint should fail.
- eDataBackup
- };
-
- RegisterCheckpoint(Reason reason) :
- UserID(0),
- m_data_sp (),
- m_reason(reason)
- {
- }
-
- ~RegisterCheckpoint()
- {
- }
-
- lldb::DataBufferSP &
- GetData()
- {
- return m_data_sp;
- }
-
- const lldb::DataBufferSP &
- GetData() const
- {
- return m_data_sp;
- }
-
- protected:
- lldb::DataBufferSP m_data_sp;
- Reason m_reason;
-
- // Make RegisterCheckpointSP if you wish to share the data in this class.
- DISALLOW_COPY_AND_ASSIGN(RegisterCheckpoint);
- };
-
+// Inherit from UserID in case pushing/popping all register values can be
+// done using a 64 bit integer that holds a baton/cookie instead of actually
+// having to read all register values into a buffer
+class RegisterCheckpoint : public UserID {
+public:
+ enum class Reason {
+ // An expression is about to be run on the thread if the protocol that
+ // talks to the debuggee supports checkpointing the registers using a
+ // push/pop then the UserID base class in the RegisterCheckpoint can
+ // be used to store the baton/cookie that refers to the remote saved
+ // state.
+ eExpression,
+ // The register checkpoint wants the raw register bytes, so they must
+ // be read into m_data_sp, or the save/restore checkpoint should fail.
+ eDataBackup
+ };
+
+ RegisterCheckpoint(Reason reason)
+ : UserID(0), m_data_sp(), m_reason(reason) {}
+
+ ~RegisterCheckpoint() {}
+
+ lldb::DataBufferSP &GetData() { return m_data_sp; }
+
+ const lldb::DataBufferSP &GetData() const { return m_data_sp; }
+
+protected:
+ lldb::DataBufferSP m_data_sp;
+ Reason m_reason;
+
+ // Make RegisterCheckpointSP if you wish to share the data in this class.
+ DISALLOW_COPY_AND_ASSIGN(RegisterCheckpoint);
+};
+
} // namespace lldb_private
-#endif // liblldb_RegisterCheckpoint_h_
+#endif // liblldb_RegisterCheckpoint_h_
diff --git a/include/lldb/Target/RegisterContext.h b/include/lldb/Target/RegisterContext.h
index dfeb18348bf7..485645b2dc14 100644
--- a/include/lldb/Target/RegisterContext.h
+++ b/include/lldb/Target/RegisterContext.h
@@ -14,255 +14,217 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Target/ExecutionContextScope.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class RegisterContext :
- public std::enable_shared_from_this<RegisterContext>,
- public ExecutionContextScope
-{
+class RegisterContext : public std::enable_shared_from_this<RegisterContext>,
+ public ExecutionContextScope {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- RegisterContext (Thread &thread, uint32_t concrete_frame_idx);
-
- ~RegisterContext() override;
-
- void
- InvalidateIfNeeded (bool force);
-
- //------------------------------------------------------------------
- // Subclasses must override these functions
- //------------------------------------------------------------------
- virtual void
- InvalidateAllRegisters () = 0;
-
- virtual size_t
- GetRegisterCount () = 0;
-
- virtual const RegisterInfo *
- GetRegisterInfoAtIndex (size_t reg) = 0;
-
- // Detect the register size dynamically.
- uint32_t
- UpdateDynamicRegisterSize (const lldb_private::ArchSpec &arch,
- RegisterInfo* reg_info);
-
- virtual size_t
- GetRegisterSetCount () = 0;
-
- virtual const RegisterSet *
- GetRegisterSet (size_t reg_set) = 0;
-
- virtual bool
- ReadRegister (const RegisterInfo *reg_info, RegisterValue &reg_value) = 0;
-
- virtual bool
- WriteRegister (const RegisterInfo *reg_info, const RegisterValue &reg_value) = 0;
-
- virtual bool
- ReadAllRegisterValues (lldb::DataBufferSP &data_sp)
- {
- return false;
- }
-
- virtual bool
- WriteAllRegisterValues (const lldb::DataBufferSP &data_sp)
- {
- return false;
- }
-
- // These two functions are used to implement "push" and "pop" of register states. They are used primarily
- // for expression evaluation, where we need to push a new state (storing the old one in data_sp) and then
- // restoring the original state by passing the data_sp we got from ReadAllRegisters to WriteAllRegisterValues.
- // ReadAllRegisters will do what is necessary to return a coherent set of register values for this thread, which
- // may mean e.g. interrupting a thread that is sitting in a kernel trap. That is a somewhat disruptive operation,
- // so these API's should only be used when this behavior is needed.
-
- virtual bool
- ReadAllRegisterValues (lldb_private::RegisterCheckpoint &reg_checkpoint);
-
- virtual bool
- WriteAllRegisterValues (const lldb_private::RegisterCheckpoint &reg_checkpoint);
-
- bool
- CopyFromRegisterContext (lldb::RegisterContextSP context);
-
- //------------------------------------------------------------------
- /// Convert from a given register numbering scheme to the lldb register
- /// numbering scheme
- ///
- /// There may be multiple ways to enumerate the registers for a given
- /// architecture. ABI references will specify one to be used with
- /// DWARF, the register numberings from process plugin, there may
- /// be a variation used for eh_frame unwind instructions (e.g. on Darwin),
- /// and so on. Register 5 by itself is meaningless - RegisterKind
- /// enumeration tells you what context that number should be translated as.
- ///
- /// Inside lldb, register numbers are in the eRegisterKindLLDB scheme;
- /// arguments which take a register number should take one in that
- /// scheme.
- ///
- /// eRegisterKindGeneric is a special numbering scheme which gives us
- /// constant values for the pc, frame register, stack register, etc., for
- /// use within lldb. They may not be defined for all architectures but
- /// it allows generic code to translate these common registers into the
- /// lldb numbering scheme.
- ///
- /// This method translates a given register kind + register number into
- /// the eRegisterKindLLDB register numbering.
- ///
- /// @param [in] kind
- /// The register numbering scheme (RegisterKind) that the following
- /// register number is in.
- ///
- /// @param [in] num
- /// A register number in the 'kind' register numbering scheme.
- ///
- /// @return
- /// The equivalent register number in the eRegisterKindLLDB
- /// numbering scheme, if possible, else LLDB_INVALID_REGNUM.
- //------------------------------------------------------------------
- virtual uint32_t
- ConvertRegisterKindToRegisterNumber (lldb::RegisterKind kind, uint32_t num) = 0;
-
- //------------------------------------------------------------------
- // Subclasses can override these functions if desired
- //------------------------------------------------------------------
- virtual uint32_t
- NumSupportedHardwareBreakpoints ();
-
- virtual uint32_t
- SetHardwareBreakpoint (lldb::addr_t addr, size_t size);
-
- virtual bool
- ClearHardwareBreakpoint (uint32_t hw_idx);
-
- virtual uint32_t
- NumSupportedHardwareWatchpoints ();
-
- virtual uint32_t
- SetHardwareWatchpoint (lldb::addr_t addr, size_t size, bool read, bool write);
-
- virtual bool
- ClearHardwareWatchpoint (uint32_t hw_index);
-
- virtual bool
- HardwareSingleStep (bool enable);
-
- virtual Error
- ReadRegisterValueFromMemory (const lldb_private::RegisterInfo *reg_info, lldb::addr_t src_addr, uint32_t src_len, RegisterValue &reg_value);
-
- virtual Error
- WriteRegisterValueToMemory (const lldb_private::RegisterInfo *reg_info, lldb::addr_t dst_addr, uint32_t dst_len, const RegisterValue &reg_value);
-
- //------------------------------------------------------------------
- // Subclasses should not override these
- //------------------------------------------------------------------
- virtual lldb::tid_t
- GetThreadID() const;
-
- virtual Thread &
- GetThread ()
- {
- return m_thread;
- }
-
- const RegisterInfo *
- GetRegisterInfoByName (const char *reg_name, uint32_t start_idx = 0);
-
- const RegisterInfo *
- GetRegisterInfo (lldb::RegisterKind reg_kind, uint32_t reg_num);
-
- uint64_t
- GetPC (uint64_t fail_value = LLDB_INVALID_ADDRESS);
-
- bool
- SetPC (uint64_t pc);
-
- bool SetPC (Address addr);
-
- uint64_t
- GetSP (uint64_t fail_value = LLDB_INVALID_ADDRESS);
-
- bool
- SetSP (uint64_t sp);
-
- uint64_t
- GetFP (uint64_t fail_value = LLDB_INVALID_ADDRESS);
-
- bool
- SetFP (uint64_t fp);
-
- const char *
- GetRegisterName (uint32_t reg);
-
- uint64_t
- GetReturnAddress (uint64_t fail_value = LLDB_INVALID_ADDRESS);
-
- uint64_t
- GetFlags (uint64_t fail_value = 0);
-
- uint64_t
- ReadRegisterAsUnsigned (uint32_t reg, uint64_t fail_value);
-
- uint64_t
- ReadRegisterAsUnsigned (const RegisterInfo *reg_info, uint64_t fail_value);
-
- bool
- WriteRegisterFromUnsigned (uint32_t reg, uint64_t uval);
-
- bool
- WriteRegisterFromUnsigned (const RegisterInfo *reg_info, uint64_t uval);
-
- bool
- ConvertBetweenRegisterKinds (lldb::RegisterKind source_rk, uint32_t source_regnum, lldb::RegisterKind target_rk, uint32_t& target_regnum);
-
- //------------------------------------------------------------------
- // lldb::ExecutionContextScope pure virtual functions
- //------------------------------------------------------------------
- lldb::TargetSP
- CalculateTarget() override;
-
- lldb::ProcessSP
- CalculateProcess() override;
-
- lldb::ThreadSP
- CalculateThread() override;
-
- lldb::StackFrameSP
- CalculateStackFrame() override;
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ RegisterContext(Thread &thread, uint32_t concrete_frame_idx);
+
+ ~RegisterContext() override;
+
+ void InvalidateIfNeeded(bool force);
+
+ //------------------------------------------------------------------
+ // Subclasses must override these functions
+ //------------------------------------------------------------------
+ virtual void InvalidateAllRegisters() = 0;
+
+ virtual size_t GetRegisterCount() = 0;
+
+ virtual const RegisterInfo *GetRegisterInfoAtIndex(size_t reg) = 0;
+
+ // Detect the register size dynamically.
+ uint32_t UpdateDynamicRegisterSize(const lldb_private::ArchSpec &arch,
+ RegisterInfo *reg_info);
+
+ virtual size_t GetRegisterSetCount() = 0;
+
+ virtual const RegisterSet *GetRegisterSet(size_t reg_set) = 0;
+
+ virtual bool ReadRegister(const RegisterInfo *reg_info,
+ RegisterValue &reg_value) = 0;
+
+ virtual bool WriteRegister(const RegisterInfo *reg_info,
+ const RegisterValue &reg_value) = 0;
+
+ virtual bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) {
+ return false;
+ }
+
+ virtual bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) {
+ return false;
+ }
+
+ // These two functions are used to implement "push" and "pop" of register
+ // states. They are used primarily
+ // for expression evaluation, where we need to push a new state (storing the
+ // old one in data_sp) and then
+ // restoring the original state by passing the data_sp we got from
+ // ReadAllRegisters to WriteAllRegisterValues.
+ // ReadAllRegisters will do what is necessary to return a coherent set of
+ // register values for this thread, which
+ // may mean e.g. interrupting a thread that is sitting in a kernel trap. That
+ // is a somewhat disruptive operation,
+ // so these API's should only be used when this behavior is needed.
+
+ virtual bool
+ ReadAllRegisterValues(lldb_private::RegisterCheckpoint &reg_checkpoint);
+
+ virtual bool WriteAllRegisterValues(
+ const lldb_private::RegisterCheckpoint &reg_checkpoint);
+
+ bool CopyFromRegisterContext(lldb::RegisterContextSP context);
+
+ //------------------------------------------------------------------
+ /// Convert from a given register numbering scheme to the lldb register
+ /// numbering scheme
+ ///
+ /// There may be multiple ways to enumerate the registers for a given
+ /// architecture. ABI references will specify one to be used with
+ /// DWARF, the register numberings from process plugin, there may
+ /// be a variation used for eh_frame unwind instructions (e.g. on Darwin),
+ /// and so on. Register 5 by itself is meaningless - RegisterKind
+ /// enumeration tells you what context that number should be translated as.
+ ///
+ /// Inside lldb, register numbers are in the eRegisterKindLLDB scheme;
+ /// arguments which take a register number should take one in that
+ /// scheme.
+ ///
+ /// eRegisterKindGeneric is a special numbering scheme which gives us
+ /// constant values for the pc, frame register, stack register, etc., for
+ /// use within lldb. They may not be defined for all architectures but
+ /// it allows generic code to translate these common registers into the
+ /// lldb numbering scheme.
+ ///
+ /// This method translates a given register kind + register number into
+ /// the eRegisterKindLLDB register numbering.
+ ///
+ /// @param [in] kind
+ /// The register numbering scheme (RegisterKind) that the following
+ /// register number is in.
+ ///
+ /// @param [in] num
+ /// A register number in the 'kind' register numbering scheme.
+ ///
+ /// @return
+ /// The equivalent register number in the eRegisterKindLLDB
+ /// numbering scheme, if possible, else LLDB_INVALID_REGNUM.
+ //------------------------------------------------------------------
+ virtual uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
+ uint32_t num) = 0;
+
+ //------------------------------------------------------------------
+ // Subclasses can override these functions if desired
+ //------------------------------------------------------------------
+ virtual uint32_t NumSupportedHardwareBreakpoints();
+
+ virtual uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size);
+
+ virtual bool ClearHardwareBreakpoint(uint32_t hw_idx);
+
+ virtual uint32_t NumSupportedHardwareWatchpoints();
+
+ virtual uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size,
+ bool read, bool write);
+
+ virtual bool ClearHardwareWatchpoint(uint32_t hw_index);
+
+ virtual bool HardwareSingleStep(bool enable);
+
+ virtual Error
+ ReadRegisterValueFromMemory(const lldb_private::RegisterInfo *reg_info,
+ lldb::addr_t src_addr, uint32_t src_len,
+ RegisterValue &reg_value);
+
+ virtual Error
+ WriteRegisterValueToMemory(const lldb_private::RegisterInfo *reg_info,
+ lldb::addr_t dst_addr, uint32_t dst_len,
+ const RegisterValue &reg_value);
+
+ //------------------------------------------------------------------
+ // Subclasses should not override these
+ //------------------------------------------------------------------
+ virtual lldb::tid_t GetThreadID() const;
+
+ virtual Thread &GetThread() { return m_thread; }
+
+ const RegisterInfo *GetRegisterInfoByName(llvm::StringRef reg_name,
+ uint32_t start_idx = 0);
+
+ const RegisterInfo *GetRegisterInfo(lldb::RegisterKind reg_kind,
+ uint32_t reg_num);
+
+ uint64_t GetPC(uint64_t fail_value = LLDB_INVALID_ADDRESS);
+
+ bool SetPC(uint64_t pc);
+
+ bool SetPC(Address addr);
+
+ uint64_t GetSP(uint64_t fail_value = LLDB_INVALID_ADDRESS);
+
+ bool SetSP(uint64_t sp);
+
+ uint64_t GetFP(uint64_t fail_value = LLDB_INVALID_ADDRESS);
+
+ bool SetFP(uint64_t fp);
+
+ const char *GetRegisterName(uint32_t reg);
+
+ uint64_t GetReturnAddress(uint64_t fail_value = LLDB_INVALID_ADDRESS);
+
+ uint64_t GetFlags(uint64_t fail_value = 0);
+
+ uint64_t ReadRegisterAsUnsigned(uint32_t reg, uint64_t fail_value);
+
+ uint64_t ReadRegisterAsUnsigned(const RegisterInfo *reg_info,
+ uint64_t fail_value);
+
+ bool WriteRegisterFromUnsigned(uint32_t reg, uint64_t uval);
+
+ bool WriteRegisterFromUnsigned(const RegisterInfo *reg_info, uint64_t uval);
+
+ bool ConvertBetweenRegisterKinds(lldb::RegisterKind source_rk,
+ uint32_t source_regnum,
+ lldb::RegisterKind target_rk,
+ uint32_t &target_regnum);
+
+ //------------------------------------------------------------------
+ // lldb::ExecutionContextScope pure virtual functions
+ //------------------------------------------------------------------
+ lldb::TargetSP CalculateTarget() override;
+
+ lldb::ProcessSP CalculateProcess() override;
+
+ lldb::ThreadSP CalculateThread() override;
+
+ lldb::StackFrameSP CalculateStackFrame() override;
- void
- CalculateExecutionContext(ExecutionContext &exe_ctx) override;
+ void CalculateExecutionContext(ExecutionContext &exe_ctx) override;
- uint32_t
- GetStopID () const
- {
- return m_stop_id;
- }
+ uint32_t GetStopID() const { return m_stop_id; }
- void
- SetStopID (uint32_t stop_id)
- {
- m_stop_id = stop_id;
- }
+ void SetStopID(uint32_t stop_id) { m_stop_id = stop_id; }
protected:
- //------------------------------------------------------------------
- // Classes that inherit from RegisterContext can see and modify these
- //------------------------------------------------------------------
- Thread &m_thread; // The thread that this register context belongs to.
- uint32_t m_concrete_frame_idx; // The concrete frame index for this register context
- uint32_t m_stop_id; // The stop ID that any data in this context is valid for
+ //------------------------------------------------------------------
+ // Classes that inherit from RegisterContext can see and modify these
+ //------------------------------------------------------------------
+ Thread &m_thread; // The thread that this register context belongs to.
+ uint32_t m_concrete_frame_idx; // The concrete frame index for this register
+ // context
+ uint32_t m_stop_id; // The stop ID that any data in this context is valid for
private:
- //------------------------------------------------------------------
- // For RegisterContext only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (RegisterContext);
+ //------------------------------------------------------------------
+ // For RegisterContext only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(RegisterContext);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/SectionLoadHistory.h b/include/lldb/Target/SectionLoadHistory.h
index 2494b7fd2779..e1db141ea9e3 100644
--- a/include/lldb/Target/SectionLoadHistory.h
+++ b/include/lldb/Target/SectionLoadHistory.h
@@ -20,86 +20,70 @@
namespace lldb_private {
-class SectionLoadHistory
-{
+class SectionLoadHistory {
public:
- enum : unsigned {
- // Pass eStopIDNow to any function that takes a stop ID to get
- // the current value.
- eStopIDNow = UINT32_MAX
- };
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- SectionLoadHistory() : m_stop_id_to_section_load_list(), m_mutex() {}
-
- ~SectionLoadHistory()
- {
- // Call clear since this takes a lock and clears the section load list
- // in case another thread is currently using this section load list
- Clear();
- }
-
- SectionLoadList &
- GetCurrentSectionLoadList ();
-
- bool
- IsEmpty() const;
-
- void
- Clear ();
-
- uint32_t
- GetLastStopID() const;
-
- // Get the section load address given a process stop ID
- lldb::addr_t
- GetSectionLoadAddress (uint32_t stop_id,
- const lldb::SectionSP &section_sp);
-
- bool
- ResolveLoadAddress (uint32_t stop_id,
- lldb::addr_t load_addr,
- Address &so_addr);
-
- bool
- SetSectionLoadAddress (uint32_t stop_id,
- const lldb::SectionSP &section_sp,
- lldb::addr_t load_addr,
- bool warn_multiple = false);
-
- // The old load address should be specified when unloading to ensure we get
- // the correct instance of the section as a shared library could be loaded
- // at more than one location.
- bool
- SetSectionUnloaded (uint32_t stop_id,
- const lldb::SectionSP &section_sp,
- lldb::addr_t load_addr);
-
- // Unload all instances of a section. This function can be used on systems
- // that don't support multiple copies of the same shared library to be
- // loaded at the same time.
- size_t
- SetSectionUnloaded (uint32_t stop_id,
- const lldb::SectionSP &section_sp);
-
- void
- Dump (Stream &s,
- Target *target);
+ enum : unsigned {
+ // Pass eStopIDNow to any function that takes a stop ID to get
+ // the current value.
+ eStopIDNow = UINT32_MAX
+ };
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ SectionLoadHistory() : m_stop_id_to_section_load_list(), m_mutex() {}
+
+ ~SectionLoadHistory() {
+ // Call clear since this takes a lock and clears the section load list
+ // in case another thread is currently using this section load list
+ Clear();
+ }
+
+ SectionLoadList &GetCurrentSectionLoadList();
+
+ bool IsEmpty() const;
+
+ void Clear();
+
+ uint32_t GetLastStopID() const;
+
+ // Get the section load address given a process stop ID
+ lldb::addr_t GetSectionLoadAddress(uint32_t stop_id,
+ const lldb::SectionSP &section_sp);
+
+ bool ResolveLoadAddress(uint32_t stop_id, lldb::addr_t load_addr,
+ Address &so_addr);
+
+ bool SetSectionLoadAddress(uint32_t stop_id,
+ const lldb::SectionSP &section_sp,
+ lldb::addr_t load_addr,
+ bool warn_multiple = false);
+
+ // The old load address should be specified when unloading to ensure we get
+ // the correct instance of the section as a shared library could be loaded
+ // at more than one location.
+ bool SetSectionUnloaded(uint32_t stop_id, const lldb::SectionSP &section_sp,
+ lldb::addr_t load_addr);
+
+ // Unload all instances of a section. This function can be used on systems
+ // that don't support multiple copies of the same shared library to be
+ // loaded at the same time.
+ size_t SetSectionUnloaded(uint32_t stop_id,
+ const lldb::SectionSP &section_sp);
+
+ void Dump(Stream &s, Target *target);
protected:
-
- SectionLoadList *
- GetSectionLoadListForStopID (uint32_t stop_id, bool read_only);
+ SectionLoadList *GetSectionLoadListForStopID(uint32_t stop_id,
+ bool read_only);
- typedef std::map<uint32_t, lldb::SectionLoadListSP> StopIDToSectionLoadList;
- StopIDToSectionLoadList m_stop_id_to_section_load_list;
- mutable std::recursive_mutex m_mutex;
+ typedef std::map<uint32_t, lldb::SectionLoadListSP> StopIDToSectionLoadList;
+ StopIDToSectionLoadList m_stop_id_to_section_load_list;
+ mutable std::recursive_mutex m_mutex;
private:
- DISALLOW_COPY_AND_ASSIGN (SectionLoadHistory);
+ DISALLOW_COPY_AND_ASSIGN(SectionLoadHistory);
};
} // namespace lldb_private
-#endif // liblldb_SectionLoadHistory_h_
+#endif // liblldb_SectionLoadHistory_h_
diff --git a/include/lldb/Target/SectionLoadList.h b/include/lldb/Target/SectionLoadList.h
index 1326d6007f2d..c232dd91a8b3 100644
--- a/include/lldb/Target/SectionLoadList.h
+++ b/include/lldb/Target/SectionLoadList.h
@@ -1,4 +1,5 @@
-//===-- SectionLoadList.h -----------------------------------------------*- C++ -*-===//
+//===-- SectionLoadList.h -----------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -18,69 +19,61 @@
// Other libraries and framework includes
#include "llvm/ADT/DenseMap.h"
// Project includes
-#include "lldb/lldb-public.h"
#include "lldb/Core/Section.h"
+#include "lldb/lldb-public.h"
namespace lldb_private {
-class SectionLoadList
-{
+class SectionLoadList {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- SectionLoadList() : m_addr_to_sect(), m_sect_to_addr(), m_mutex() {}
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ SectionLoadList() : m_addr_to_sect(), m_sect_to_addr(), m_mutex() {}
+
+ SectionLoadList(const SectionLoadList &rhs);
- SectionLoadList (const SectionLoadList& rhs);
+ ~SectionLoadList() {
+ // Call clear since this takes a lock and clears the section load list
+ // in case another thread is currently using this section load list
+ Clear();
+ }
- ~SectionLoadList()
- {
- // Call clear since this takes a lock and clears the section load list
- // in case another thread is currently using this section load list
- Clear();
- }
+ void operator=(const SectionLoadList &rhs);
- void
- operator=(const SectionLoadList &rhs);
-
- bool
- IsEmpty() const;
+ bool IsEmpty() const;
- void
- Clear ();
+ void Clear();
- lldb::addr_t
- GetSectionLoadAddress (const lldb::SectionSP &section_sp) const;
+ lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP &section_sp) const;
- bool
- ResolveLoadAddress (lldb::addr_t load_addr, Address &so_addr) const;
+ bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr) const;
- bool
- SetSectionLoadAddress (const lldb::SectionSP &section_sp, lldb::addr_t load_addr, bool warn_multiple = false);
+ bool SetSectionLoadAddress(const lldb::SectionSP &section_sp,
+ lldb::addr_t load_addr,
+ bool warn_multiple = false);
- // The old load address should be specified when unloading to ensure we get
- // the correct instance of the section as a shared library could be loaded
- // at more than one location.
- bool
- SetSectionUnloaded (const lldb::SectionSP &section_sp, lldb::addr_t load_addr);
+ // The old load address should be specified when unloading to ensure we get
+ // the correct instance of the section as a shared library could be loaded
+ // at more than one location.
+ bool SetSectionUnloaded(const lldb::SectionSP &section_sp,
+ lldb::addr_t load_addr);
- // Unload all instances of a section. This function can be used on systems
- // that don't support multiple copies of the same shared library to be
- // loaded at the same time.
- size_t
- SetSectionUnloaded (const lldb::SectionSP &section_sp);
+ // Unload all instances of a section. This function can be used on systems
+ // that don't support multiple copies of the same shared library to be
+ // loaded at the same time.
+ size_t SetSectionUnloaded(const lldb::SectionSP &section_sp);
- void
- Dump (Stream &s, Target *target);
+ void Dump(Stream &s, Target *target);
protected:
- typedef std::map<lldb::addr_t, lldb::SectionSP> addr_to_sect_collection;
- typedef llvm::DenseMap<const Section *, lldb::addr_t> sect_to_addr_collection;
- addr_to_sect_collection m_addr_to_sect;
- sect_to_addr_collection m_sect_to_addr;
- mutable std::recursive_mutex m_mutex;
+ typedef std::map<lldb::addr_t, lldb::SectionSP> addr_to_sect_collection;
+ typedef llvm::DenseMap<const Section *, lldb::addr_t> sect_to_addr_collection;
+ addr_to_sect_collection m_addr_to_sect;
+ sect_to_addr_collection m_sect_to_addr;
+ mutable std::recursive_mutex m_mutex;
};
} // namespace lldb_private
-#endif // liblldb_SectionLoadList_h_
+#endif // liblldb_SectionLoadList_h_
diff --git a/include/lldb/Target/StackFrame.h b/include/lldb/Target/StackFrame.h
index b3cc57f176ca..34bd187b776c 100644
--- a/include/lldb/Target/StackFrame.h
+++ b/include/lldb/Target/StackFrame.h
@@ -33,514 +33,522 @@ namespace lldb_private {
///
/// @brief This base class provides an interface to stack frames.
///
-/// StackFrames may have a Canonical Frame Address (CFA) or not.
-/// A frame may have a plain pc value or it may have a pc value + stop_id
-/// to indicate a specific point in the debug session so the correct section
+/// StackFrames may have a Canonical Frame Address (CFA) or not.
+/// A frame may have a plain pc value or it may have a pc value + stop_id
+/// to indicate a specific point in the debug session so the correct section
/// load list is used for symbolication.
///
/// Local variables may be available, or not. A register context may be
/// available, or not.
-class StackFrame :
- public ExecutionContextScope,
- public std::enable_shared_from_this<StackFrame>
-{
+class StackFrame : public ExecutionContextScope,
+ public std::enable_shared_from_this<StackFrame> {
public:
- enum ExpressionPathOption
- {
- eExpressionPathOptionCheckPtrVsMember = (1u << 0),
- eExpressionPathOptionsNoFragileObjcIvar = (1u << 1),
- eExpressionPathOptionsNoSyntheticChildren = (1u << 2),
- eExpressionPathOptionsNoSyntheticArrayRange = (1u << 3),
- eExpressionPathOptionsAllowDirectIVarAccess = (1u << 4),
- eExpressionPathOptionsInspectAnonymousUnions = (1u << 5)
- };
-
- //------------------------------------------------------------------
- /// Construct a StackFrame object without supplying a RegisterContextSP.
- ///
- /// This is the one constructor that doesn't take a RegisterContext
- /// parameter. This ctor may be called when creating a history StackFrame;
- /// these are used if we've collected a stack trace of pc addresses at
- /// some point in the past. We may only have pc values. We may have pc
- /// values and the stop_id when the stack trace was recorded. We may have a
- /// CFA, or more likely, we won't.
- ///
- /// @param [in] thread_sp
- /// The Thread that this frame belongs to.
- ///
- /// @param [in] frame_idx
- /// This StackFrame's frame index number in the Thread. If inlined stack
- /// frames are being created, this may differ from the concrete_frame_idx
- /// which is the frame index without any inlined stack frames.
- ///
- /// @param [in] concrete_frame_idx
- /// The StackFrame's frame index number in the Thread without any inlined
- /// stack frames being included in the index.
- ///
- /// @param [in] cfa
- /// The Canonical Frame Address (this terminology from DWARF) for this
- /// stack frame. The CFA for a stack frame does not change over the
- /// span of the stack frame's existence. It is often the value of the
- /// caller's stack pointer before the call instruction into this frame's
- /// function. It is usually not the same as the frame pointer register's
- /// value.
- ///
- /// @param [in] cfa_is_valid
- /// A history stack frame may not have a CFA value collected. We want to
- /// distinguish between "no CFA available" and a CFA of
- /// LLDB_INVALID_ADDRESS.
- ///
- /// @param [in] pc
- /// The current pc value of this stack frame.
- ///
- /// @param [in] stop_id
- /// The stop_id which should be used when looking up symbols for the pc value,
- /// if appropriate. This argument is ignored if stop_id_is_valid is false.
- ///
- /// @param [in] stop_id_is_valid
- /// If the stop_id argument provided is not needed for this StackFrame, this
- /// should be false. If this is a history stack frame and we know the stop_id
- /// when the pc value was collected, that stop_id should be provided and this
- /// will be true.
- ///
- /// @param [in] is_history_frame
- /// If this is a historical stack frame -- possibly without CFA or registers or
- /// local variables -- then this should be set to true.
- ///
- /// @param [in] sc_ptr
- /// Optionally seed the StackFrame with the SymbolContext information that has
- /// already been discovered.
- //------------------------------------------------------------------
- StackFrame (const lldb::ThreadSP &thread_sp,
- lldb::user_id_t frame_idx,
- lldb::user_id_t concrete_frame_idx,
- lldb::addr_t cfa,
- bool cfa_is_valid,
- lldb::addr_t pc,
- uint32_t stop_id,
- bool stop_id_is_valid,
- bool is_history_frame,
- const SymbolContext *sc_ptr);
-
- StackFrame (const lldb::ThreadSP &thread_sp,
- lldb::user_id_t frame_idx,
- lldb::user_id_t concrete_frame_idx,
- const lldb::RegisterContextSP &reg_context_sp,
- lldb::addr_t cfa,
- lldb::addr_t pc,
- const SymbolContext *sc_ptr);
-
- StackFrame (const lldb::ThreadSP &thread_sp,
- lldb::user_id_t frame_idx,
- lldb::user_id_t concrete_frame_idx,
- const lldb::RegisterContextSP &reg_context_sp,
- lldb::addr_t cfa,
- const Address& pc,
- const SymbolContext *sc_ptr);
-
- ~StackFrame() override;
-
- lldb::ThreadSP
- GetThread () const
- {
- return m_thread_wp.lock();
- }
-
- StackID&
- GetStackID();
-
- //------------------------------------------------------------------
- /// Get an Address for the current pc value in this StackFrame.
- ///
- /// May not be the same as the actual PC value for inlined stack frames.
- ///
- /// @return
- /// The Address object set to the current PC value.
- //------------------------------------------------------------------
- const Address&
- GetFrameCodeAddress();
-
- //------------------------------------------------------------------
- /// Change the pc value for a given thread.
- ///
- /// Change the current pc value for the frame on this thread.
- ///
- /// @param[in] pc
- /// The load address that the pc will be set to.
- ///
- /// @return
- /// true if the pc was changed. false if this failed -- possibly
- /// because this frame is not a live StackFrame.
- //------------------------------------------------------------------
- bool
- ChangePC (lldb::addr_t pc);
-
- //------------------------------------------------------------------
- /// Provide a SymbolContext for this StackFrame's current pc value.
- ///
- /// The StackFrame maintains this SymbolContext and adds additional information
- /// to it on an as-needed basis. This helps to avoid different functions
- /// looking up symbolic information for a given pc value multiple times.
- ///
- /// @params [in] resolve_scope
- /// Flags from the SymbolContextItem enumerated type which specify what
- /// type of symbol context is needed by this caller.
- ///
- /// @return
- /// A SymbolContext reference which includes the types of information
- /// requested by resolve_scope, if they are available.
- //------------------------------------------------------------------
- const SymbolContext&
- GetSymbolContext (uint32_t resolve_scope);
-
- //------------------------------------------------------------------
- /// Return the Canonical Frame Address (DWARF term) for this frame.
- ///
- /// The CFA is typically the value of the stack pointer register before
- /// the call invocation is made. It will not change during the lifetime
- /// of a stack frame. It is often not the same thing as the frame pointer
- /// register value.
- ///
- /// Live StackFrames will always have a CFA but other types of frames may
- /// not be able to supply one.
- ///
- /// @param [out] value
- /// The address of the CFA for this frame, if available.
- ///
- /// @param [out] error_ptr
- /// If there is an error determining the CFA address, this may contain a
- /// string explaining the failure.
- ///
- /// @return
- /// Returns true if the CFA value was successfully set in value. Some
- /// frames may be unable to provide this value; they will return false.
- //------------------------------------------------------------------
- bool
- GetFrameBaseValue(Scalar &value, Error *error_ptr);
-
- //------------------------------------------------------------------
- /// Get the current lexical scope block for this StackFrame, if possible.
- ///
- /// If debug information is available for this stack frame, return a
- /// pointer to the innermost lexical Block that the frame is currently
- /// executing.
- ///
- /// @return
- /// A pointer to the current Block. nullptr is returned if this can
- /// not be provided.
- //------------------------------------------------------------------
- Block *
- GetFrameBlock ();
-
- //------------------------------------------------------------------
- /// Get the RegisterContext for this frame, if possible.
- ///
- /// Returns a shared pointer to the RegisterContext for this stack frame.
- /// Only a live StackFrame object will be able to return a RegisterContext -
- /// callers must be prepared for an empty shared pointer being returned.
- ///
- /// Even a live StackFrame RegisterContext may not be able to provide all
- /// registers. Only the currently executing frame (frame 0) can reliably
- /// provide every register in the register context.
- ///
- /// @return
- /// The RegisterContext shared point for this frame.
- //------------------------------------------------------------------
- lldb::RegisterContextSP
- GetRegisterContext ();
-
- const lldb::RegisterContextSP &
- GetRegisterContextSP () const
- {
- return m_reg_context_sp;
- }
-
- //------------------------------------------------------------------
- /// Retrieve the list of variables that are in scope at this StackFrame's pc.
- ///
- /// A frame that is not live may return an empty VariableList for a given
- /// pc value even though variables would be available at this point if
- /// it were a live stack frame.
- ///
- /// @param[in] get_file_globals
- /// Whether to also retrieve compilation-unit scoped variables
- /// that are visible to the entire compilation unit (e.g. file
- /// static in C, globals that are homed in this CU).
- ///
- /// @return
- /// A pointer to a list of variables.
- //------------------------------------------------------------------
- VariableList *
- GetVariableList (bool get_file_globals);
-
- //------------------------------------------------------------------
- /// Retrieve the list of variables that are in scope at this StackFrame's pc.
- ///
- /// A frame that is not live may return an empty VariableListSP for a
- /// given pc value even though variables would be available at this point
- /// if it were a live stack frame.
- ///
- /// @param[in] get_file_globals
- /// Whether to also retrieve compilation-unit scoped variables
- /// that are visible to the entire compilation unit (e.g. file
- /// static in C, globals that are homed in this CU).
- ///
- /// @return
- /// A pointer to a list of variables.
- //------------------------------------------------------------------
- lldb::VariableListSP
- GetInScopeVariableList (bool get_file_globals, bool must_have_valid_location = false);
-
- //------------------------------------------------------------------
- /// Create a ValueObject for a variable name / pathname, possibly
- /// including simple dereference/child selection syntax.
- ///
- /// @param[in] var_expr
- /// The string specifying a variable to base the VariableObject off
- /// of.
- ///
- /// @param[in] use_dynamic
- /// Whether the correct dynamic type of an object pointer should be
- /// determined before creating the object, or if the static type is
- /// sufficient. One of the DynamicValueType enumerated values.
- ///
- /// @param[in] options
- /// An unsigned integer of flags, values from StackFrame::ExpressionPathOption
- /// enum.
- /// @param[in] var_sp
- /// A VariableSP that will be set to the variable described in the
- /// var_expr path.
- ///
- /// @param[in] error
- /// Record any errors encountered while evaluating var_expr.
- ///
- /// @return
- /// A shared pointer to the ValueObject described by var_expr.
- //------------------------------------------------------------------
- lldb::ValueObjectSP
- GetValueForVariableExpressionPath (const char *var_expr,
- lldb::DynamicValueType use_dynamic,
- uint32_t options,
- lldb::VariableSP &var_sp,
- Error &error);
-
- //------------------------------------------------------------------
- /// Determine whether this StackFrame has debug information available or not
- ///
- /// @return
- // true if debug information is available for this frame (function,
- // compilation unit, block, etc.)
- //------------------------------------------------------------------
- bool
- HasDebugInformation ();
-
- //------------------------------------------------------------------
- /// Return the disassembly for the instructions of this StackFrame's function
- /// as a single C string.
- ///
- /// @return
- // C string with the assembly instructions for this function.
- //------------------------------------------------------------------
- const char *
- Disassemble ();
-
- //------------------------------------------------------------------
- /// Print a description for this frame using the frame-format formatter settings.
- ///
- /// @param [in] strm
- /// The Stream to print the description to.
- ///
- /// @param [in] frame_marker
- /// Optional string that will be prepended to the frame output description.
- //------------------------------------------------------------------
- void
- DumpUsingSettingsFormat(Stream *strm, const char *frame_marker = nullptr);
-
- //------------------------------------------------------------------
- /// Print a description for this frame using a default format.
- ///
- /// @param [in] strm
- /// The Stream to print the description to.
- ///
- /// @param [in] show_frame_index
- /// Whether to print the frame number or not.
- ///
- /// @param [in] show_fullpaths
- /// Whether to print the full source paths or just the file base name.
- //------------------------------------------------------------------
- void
- Dump (Stream *strm, bool show_frame_index, bool show_fullpaths);
-
- //------------------------------------------------------------------
- /// Print a description of this stack frame and/or the source context/assembly
- /// for this stack frame.
- ///
- /// @param[in] strm
- /// The Stream to send the output to.
- ///
- /// @param[in] show_frame_info
- /// If true, print the frame info by calling DumpUsingSettingsFormat().
- ///
- /// @param[in] show_source
- /// If true, print source or disassembly as per the user's settings.
- ///
- /// @param[in] frame_marker
- /// Passed to DumpUsingSettingsFormat() for the frame info printing.
- ///
- /// @return
- /// Returns true if successful.
- //------------------------------------------------------------------
- bool
- GetStatus(Stream &strm,
- bool show_frame_info,
- bool show_source,
- const char *frame_marker = nullptr);
-
- //------------------------------------------------------------------
- /// Query whether this frame is a concrete frame on the call stack,
- /// or if it is an inlined frame derived from the debug information
- /// and presented by the debugger.
- ///
- /// @return
- /// true if this is an inlined frame.
- //------------------------------------------------------------------
- bool
- IsInlined ();
-
- //------------------------------------------------------------------
- /// Query this frame to find what frame it is in this Thread's StackFrameList.
- ///
- /// @return
- /// StackFrame index 0 indicates the currently-executing function. Inline
- /// frames are included in this frame index count.
- //------------------------------------------------------------------
- uint32_t
- GetFrameIndex () const;
-
- //------------------------------------------------------------------
- /// Query this frame to find what frame it is in this Thread's StackFrameList,
- /// not counting inlined frames.
- ///
- /// @return
- /// StackFrame index 0 indicates the currently-executing function. Inline
- /// frames are not included in this frame index count; their concrete
- /// frame index will be the same as the concrete frame that they are
- /// derived from.
- //------------------------------------------------------------------
- uint32_t
- GetConcreteFrameIndex () const
- {
- return m_concrete_frame_index;
- }
-
- //------------------------------------------------------------------
- /// Create a ValueObject for a given Variable in this StackFrame.
- ///
- /// @params [in] variable_sp
- /// The Variable to base this ValueObject on
- ///
- /// @params [in] use_dynamic
- /// Whether the correct dynamic type of the variable should be
- /// determined before creating the ValueObject, or if the static type
- /// is sufficient. One of the DynamicValueType enumerated values.
- ///
- /// @return
- // A ValueObject for this variable.
- //------------------------------------------------------------------
- lldb::ValueObjectSP
- GetValueObjectForFrameVariable (const lldb::VariableSP &variable_sp, lldb::DynamicValueType use_dynamic);
-
- //------------------------------------------------------------------
- /// Add an arbitrary Variable object (e.g. one that specifics a global or static)
- /// to a StackFrame's list of ValueObjects.
- ///
- /// @params [in] variable_sp
- /// The Variable to base this ValueObject on
- ///
- /// @params [in] use_dynamic
- /// Whether the correct dynamic type of the variable should be
- /// determined before creating the ValueObject, or if the static type
- /// is sufficient. One of the DynamicValueType enumerated values.
- ///
- /// @return
- // A ValueObject for this variable.
- //------------------------------------------------------------------
- lldb::ValueObjectSP
- TrackGlobalVariable (const lldb::VariableSP &variable_sp, lldb::DynamicValueType use_dynamic);
-
- //------------------------------------------------------------------
- /// Query this frame to determine what the default language should be
- /// when parsing expressions given the execution context.
- ///
- /// @return
- /// The language of the frame if known, else lldb::eLanguageTypeUnknown.
- //------------------------------------------------------------------
- lldb::LanguageType
- GetLanguage ();
-
- // similar to GetLanguage(), but is allowed to take a potentially incorrect guess
- // if exact information is not available
- lldb::LanguageType
- GuessLanguage ();
-
- //------------------------------------------------------------------
- // lldb::ExecutionContextScope pure virtual functions
- //------------------------------------------------------------------
- lldb::TargetSP
- CalculateTarget() override;
-
- lldb::ProcessSP
- CalculateProcess() override;
-
- lldb::ThreadSP
- CalculateThread() override;
-
- lldb::StackFrameSP
- CalculateStackFrame() override;
-
- void
- CalculateExecutionContext(ExecutionContext &exe_ctx) override;
+ enum ExpressionPathOption {
+ eExpressionPathOptionCheckPtrVsMember = (1u << 0),
+ eExpressionPathOptionsNoFragileObjcIvar = (1u << 1),
+ eExpressionPathOptionsNoSyntheticChildren = (1u << 2),
+ eExpressionPathOptionsNoSyntheticArrayRange = (1u << 3),
+ eExpressionPathOptionsAllowDirectIVarAccess = (1u << 4),
+ eExpressionPathOptionsInspectAnonymousUnions = (1u << 5)
+ };
+
+ //------------------------------------------------------------------
+ /// Construct a StackFrame object without supplying a RegisterContextSP.
+ ///
+ /// This is the one constructor that doesn't take a RegisterContext
+ /// parameter. This ctor may be called when creating a history StackFrame;
+ /// these are used if we've collected a stack trace of pc addresses at
+ /// some point in the past. We may only have pc values. We may have pc
+ /// values and the stop_id when the stack trace was recorded. We may have a
+ /// CFA, or more likely, we won't.
+ ///
+ /// @param [in] thread_sp
+ /// The Thread that this frame belongs to.
+ ///
+ /// @param [in] frame_idx
+ /// This StackFrame's frame index number in the Thread. If inlined stack
+ /// frames are being created, this may differ from the concrete_frame_idx
+ /// which is the frame index without any inlined stack frames.
+ ///
+ /// @param [in] concrete_frame_idx
+ /// The StackFrame's frame index number in the Thread without any inlined
+ /// stack frames being included in the index.
+ ///
+ /// @param [in] cfa
+ /// The Canonical Frame Address (this terminology from DWARF) for this
+ /// stack frame. The CFA for a stack frame does not change over the
+ /// span of the stack frame's existence. It is often the value of the
+ /// caller's stack pointer before the call instruction into this frame's
+ /// function. It is usually not the same as the frame pointer register's
+ /// value.
+ ///
+ /// @param [in] cfa_is_valid
+ /// A history stack frame may not have a CFA value collected. We want to
+ /// distinguish between "no CFA available" and a CFA of
+ /// LLDB_INVALID_ADDRESS.
+ ///
+ /// @param [in] pc
+ /// The current pc value of this stack frame.
+ ///
+ /// @param [in] stop_id
+ /// The stop_id which should be used when looking up symbols for the pc
+ /// value,
+ /// if appropriate. This argument is ignored if stop_id_is_valid is false.
+ ///
+ /// @param [in] stop_id_is_valid
+ /// If the stop_id argument provided is not needed for this StackFrame, this
+ /// should be false. If this is a history stack frame and we know the
+ /// stop_id
+ /// when the pc value was collected, that stop_id should be provided and
+ /// this
+ /// will be true.
+ ///
+ /// @param [in] is_history_frame
+ /// If this is a historical stack frame -- possibly without CFA or registers
+ /// or
+ /// local variables -- then this should be set to true.
+ ///
+ /// @param [in] sc_ptr
+ /// Optionally seed the StackFrame with the SymbolContext information that
+ /// has
+ /// already been discovered.
+ //------------------------------------------------------------------
+ StackFrame(const lldb::ThreadSP &thread_sp, lldb::user_id_t frame_idx,
+ lldb::user_id_t concrete_frame_idx, lldb::addr_t cfa,
+ bool cfa_is_valid, lldb::addr_t pc, uint32_t stop_id,
+ bool stop_id_is_valid, bool is_history_frame,
+ const SymbolContext *sc_ptr);
+
+ StackFrame(const lldb::ThreadSP &thread_sp, lldb::user_id_t frame_idx,
+ lldb::user_id_t concrete_frame_idx,
+ const lldb::RegisterContextSP &reg_context_sp, lldb::addr_t cfa,
+ lldb::addr_t pc, const SymbolContext *sc_ptr);
+
+ StackFrame(const lldb::ThreadSP &thread_sp, lldb::user_id_t frame_idx,
+ lldb::user_id_t concrete_frame_idx,
+ const lldb::RegisterContextSP &reg_context_sp, lldb::addr_t cfa,
+ const Address &pc, const SymbolContext *sc_ptr);
+
+ ~StackFrame() override;
+
+ lldb::ThreadSP GetThread() const { return m_thread_wp.lock(); }
+
+ StackID &GetStackID();
+
+ //------------------------------------------------------------------
+ /// Get an Address for the current pc value in this StackFrame.
+ ///
+ /// May not be the same as the actual PC value for inlined stack frames.
+ ///
+ /// @return
+ /// The Address object set to the current PC value.
+ //------------------------------------------------------------------
+ const Address &GetFrameCodeAddress();
+
+ //------------------------------------------------------------------
+ /// Change the pc value for a given thread.
+ ///
+ /// Change the current pc value for the frame on this thread.
+ ///
+ /// @param[in] pc
+ /// The load address that the pc will be set to.
+ ///
+ /// @return
+ /// true if the pc was changed. false if this failed -- possibly
+ /// because this frame is not a live StackFrame.
+ //------------------------------------------------------------------
+ bool ChangePC(lldb::addr_t pc);
+
+ //------------------------------------------------------------------
+ /// Provide a SymbolContext for this StackFrame's current pc value.
+ ///
+ /// The StackFrame maintains this SymbolContext and adds additional
+ /// information
+ /// to it on an as-needed basis. This helps to avoid different functions
+ /// looking up symbolic information for a given pc value multiple times.
+ ///
+ /// @params [in] resolve_scope
+ /// Flags from the SymbolContextItem enumerated type which specify what
+ /// type of symbol context is needed by this caller.
+ ///
+ /// @return
+ /// A SymbolContext reference which includes the types of information
+ /// requested by resolve_scope, if they are available.
+ //------------------------------------------------------------------
+ const SymbolContext &GetSymbolContext(uint32_t resolve_scope);
+
+ //------------------------------------------------------------------
+ /// Return the Canonical Frame Address (DWARF term) for this frame.
+ ///
+ /// The CFA is typically the value of the stack pointer register before
+ /// the call invocation is made. It will not change during the lifetime
+ /// of a stack frame. It is often not the same thing as the frame pointer
+ /// register value.
+ ///
+ /// Live StackFrames will always have a CFA but other types of frames may
+ /// not be able to supply one.
+ ///
+ /// @param [out] value
+ /// The address of the CFA for this frame, if available.
+ ///
+ /// @param [out] error_ptr
+ /// If there is an error determining the CFA address, this may contain a
+ /// string explaining the failure.
+ ///
+ /// @return
+ /// Returns true if the CFA value was successfully set in value. Some
+ /// frames may be unable to provide this value; they will return false.
+ //------------------------------------------------------------------
+ bool GetFrameBaseValue(Scalar &value, Error *error_ptr);
+
+ //------------------------------------------------------------------
+ /// Get the DWARFExpression corresponding to the Canonical Frame Address.
+ ///
+ /// Often a register (bp), but sometimes a register + offset.
+ ///
+ /// @param [out] error_ptr
+ /// If there is an error determining the CFA address, this may contain a
+ /// string explaining the failure.
+ ///
+ /// @return
+ /// Returns the corresponding DWARF expression, or NULL.
+ //------------------------------------------------------------------
+ DWARFExpression *GetFrameBaseExpression(Error *error_ptr);
+
+ //------------------------------------------------------------------
+ /// Get the current lexical scope block for this StackFrame, if possible.
+ ///
+ /// If debug information is available for this stack frame, return a
+ /// pointer to the innermost lexical Block that the frame is currently
+ /// executing.
+ ///
+ /// @return
+ /// A pointer to the current Block. nullptr is returned if this can
+ /// not be provided.
+ //------------------------------------------------------------------
+ Block *GetFrameBlock();
+
+ //------------------------------------------------------------------
+ /// Get the RegisterContext for this frame, if possible.
+ ///
+ /// Returns a shared pointer to the RegisterContext for this stack frame.
+ /// Only a live StackFrame object will be able to return a RegisterContext -
+ /// callers must be prepared for an empty shared pointer being returned.
+ ///
+ /// Even a live StackFrame RegisterContext may not be able to provide all
+ /// registers. Only the currently executing frame (frame 0) can reliably
+ /// provide every register in the register context.
+ ///
+ /// @return
+ /// The RegisterContext shared point for this frame.
+ //------------------------------------------------------------------
+ lldb::RegisterContextSP GetRegisterContext();
+
+ const lldb::RegisterContextSP &GetRegisterContextSP() const {
+ return m_reg_context_sp;
+ }
+
+ //------------------------------------------------------------------
+ /// Retrieve the list of variables that are in scope at this StackFrame's pc.
+ ///
+ /// A frame that is not live may return an empty VariableList for a given
+ /// pc value even though variables would be available at this point if
+ /// it were a live stack frame.
+ ///
+ /// @param[in] get_file_globals
+ /// Whether to also retrieve compilation-unit scoped variables
+ /// that are visible to the entire compilation unit (e.g. file
+ /// static in C, globals that are homed in this CU).
+ ///
+ /// @return
+ /// A pointer to a list of variables.
+ //------------------------------------------------------------------
+ VariableList *GetVariableList(bool get_file_globals);
+
+ //------------------------------------------------------------------
+ /// Retrieve the list of variables that are in scope at this StackFrame's pc.
+ ///
+ /// A frame that is not live may return an empty VariableListSP for a
+ /// given pc value even though variables would be available at this point
+ /// if it were a live stack frame.
+ ///
+ /// @param[in] get_file_globals
+ /// Whether to also retrieve compilation-unit scoped variables
+ /// that are visible to the entire compilation unit (e.g. file
+ /// static in C, globals that are homed in this CU).
+ ///
+ /// @return
+ /// A pointer to a list of variables.
+ //------------------------------------------------------------------
+ lldb::VariableListSP
+ GetInScopeVariableList(bool get_file_globals,
+ bool must_have_valid_location = false);
+
+ //------------------------------------------------------------------
+ /// Create a ValueObject for a variable name / pathname, possibly
+ /// including simple dereference/child selection syntax.
+ ///
+ /// @param[in] var_expr
+ /// The string specifying a variable to base the VariableObject off
+ /// of.
+ ///
+ /// @param[in] use_dynamic
+ /// Whether the correct dynamic type of an object pointer should be
+ /// determined before creating the object, or if the static type is
+ /// sufficient. One of the DynamicValueType enumerated values.
+ ///
+ /// @param[in] options
+ /// An unsigned integer of flags, values from
+ /// StackFrame::ExpressionPathOption
+ /// enum.
+ /// @param[in] var_sp
+ /// A VariableSP that will be set to the variable described in the
+ /// var_expr path.
+ ///
+ /// @param[in] error
+ /// Record any errors encountered while evaluating var_expr.
+ ///
+ /// @return
+ /// A shared pointer to the ValueObject described by var_expr.
+ //------------------------------------------------------------------
+ lldb::ValueObjectSP GetValueForVariableExpressionPath(
+ llvm::StringRef var_expr, lldb::DynamicValueType use_dynamic,
+ uint32_t options, lldb::VariableSP &var_sp, Error &error);
+
+ //------------------------------------------------------------------
+ /// Determine whether this StackFrame has debug information available or not
+ ///
+ /// @return
+ // true if debug information is available for this frame (function,
+ // compilation unit, block, etc.)
+ //------------------------------------------------------------------
+ bool HasDebugInformation();
+
+ //------------------------------------------------------------------
+ /// Return the disassembly for the instructions of this StackFrame's function
+ /// as a single C string.
+ ///
+ /// @return
+ // C string with the assembly instructions for this function.
+ //------------------------------------------------------------------
+ const char *Disassemble();
+
+ //------------------------------------------------------------------
+ /// Print a description for this frame using the frame-format formatter
+ /// settings.
+ ///
+ /// @param [in] strm
+ /// The Stream to print the description to.
+ ///
+ /// @param [in] frame_marker
+ /// Optional string that will be prepended to the frame output description.
+ //------------------------------------------------------------------
+ void DumpUsingSettingsFormat(Stream *strm,
+ const char *frame_marker = nullptr);
+
+ //------------------------------------------------------------------
+ /// Print a description for this frame using a default format.
+ ///
+ /// @param [in] strm
+ /// The Stream to print the description to.
+ ///
+ /// @param [in] show_frame_index
+ /// Whether to print the frame number or not.
+ ///
+ /// @param [in] show_fullpaths
+ /// Whether to print the full source paths or just the file base name.
+ //------------------------------------------------------------------
+ void Dump(Stream *strm, bool show_frame_index, bool show_fullpaths);
+
+ //------------------------------------------------------------------
+ /// Print a description of this stack frame and/or the source context/assembly
+ /// for this stack frame.
+ ///
+ /// @param[in] strm
+ /// The Stream to send the output to.
+ ///
+ /// @param[in] show_frame_info
+ /// If true, print the frame info by calling DumpUsingSettingsFormat().
+ ///
+ /// @param[in] show_source
+ /// If true, print source or disassembly as per the user's settings.
+ ///
+ /// @param[in] frame_marker
+ /// Passed to DumpUsingSettingsFormat() for the frame info printing.
+ ///
+ /// @return
+ /// Returns true if successful.
+ //------------------------------------------------------------------
+ bool GetStatus(Stream &strm, bool show_frame_info, bool show_source,
+ const char *frame_marker = nullptr);
+
+ //------------------------------------------------------------------
+ /// Query whether this frame is a concrete frame on the call stack,
+ /// or if it is an inlined frame derived from the debug information
+ /// and presented by the debugger.
+ ///
+ /// @return
+ /// true if this is an inlined frame.
+ //------------------------------------------------------------------
+ bool IsInlined();
+
+ //------------------------------------------------------------------
+ /// Query this frame to find what frame it is in this Thread's StackFrameList.
+ ///
+ /// @return
+ /// StackFrame index 0 indicates the currently-executing function. Inline
+ /// frames are included in this frame index count.
+ //------------------------------------------------------------------
+ uint32_t GetFrameIndex() const;
+
+ //------------------------------------------------------------------
+ /// Query this frame to find what frame it is in this Thread's StackFrameList,
+ /// not counting inlined frames.
+ ///
+ /// @return
+ /// StackFrame index 0 indicates the currently-executing function. Inline
+ /// frames are not included in this frame index count; their concrete
+ /// frame index will be the same as the concrete frame that they are
+ /// derived from.
+ //------------------------------------------------------------------
+ uint32_t GetConcreteFrameIndex() const { return m_concrete_frame_index; }
+
+ //------------------------------------------------------------------
+ /// Create a ValueObject for a given Variable in this StackFrame.
+ ///
+ /// @params [in] variable_sp
+ /// The Variable to base this ValueObject on
+ ///
+ /// @params [in] use_dynamic
+ /// Whether the correct dynamic type of the variable should be
+ /// determined before creating the ValueObject, or if the static type
+ /// is sufficient. One of the DynamicValueType enumerated values.
+ ///
+ /// @return
+ // A ValueObject for this variable.
+ //------------------------------------------------------------------
+ lldb::ValueObjectSP
+ GetValueObjectForFrameVariable(const lldb::VariableSP &variable_sp,
+ lldb::DynamicValueType use_dynamic);
+
+ //------------------------------------------------------------------
+ /// Add an arbitrary Variable object (e.g. one that specifics a global or
+ /// static)
+ /// to a StackFrame's list of ValueObjects.
+ ///
+ /// @params [in] variable_sp
+ /// The Variable to base this ValueObject on
+ ///
+ /// @params [in] use_dynamic
+ /// Whether the correct dynamic type of the variable should be
+ /// determined before creating the ValueObject, or if the static type
+ /// is sufficient. One of the DynamicValueType enumerated values.
+ ///
+ /// @return
+ // A ValueObject for this variable.
+ //------------------------------------------------------------------
+ lldb::ValueObjectSP TrackGlobalVariable(const lldb::VariableSP &variable_sp,
+ lldb::DynamicValueType use_dynamic);
+
+ //------------------------------------------------------------------
+ /// Query this frame to determine what the default language should be
+ /// when parsing expressions given the execution context.
+ ///
+ /// @return
+ /// The language of the frame if known, else lldb::eLanguageTypeUnknown.
+ //------------------------------------------------------------------
+ lldb::LanguageType GetLanguage();
+
+ // similar to GetLanguage(), but is allowed to take a potentially incorrect
+ // guess
+ // if exact information is not available
+ lldb::LanguageType GuessLanguage();
+
+ //------------------------------------------------------------------
+ /// Attempt to econstruct the ValueObject for a given raw address touched by
+ /// the current instruction. The ExpressionPath should indicate how to get
+ /// to this value using "frame variable."
+ ///
+ /// @params [in] addr
+ /// The raw address.
+ ///
+ /// @return
+ /// The ValueObject if found. If valid, it has a valid ExpressionPath.
+ //------------------------------------------------------------------
+ lldb::ValueObjectSP GuessValueForAddress(lldb::addr_t addr);
+
+ //------------------------------------------------------------------
+ /// Attempt to reconstruct the ValueObject for the address contained in a
+ /// given register plus an offset. The ExpressionPath should indicate how to
+ /// get to this value using "frame variable."
+ ///
+ /// @params [in] reg
+ /// The name of the register.
+ ///
+ /// @params [in] offset
+ /// The offset from the register. Particularly important for sp...
+ ///
+ /// @return
+ /// The ValueObject if found. If valid, it has a valid ExpressionPath.
+ //------------------------------------------------------------------
+ lldb::ValueObjectSP GuessValueForRegisterAndOffset(ConstString reg,
+ int64_t offset);
+
+ //------------------------------------------------------------------
+ // lldb::ExecutionContextScope pure virtual functions
+ //------------------------------------------------------------------
+ lldb::TargetSP CalculateTarget() override;
+
+ lldb::ProcessSP CalculateProcess() override;
+
+ lldb::ThreadSP CalculateThread() override;
+
+ lldb::StackFrameSP CalculateStackFrame() override;
+
+ void CalculateExecutionContext(ExecutionContext &exe_ctx) override;
protected:
- friend class StackFrameList;
+ friend class StackFrameList;
- void
- SetSymbolContextScope (SymbolContextScope *symbol_scope);
+ void SetSymbolContextScope(SymbolContextScope *symbol_scope);
- void
- UpdateCurrentFrameFromPreviousFrame (StackFrame &prev_frame);
+ void UpdateCurrentFrameFromPreviousFrame(StackFrame &prev_frame);
- void
- UpdatePreviousFrameFromCurrentFrame (StackFrame &curr_frame);
+ void UpdatePreviousFrameFromCurrentFrame(StackFrame &curr_frame);
+
+ bool HasCachedData() const;
- bool
- HasCachedData () const;
-
private:
- //------------------------------------------------------------------
- // For StackFrame only
- //------------------------------------------------------------------
- lldb::ThreadWP m_thread_wp;
- uint32_t m_frame_index;
- uint32_t m_concrete_frame_index;
- lldb::RegisterContextSP m_reg_context_sp;
- StackID m_id;
- Address m_frame_code_addr; // The frame code address (might not be the same as the actual PC for inlined frames) as a section/offset address
- SymbolContext m_sc;
- Flags m_flags;
- Scalar m_frame_base;
- Error m_frame_base_error;
- bool m_cfa_is_valid; // Does this frame have a CFA? Different from CFA == LLDB_INVALID_ADDRESS
- uint32_t m_stop_id;
- bool m_stop_id_is_valid; // Does this frame have a stop_id? Use it when referring to the m_frame_code_addr.
- bool m_is_history_frame;
- lldb::VariableListSP m_variable_list_sp;
- ValueObjectList m_variable_list_value_objects; // Value objects for each variable in m_variable_list_sp
- StreamString m_disassembly;
- std::recursive_mutex m_mutex;
-
- DISALLOW_COPY_AND_ASSIGN (StackFrame);
+ //------------------------------------------------------------------
+ // For StackFrame only
+ //------------------------------------------------------------------
+ lldb::ThreadWP m_thread_wp;
+ uint32_t m_frame_index;
+ uint32_t m_concrete_frame_index;
+ lldb::RegisterContextSP m_reg_context_sp;
+ StackID m_id;
+ Address m_frame_code_addr; // The frame code address (might not be the same as
+ // the actual PC for inlined frames) as a
+ // section/offset address
+ SymbolContext m_sc;
+ Flags m_flags;
+ Scalar m_frame_base;
+ Error m_frame_base_error;
+ bool m_cfa_is_valid; // Does this frame have a CFA? Different from CFA ==
+ // LLDB_INVALID_ADDRESS
+ uint32_t m_stop_id;
+ bool m_stop_id_is_valid; // Does this frame have a stop_id? Use it when
+ // referring to the m_frame_code_addr.
+ bool m_is_history_frame;
+ lldb::VariableListSP m_variable_list_sp;
+ ValueObjectList m_variable_list_value_objects; // Value objects for each
+ // variable in
+ // m_variable_list_sp
+ StreamString m_disassembly;
+ std::recursive_mutex m_mutex;
+
+ DISALLOW_COPY_AND_ASSIGN(StackFrame);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/StackFrameList.h b/include/lldb/Target/StackFrameList.h
index 8b6bea3193c5..a770346b58f0 100644
--- a/include/lldb/Target/StackFrameList.h
+++ b/include/lldb/Target/StackFrameList.h
@@ -22,129 +22,94 @@
namespace lldb_private {
-class StackFrameList
-{
+class StackFrameList {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- StackFrameList (Thread &thread,
- const lldb::StackFrameListSP &prev_frames_sp,
- bool show_inline_frames);
-
- ~StackFrameList();
-
- uint32_t
- GetNumFrames (bool can_create = true);
-
- lldb::StackFrameSP
- GetFrameAtIndex (uint32_t idx);
-
- lldb::StackFrameSP
- GetFrameWithConcreteFrameIndex (uint32_t unwind_idx);
-
- lldb::StackFrameSP
- GetFrameWithStackID (const StackID &stack_id);
-
- // Mark a stack frame as the current frame
- uint32_t
- SetSelectedFrame (lldb_private::StackFrame *frame);
-
- uint32_t
- GetSelectedFrameIndex () const;
-
- // Mark a stack frame as the current frame using the frame index
- bool
- SetSelectedFrameByIndex (uint32_t idx);
-
- uint32_t
- GetVisibleStackFrameIndex(uint32_t idx)
- {
- if (m_current_inlined_depth < UINT32_MAX)
- return idx - m_current_inlined_depth;
- else
- return idx;
- }
-
- void
- CalculateCurrentInlinedDepth ();
-
- void
- SetDefaultFileAndLineToSelectedFrame();
-
- void
- Clear ();
-
- void
- InvalidateFrames (uint32_t start_idx);
-
- void
- Dump (Stream *s);
-
- lldb::StackFrameSP
- GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr);
-
- size_t
- GetStatus(Stream &strm,
- uint32_t first_frame,
- uint32_t num_frames,
- bool show_frame_info,
- uint32_t num_frames_with_source,
- const char *frame_marker = nullptr);
-
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ StackFrameList(Thread &thread, const lldb::StackFrameListSP &prev_frames_sp,
+ bool show_inline_frames);
+
+ ~StackFrameList();
+
+ uint32_t GetNumFrames(bool can_create = true);
+
+ lldb::StackFrameSP GetFrameAtIndex(uint32_t idx);
+
+ lldb::StackFrameSP GetFrameWithConcreteFrameIndex(uint32_t unwind_idx);
+
+ lldb::StackFrameSP GetFrameWithStackID(const StackID &stack_id);
+
+ // Mark a stack frame as the current frame
+ uint32_t SetSelectedFrame(lldb_private::StackFrame *frame);
+
+ uint32_t GetSelectedFrameIndex() const;
+
+ // Mark a stack frame as the current frame using the frame index
+ bool SetSelectedFrameByIndex(uint32_t idx);
+
+ uint32_t GetVisibleStackFrameIndex(uint32_t idx) {
+ if (m_current_inlined_depth < UINT32_MAX)
+ return idx - m_current_inlined_depth;
+ else
+ return idx;
+ }
+
+ void CalculateCurrentInlinedDepth();
+
+ void SetDefaultFileAndLineToSelectedFrame();
+
+ void Clear();
+
+ void InvalidateFrames(uint32_t start_idx);
+
+ void Dump(Stream *s);
+
+ lldb::StackFrameSP
+ GetStackFrameSPForStackFramePtr(StackFrame *stack_frame_ptr);
+
+ size_t GetStatus(Stream &strm, uint32_t first_frame, uint32_t num_frames,
+ bool show_frame_info, uint32_t num_frames_with_source,
+ const char *frame_marker = nullptr);
+
protected:
- friend class Thread;
-
- bool
- SetFrameAtIndex (uint32_t idx, lldb::StackFrameSP &frame_sp);
-
- static void
- Merge (std::unique_ptr<StackFrameList>& curr_ap,
- lldb::StackFrameListSP& prev_sp);
-
- void
- GetFramesUpTo (uint32_t end_idx);
-
- bool
- GetAllFramesFetched()
- {
- return m_concrete_frames_fetched == UINT32_MAX;
- }
-
- void
- SetAllFramesFetched ()
- {
- m_concrete_frames_fetched = UINT32_MAX;
- }
-
- bool
- DecrementCurrentInlinedDepth ();
-
- void
- ResetCurrentInlinedDepth();
-
- uint32_t
- GetCurrentInlinedDepth ();
-
- void
- SetCurrentInlinedDepth (uint32_t new_depth);
-
- typedef std::vector<lldb::StackFrameSP> collection;
- typedef collection::iterator iterator;
- typedef collection::const_iterator const_iterator;
-
- Thread &m_thread;
- lldb::StackFrameListSP m_prev_frames_sp;
- mutable std::recursive_mutex m_mutex;
- collection m_frames;
- uint32_t m_selected_frame_idx;
- uint32_t m_concrete_frames_fetched;
- uint32_t m_current_inlined_depth;
- lldb::addr_t m_current_inlined_pc;
- bool m_show_inlined_frames;
+ friend class Thread;
+
+ bool SetFrameAtIndex(uint32_t idx, lldb::StackFrameSP &frame_sp);
+
+ static void Merge(std::unique_ptr<StackFrameList> &curr_ap,
+ lldb::StackFrameListSP &prev_sp);
+
+ void GetFramesUpTo(uint32_t end_idx);
+
+ bool GetAllFramesFetched() { return m_concrete_frames_fetched == UINT32_MAX; }
+
+ void SetAllFramesFetched() { m_concrete_frames_fetched = UINT32_MAX; }
+
+ bool DecrementCurrentInlinedDepth();
+
+ void ResetCurrentInlinedDepth();
+
+ uint32_t GetCurrentInlinedDepth();
+
+ void SetCurrentInlinedDepth(uint32_t new_depth);
+
+ typedef std::vector<lldb::StackFrameSP> collection;
+ typedef collection::iterator iterator;
+ typedef collection::const_iterator const_iterator;
+
+ Thread &m_thread;
+ lldb::StackFrameListSP m_prev_frames_sp;
+ mutable std::recursive_mutex m_mutex;
+ collection m_frames;
+ uint32_t m_selected_frame_idx;
+ uint32_t m_concrete_frames_fetched;
+ uint32_t m_current_inlined_depth;
+ lldb::addr_t m_current_inlined_pc;
+ bool m_show_inlined_frames;
private:
- DISALLOW_COPY_AND_ASSIGN (StackFrameList);
+ DISALLOW_COPY_AND_ASSIGN(StackFrameList);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/StackID.h b/include/lldb/Target/StackID.h
index aad9d0cfc25c..7b7e9e5187b6 100644
--- a/include/lldb/Target/StackID.h
+++ b/include/lldb/Target/StackID.h
@@ -14,134 +14,94 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/AddressRange.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class StackID
-{
+class StackID {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- StackID () :
- m_pc (LLDB_INVALID_ADDRESS),
- m_cfa (LLDB_INVALID_ADDRESS),
- m_symbol_scope (nullptr)
- {
- }
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ StackID()
+ : m_pc(LLDB_INVALID_ADDRESS), m_cfa(LLDB_INVALID_ADDRESS),
+ m_symbol_scope(nullptr) {}
- explicit
- StackID (lldb::addr_t pc, lldb::addr_t cfa, SymbolContextScope *symbol_scope) :
- m_pc (pc),
- m_cfa (cfa),
- m_symbol_scope (symbol_scope)
- {
- }
+ explicit StackID(lldb::addr_t pc, lldb::addr_t cfa,
+ SymbolContextScope *symbol_scope)
+ : m_pc(pc), m_cfa(cfa), m_symbol_scope(symbol_scope) {}
- StackID (const StackID& rhs) :
- m_pc (rhs.m_pc),
- m_cfa (rhs.m_cfa),
- m_symbol_scope (rhs.m_symbol_scope)
- {
- }
+ StackID(const StackID &rhs)
+ : m_pc(rhs.m_pc), m_cfa(rhs.m_cfa), m_symbol_scope(rhs.m_symbol_scope) {}
- ~StackID() = default;
+ ~StackID() = default;
- lldb::addr_t
- GetPC() const
- {
- return m_pc;
- }
-
- lldb::addr_t
- GetCallFrameAddress() const
- {
- return m_cfa;
- }
+ lldb::addr_t GetPC() const { return m_pc; }
- SymbolContextScope *
- GetSymbolContextScope () const
- {
- return m_symbol_scope;
- }
-
- void
- SetSymbolContextScope (SymbolContextScope *symbol_scope)
- {
- m_symbol_scope = symbol_scope;
- }
+ lldb::addr_t GetCallFrameAddress() const { return m_cfa; }
- void
- Clear ()
- {
- m_pc = LLDB_INVALID_ADDRESS;
- m_cfa = LLDB_INVALID_ADDRESS;
- m_symbol_scope = nullptr;
- }
-
- bool
- IsValid () const
- {
- return m_pc != LLDB_INVALID_ADDRESS || m_cfa != LLDB_INVALID_ADDRESS;
- }
-
- void
- Dump (Stream *s);
-
- //------------------------------------------------------------------
- // Operators
- //------------------------------------------------------------------
- const StackID&
- operator=(const StackID& rhs)
- {
- if (this != &rhs)
- {
- m_pc = rhs.m_pc;
- m_cfa = rhs.m_cfa;
- m_symbol_scope = rhs.m_symbol_scope;
- }
- return *this;
- }
+ SymbolContextScope *GetSymbolContextScope() const { return m_symbol_scope; }
-protected:
- friend class StackFrame;
+ void SetSymbolContextScope(SymbolContextScope *symbol_scope) {
+ m_symbol_scope = symbol_scope;
+ }
- void
- SetPC (lldb::addr_t pc)
- {
- m_pc = pc;
- }
+ void Clear() {
+ m_pc = LLDB_INVALID_ADDRESS;
+ m_cfa = LLDB_INVALID_ADDRESS;
+ m_symbol_scope = nullptr;
+ }
+
+ bool IsValid() const {
+ return m_pc != LLDB_INVALID_ADDRESS || m_cfa != LLDB_INVALID_ADDRESS;
+ }
- void
- SetCFA (lldb::addr_t cfa)
- {
- m_cfa = cfa;
+ void Dump(Stream *s);
+
+ //------------------------------------------------------------------
+ // Operators
+ //------------------------------------------------------------------
+ const StackID &operator=(const StackID &rhs) {
+ if (this != &rhs) {
+ m_pc = rhs.m_pc;
+ m_cfa = rhs.m_cfa;
+ m_symbol_scope = rhs.m_symbol_scope;
}
+ return *this;
+ }
- lldb::addr_t m_pc; // The pc value for the function/symbol for this frame. This will
- // only get used if the symbol scope is nullptr (the code where we are
- // stopped is not represented by any function or symbol in any
- // shared library).
- lldb::addr_t m_cfa; // The call frame address (stack pointer) value
- // at the beginning of the function that uniquely
- // identifies this frame (along with m_symbol_scope below)
- SymbolContextScope *m_symbol_scope; // If nullptr, there is no block or symbol for this frame.
- // If not nullptr, this will either be the scope for the
- // lexical block for the frame, or the scope
- // for the symbol. Symbol context scopes are
- // always be unique pointers since the are part
- // of the Block and Symbol objects and can easily
- // be used to tell if a stack ID is the same as
- // another.
+protected:
+ friend class StackFrame;
+
+ void SetPC(lldb::addr_t pc) { m_pc = pc; }
+
+ void SetCFA(lldb::addr_t cfa) { m_cfa = cfa; }
+
+ lldb::addr_t
+ m_pc; // The pc value for the function/symbol for this frame. This will
+ // only get used if the symbol scope is nullptr (the code where we are
+ // stopped is not represented by any function or symbol in any
+ // shared library).
+ lldb::addr_t m_cfa; // The call frame address (stack pointer) value
+ // at the beginning of the function that uniquely
+ // identifies this frame (along with m_symbol_scope below)
+ SymbolContextScope *
+ m_symbol_scope; // If nullptr, there is no block or symbol for this frame.
+ // If not nullptr, this will either be the scope for the
+ // lexical block for the frame, or the scope
+ // for the symbol. Symbol context scopes are
+ // always be unique pointers since the are part
+ // of the Block and Symbol objects and can easily
+ // be used to tell if a stack ID is the same as
+ // another.
};
-bool operator== (const StackID& lhs, const StackID& rhs);
-bool operator!= (const StackID& lhs, const StackID& rhs);
+bool operator==(const StackID &lhs, const StackID &rhs);
+bool operator!=(const StackID &lhs, const StackID &rhs);
// frame_id_1 < frame_id_2 means "frame_id_1 is YOUNGER than frame_id_2"
-bool operator< (const StackID& lhs, const StackID& rhs);
+bool operator<(const StackID &lhs, const StackID &rhs);
} // namespace lldb_private
diff --git a/include/lldb/Target/StopInfo.h b/include/lldb/Target/StopInfo.h
index dfc9860b604a..46f34567350d 100644
--- a/include/lldb/Target/StopInfo.h
+++ b/include/lldb/Target/StopInfo.h
@@ -16,232 +16,192 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
-#include "lldb/Target/Process.h"
#include "lldb/Core/StructuredData.h"
+#include "lldb/Target/Process.h"
+#include "lldb/lldb-public.h"
namespace lldb_private {
-class StopInfo
-{
- friend class Process::ProcessEventData;
- friend class ThreadPlanBase;
-
+class StopInfo {
+ friend class Process::ProcessEventData;
+ friend class ThreadPlanBase;
+
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- StopInfo (Thread &thread, uint64_t value);
-
- virtual ~StopInfo()
- {
- }
-
-
- bool
- IsValid () const;
-
- void
- SetThread (const lldb::ThreadSP &thread_sp)
- {
- m_thread_wp = thread_sp;
- }
-
- lldb::ThreadSP
- GetThread() const
- {
- return m_thread_wp.lock();
- }
-
- // The value of the StopInfo depends on the StopReason.
- // StopReason Meaning
- // ----------------------------------------------
- // eStopReasonBreakpoint BreakpointSiteID
- // eStopReasonSignal Signal number
- // eStopReasonWatchpoint WatchpointLocationID
- // eStopReasonPlanComplete No significance
-
- uint64_t
- GetValue() const
- {
- return m_value;
- }
-
- virtual lldb::StopReason
- GetStopReason () const = 0;
-
- // ShouldStopSynchronous will get called before any thread plans are consulted, and if it says we should
- // resume the target, then we will just immediately resume. This should not run any code in or resume the
- // target.
-
- virtual bool
- ShouldStopSynchronous (Event *event_ptr)
- {
- return true;
- }
-
- void
- OverrideShouldNotify (bool override_value)
- {
- m_override_should_notify = override_value ? eLazyBoolYes : eLazyBoolNo;
- }
-
- // If should stop returns false, check if we should notify of this event
- virtual bool
- ShouldNotify (Event *event_ptr)
- {
- if (m_override_should_notify == eLazyBoolCalculate)
- return DoShouldNotify (event_ptr);
- else
- return m_override_should_notify == eLazyBoolYes;
- }
-
- virtual void
- WillResume (lldb::StateType resume_state)
- {
- // By default, don't do anything
- }
-
- virtual const char *
- GetDescription ()
- {
- return m_description.c_str();
- }
-
- virtual void
- SetDescription (const char *desc_cstr)
- {
- if (desc_cstr && desc_cstr[0])
- m_description.assign (desc_cstr);
- else
- m_description.clear();
- }
-
- virtual bool
- IsValidForOperatingSystemThread (Thread &thread)
- {
- return true;
- }
-
- // Sometimes the thread plan logic will know that it wants a given stop to stop or not,
- // regardless of what the ordinary logic for that StopInfo would dictate. The main example
- // of this is the ThreadPlanCallFunction, which for instance knows - based on how that particular
- // expression was executed - whether it wants all breakpoints to auto-continue or not.
- // Use OverrideShouldStop on the StopInfo to implement this.
-
- void
- OverrideShouldStop (bool override_value)
- {
- m_override_should_stop = override_value ? eLazyBoolYes : eLazyBoolNo;
- }
-
- bool
- GetOverrideShouldStop()
- {
- return m_override_should_stop != eLazyBoolCalculate;
- }
-
- bool
- GetOverriddenShouldStopValue ()
- {
- return m_override_should_stop == eLazyBoolYes;
- }
-
- StructuredData::ObjectSP
- GetExtendedInfo ()
- {
- return m_extended_info;
- }
-
- static lldb::StopInfoSP
- CreateStopReasonWithBreakpointSiteID (Thread &thread, lldb::break_id_t break_id);
-
- // This creates a StopInfo for the thread where the should_stop is already set, and won't be recalculated.
- static lldb::StopInfoSP
- CreateStopReasonWithBreakpointSiteID (Thread &thread, lldb::break_id_t break_id, bool should_stop);
-
- static lldb::StopInfoSP
- CreateStopReasonWithWatchpointID (Thread &thread, lldb::break_id_t watch_id, lldb::addr_t watch_hit_addr = LLDB_INVALID_ADDRESS);
-
- static lldb::StopInfoSP
- CreateStopReasonWithSignal (Thread &thread, int signo, const char *description = nullptr);
-
- static lldb::StopInfoSP
- CreateStopReasonToTrace (Thread &thread);
-
- static lldb::StopInfoSP
- CreateStopReasonWithPlan (lldb::ThreadPlanSP &plan,
- lldb::ValueObjectSP return_valobj_sp,
- lldb::ExpressionVariableSP expression_variable_sp);
-
- static lldb::StopInfoSP
- CreateStopReasonWithException (Thread &thread, const char *description);
-
- static lldb::StopInfoSP
- CreateStopReasonWithExec (Thread &thread);
-
- static lldb::ValueObjectSP
- GetReturnValueObject (lldb::StopInfoSP &stop_info_sp);
-
- static lldb::ExpressionVariableSP
- GetExpressionVariable (lldb::StopInfoSP &stop_info_sp);
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ StopInfo(Thread &thread, uint64_t value);
+
+ virtual ~StopInfo() {}
+
+ bool IsValid() const;
+
+ void SetThread(const lldb::ThreadSP &thread_sp) { m_thread_wp = thread_sp; }
+
+ lldb::ThreadSP GetThread() const { return m_thread_wp.lock(); }
+
+ // The value of the StopInfo depends on the StopReason.
+ // StopReason Meaning
+ // ----------------------------------------------
+ // eStopReasonBreakpoint BreakpointSiteID
+ // eStopReasonSignal Signal number
+ // eStopReasonWatchpoint WatchpointLocationID
+ // eStopReasonPlanComplete No significance
+
+ uint64_t GetValue() const { return m_value; }
+
+ virtual lldb::StopReason GetStopReason() const = 0;
+
+ // ShouldStopSynchronous will get called before any thread plans are
+ // consulted, and if it says we should
+ // resume the target, then we will just immediately resume. This should not
+ // run any code in or resume the
+ // target.
+
+ virtual bool ShouldStopSynchronous(Event *event_ptr) { return true; }
+
+ void OverrideShouldNotify(bool override_value) {
+ m_override_should_notify = override_value ? eLazyBoolYes : eLazyBoolNo;
+ }
+
+ // If should stop returns false, check if we should notify of this event
+ virtual bool ShouldNotify(Event *event_ptr) {
+ if (m_override_should_notify == eLazyBoolCalculate)
+ return DoShouldNotify(event_ptr);
+ else
+ return m_override_should_notify == eLazyBoolYes;
+ }
+
+ virtual void WillResume(lldb::StateType resume_state) {
+ // By default, don't do anything
+ }
+
+ virtual const char *GetDescription() { return m_description.c_str(); }
+
+ virtual void SetDescription(const char *desc_cstr) {
+ if (desc_cstr && desc_cstr[0])
+ m_description.assign(desc_cstr);
+ else
+ m_description.clear();
+ }
+
+ virtual bool IsValidForOperatingSystemThread(Thread &thread) { return true; }
+
+ // Sometimes the thread plan logic will know that it wants a given stop to
+ // stop or not,
+ // regardless of what the ordinary logic for that StopInfo would dictate. The
+ // main example
+ // of this is the ThreadPlanCallFunction, which for instance knows - based on
+ // how that particular
+ // expression was executed - whether it wants all breakpoints to auto-continue
+ // or not.
+ // Use OverrideShouldStop on the StopInfo to implement this.
+
+ void OverrideShouldStop(bool override_value) {
+ m_override_should_stop = override_value ? eLazyBoolYes : eLazyBoolNo;
+ }
+
+ bool GetOverrideShouldStop() {
+ return m_override_should_stop != eLazyBoolCalculate;
+ }
+
+ bool GetOverriddenShouldStopValue() {
+ return m_override_should_stop == eLazyBoolYes;
+ }
+
+ StructuredData::ObjectSP GetExtendedInfo() { return m_extended_info; }
+
+ static lldb::StopInfoSP
+ CreateStopReasonWithBreakpointSiteID(Thread &thread,
+ lldb::break_id_t break_id);
+
+ // This creates a StopInfo for the thread where the should_stop is already
+ // set, and won't be recalculated.
+ static lldb::StopInfoSP CreateStopReasonWithBreakpointSiteID(
+ Thread &thread, lldb::break_id_t break_id, bool should_stop);
+
+ static lldb::StopInfoSP CreateStopReasonWithWatchpointID(
+ Thread &thread, lldb::break_id_t watch_id,
+ lldb::addr_t watch_hit_addr = LLDB_INVALID_ADDRESS);
+
+ static lldb::StopInfoSP
+ CreateStopReasonWithSignal(Thread &thread, int signo,
+ const char *description = nullptr);
+
+ static lldb::StopInfoSP CreateStopReasonToTrace(Thread &thread);
+
+ static lldb::StopInfoSP
+ CreateStopReasonWithPlan(lldb::ThreadPlanSP &plan,
+ lldb::ValueObjectSP return_valobj_sp,
+ lldb::ExpressionVariableSP expression_variable_sp);
+
+ static lldb::StopInfoSP
+ CreateStopReasonWithException(Thread &thread, const char *description);
+
+ static lldb::StopInfoSP CreateStopReasonWithExec(Thread &thread);
+
+ static lldb::ValueObjectSP
+ GetReturnValueObject(lldb::StopInfoSP &stop_info_sp);
+
+ static lldb::ExpressionVariableSP
+ GetExpressionVariable(lldb::StopInfoSP &stop_info_sp);
+
+ static lldb::ValueObjectSP
+ GetCrashingDereference(lldb::StopInfoSP &stop_info_sp,
+ lldb::addr_t *crashing_address = nullptr);
protected:
- // Perform any action that is associated with this stop. This is done as the
- // Event is removed from the event queue. ProcessEventData::DoOnRemoval does the job.
-
- virtual void
- PerformAction (Event *event_ptr)
- {
- }
-
- virtual bool
- DoShouldNotify (Event *event_ptr)
- {
- return false;
- }
-
- // Stop the thread by default. Subclasses can override this to allow
- // the thread to continue if desired. The ShouldStop method should not do anything
- // that might run code. If you need to run code when deciding whether to stop
- // at this StopInfo, that must be done in the PerformAction.
- // The PerformAction will always get called before the ShouldStop. This is done by the
- // ProcessEventData::DoOnRemoval, though the ThreadPlanBase needs to consult this later on.
- virtual bool
- ShouldStop (Event *event_ptr)
- {
- return true;
- }
-
- //------------------------------------------------------------------
- // Classes that inherit from StackID can see and modify these
- //------------------------------------------------------------------
- lldb::ThreadWP m_thread_wp; // The thread corresponding to the stop reason.
- uint32_t m_stop_id; // The process stop ID for which this stop info is valid
- uint32_t m_resume_id; // This is the resume ID when we made this stop ID.
- uint64_t m_value; // A generic value that can be used for things pertaining to this stop info
- std::string m_description; // A textual description describing this stop.
- LazyBool m_override_should_notify;
- LazyBool m_override_should_stop;
-
- StructuredData::ObjectSP m_extended_info; // The extended info for this stop info
-
- // This determines whether the target has run since this stop info.
- // N.B. running to evaluate a user expression does not count.
- bool HasTargetRunSinceMe ();
-
- // MakeStopInfoValid is necessary to allow saved stop infos to resurrect themselves as valid.
- // It should only be used by Thread::RestoreThreadStateFromCheckpoint and to make sure the one-step
- // needed for before-the-fact watchpoints does not prevent us from stopping
- void
- MakeStopInfoValid ();
-
+ // Perform any action that is associated with this stop. This is done as the
+ // Event is removed from the event queue. ProcessEventData::DoOnRemoval does
+ // the job.
+
+ virtual void PerformAction(Event *event_ptr) {}
+
+ virtual bool DoShouldNotify(Event *event_ptr) { return false; }
+
+ // Stop the thread by default. Subclasses can override this to allow
+ // the thread to continue if desired. The ShouldStop method should not do
+ // anything
+ // that might run code. If you need to run code when deciding whether to stop
+ // at this StopInfo, that must be done in the PerformAction.
+ // The PerformAction will always get called before the ShouldStop. This is
+ // done by the
+ // ProcessEventData::DoOnRemoval, though the ThreadPlanBase needs to consult
+ // this later on.
+ virtual bool ShouldStop(Event *event_ptr) { return true; }
+
+ //------------------------------------------------------------------
+ // Classes that inherit from StackID can see and modify these
+ //------------------------------------------------------------------
+ lldb::ThreadWP m_thread_wp; // The thread corresponding to the stop reason.
+ uint32_t m_stop_id; // The process stop ID for which this stop info is valid
+ uint32_t m_resume_id; // This is the resume ID when we made this stop ID.
+ uint64_t m_value; // A generic value that can be used for things pertaining to
+ // this stop info
+ std::string m_description; // A textual description describing this stop.
+ LazyBool m_override_should_notify;
+ LazyBool m_override_should_stop;
+
+ StructuredData::ObjectSP
+ m_extended_info; // The extended info for this stop info
+
+ // This determines whether the target has run since this stop info.
+ // N.B. running to evaluate a user expression does not count.
+ bool HasTargetRunSinceMe();
+
+ // MakeStopInfoValid is necessary to allow saved stop infos to resurrect
+ // themselves as valid.
+ // It should only be used by Thread::RestoreThreadStateFromCheckpoint and to
+ // make sure the one-step
+ // needed for before-the-fact watchpoints does not prevent us from stopping
+ void MakeStopInfoValid();
+
private:
- friend class Thread;
-
- DISALLOW_COPY_AND_ASSIGN (StopInfo);
+ friend class Thread;
+
+ DISALLOW_COPY_AND_ASSIGN(StopInfo);
};
} // namespace lldb_private
-#endif // liblldb_StopInfo_h_
+#endif // liblldb_StopInfo_h_
diff --git a/include/lldb/Target/StructuredDataPlugin.h b/include/lldb/Target/StructuredDataPlugin.h
new file mode 100644
index 000000000000..aa4452a9c3f2
--- /dev/null
+++ b/include/lldb/Target/StructuredDataPlugin.h
@@ -0,0 +1,188 @@
+//===-- StructuredDataPlugin.h ----------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef StructuredDataPlugin_h
+#define StructuredDataPlugin_h
+
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/StructuredData.h"
+
+namespace lldb_private {
+
+class CommandObjectMultiword;
+
+// -----------------------------------------------------------------------------
+/// Plugin that supports process-related structured data sent asynchronously
+/// from the debug monitor (e.g. debugserver, lldb-server, etc.)
+///
+/// This plugin type is activated by a Process-derived instance when that
+/// instance detects that a given structured data feature is available.
+///
+/// StructuredDataPlugin instances are inherently tied to a process. The
+/// main functionality they support is the ability to consume asynchronously-
+/// delivered structured data from the process monitor, and do something
+/// reasonable with it. Something reasonable can include broadcasting a
+/// StructuredData event, which other parts of the system can then do with
+/// as they please. An IDE could use this facility to retrieve CPU usage,
+/// memory usage, and other run-time aspects of the process. That data
+/// can then be displayed meaningfully to the user through the IDE.
+
+/// For command-line LLDB, the Debugger instance listens for the structured
+/// data events raised by the plugin, and give the plugin both the output
+/// and error streams such that the plugin can display something about the
+/// event, at a time when the debugger ensures it is safe to write to the
+/// output or error streams.
+// -----------------------------------------------------------------------------
+
+class StructuredDataPlugin
+ : public PluginInterface,
+ public std::enable_shared_from_this<StructuredDataPlugin> {
+public:
+ virtual ~StructuredDataPlugin();
+
+ lldb::ProcessSP GetProcess() const;
+
+ // -------------------------------------------------------------------------
+ // Public instance API
+ // -------------------------------------------------------------------------
+
+ // -------------------------------------------------------------------------
+ /// Return whether this plugin supports the given StructuredData feature.
+ ///
+ /// When Process is informed of a list of process-monitor-supported
+ /// structured data features, Process will go through the list of plugins,
+ /// one at a time, and have the first plugin that supports a given feature
+ /// be the plugin instantiated to handle that feature. There is a 1-1
+ /// correspondence between a Process instance and a StructuredDataPlugin
+ /// mapped to that process. A plugin can support handling multiple
+ /// features, and if that happens, there is a single plugin instance
+ /// created covering all of the mapped features for a given process.
+ ///
+ /// @param[in] type_name
+ /// The name of the feature tag supported by a process.
+ /// e.g. "darwin-log".
+ ///
+ /// @return
+ /// true if the plugin supports the feature; otherwise, false.
+ // -------------------------------------------------------------------------
+ virtual bool SupportsStructuredDataType(const ConstString &type_name) = 0;
+
+ // -------------------------------------------------------------------------
+ /// Handle the arrival of asynchronous structured data from the process.
+ ///
+ /// When asynchronous structured data arrives from the process monitor,
+ /// it is immediately delivered to the plugin mapped for that feature
+ /// if one exists. The structured data that arrives from a process
+ /// monitor must be a dictionary, and it must have a string field named
+ /// "type" that must contain the StructuredData feature name set as the
+ /// value. This is the manner in which the data is routed to the proper
+ /// plugin instance.
+ ///
+ /// @param[in] process
+ /// The process instance that just received the structured data.
+ /// This will always be the same process for a given instance of
+ /// a plugin.
+ ///
+ /// @param[in] type_name
+ /// The name of the feature tag for the asynchronous structured data.
+ /// Note this data will also be present in the \b object_sp dictionary
+ /// under the string value with key "type".
+ ///
+ /// @param[in] object_sp
+ /// A shared pointer to the structured data that arrived. This must
+ /// be a dictionary. The only key required is the aforementioned
+ /// key named "type" that must be a string value containing the
+ /// structured data type name.
+ // -------------------------------------------------------------------------
+ virtual void
+ HandleArrivalOfStructuredData(Process &process, const ConstString &type_name,
+ const StructuredData::ObjectSP &object_sp) = 0;
+
+ // -------------------------------------------------------------------------
+ /// Get a human-readable description of the contents of the data.
+ ///
+ /// In command-line LLDB, this method will be called by the Debugger
+ /// instance for each structured data event generated, and the output
+ /// will be printed to the LLDB console. If nothing is added to the stream,
+ /// nothing will be printed; otherwise, a newline will be added to the end
+ /// when displayed.
+ ///
+ /// @param[in] object_sp
+ /// A shared pointer to the structured data to format.
+ ///
+ /// @param[in] stream
+ /// The stream where the structured data should be pretty printed.
+ ///
+ /// @return
+ /// The error if formatting the object contents failed; otherwise,
+ /// success.
+ // -------------------------------------------------------------------------
+ virtual Error GetDescription(const StructuredData::ObjectSP &object_sp,
+ lldb_private::Stream &stream) = 0;
+
+ // -------------------------------------------------------------------------
+ /// Returns whether the plugin's features are enabled.
+ ///
+ /// This is a convenience method for plugins that can enable or disable
+ /// their functionality. It allows retrieval of this state without
+ /// requiring a cast.
+ ///
+ /// @param[in] type_name
+ /// The name of the feature tag for the asynchronous structured data.
+ /// This is needed for plugins that support more than one feature.
+ // -------------------------------------------------------------------------
+ virtual bool GetEnabled(const ConstString &type_name) const;
+
+ // -------------------------------------------------------------------------
+ /// Allow the plugin to do work related to modules that loaded in the
+ /// the corresponding process.
+ ///
+ /// This method defaults to doing nothing. Plugins can override it
+ /// if they have any behavior they want to enable/modify based on loaded
+ /// modules.
+ ///
+ /// @param[in] process
+ /// The process that just was notified of modules having been loaded.
+ /// This will always be the same process for a given instance of
+ /// a plugin.
+ ///
+ /// @param[in] module_list
+ /// The list of modules that the process registered as having just
+ /// loaded. See \b Process::ModulesDidLoad(...).
+ // -------------------------------------------------------------------------
+ virtual void ModulesDidLoad(Process &process, ModuleList &module_list);
+
+protected:
+ // -------------------------------------------------------------------------
+ // Derived-class API
+ // -------------------------------------------------------------------------
+ StructuredDataPlugin(const lldb::ProcessWP &process_wp);
+
+ // -------------------------------------------------------------------------
+ /// Derived classes must call this before attempting to hook up commands
+ /// to the 'plugin structured-data' tree.
+ ///
+ /// This ensures the relevant command and options hook points for all
+ /// StructuredDataPlugin derived classes are available for this debugger.
+ /// If this has already happened, this call is a no-op.
+ ///
+ /// @param[in] debugger
+ /// The Debugger instance for which we're creating the required shared
+ /// components for the StructuredDataPlugin derived classes.
+ // -------------------------------------------------------------------------
+ static void InitializeBasePluginForDebugger(Debugger &debugger);
+
+private:
+ lldb::ProcessWP m_process_wp;
+
+ DISALLOW_COPY_AND_ASSIGN(StructuredDataPlugin);
+};
+}
+
+#endif
diff --git a/include/lldb/Target/SystemRuntime.h b/include/lldb/Target/SystemRuntime.h
index cefd72400450..3a2a544fe0b0 100644
--- a/include/lldb/Target/SystemRuntime.h
+++ b/include/lldb/Target/SystemRuntime.h
@@ -16,14 +16,14 @@
// Project includes
#include <vector>
-#include "lldb/lldb-public.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/StructuredData.h"
-#include "lldb/Target/QueueList.h"
#include "lldb/Target/QueueItem.h"
+#include "lldb/Target/QueueList.h"
#include "lldb/lldb-private.h"
+#include "lldb/lldb-public.h"
namespace lldb_private {
@@ -38,7 +38,7 @@ namespace lldb_private {
/// For instance, a system runtime plugin use a breakpoint when threads
/// are created to record the backtrace of where that thread was created.
/// Later, when backtracing the created thread, it could extend the backtrace
-/// to show where it was originally created from.
+/// to show where it was originally created from.
///
/// The plugin will insert its own breakpoint when Created and start collecting
/// information. Later when it comes time to augment a Thread, it can be
@@ -46,332 +46,315 @@ namespace lldb_private {
///
//----------------------------------------------------------------------
-class SystemRuntime :
- public PluginInterface
-{
+class SystemRuntime : public PluginInterface {
public:
- //------------------------------------------------------------------
- /// Find a system runtime plugin for a given process.
- ///
- /// Scans the installed SystemRuntime plugins and tries to find
- /// an instance that can be used to track image changes in \a
- /// process.
- ///
- /// @param[in] process
- /// The process for which to try and locate a system runtime
- /// plugin instance.
- //------------------------------------------------------------------
- static SystemRuntime*
- FindPlugin (Process *process);
-
- //------------------------------------------------------------------
- /// Construct with a process.
- // -----------------------------------------------------------------
- SystemRuntime(lldb_private::Process *process);
+ //------------------------------------------------------------------
+ /// Find a system runtime plugin for a given process.
+ ///
+ /// Scans the installed SystemRuntime plugins and tries to find
+ /// an instance that can be used to track image changes in \a
+ /// process.
+ ///
+ /// @param[in] process
+ /// The process for which to try and locate a system runtime
+ /// plugin instance.
+ //------------------------------------------------------------------
+ static SystemRuntime *FindPlugin(Process *process);
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// The destructor is virtual since this class is designed to be
- /// inherited by the plug-in instance.
- //------------------------------------------------------------------
- ~SystemRuntime() override;
+ //------------------------------------------------------------------
+ /// Construct with a process.
+ // -----------------------------------------------------------------
+ SystemRuntime(lldb_private::Process *process);
- //------------------------------------------------------------------
- /// Called after attaching to a process.
- ///
- /// Allow the SystemRuntime plugin to execute some code after attaching
- /// to a process.
- //------------------------------------------------------------------
- virtual void
- DidAttach ();
+ //------------------------------------------------------------------
+ /// Destructor.
+ ///
+ /// The destructor is virtual since this class is designed to be
+ /// inherited by the plug-in instance.
+ //------------------------------------------------------------------
+ ~SystemRuntime() override;
- //------------------------------------------------------------------
- /// Called after launching a process.
- ///
- /// Allow the SystemRuntime plugin to execute some code after launching
- /// a process.
- //------------------------------------------------------------------
- virtual void
- DidLaunch();
+ //------------------------------------------------------------------
+ /// Called after attaching to a process.
+ ///
+ /// Allow the SystemRuntime plugin to execute some code after attaching
+ /// to a process.
+ //------------------------------------------------------------------
+ virtual void DidAttach();
- //------------------------------------------------------------------
- /// Called when modules have been loaded in the process.
- ///
- /// Allow the SystemRuntime plugin to enable logging features in the
- /// system runtime libraries.
- //------------------------------------------------------------------
- virtual void
- ModulesDidLoad(lldb_private::ModuleList &module_list);
+ //------------------------------------------------------------------
+ /// Called after launching a process.
+ ///
+ /// Allow the SystemRuntime plugin to execute some code after launching
+ /// a process.
+ //------------------------------------------------------------------
+ virtual void DidLaunch();
- //------------------------------------------------------------------
- /// Called before detaching from a process.
- ///
- /// This will give a SystemRuntime plugin a chance to free any resources
- /// in the inferior process before we detach.
- //------------------------------------------------------------------
- virtual void
- Detach ();
+ //------------------------------------------------------------------
+ /// Called when modules have been loaded in the process.
+ ///
+ /// Allow the SystemRuntime plugin to enable logging features in the
+ /// system runtime libraries.
+ //------------------------------------------------------------------
+ virtual void ModulesDidLoad(lldb_private::ModuleList &module_list);
- //------------------------------------------------------------------
- /// Return a list of thread origin extended backtraces that may
- /// be available.
- ///
- /// A System Runtime may be able to provide a backtrace of when this
- /// thread was originally created. Furthermore, it may be able to
- /// provide that extended backtrace for different styles of creation.
- /// On a system with both pthreads and libdispatch, aka Grand Central
- /// Dispatch, queues, the system runtime may be able to provide the
- /// pthread creation of the thread and it may also be able to provide
- /// the backtrace of when this GCD queue work block was enqueued.
- /// The caller may request these different origins by name.
- ///
- /// The names will be provided in the order that they are most likely
- /// to be requested. For instance, a most natural order may be to
- /// request the GCD libdispatch queue origin. If there is none, then
- /// request the pthread origin.
- ///
- /// @return
- /// A vector of ConstStrings with names like "pthread" or "libdispatch".
- /// An empty vector may be returned if no thread origin extended
- /// backtrace capabilities are available.
- //------------------------------------------------------------------
- virtual const std::vector<ConstString> &
- GetExtendedBacktraceTypes ();
+ //------------------------------------------------------------------
+ /// Called before detaching from a process.
+ ///
+ /// This will give a SystemRuntime plugin a chance to free any resources
+ /// in the inferior process before we detach.
+ //------------------------------------------------------------------
+ virtual void Detach();
- //------------------------------------------------------------------
- /// Return a Thread which shows the origin of this thread's creation.
- ///
- /// This likely returns a HistoryThread which shows how thread was
- /// originally created (e.g. "pthread" type), or how the work that
- /// is currently executing on it was originally enqueued (e.g.
- /// "libdispatch" type).
- ///
- /// There may be a chain of thread-origins; it may be informative to
- /// the end user to query the returned ThreadSP for its origins as
- /// well.
- ///
- /// @param [in] thread
- /// The thread to examine.
- ///
- /// @param [in] type
- /// The type of thread origin being requested. The types supported
- /// are returned from SystemRuntime::GetExtendedBacktraceTypes.
- ///
- /// @return
- /// A ThreadSP which will have a StackList of frames. This Thread will
- /// not appear in the Process' list of current threads. Normal thread
- /// operations like stepping will not be available. This is a historical
- /// view thread and may be only useful for showing a backtrace.
- ///
- /// An empty ThreadSP will be returned if no thread origin is available.
- //------------------------------------------------------------------
- virtual lldb::ThreadSP
- GetExtendedBacktraceThread (lldb::ThreadSP thread, ConstString type);
+ //------------------------------------------------------------------
+ /// Return a list of thread origin extended backtraces that may
+ /// be available.
+ ///
+ /// A System Runtime may be able to provide a backtrace of when this
+ /// thread was originally created. Furthermore, it may be able to
+ /// provide that extended backtrace for different styles of creation.
+ /// On a system with both pthreads and libdispatch, aka Grand Central
+ /// Dispatch, queues, the system runtime may be able to provide the
+ /// pthread creation of the thread and it may also be able to provide
+ /// the backtrace of when this GCD queue work block was enqueued.
+ /// The caller may request these different origins by name.
+ ///
+ /// The names will be provided in the order that they are most likely
+ /// to be requested. For instance, a most natural order may be to
+ /// request the GCD libdispatch queue origin. If there is none, then
+ /// request the pthread origin.
+ ///
+ /// @return
+ /// A vector of ConstStrings with names like "pthread" or "libdispatch".
+ /// An empty vector may be returned if no thread origin extended
+ /// backtrace capabilities are available.
+ //------------------------------------------------------------------
+ virtual const std::vector<ConstString> &GetExtendedBacktraceTypes();
- //------------------------------------------------------------------
- /// Get the extended backtrace thread for a QueueItem
- ///
- /// A QueueItem represents a function/block that will be executed on
- /// a libdispatch queue in the future, or it represents a function/block
- /// that is currently executing on a thread.
- ///
- /// This method will report a thread backtrace of the function that
- /// enqueued it originally, if possible.
- ///
- /// @param [in] queue_item_sp
- /// The QueueItem that we are getting an extended backtrace for.
- ///
- /// @param [in] type
- /// The type of extended backtrace to fetch. The types supported
- /// are returned from SystemRuntime::GetExtendedBacktraceTypes.
- ///
- /// @return
- /// If an extended backtrace is available, it is returned. Else
- /// an empty ThreadSP is returned.
- //------------------------------------------------------------------
- virtual lldb::ThreadSP
- GetExtendedBacktraceForQueueItem (lldb::QueueItemSP queue_item_sp, ConstString type)
- {
- return lldb::ThreadSP();
- }
+ //------------------------------------------------------------------
+ /// Return a Thread which shows the origin of this thread's creation.
+ ///
+ /// This likely returns a HistoryThread which shows how thread was
+ /// originally created (e.g. "pthread" type), or how the work that
+ /// is currently executing on it was originally enqueued (e.g.
+ /// "libdispatch" type).
+ ///
+ /// There may be a chain of thread-origins; it may be informative to
+ /// the end user to query the returned ThreadSP for its origins as
+ /// well.
+ ///
+ /// @param [in] thread
+ /// The thread to examine.
+ ///
+ /// @param [in] type
+ /// The type of thread origin being requested. The types supported
+ /// are returned from SystemRuntime::GetExtendedBacktraceTypes.
+ ///
+ /// @return
+ /// A ThreadSP which will have a StackList of frames. This Thread will
+ /// not appear in the Process' list of current threads. Normal thread
+ /// operations like stepping will not be available. This is a historical
+ /// view thread and may be only useful for showing a backtrace.
+ ///
+ /// An empty ThreadSP will be returned if no thread origin is available.
+ //------------------------------------------------------------------
+ virtual lldb::ThreadSP GetExtendedBacktraceThread(lldb::ThreadSP thread,
+ ConstString type);
- //------------------------------------------------------------------
- /// Populate the Process' QueueList with libdispatch / GCD queues that exist.
- ///
- /// When process execution is paused, the SystemRuntime may be called to fill
- /// in the list of Queues that currently exist.
- ///
- /// @param [out] queue_list
- /// This QueueList will be cleared, and any queues that currently exist
- /// will be added. An empty QueueList will be returned if no queues
- /// exist or if this Systemruntime does not support libdispatch queues.
- //------------------------------------------------------------------
- virtual void
- PopulateQueueList (lldb_private::QueueList &queue_list)
- {
- }
+ //------------------------------------------------------------------
+ /// Get the extended backtrace thread for a QueueItem
+ ///
+ /// A QueueItem represents a function/block that will be executed on
+ /// a libdispatch queue in the future, or it represents a function/block
+ /// that is currently executing on a thread.
+ ///
+ /// This method will report a thread backtrace of the function that
+ /// enqueued it originally, if possible.
+ ///
+ /// @param [in] queue_item_sp
+ /// The QueueItem that we are getting an extended backtrace for.
+ ///
+ /// @param [in] type
+ /// The type of extended backtrace to fetch. The types supported
+ /// are returned from SystemRuntime::GetExtendedBacktraceTypes.
+ ///
+ /// @return
+ /// If an extended backtrace is available, it is returned. Else
+ /// an empty ThreadSP is returned.
+ //------------------------------------------------------------------
+ virtual lldb::ThreadSP
+ GetExtendedBacktraceForQueueItem(lldb::QueueItemSP queue_item_sp,
+ ConstString type) {
+ return lldb::ThreadSP();
+ }
- //------------------------------------------------------------------
- /// Get the queue name for a thread given a thread's dispatch_qaddr.
- ///
- /// On systems using libdispatch queues, a thread may be associated with a queue.
- /// There will be a call to get the thread's dispatch_qaddr. At the dispatch_qaddr
- /// we will find the address of this thread's dispatch_queue_t structure.
- /// Given the address of the dispatch_queue_t structure for a thread,
- /// get the queue name and return it.
- ///
- /// @param [in] dispatch_qaddr
- /// The address of the dispatch_qaddr pointer for this thread.
- ///
- /// @return
- /// The string of this queue's name. An empty string is returned if the
- /// name could not be found.
- //------------------------------------------------------------------
- virtual std::string
- GetQueueNameFromThreadQAddress (lldb::addr_t dispatch_qaddr)
- {
- return "";
- }
+ //------------------------------------------------------------------
+ /// Populate the Process' QueueList with libdispatch / GCD queues that exist.
+ ///
+ /// When process execution is paused, the SystemRuntime may be called to fill
+ /// in the list of Queues that currently exist.
+ ///
+ /// @param [out] queue_list
+ /// This QueueList will be cleared, and any queues that currently exist
+ /// will be added. An empty QueueList will be returned if no queues
+ /// exist or if this Systemruntime does not support libdispatch queues.
+ //------------------------------------------------------------------
+ virtual void PopulateQueueList(lldb_private::QueueList &queue_list) {}
- //------------------------------------------------------------------
- /// Get the QueueID for the libdispatch queue given the thread's dispatch_qaddr.
- ///
- /// On systems using libdispatch queues, a thread may be associated with a queue.
- /// There will be a call to get the thread's dispatch_qaddr. At the dispatch_qaddr
- /// we will find the address of this thread's dispatch_queue_t structure.
- /// Given the address of the dispatch_queue_t structure for a thread,
- /// get the queue ID and return it.
- ///
- /// @param [in] dispatch_qaddr
- /// The address of the dispatch_qaddr pointer for this thread.
- ///
- /// @return
- /// The queue ID, or if it could not be retrieved, LLDB_INVALID_QUEUE_ID.
- //------------------------------------------------------------------
- virtual lldb::queue_id_t
- GetQueueIDFromThreadQAddress (lldb::addr_t dispatch_qaddr)
- {
- return LLDB_INVALID_QUEUE_ID;
- }
+ //------------------------------------------------------------------
+ /// Get the queue name for a thread given a thread's dispatch_qaddr.
+ ///
+ /// On systems using libdispatch queues, a thread may be associated with a
+ /// queue.
+ /// There will be a call to get the thread's dispatch_qaddr. At the
+ /// dispatch_qaddr
+ /// we will find the address of this thread's dispatch_queue_t structure.
+ /// Given the address of the dispatch_queue_t structure for a thread,
+ /// get the queue name and return it.
+ ///
+ /// @param [in] dispatch_qaddr
+ /// The address of the dispatch_qaddr pointer for this thread.
+ ///
+ /// @return
+ /// The string of this queue's name. An empty string is returned if the
+ /// name could not be found.
+ //------------------------------------------------------------------
+ virtual std::string
+ GetQueueNameFromThreadQAddress(lldb::addr_t dispatch_qaddr) {
+ return "";
+ }
- //------------------------------------------------------------------
- /// Get the libdispatch_queue_t address for the queue given the thread's dispatch_qaddr.
- ///
- /// On systems using libdispatch queues, a thread may be associated with a queue.
- /// There will be a call to get the thread's dispatch_qaddr.
- /// Given the thread's dispatch_qaddr, find the libdispatch_queue_t address and
- /// return it.
- ///
- /// @param [in] dispatch_qaddr
- /// The address of the dispatch_qaddr pointer for this thread.
- ///
- /// @return
- /// The libdispatch_queue_t address, or LLDB_INVALID_ADDRESS if unavailable/not found.
- //------------------------------------------------------------------
- virtual lldb::addr_t
- GetLibdispatchQueueAddressFromThreadQAddress (lldb::addr_t dispatch_qaddr)
- {
- return LLDB_INVALID_ADDRESS;
- }
+ //------------------------------------------------------------------
+ /// Get the QueueID for the libdispatch queue given the thread's
+ /// dispatch_qaddr.
+ ///
+ /// On systems using libdispatch queues, a thread may be associated with a
+ /// queue.
+ /// There will be a call to get the thread's dispatch_qaddr. At the
+ /// dispatch_qaddr
+ /// we will find the address of this thread's dispatch_queue_t structure.
+ /// Given the address of the dispatch_queue_t structure for a thread,
+ /// get the queue ID and return it.
+ ///
+ /// @param [in] dispatch_qaddr
+ /// The address of the dispatch_qaddr pointer for this thread.
+ ///
+ /// @return
+ /// The queue ID, or if it could not be retrieved, LLDB_INVALID_QUEUE_ID.
+ //------------------------------------------------------------------
+ virtual lldb::queue_id_t
+ GetQueueIDFromThreadQAddress(lldb::addr_t dispatch_qaddr) {
+ return LLDB_INVALID_QUEUE_ID;
+ }
+ //------------------------------------------------------------------
+ /// Get the libdispatch_queue_t address for the queue given the thread's
+ /// dispatch_qaddr.
+ ///
+ /// On systems using libdispatch queues, a thread may be associated with a
+ /// queue.
+ /// There will be a call to get the thread's dispatch_qaddr.
+ /// Given the thread's dispatch_qaddr, find the libdispatch_queue_t address
+ /// and
+ /// return it.
+ ///
+ /// @param [in] dispatch_qaddr
+ /// The address of the dispatch_qaddr pointer for this thread.
+ ///
+ /// @return
+ /// The libdispatch_queue_t address, or LLDB_INVALID_ADDRESS if
+ /// unavailable/not found.
+ //------------------------------------------------------------------
+ virtual lldb::addr_t
+ GetLibdispatchQueueAddressFromThreadQAddress(lldb::addr_t dispatch_qaddr) {
+ return LLDB_INVALID_ADDRESS;
+ }
- //------------------------------------------------------------------
- /// Retrieve the Queue kind for the queue at a thread's dispatch_qaddr.
- ///
- /// Retrieve the Queue kind - either eQueueKindSerial or
- /// eQueueKindConcurrent, indicating that this queue processes work
- /// items serially or concurrently.
- ///
- /// @return
- /// The Queue kind, if it could be read, else eQueueKindUnknown.
- //------------------------------------------------------------------
- virtual lldb::QueueKind
- GetQueueKind (lldb::addr_t dispatch_qaddr)
- {
- return lldb::eQueueKindUnknown;
- }
+ //------------------------------------------------------------------
+ /// Retrieve the Queue kind for the queue at a thread's dispatch_qaddr.
+ ///
+ /// Retrieve the Queue kind - either eQueueKindSerial or
+ /// eQueueKindConcurrent, indicating that this queue processes work
+ /// items serially or concurrently.
+ ///
+ /// @return
+ /// The Queue kind, if it could be read, else eQueueKindUnknown.
+ //------------------------------------------------------------------
+ virtual lldb::QueueKind GetQueueKind(lldb::addr_t dispatch_qaddr) {
+ return lldb::eQueueKindUnknown;
+ }
- //------------------------------------------------------------------
- /// Get the pending work items for a libdispatch Queue
- ///
- /// If this system/process is using libdispatch and the runtime can do so,
- /// retrieve the list of pending work items for the specified Queue and
- /// add it to the Queue.
- ///
- /// @param [in] queue
- /// The queue of interest.
- //------------------------------------------------------------------
- virtual void
- PopulatePendingItemsForQueue (lldb_private::Queue *queue)
- {
- }
+ //------------------------------------------------------------------
+ /// Get the pending work items for a libdispatch Queue
+ ///
+ /// If this system/process is using libdispatch and the runtime can do so,
+ /// retrieve the list of pending work items for the specified Queue and
+ /// add it to the Queue.
+ ///
+ /// @param [in] queue
+ /// The queue of interest.
+ //------------------------------------------------------------------
+ virtual void PopulatePendingItemsForQueue(lldb_private::Queue *queue) {}
- //------------------------------------------------------------------
- /// Complete the fields in a QueueItem
- ///
- /// PopulatePendingItemsForQueue() may not fill in all of the QueueItem
- /// details; when the remaining fields are needed, they will be
- /// fetched by call this method.
- ///
- /// @param [in] queue_item
- /// The QueueItem that we will be completing.
- ///
- /// @param [in] item_ref
- /// The item_ref token that is needed to retrieve the rest of the
- /// information about the QueueItem.
- //------------------------------------------------------------------
- virtual void
- CompleteQueueItem (lldb_private::QueueItem *queue_item, lldb::addr_t item_ref)
- {
- }
+ //------------------------------------------------------------------
+ /// Complete the fields in a QueueItem
+ ///
+ /// PopulatePendingItemsForQueue() may not fill in all of the QueueItem
+ /// details; when the remaining fields are needed, they will be
+ /// fetched by call this method.
+ ///
+ /// @param [in] queue_item
+ /// The QueueItem that we will be completing.
+ ///
+ /// @param [in] item_ref
+ /// The item_ref token that is needed to retrieve the rest of the
+ /// information about the QueueItem.
+ //------------------------------------------------------------------
+ virtual void CompleteQueueItem(lldb_private::QueueItem *queue_item,
+ lldb::addr_t item_ref) {}
- //------------------------------------------------------------------
- /// Add key-value pairs to the StructuredData dictionary object with
- /// information debugserver may need when constructing the jThreadExtendedInfo
- /// packet.
- ///
- /// @param [out] dict
- /// Dictionary to which key-value pairs should be added; they will
- /// be sent to the remote gdb server stub as arguments in the
- /// jThreadExtendedInfo request.
- //------------------------------------------------------------------
- virtual void
- AddThreadExtendedInfoPacketHints (lldb_private::StructuredData::ObjectSP dict)
- {
- }
+ //------------------------------------------------------------------
+ /// Add key-value pairs to the StructuredData dictionary object with
+ /// information debugserver may need when constructing the
+ /// jThreadExtendedInfo
+ /// packet.
+ ///
+ /// @param [out] dict
+ /// Dictionary to which key-value pairs should be added; they will
+ /// be sent to the remote gdb server stub as arguments in the
+ /// jThreadExtendedInfo request.
+ //------------------------------------------------------------------
+ virtual void AddThreadExtendedInfoPacketHints(
+ lldb_private::StructuredData::ObjectSP dict) {}
- /// Determine whether it is safe to run an expression on a given thread
- ///
- /// If a system must not run functions on a thread in some particular state,
- /// this method gives a way for it to flag that the expression should not be
- /// run.
- ///
- /// @param [in] thread_sp
- /// The thread we want to run the expression on.
- ///
- /// @return
- /// True will be returned if there are no known problems with running an
- /// expression on this thread. False means that the inferior function
- /// call should not be made on this thread.
- //------------------------------------------------------------------
- virtual bool
- SafeToCallFunctionsOnThisThread (lldb::ThreadSP thread_sp)
- {
- return true;
- }
+ /// Determine whether it is safe to run an expression on a given thread
+ ///
+ /// If a system must not run functions on a thread in some particular state,
+ /// this method gives a way for it to flag that the expression should not be
+ /// run.
+ ///
+ /// @param [in] thread_sp
+ /// The thread we want to run the expression on.
+ ///
+ /// @return
+ /// True will be returned if there are no known problems with running an
+ /// expression on this thread. False means that the inferior function
+ /// call should not be made on this thread.
+ //------------------------------------------------------------------
+ virtual bool SafeToCallFunctionsOnThisThread(lldb::ThreadSP thread_sp) {
+ return true;
+ }
protected:
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- Process *m_process;
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ Process *m_process;
- std::vector<ConstString> m_types;
+ std::vector<ConstString> m_types;
private:
-
- DISALLOW_COPY_AND_ASSIGN (SystemRuntime);
+ DISALLOW_COPY_AND_ASSIGN(SystemRuntime);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/Target.h b/include/lldb/Target/Target.h
index 7124b2e83467..8d6fc772c887 100644
--- a/include/lldb/Target/Target.h
+++ b/include/lldb/Target/Target.h
@@ -20,7 +20,6 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
#include "lldb/Breakpoint/BreakpointList.h"
#include "lldb/Breakpoint/WatchpointList.h"
#include "lldb/Core/ArchSpec.h"
@@ -34,1643 +33,1237 @@
#include "lldb/Target/PathMappingList.h"
#include "lldb/Target/ProcessLaunchInfo.h"
#include "lldb/Target/SectionLoadHistory.h"
+#include "lldb/Utility/Timeout.h"
+#include "lldb/lldb-public.h"
namespace lldb_private {
extern OptionEnumValueElement g_dynamic_value_types[];
-typedef enum InlineStrategy
-{
- eInlineBreakpointsNever = 0,
- eInlineBreakpointsHeaders,
- eInlineBreakpointsAlways
+typedef enum InlineStrategy {
+ eInlineBreakpointsNever = 0,
+ eInlineBreakpointsHeaders,
+ eInlineBreakpointsAlways
} InlineStrategy;
-typedef enum LoadScriptFromSymFile
-{
- eLoadScriptFromSymFileTrue,
- eLoadScriptFromSymFileFalse,
- eLoadScriptFromSymFileWarn
+typedef enum LoadScriptFromSymFile {
+ eLoadScriptFromSymFileTrue,
+ eLoadScriptFromSymFileFalse,
+ eLoadScriptFromSymFileWarn
} LoadScriptFromSymFile;
-typedef enum LoadCWDlldbinitFile
-{
- eLoadCWDlldbinitTrue,
- eLoadCWDlldbinitFalse,
- eLoadCWDlldbinitWarn
+typedef enum LoadCWDlldbinitFile {
+ eLoadCWDlldbinitTrue,
+ eLoadCWDlldbinitFalse,
+ eLoadCWDlldbinitWarn
} LoadCWDlldbinitFile;
//----------------------------------------------------------------------
// TargetProperties
//----------------------------------------------------------------------
-class TargetExperimentalProperties : public Properties
-{
+class TargetExperimentalProperties : public Properties {
public:
- TargetExperimentalProperties();
+ TargetExperimentalProperties();
};
-class TargetProperties : public Properties
-{
+class TargetProperties : public Properties {
public:
- TargetProperties(Target *target);
-
- ~TargetProperties() override;
-
- ArchSpec
- GetDefaultArchitecture () const;
-
- void
- SetDefaultArchitecture (const ArchSpec& arch);
-
- bool
- GetMoveToNearestCode () const;
-
- lldb::DynamicValueType
- GetPreferDynamicValue() const;
-
- bool
- SetPreferDynamicValue (lldb::DynamicValueType d);
-
- bool
- GetDisableASLR () const;
-
- void
- SetDisableASLR (bool b);
-
- bool
- GetDetachOnError () const;
-
- void
- SetDetachOnError (bool b);
-
- bool
- GetDisableSTDIO () const;
-
- void
- SetDisableSTDIO (bool b);
-
- const char *
- GetDisassemblyFlavor() const;
-
-// void
-// SetDisassemblyFlavor(const char *flavor);
-
- InlineStrategy
- GetInlineStrategy () const;
-
- const char *
- GetArg0 () const;
-
- void
- SetArg0 (const char *arg);
-
- bool
- GetRunArguments (Args &args) const;
-
- void
- SetRunArguments (const Args &args);
-
- size_t
- GetEnvironmentAsArgs (Args &env) const;
-
- void
- SetEnvironmentFromArgs (const Args &env);
-
- bool
- GetSkipPrologue() const;
-
- PathMappingList &
- GetSourcePathMap () const;
-
- FileSpecList &
- GetExecutableSearchPaths ();
-
- FileSpecList &
- GetDebugFileSearchPaths ();
-
- FileSpecList &
- GetClangModuleSearchPaths ();
-
- bool
- GetEnableAutoImportClangModules () const;
-
- bool
- GetEnableAutoApplyFixIts () const;
-
- bool
- GetEnableNotifyAboutFixIts () const;
-
- bool
- GetEnableSyntheticValue () const;
-
- uint32_t
- GetMaximumNumberOfChildrenToDisplay() const;
-
- uint32_t
- GetMaximumSizeOfStringSummary() const;
-
- uint32_t
- GetMaximumMemReadSize () const;
-
- FileSpec
- GetStandardInputPath () const;
-
- void
- SetStandardInputPath (const char *path);
-
- FileSpec
- GetStandardOutputPath () const;
-
- void
- SetStandardOutputPath (const char *path);
-
- FileSpec
- GetStandardErrorPath () const;
-
- void
- SetStandardErrorPath (const char *path);
-
- bool
- GetBreakpointsConsultPlatformAvoidList ();
-
- lldb::LanguageType
- GetLanguage () const;
-
- const char *
- GetExpressionPrefixContentsAsCString ();
-
- bool
- GetUseHexImmediates() const;
-
- bool
- GetUseFastStepping() const;
-
- bool
- GetDisplayExpressionsInCrashlogs () const;
-
- LoadScriptFromSymFile
- GetLoadScriptFromSymbolFile() const;
-
- LoadCWDlldbinitFile
- GetLoadCWDlldbinitFile () const;
-
- Disassembler::HexImmediateStyle
- GetHexImmediateStyle() const;
-
- MemoryModuleLoadLevel
- GetMemoryModuleLoadLevel() const;
-
- bool
- GetUserSpecifiedTrapHandlerNames (Args &args) const;
-
- void
- SetUserSpecifiedTrapHandlerNames (const Args &args);
-
- bool
- GetNonStopModeEnabled () const;
-
- void
- SetNonStopModeEnabled (bool b);
-
- bool
- GetDisplayRuntimeSupportValues () const;
-
- void
- SetDisplayRuntimeSupportValues (bool b);
-
- const ProcessLaunchInfo &
- GetProcessLaunchInfo();
-
- void
- SetProcessLaunchInfo(const ProcessLaunchInfo &launch_info);
-
- bool
- GetInjectLocalVariables(ExecutionContext *exe_ctx) const;
-
- void
- SetInjectLocalVariables(ExecutionContext *exe_ctx, bool b);
+ TargetProperties(Target *target);
+
+ ~TargetProperties() override;
+
+ ArchSpec GetDefaultArchitecture() const;
+
+ void SetDefaultArchitecture(const ArchSpec &arch);
+
+ bool GetMoveToNearestCode() const;
+
+ lldb::DynamicValueType GetPreferDynamicValue() const;
+
+ bool SetPreferDynamicValue(lldb::DynamicValueType d);
+
+ bool GetDisableASLR() const;
+
+ void SetDisableASLR(bool b);
+
+ bool GetDetachOnError() const;
+
+ void SetDetachOnError(bool b);
+
+ bool GetDisableSTDIO() const;
+
+ void SetDisableSTDIO(bool b);
+
+ const char *GetDisassemblyFlavor() const;
+
+ // void
+ // SetDisassemblyFlavor(const char *flavor);
+
+ InlineStrategy GetInlineStrategy() const;
+
+ llvm::StringRef GetArg0() const;
+
+ void SetArg0(llvm::StringRef arg);
+
+ bool GetRunArguments(Args &args) const;
+
+ void SetRunArguments(const Args &args);
+
+ size_t GetEnvironmentAsArgs(Args &env) const;
+
+ void SetEnvironmentFromArgs(const Args &env);
+
+ bool GetSkipPrologue() const;
+
+ PathMappingList &GetSourcePathMap() const;
+
+ FileSpecList &GetExecutableSearchPaths();
+
+ FileSpecList &GetDebugFileSearchPaths();
+
+ FileSpecList &GetClangModuleSearchPaths();
+
+ bool GetEnableAutoImportClangModules() const;
+
+ bool GetEnableAutoApplyFixIts() const;
+
+ bool GetEnableNotifyAboutFixIts() const;
+
+ bool GetEnableSaveObjects() const;
+
+ bool GetEnableSyntheticValue() const;
+
+ uint32_t GetMaximumNumberOfChildrenToDisplay() const;
+
+ uint32_t GetMaximumSizeOfStringSummary() const;
+
+ uint32_t GetMaximumMemReadSize() const;
+
+ FileSpec GetStandardInputPath() const;
+ FileSpec GetStandardErrorPath() const;
+ FileSpec GetStandardOutputPath() const;
+
+ void SetStandardInputPath(llvm::StringRef path);
+ void SetStandardOutputPath(llvm::StringRef path);
+ void SetStandardErrorPath(llvm::StringRef path);
+
+ void SetStandardInputPath(const char *path) = delete;
+ void SetStandardOutputPath(const char *path) = delete;
+ void SetStandardErrorPath(const char *path) = delete;
+
+ bool GetBreakpointsConsultPlatformAvoidList();
+
+ lldb::LanguageType GetLanguage() const;
+
+ const char *GetExpressionPrefixContentsAsCString();
+
+ bool GetUseHexImmediates() const;
+
+ bool GetUseFastStepping() const;
+
+ bool GetDisplayExpressionsInCrashlogs() const;
+
+ LoadScriptFromSymFile GetLoadScriptFromSymbolFile() const;
+
+ LoadCWDlldbinitFile GetLoadCWDlldbinitFile() const;
+
+ Disassembler::HexImmediateStyle GetHexImmediateStyle() const;
+
+ MemoryModuleLoadLevel GetMemoryModuleLoadLevel() const;
+
+ bool GetUserSpecifiedTrapHandlerNames(Args &args) const;
+
+ void SetUserSpecifiedTrapHandlerNames(const Args &args);
+
+ bool GetNonStopModeEnabled() const;
+
+ void SetNonStopModeEnabled(bool b);
+
+ bool GetDisplayRuntimeSupportValues() const;
+
+ void SetDisplayRuntimeSupportValues(bool b);
+
+ const ProcessLaunchInfo &GetProcessLaunchInfo();
+
+ void SetProcessLaunchInfo(const ProcessLaunchInfo &launch_info);
+
+ bool GetInjectLocalVariables(ExecutionContext *exe_ctx) const;
+
+ void SetInjectLocalVariables(ExecutionContext *exe_ctx, bool b);
private:
- //------------------------------------------------------------------
- // Callbacks for m_launch_info.
- //------------------------------------------------------------------
- static void Arg0ValueChangedCallback(void *target_property_ptr, OptionValue *);
- static void RunArgsValueChangedCallback(void *target_property_ptr, OptionValue *);
- static void EnvVarsValueChangedCallback(void *target_property_ptr, OptionValue *);
- static void InheritEnvValueChangedCallback(void *target_property_ptr, OptionValue *);
- static void InputPathValueChangedCallback(void *target_property_ptr, OptionValue *);
- static void OutputPathValueChangedCallback(void *target_property_ptr, OptionValue *);
- static void ErrorPathValueChangedCallback(void *target_property_ptr, OptionValue *);
- static void DetachOnErrorValueChangedCallback(void *target_property_ptr, OptionValue *);
- static void DisableASLRValueChangedCallback(void *target_property_ptr, OptionValue *);
- static void DisableSTDIOValueChangedCallback(void *target_property_ptr, OptionValue *);
-
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- ProcessLaunchInfo m_launch_info;
- std::unique_ptr<TargetExperimentalProperties> m_experimental_properties_up;
+ //------------------------------------------------------------------
+ // Callbacks for m_launch_info.
+ //------------------------------------------------------------------
+ static void Arg0ValueChangedCallback(void *target_property_ptr,
+ OptionValue *);
+ static void RunArgsValueChangedCallback(void *target_property_ptr,
+ OptionValue *);
+ static void EnvVarsValueChangedCallback(void *target_property_ptr,
+ OptionValue *);
+ static void InheritEnvValueChangedCallback(void *target_property_ptr,
+ OptionValue *);
+ static void InputPathValueChangedCallback(void *target_property_ptr,
+ OptionValue *);
+ static void OutputPathValueChangedCallback(void *target_property_ptr,
+ OptionValue *);
+ static void ErrorPathValueChangedCallback(void *target_property_ptr,
+ OptionValue *);
+ static void DetachOnErrorValueChangedCallback(void *target_property_ptr,
+ OptionValue *);
+ static void DisableASLRValueChangedCallback(void *target_property_ptr,
+ OptionValue *);
+ static void DisableSTDIOValueChangedCallback(void *target_property_ptr,
+ OptionValue *);
+
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ ProcessLaunchInfo m_launch_info;
+ std::unique_ptr<TargetExperimentalProperties> m_experimental_properties_up;
};
-class EvaluateExpressionOptions
-{
+class EvaluateExpressionOptions {
public:
- static const uint32_t default_timeout = 500000;
- static const ExecutionPolicy default_execution_policy = eExecutionPolicyOnlyWhenNeeded;
-
- EvaluateExpressionOptions() :
- m_execution_policy(default_execution_policy),
- m_language (lldb::eLanguageTypeUnknown),
- m_prefix (), // A prefix specific to this expression that is added after the prefix from the settings (if any)
- m_coerce_to_id (false),
- m_unwind_on_error (true),
- m_ignore_breakpoints (false),
- m_keep_in_memory (false),
- m_try_others (true),
- m_stop_others (true),
- m_debug (false),
- m_trap_exceptions (true),
- m_generate_debug_info (false),
- m_result_is_internal (false),
- m_auto_apply_fixits (true),
- m_use_dynamic (lldb::eNoDynamicValues),
- m_timeout_usec (default_timeout),
- m_one_thread_timeout_usec (0),
- m_cancel_callback (nullptr),
- m_cancel_callback_baton (nullptr)
- {
- }
-
- ExecutionPolicy
- GetExecutionPolicy () const
- {
- return m_execution_policy;
- }
-
- void
- SetExecutionPolicy (ExecutionPolicy policy = eExecutionPolicyAlways)
- {
- m_execution_policy = policy;
- }
-
- lldb::LanguageType
- GetLanguage() const
- {
- return m_language;
- }
-
- void
- SetLanguage(lldb::LanguageType language)
- {
- m_language = language;
- }
-
- bool
- DoesCoerceToId () const
- {
- return m_coerce_to_id;
- }
+// MSVC has a bug here that reports C4268: 'const' static/global data
+// initialized with compiler generated default constructor fills the object
+// with zeros.
+// Confirmed that MSVC is *not* zero-initializing, it's just a bogus warning.
+#if defined(_MSC_VER)
+#pragma warning(push)
+#pragma warning(disable : 4268)
+#endif
+ static constexpr std::chrono::milliseconds default_timeout{500};
+#if defined(_MSC_VER)
+#pragma warning(pop)
+#endif
- const char *
- GetPrefix () const
- {
- return (m_prefix.empty() ? nullptr : m_prefix.c_str());
- }
+ static constexpr ExecutionPolicy default_execution_policy =
+ eExecutionPolicyOnlyWhenNeeded;
- void
- SetPrefix (const char *prefix)
- {
- if (prefix && prefix[0])
- m_prefix = prefix;
- else
- m_prefix.clear();
- }
+ EvaluateExpressionOptions() = default;
- void
- SetCoerceToId (bool coerce = true)
- {
- m_coerce_to_id = coerce;
- }
-
- bool
- DoesUnwindOnError () const
- {
- return m_unwind_on_error;
- }
-
- void
- SetUnwindOnError (bool unwind = false)
- {
- m_unwind_on_error = unwind;
- }
-
- bool
- DoesIgnoreBreakpoints () const
- {
- return m_ignore_breakpoints;
- }
-
- void
- SetIgnoreBreakpoints (bool ignore = false)
- {
- m_ignore_breakpoints = ignore;
- }
-
- bool
- DoesKeepInMemory () const
- {
- return m_keep_in_memory;
- }
-
- void
- SetKeepInMemory (bool keep = true)
- {
- m_keep_in_memory = keep;
- }
-
- lldb::DynamicValueType
- GetUseDynamic () const
- {
- return m_use_dynamic;
- }
-
- void
- SetUseDynamic (lldb::DynamicValueType dynamic = lldb::eDynamicCanRunTarget)
- {
- m_use_dynamic = dynamic;
- }
-
- uint32_t
- GetTimeoutUsec () const
- {
- return m_timeout_usec;
- }
-
- void
- SetTimeoutUsec (uint32_t timeout = 0)
- {
- m_timeout_usec = timeout;
- }
-
- uint32_t
- GetOneThreadTimeoutUsec () const
- {
- return m_one_thread_timeout_usec;
- }
-
- void
- SetOneThreadTimeoutUsec (uint32_t timeout = 0)
- {
- m_one_thread_timeout_usec = timeout;
- }
-
- bool
- GetTryAllThreads () const
- {
- return m_try_others;
- }
-
- void
- SetTryAllThreads (bool try_others = true)
- {
- m_try_others = try_others;
- }
-
- bool
- GetStopOthers () const
- {
- return m_stop_others;
- }
-
- void
- SetStopOthers (bool stop_others = true)
- {
- m_stop_others = stop_others;
- }
-
- bool
- GetDebug() const
- {
- return m_debug;
- }
-
- void
- SetDebug(bool b)
- {
- m_debug = b;
- if (m_debug)
- m_generate_debug_info = true;
- }
-
- bool
- GetGenerateDebugInfo() const
- {
- return m_generate_debug_info;
- }
-
- void
- SetGenerateDebugInfo(bool b)
- {
- m_generate_debug_info = b;
- }
-
- bool
- GetColorizeErrors () const
- {
- return m_ansi_color_errors;
- }
-
- void
- SetColorizeErrors (bool b)
- {
- m_ansi_color_errors = b;
- }
-
- bool
- GetTrapExceptions() const
- {
- return m_trap_exceptions;
- }
-
- void
- SetTrapExceptions (bool b)
- {
- m_trap_exceptions = b;
- }
-
- bool
- GetREPLEnabled() const
- {
- return m_repl;
- }
-
- void
- SetREPLEnabled (bool b)
- {
- m_repl = b;
- }
-
- void
- SetCancelCallback (lldb::ExpressionCancelCallback callback, void *baton)
- {
- m_cancel_callback_baton = baton;
- m_cancel_callback = callback;
- }
-
- bool
- InvokeCancelCallback (lldb::ExpressionEvaluationPhase phase) const
- {
- return ((m_cancel_callback != nullptr) ? m_cancel_callback(phase, m_cancel_callback_baton) : false);
- }
-
- // Allows the expression contents to be remapped to point to the specified file and line
- // using #line directives.
- void
- SetPoundLine (const char *path, uint32_t line) const
- {
- if (path && path[0])
- {
- m_pound_line_file = path;
- m_pound_line_line = line;
- }
- else
- {
- m_pound_line_file.clear();
- m_pound_line_line = 0;
- }
- }
-
- const char *
- GetPoundLineFilePath () const
- {
- return (m_pound_line_file.empty() ? nullptr : m_pound_line_file.c_str());
- }
-
- uint32_t
- GetPoundLineLine () const
- {
- return m_pound_line_line;
- }
+ ExecutionPolicy GetExecutionPolicy() const { return m_execution_policy; }
- void
- SetResultIsInternal (bool b)
- {
- m_result_is_internal = b;
- }
+ void SetExecutionPolicy(ExecutionPolicy policy = eExecutionPolicyAlways) {
+ m_execution_policy = policy;
+ }
- bool
- GetResultIsInternal () const
- {
- return m_result_is_internal;
- }
-
- void
- SetAutoApplyFixIts(bool b)
- {
- m_auto_apply_fixits = b;
- }
-
- bool
- GetAutoApplyFixIts() const
- {
- return m_auto_apply_fixits;
+ lldb::LanguageType GetLanguage() const { return m_language; }
+
+ void SetLanguage(lldb::LanguageType language) { m_language = language; }
+
+ bool DoesCoerceToId() const { return m_coerce_to_id; }
+
+ const char *GetPrefix() const {
+ return (m_prefix.empty() ? nullptr : m_prefix.c_str());
+ }
+
+ void SetPrefix(const char *prefix) {
+ if (prefix && prefix[0])
+ m_prefix = prefix;
+ else
+ m_prefix.clear();
+ }
+
+ void SetCoerceToId(bool coerce = true) { m_coerce_to_id = coerce; }
+
+ bool DoesUnwindOnError() const { return m_unwind_on_error; }
+
+ void SetUnwindOnError(bool unwind = false) { m_unwind_on_error = unwind; }
+
+ bool DoesIgnoreBreakpoints() const { return m_ignore_breakpoints; }
+
+ void SetIgnoreBreakpoints(bool ignore = false) {
+ m_ignore_breakpoints = ignore;
+ }
+
+ bool DoesKeepInMemory() const { return m_keep_in_memory; }
+
+ void SetKeepInMemory(bool keep = true) { m_keep_in_memory = keep; }
+
+ lldb::DynamicValueType GetUseDynamic() const { return m_use_dynamic; }
+
+ void
+ SetUseDynamic(lldb::DynamicValueType dynamic = lldb::eDynamicCanRunTarget) {
+ m_use_dynamic = dynamic;
+ }
+
+ const Timeout<std::micro> &GetTimeout() const { return m_timeout; }
+
+ void SetTimeout(const Timeout<std::micro> &timeout) { m_timeout = timeout; }
+
+ const Timeout<std::micro> &GetOneThreadTimeout() const {
+ return m_one_thread_timeout;
+ }
+
+ void SetOneThreadTimeout(const Timeout<std::micro> &timeout) {
+ m_one_thread_timeout = timeout;
+ }
+
+ bool GetTryAllThreads() const { return m_try_others; }
+
+ void SetTryAllThreads(bool try_others = true) { m_try_others = try_others; }
+
+ bool GetStopOthers() const { return m_stop_others; }
+
+ void SetStopOthers(bool stop_others = true) { m_stop_others = stop_others; }
+
+ bool GetDebug() const { return m_debug; }
+
+ void SetDebug(bool b) {
+ m_debug = b;
+ if (m_debug)
+ m_generate_debug_info = true;
+ }
+
+ bool GetGenerateDebugInfo() const { return m_generate_debug_info; }
+
+ void SetGenerateDebugInfo(bool b) { m_generate_debug_info = b; }
+
+ bool GetColorizeErrors() const { return m_ansi_color_errors; }
+
+ void SetColorizeErrors(bool b) { m_ansi_color_errors = b; }
+
+ bool GetTrapExceptions() const { return m_trap_exceptions; }
+
+ void SetTrapExceptions(bool b) { m_trap_exceptions = b; }
+
+ bool GetREPLEnabled() const { return m_repl; }
+
+ void SetREPLEnabled(bool b) { m_repl = b; }
+
+ void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton) {
+ m_cancel_callback_baton = baton;
+ m_cancel_callback = callback;
+ }
+
+ bool InvokeCancelCallback(lldb::ExpressionEvaluationPhase phase) const {
+ return ((m_cancel_callback != nullptr)
+ ? m_cancel_callback(phase, m_cancel_callback_baton)
+ : false);
+ }
+
+ // Allows the expression contents to be remapped to point to the specified
+ // file and line
+ // using #line directives.
+ void SetPoundLine(const char *path, uint32_t line) const {
+ if (path && path[0]) {
+ m_pound_line_file = path;
+ m_pound_line_line = line;
+ } else {
+ m_pound_line_file.clear();
+ m_pound_line_line = 0;
}
+ }
+
+ const char *GetPoundLineFilePath() const {
+ return (m_pound_line_file.empty() ? nullptr : m_pound_line_file.c_str());
+ }
+
+ uint32_t GetPoundLineLine() const { return m_pound_line_line; }
+
+ void SetResultIsInternal(bool b) { m_result_is_internal = b; }
+
+ bool GetResultIsInternal() const { return m_result_is_internal; }
+
+ void SetAutoApplyFixIts(bool b) { m_auto_apply_fixits = b; }
+
+ bool GetAutoApplyFixIts() const { return m_auto_apply_fixits; }
private:
- ExecutionPolicy m_execution_policy;
- lldb::LanguageType m_language;
- std::string m_prefix;
- bool m_coerce_to_id;
- bool m_unwind_on_error;
- bool m_ignore_breakpoints;
- bool m_keep_in_memory;
- bool m_try_others;
- bool m_stop_others;
- bool m_debug;
- bool m_trap_exceptions;
- bool m_repl;
- bool m_generate_debug_info;
- bool m_ansi_color_errors;
- bool m_result_is_internal;
- bool m_auto_apply_fixits;
- lldb::DynamicValueType m_use_dynamic;
- uint32_t m_timeout_usec;
- uint32_t m_one_thread_timeout_usec;
- lldb::ExpressionCancelCallback m_cancel_callback;
- void *m_cancel_callback_baton;
- // If m_pound_line_file is not empty and m_pound_line_line is non-zero,
- // use #line %u "%s" before the expression content to remap where the source
- // originates
- mutable std::string m_pound_line_file;
- mutable uint32_t m_pound_line_line;
+ ExecutionPolicy m_execution_policy = default_execution_policy;
+ lldb::LanguageType m_language = lldb::eLanguageTypeUnknown;
+ std::string m_prefix;
+ bool m_coerce_to_id = false;
+ bool m_unwind_on_error = true;
+ bool m_ignore_breakpoints = false;
+ bool m_keep_in_memory = false;
+ bool m_try_others = true;
+ bool m_stop_others = true;
+ bool m_debug = false;
+ bool m_trap_exceptions = true;
+ bool m_repl = false;
+ bool m_generate_debug_info = false;
+ bool m_ansi_color_errors = false;
+ bool m_result_is_internal = false;
+ bool m_auto_apply_fixits = true;
+ lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues;
+ Timeout<std::micro> m_timeout = default_timeout;
+ Timeout<std::micro> m_one_thread_timeout = llvm::None;
+ lldb::ExpressionCancelCallback m_cancel_callback = nullptr;
+ void *m_cancel_callback_baton = nullptr;
+ // If m_pound_line_file is not empty and m_pound_line_line is non-zero,
+ // use #line %u "%s" before the expression content to remap where the source
+ // originates
+ mutable std::string m_pound_line_file;
+ mutable uint32_t m_pound_line_line;
};
//----------------------------------------------------------------------
// Target
//----------------------------------------------------------------------
-class Target :
- public std::enable_shared_from_this<Target>,
- public TargetProperties,
- public Broadcaster,
- public ExecutionContextScope,
- public ModuleList::Notifier
-{
+class Target : public std::enable_shared_from_this<Target>,
+ public TargetProperties,
+ public Broadcaster,
+ public ExecutionContextScope,
+ public ModuleList::Notifier {
public:
- friend class TargetList;
-
- //------------------------------------------------------------------
- /// Broadcaster event bits definitions.
- //------------------------------------------------------------------
- enum
- {
- eBroadcastBitBreakpointChanged = (1 << 0),
- eBroadcastBitModulesLoaded = (1 << 1),
- eBroadcastBitModulesUnloaded = (1 << 2),
- eBroadcastBitWatchpointChanged = (1 << 3),
- eBroadcastBitSymbolsLoaded = (1 << 4)
- };
-
- // These two functions fill out the Broadcaster interface:
-
- static ConstString &GetStaticBroadcasterClass ();
-
- ConstString &GetBroadcasterClass() const override
- {
- return GetStaticBroadcasterClass();
+ friend class TargetList;
+
+ //------------------------------------------------------------------
+ /// Broadcaster event bits definitions.
+ //------------------------------------------------------------------
+ enum {
+ eBroadcastBitBreakpointChanged = (1 << 0),
+ eBroadcastBitModulesLoaded = (1 << 1),
+ eBroadcastBitModulesUnloaded = (1 << 2),
+ eBroadcastBitWatchpointChanged = (1 << 3),
+ eBroadcastBitSymbolsLoaded = (1 << 4)
+ };
+
+ // These two functions fill out the Broadcaster interface:
+
+ static ConstString &GetStaticBroadcasterClass();
+
+ ConstString &GetBroadcasterClass() const override {
+ return GetStaticBroadcasterClass();
+ }
+
+ // This event data class is for use by the TargetList to broadcast new target
+ // notifications.
+ class TargetEventData : public EventData {
+ public:
+ TargetEventData(const lldb::TargetSP &target_sp);
+
+ TargetEventData(const lldb::TargetSP &target_sp,
+ const ModuleList &module_list);
+
+ ~TargetEventData() override;
+
+ static const ConstString &GetFlavorString();
+
+ const ConstString &GetFlavor() const override {
+ return TargetEventData::GetFlavorString();
}
- // This event data class is for use by the TargetList to broadcast new target notifications.
- class TargetEventData : public EventData
- {
- public:
- TargetEventData (const lldb::TargetSP &target_sp);
+ void Dump(Stream *s) const override;
- TargetEventData (const lldb::TargetSP &target_sp, const ModuleList &module_list);
+ static const TargetEventData *GetEventDataFromEvent(const Event *event_ptr);
- ~TargetEventData() override;
+ static lldb::TargetSP GetTargetFromEvent(const Event *event_ptr);
- static const ConstString &
- GetFlavorString ();
+ static ModuleList GetModuleListFromEvent(const Event *event_ptr);
- const ConstString &
- GetFlavor() const override
- {
- return TargetEventData::GetFlavorString ();
- }
+ const lldb::TargetSP &GetTarget() const { return m_target_sp; }
- void
- Dump(Stream *s) const override;
+ const ModuleList &GetModuleList() const { return m_module_list; }
- static const TargetEventData *
- GetEventDataFromEvent (const Event *event_ptr);
+ private:
+ lldb::TargetSP m_target_sp;
+ ModuleList m_module_list;
- static lldb::TargetSP
- GetTargetFromEvent (const Event *event_ptr);
+ DISALLOW_COPY_AND_ASSIGN(TargetEventData);
+ };
- static ModuleList
- GetModuleListFromEvent (const Event *event_ptr);
+ ~Target() override;
- const lldb::TargetSP &
- GetTarget() const
- {
- return m_target_sp;
- }
+ static void SettingsInitialize();
- const ModuleList &
- GetModuleList() const
- {
- return m_module_list;
- }
+ static void SettingsTerminate();
- private:
- lldb::TargetSP m_target_sp;
- ModuleList m_module_list;
+ static FileSpecList GetDefaultExecutableSearchPaths();
- DISALLOW_COPY_AND_ASSIGN (TargetEventData);
- };
-
- ~Target() override;
+ static FileSpecList GetDefaultDebugFileSearchPaths();
- static void
- SettingsInitialize ();
+ static FileSpecList GetDefaultClangModuleSearchPaths();
- static void
- SettingsTerminate ();
+ static ArchSpec GetDefaultArchitecture();
- static FileSpecList
- GetDefaultExecutableSearchPaths ();
+ static void SetDefaultArchitecture(const ArchSpec &arch);
- static FileSpecList
- GetDefaultDebugFileSearchPaths ();
-
- static FileSpecList
- GetDefaultClangModuleSearchPaths ();
+ // void
+ // UpdateInstanceName ();
- static ArchSpec
- GetDefaultArchitecture ();
+ lldb::ModuleSP GetSharedModule(const ModuleSpec &module_spec,
+ Error *error_ptr = nullptr);
- static void
- SetDefaultArchitecture (const ArchSpec &arch);
+ //----------------------------------------------------------------------
+ // Settings accessors
+ //----------------------------------------------------------------------
-// void
-// UpdateInstanceName ();
+ static const lldb::TargetPropertiesSP &GetGlobalProperties();
- lldb::ModuleSP
- GetSharedModule(const ModuleSpec &module_spec,
- Error *error_ptr = nullptr);
+ std::recursive_mutex &GetAPIMutex() { return m_mutex; }
- //----------------------------------------------------------------------
- // Settings accessors
- //----------------------------------------------------------------------
+ void DeleteCurrentProcess();
- static const lldb::TargetPropertiesSP &
- GetGlobalProperties();
+ void CleanupProcess();
- std::recursive_mutex &
- GetAPIMutex()
- {
- return m_mutex;
- }
+ //------------------------------------------------------------------
+ /// Dump a description of this object to a Stream.
+ ///
+ /// Dump a description of the contents of this object to the
+ /// supplied stream \a s. The dumped content will be only what has
+ /// been loaded or parsed up to this point at which this function
+ /// is called, so this is a good way to see what has been parsed
+ /// in a target.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ //------------------------------------------------------------------
+ void Dump(Stream *s, lldb::DescriptionLevel description_level);
- void
- DeleteCurrentProcess ();
-
- void
- CleanupProcess ();
-
- //------------------------------------------------------------------
- /// Dump a description of this object to a Stream.
- ///
- /// Dump a description of the contents of this object to the
- /// supplied stream \a s. The dumped content will be only what has
- /// been loaded or parsed up to this point at which this function
- /// is called, so this is a good way to see what has been parsed
- /// in a target.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- //------------------------------------------------------------------
- void
- Dump (Stream *s, lldb::DescriptionLevel description_level);
-
- const lldb::ProcessSP &
- CreateProcess (lldb::ListenerSP listener,
- const char *plugin_name,
- const FileSpec *crash_file);
-
- const lldb::ProcessSP &
- GetProcessSP () const;
-
- bool
- IsValid()
- {
- return m_valid;
- }
+ const lldb::ProcessSP &CreateProcess(lldb::ListenerSP listener,
+ llvm::StringRef plugin_name,
+ const FileSpec *crash_file);
- void
- Destroy();
-
- Error
- Launch (ProcessLaunchInfo &launch_info,
- Stream *stream); // Optional stream to receive first stop info
-
- Error
- Attach (ProcessAttachInfo &attach_info,
- Stream *stream); // Optional stream to receive first stop info
-
- //------------------------------------------------------------------
- // This part handles the breakpoints.
- //------------------------------------------------------------------
-
- BreakpointList &
- GetBreakpointList(bool internal = false);
-
- const BreakpointList &
- GetBreakpointList(bool internal = false) const;
-
- lldb::BreakpointSP
- GetLastCreatedBreakpoint ()
- {
- return m_last_created_breakpoint;
- }
+ const lldb::ProcessSP &GetProcessSP() const;
- lldb::BreakpointSP
- GetBreakpointByID (lldb::break_id_t break_id);
-
- // Use this to create a file and line breakpoint to a given module or all module it is nullptr
- lldb::BreakpointSP
- CreateBreakpoint (const FileSpecList *containingModules,
- const FileSpec &file,
- uint32_t line_no,
- lldb::addr_t offset,
- LazyBool check_inlines,
- LazyBool skip_prologue,
- bool internal,
- bool request_hardware,
- LazyBool move_to_nearest_code);
-
- // Use this to create breakpoint that matches regex against the source lines in files given in source_file_list:
- // If function_names is non-empty, also filter by function after the matches are made.
- lldb::BreakpointSP
- CreateSourceRegexBreakpoint (const FileSpecList *containingModules,
- const FileSpecList *source_file_list,
- const std::unordered_set<std::string> &function_names,
- RegularExpression &source_regex,
- bool internal,
- bool request_hardware,
- LazyBool move_to_nearest_code);
-
- // Use this to create a breakpoint from a load address
- lldb::BreakpointSP
- CreateBreakpoint (lldb::addr_t load_addr,
- bool internal,
- bool request_hardware);
-
- // Use this to create a breakpoint from a load address and a module file spec
- lldb::BreakpointSP
- CreateAddressInModuleBreakpoint (lldb::addr_t file_addr,
- bool internal,
- const FileSpec *file_spec,
- bool request_hardware);
-
- // Use this to create Address breakpoints:
- lldb::BreakpointSP
- CreateBreakpoint (const Address &addr,
- bool internal,
- bool request_hardware);
-
- // Use this to create a function breakpoint by regexp in containingModule/containingSourceFiles, or all modules if it is nullptr
- // When "skip_prologue is set to eLazyBoolCalculate, we use the current target
- // setting, else we use the values passed in
- lldb::BreakpointSP
- CreateFuncRegexBreakpoint (const FileSpecList *containingModules,
- const FileSpecList *containingSourceFiles,
- RegularExpression &func_regexp,
- lldb::LanguageType requested_language,
- LazyBool skip_prologue,
- bool internal,
- bool request_hardware);
-
- // Use this to create a function breakpoint by name in containingModule, or all modules if it is nullptr
- // When "skip_prologue is set to eLazyBoolCalculate, we use the current target
- // setting, else we use the values passed in.
- // func_name_type_mask is or'ed values from the FunctionNameType enum.
- lldb::BreakpointSP
- CreateBreakpoint (const FileSpecList *containingModules,
- const FileSpecList *containingSourceFiles,
- const char *func_name,
- uint32_t func_name_type_mask,
- lldb::LanguageType language,
- lldb::addr_t offset,
- LazyBool skip_prologue,
- bool internal,
- bool request_hardware);
-
- lldb::BreakpointSP
- CreateExceptionBreakpoint(enum lldb::LanguageType language,
- bool catch_bp,
- bool throw_bp,
- bool internal,
- Args *additional_args = nullptr,
- Error *additional_args_error = nullptr);
-
- // This is the same as the func_name breakpoint except that you can specify a vector of names. This is cheaper
- // than a regular expression breakpoint in the case where you just want to set a breakpoint on a set of names
- // you already know.
- // func_name_type_mask is or'ed values from the FunctionNameType enum.
- lldb::BreakpointSP
- CreateBreakpoint (const FileSpecList *containingModules,
- const FileSpecList *containingSourceFiles,
- const char *func_names[],
- size_t num_names,
- uint32_t func_name_type_mask,
- lldb::LanguageType language,
- lldb::addr_t offset,
- LazyBool skip_prologue,
- bool internal,
- bool request_hardware);
-
- lldb::BreakpointSP
- CreateBreakpoint (const FileSpecList *containingModules,
- const FileSpecList *containingSourceFiles,
- const std::vector<std::string> &func_names,
- uint32_t func_name_type_mask,
- lldb::LanguageType language,
- lldb::addr_t m_offset,
- LazyBool skip_prologue,
- bool internal,
- bool request_hardware);
-
- // Use this to create a general breakpoint:
- lldb::BreakpointSP
- CreateBreakpoint (lldb::SearchFilterSP &filter_sp,
- lldb::BreakpointResolverSP &resolver_sp,
- bool internal,
- bool request_hardware,
- bool resolve_indirect_symbols);
-
- // Use this to create a watchpoint:
- lldb::WatchpointSP
- CreateWatchpoint (lldb::addr_t addr,
- size_t size,
- const CompilerType *type,
- uint32_t kind,
- Error &error);
-
- lldb::WatchpointSP
- GetLastCreatedWatchpoint ()
- {
- return m_last_created_watchpoint;
- }
+ bool IsValid() { return m_valid; }
- WatchpointList &
- GetWatchpointList()
- {
- return m_watchpoint_list;
- }
+ void Destroy();
- void
- RemoveAllBreakpoints (bool internal_also = false);
-
- void
- DisableAllBreakpoints (bool internal_also = false);
-
- void
- EnableAllBreakpoints (bool internal_also = false);
-
- bool
- DisableBreakpointByID (lldb::break_id_t break_id);
-
- bool
- EnableBreakpointByID (lldb::break_id_t break_id);
-
- bool
- RemoveBreakpointByID (lldb::break_id_t break_id);
-
- // The flag 'end_to_end', default to true, signifies that the operation is
- // performed end to end, for both the debugger and the debuggee.
-
- bool
- RemoveAllWatchpoints (bool end_to_end = true);
-
- bool
- DisableAllWatchpoints (bool end_to_end = true);
-
- bool
- EnableAllWatchpoints (bool end_to_end = true);
-
- bool
- ClearAllWatchpointHitCounts ();
-
- bool
- ClearAllWatchpointHistoricValues ();
-
- bool
- IgnoreAllWatchpoints (uint32_t ignore_count);
-
- bool
- DisableWatchpointByID (lldb::watch_id_t watch_id);
-
- bool
- EnableWatchpointByID (lldb::watch_id_t watch_id);
-
- bool
- RemoveWatchpointByID (lldb::watch_id_t watch_id);
-
- bool
- IgnoreWatchpointByID (lldb::watch_id_t watch_id, uint32_t ignore_count);
-
- //------------------------------------------------------------------
- /// Get \a load_addr as a callable code load address for this target
- ///
- /// Take \a load_addr and potentially add any address bits that are
- /// needed to make the address callable. For ARM this can set bit
- /// zero (if it already isn't) if \a load_addr is a thumb function.
- /// If \a addr_class is set to eAddressClassInvalid, then the address
- /// adjustment will always happen. If it is set to an address class
- /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
- /// returned.
- //------------------------------------------------------------------
- lldb::addr_t
- GetCallableLoadAddress (lldb::addr_t load_addr, lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const;
-
- //------------------------------------------------------------------
- /// Get \a load_addr as an opcode for this target.
- ///
- /// Take \a load_addr and potentially strip any address bits that are
- /// needed to make the address point to an opcode. For ARM this can
- /// clear bit zero (if it already isn't) if \a load_addr is a
- /// thumb function and load_addr is in code.
- /// If \a addr_class is set to eAddressClassInvalid, then the address
- /// adjustment will always happen. If it is set to an address class
- /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
- /// returned.
- //------------------------------------------------------------------
- lldb::addr_t
- GetOpcodeLoadAddress (lldb::addr_t load_addr, lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const;
-
- // Get load_addr as breakable load address for this target.
- // Take a addr and check if for any reason there is a better address than this to put a breakpoint on.
- // If there is then return that address.
- // For MIPS, if instruction at addr is a delay slot instruction then this method will find the address of its
- // previous instruction and return that address.
- lldb::addr_t
- GetBreakableLoadAddress (lldb::addr_t addr);
-
- void
- ModulesDidLoad (ModuleList &module_list);
-
- void
- ModulesDidUnload (ModuleList &module_list, bool delete_locations);
-
- void
- SymbolsDidLoad (ModuleList &module_list);
-
- void
- ClearModules(bool delete_locations);
-
- //------------------------------------------------------------------
- /// Called as the last function in Process::DidExec().
- ///
- /// Process::DidExec() will clear a lot of state in the process,
- /// then try to reload a dynamic loader plugin to discover what
- /// binaries are currently available and then this function should
- /// be called to allow the target to do any cleanup after everything
- /// has been figured out. It can remove breakpoints that no longer
- /// make sense as the exec might have changed the target
- /// architecture, and unloaded some modules that might get deleted.
- //------------------------------------------------------------------
- void
- DidExec ();
-
- //------------------------------------------------------------------
- /// Gets the module for the main executable.
- ///
- /// Each process has a notion of a main executable that is the file
- /// that will be executed or attached to. Executable files can have
- /// dependent modules that are discovered from the object files, or
- /// discovered at runtime as things are dynamically loaded.
- ///
- /// @return
- /// The shared pointer to the executable module which can
- /// contains a nullptr Module object if no executable has been
- /// set.
- ///
- /// @see DynamicLoader
- /// @see ObjectFile::GetDependentModules (FileSpecList&)
- /// @see Process::SetExecutableModule(lldb::ModuleSP&)
- //------------------------------------------------------------------
- lldb::ModuleSP
- GetExecutableModule ();
-
- Module*
- GetExecutableModulePointer ();
-
- //------------------------------------------------------------------
- /// Set the main executable module.
- ///
- /// Each process has a notion of a main executable that is the file
- /// that will be executed or attached to. Executable files can have
- /// dependent modules that are discovered from the object files, or
- /// discovered at runtime as things are dynamically loaded.
- ///
- /// Setting the executable causes any of the current dependant
- /// image information to be cleared and replaced with the static
- /// dependent image information found by calling
- /// ObjectFile::GetDependentModules (FileSpecList&) on the main
- /// executable and any modules on which it depends. Calling
- /// Process::GetImages() will return the newly found images that
- /// were obtained from all of the object files.
- ///
- /// @param[in] module_sp
- /// A shared pointer reference to the module that will become
- /// the main executable for this process.
- ///
- /// @param[in] get_dependent_files
- /// If \b true then ask the object files to track down any
- /// known dependent files.
- ///
- /// @see ObjectFile::GetDependentModules (FileSpecList&)
- /// @see Process::GetImages()
- //------------------------------------------------------------------
- void
- SetExecutableModule (lldb::ModuleSP& module_sp, bool get_dependent_files);
-
- bool
- LoadScriptingResources(std::list<Error>& errors,
- Stream* feedback_stream = nullptr,
- bool continue_on_error = true)
- {
- return m_images.LoadScriptingResourcesInTarget(this,errors,feedback_stream,continue_on_error);
- }
-
- //------------------------------------------------------------------
- /// Get accessor for the images for this process.
- ///
- /// Each process has a notion of a main executable that is the file
- /// that will be executed or attached to. Executable files can have
- /// dependent modules that are discovered from the object files, or
- /// discovered at runtime as things are dynamically loaded. After
- /// a main executable has been set, the images will contain a list
- /// of all the files that the executable depends upon as far as the
- /// object files know. These images will usually contain valid file
- /// virtual addresses only. When the process is launched or attached
- /// to, the DynamicLoader plug-in will discover where these images
- /// were loaded in memory and will resolve the load virtual
- /// addresses is each image, and also in images that are loaded by
- /// code.
- ///
- /// @return
- /// A list of Module objects in a module list.
- //------------------------------------------------------------------
- const ModuleList&
- GetImages () const
- {
- return m_images;
- }
-
- ModuleList&
- GetImages ()
- {
- return m_images;
- }
-
- //------------------------------------------------------------------
- /// Return whether this FileSpec corresponds to a module that should be considered for general searches.
- ///
- /// This API will be consulted by the SearchFilterForUnconstrainedSearches
- /// and any module that returns \b true will not be searched. Note the
- /// SearchFilterForUnconstrainedSearches is the search filter that
- /// gets used in the CreateBreakpoint calls when no modules is provided.
- ///
- /// The target call at present just consults the Platform's call of the
- /// same name.
- ///
- /// @param[in] module_sp
- /// A shared pointer reference to the module that checked.
- ///
- /// @return \b true if the module should be excluded, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ModuleIsExcludedForUnconstrainedSearches (const FileSpec &module_spec);
-
- //------------------------------------------------------------------
- /// Return whether this module should be considered for general searches.
- ///
- /// This API will be consulted by the SearchFilterForUnconstrainedSearches
- /// and any module that returns \b true will not be searched. Note the
- /// SearchFilterForUnconstrainedSearches is the search filter that
- /// gets used in the CreateBreakpoint calls when no modules is provided.
- ///
- /// The target call at present just consults the Platform's call of the
- /// same name.
- ///
- /// FIXME: When we get time we should add a way for the user to set modules that they
- /// don't want searched, in addition to or instead of the platform ones.
- ///
- /// @param[in] module_sp
- /// A shared pointer reference to the module that checked.
- ///
- /// @return \b true if the module should be excluded, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ModuleIsExcludedForUnconstrainedSearches (const lldb::ModuleSP &module_sp);
-
- const ArchSpec &
- GetArchitecture () const
- {
- return m_arch;
- }
-
- //------------------------------------------------------------------
- /// Set the architecture for this target.
- ///
- /// If the current target has no Images read in, then this just sets the architecture, which will
- /// be used to select the architecture of the ExecutableModule when that is set.
- /// If the current target has an ExecutableModule, then calling SetArchitecture with a different
- /// architecture from the currently selected one will reset the ExecutableModule to that slice
- /// of the file backing the ExecutableModule. If the file backing the ExecutableModule does not
- /// contain a fork of this architecture, then this code will return false, and the architecture
- /// won't be changed.
- /// If the input arch_spec is the same as the already set architecture, this is a no-op.
- ///
- /// @param[in] arch_spec
- /// The new architecture.
- ///
- /// @return
- /// \b true if the architecture was successfully set, \bfalse otherwise.
- //------------------------------------------------------------------
- bool
- SetArchitecture (const ArchSpec &arch_spec);
-
- bool
- MergeArchitecture (const ArchSpec &arch_spec);
-
- Debugger &
- GetDebugger ()
- {
- return m_debugger;
- }
+ Error Launch(ProcessLaunchInfo &launch_info,
+ Stream *stream); // Optional stream to receive first stop info
- size_t
- ReadMemoryFromFileCache (const Address& addr,
- void *dst,
- size_t dst_len,
- Error &error);
-
- // Reading memory through the target allows us to skip going to the process
- // for reading memory if possible and it allows us to try and read from
- // any constant sections in our object files on disk. If you always want
- // live program memory, read straight from the process. If you possibly
- // want to read from const sections in object files, read from the target.
- // This version of ReadMemory will try and read memory from the process
- // if the process is alive. The order is:
- // 1 - if (prefer_file_cache == true) then read from object file cache
- // 2 - if there is a valid process, try and read from its memory
- // 3 - if (prefer_file_cache == false) then read from object file cache
- size_t
- ReadMemory(const Address& addr,
- bool prefer_file_cache,
- void *dst,
- size_t dst_len,
- Error &error,
- lldb::addr_t *load_addr_ptr = nullptr);
-
- size_t
- ReadCStringFromMemory (const Address& addr, std::string &out_str, Error &error);
-
- size_t
- ReadCStringFromMemory (const Address& addr, char *dst, size_t dst_max_len, Error &result_error);
-
- size_t
- ReadScalarIntegerFromMemory (const Address& addr,
- bool prefer_file_cache,
- uint32_t byte_size,
- bool is_signed,
- Scalar &scalar,
- Error &error);
+ Error Attach(ProcessAttachInfo &attach_info,
+ Stream *stream); // Optional stream to receive first stop info
+
+ //------------------------------------------------------------------
+ // This part handles the breakpoints.
+ //------------------------------------------------------------------
+
+ BreakpointList &GetBreakpointList(bool internal = false);
+
+ const BreakpointList &GetBreakpointList(bool internal = false) const;
+
+ lldb::BreakpointSP GetLastCreatedBreakpoint() {
+ return m_last_created_breakpoint;
+ }
+
+ lldb::BreakpointSP GetBreakpointByID(lldb::break_id_t break_id);
+
+ // Use this to create a file and line breakpoint to a given module or all
+ // module it is nullptr
+ lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules,
+ const FileSpec &file, uint32_t line_no,
+ lldb::addr_t offset,
+ LazyBool check_inlines,
+ LazyBool skip_prologue, bool internal,
+ bool request_hardware,
+ LazyBool move_to_nearest_code);
+
+ // Use this to create breakpoint that matches regex against the source lines
+ // in files given in source_file_list:
+ // If function_names is non-empty, also filter by function after the matches
+ // are made.
+ lldb::BreakpointSP CreateSourceRegexBreakpoint(
+ const FileSpecList *containingModules,
+ const FileSpecList *source_file_list,
+ const std::unordered_set<std::string> &function_names,
+ RegularExpression &source_regex, bool internal, bool request_hardware,
+ LazyBool move_to_nearest_code);
- uint64_t
- ReadUnsignedIntegerFromMemory (const Address& addr,
- bool prefer_file_cache,
- size_t integer_byte_size,
- uint64_t fail_value,
- Error &error);
-
- bool
- ReadPointerFromMemory (const Address& addr,
- bool prefer_file_cache,
- Error &error,
- Address &pointer_addr);
-
- SectionLoadList&
- GetSectionLoadList()
- {
- return m_section_load_history.GetCurrentSectionLoadList();
- }
+ // Use this to create a breakpoint from a load address
+ lldb::BreakpointSP CreateBreakpoint(lldb::addr_t load_addr, bool internal,
+ bool request_hardware);
+
+ // Use this to create a breakpoint from a load address and a module file spec
+ lldb::BreakpointSP CreateAddressInModuleBreakpoint(lldb::addr_t file_addr,
+ bool internal,
+ const FileSpec *file_spec,
+ bool request_hardware);
-// const SectionLoadList&
-// GetSectionLoadList() const
-// {
-// return const_cast<SectionLoadHistory *>(&m_section_load_history)->GetCurrentSectionLoadList();
-// }
-
- static Target *
- GetTargetFromContexts (const ExecutionContext *exe_ctx_ptr,
- const SymbolContext *sc_ptr);
-
- //------------------------------------------------------------------
- // lldb::ExecutionContextScope pure virtual functions
- //------------------------------------------------------------------
- lldb::TargetSP
- CalculateTarget() override;
-
- lldb::ProcessSP
- CalculateProcess() override;
-
- lldb::ThreadSP
- CalculateThread() override;
-
- lldb::StackFrameSP
- CalculateStackFrame() override;
-
- void
- CalculateExecutionContext(ExecutionContext &exe_ctx) override;
-
- PathMappingList &
- GetImageSearchPathList ();
-
- TypeSystem *
- GetScratchTypeSystemForLanguage (Error *error, lldb::LanguageType language, bool create_on_demand = true);
-
- PersistentExpressionState *
- GetPersistentExpressionStateForLanguage (lldb::LanguageType language);
-
- // Creates a UserExpression for the given language, the rest of the parameters have the
- // same meaning as for the UserExpression constructor.
- // Returns a new-ed object which the caller owns.
-
- UserExpression *
- GetUserExpressionForLanguage(const char *expr,
- const char *expr_prefix,
- lldb::LanguageType language,
- Expression::ResultType desired_type,
- const EvaluateExpressionOptions &options,
+ // Use this to create Address breakpoints:
+ lldb::BreakpointSP CreateBreakpoint(const Address &addr, bool internal,
+ bool request_hardware);
+
+ // Use this to create a function breakpoint by regexp in
+ // containingModule/containingSourceFiles, or all modules if it is nullptr
+ // When "skip_prologue is set to eLazyBoolCalculate, we use the current target
+ // setting, else we use the values passed in
+ lldb::BreakpointSP CreateFuncRegexBreakpoint(
+ const FileSpecList *containingModules,
+ const FileSpecList *containingSourceFiles, RegularExpression &func_regexp,
+ lldb::LanguageType requested_language, LazyBool skip_prologue,
+ bool internal, bool request_hardware);
+
+ // Use this to create a function breakpoint by name in containingModule, or
+ // all modules if it is nullptr
+ // When "skip_prologue is set to eLazyBoolCalculate, we use the current target
+ // setting, else we use the values passed in.
+ // func_name_type_mask is or'ed values from the FunctionNameType enum.
+ lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules,
+ const FileSpecList *containingSourceFiles,
+ const char *func_name,
+ uint32_t func_name_type_mask,
+ lldb::LanguageType language,
+ lldb::addr_t offset,
+ LazyBool skip_prologue, bool internal,
+ bool request_hardware);
+
+ lldb::BreakpointSP
+ CreateExceptionBreakpoint(enum lldb::LanguageType language, bool catch_bp,
+ bool throw_bp, bool internal,
+ Args *additional_args = nullptr,
+ Error *additional_args_error = nullptr);
+
+ // This is the same as the func_name breakpoint except that you can specify a
+ // vector of names. This is cheaper
+ // than a regular expression breakpoint in the case where you just want to set
+ // a breakpoint on a set of names
+ // you already know.
+ // func_name_type_mask is or'ed values from the FunctionNameType enum.
+ lldb::BreakpointSP
+ CreateBreakpoint(const FileSpecList *containingModules,
+ const FileSpecList *containingSourceFiles,
+ const char *func_names[], size_t num_names,
+ uint32_t func_name_type_mask, lldb::LanguageType language,
+ lldb::addr_t offset, LazyBool skip_prologue, bool internal,
+ bool request_hardware);
+
+ lldb::BreakpointSP
+ CreateBreakpoint(const FileSpecList *containingModules,
+ const FileSpecList *containingSourceFiles,
+ const std::vector<std::string> &func_names,
+ uint32_t func_name_type_mask, lldb::LanguageType language,
+ lldb::addr_t m_offset, LazyBool skip_prologue, bool internal,
+ bool request_hardware);
+
+ // Use this to create a general breakpoint:
+ lldb::BreakpointSP CreateBreakpoint(lldb::SearchFilterSP &filter_sp,
+ lldb::BreakpointResolverSP &resolver_sp,
+ bool internal, bool request_hardware,
+ bool resolve_indirect_symbols);
+
+ // Use this to create a watchpoint:
+ lldb::WatchpointSP CreateWatchpoint(lldb::addr_t addr, size_t size,
+ const CompilerType *type, uint32_t kind,
+ Error &error);
+
+ lldb::WatchpointSP GetLastCreatedWatchpoint() {
+ return m_last_created_watchpoint;
+ }
+
+ WatchpointList &GetWatchpointList() { return m_watchpoint_list; }
+
+ void RemoveAllBreakpoints(bool internal_also = false);
+
+ void DisableAllBreakpoints(bool internal_also = false);
+
+ void EnableAllBreakpoints(bool internal_also = false);
+
+ bool DisableBreakpointByID(lldb::break_id_t break_id);
+
+ bool EnableBreakpointByID(lldb::break_id_t break_id);
+
+ bool RemoveBreakpointByID(lldb::break_id_t break_id);
+
+ // The flag 'end_to_end', default to true, signifies that the operation is
+ // performed end to end, for both the debugger and the debuggee.
+
+ bool RemoveAllWatchpoints(bool end_to_end = true);
+
+ bool DisableAllWatchpoints(bool end_to_end = true);
+
+ bool EnableAllWatchpoints(bool end_to_end = true);
+
+ bool ClearAllWatchpointHitCounts();
+
+ bool ClearAllWatchpointHistoricValues();
+
+ bool IgnoreAllWatchpoints(uint32_t ignore_count);
+
+ bool DisableWatchpointByID(lldb::watch_id_t watch_id);
+
+ bool EnableWatchpointByID(lldb::watch_id_t watch_id);
+
+ bool RemoveWatchpointByID(lldb::watch_id_t watch_id);
+
+ bool IgnoreWatchpointByID(lldb::watch_id_t watch_id, uint32_t ignore_count);
+
+ Error SerializeBreakpointsToFile(const FileSpec &file,
+ const BreakpointIDList &bp_ids, bool append);
+
+ Error CreateBreakpointsFromFile(const FileSpec &file,
+ BreakpointIDList &new_bps);
+
+ Error CreateBreakpointsFromFile(const FileSpec &file,
+ std::vector<std::string> &names,
+ BreakpointIDList &new_bps);
+
+ //------------------------------------------------------------------
+ /// Get \a load_addr as a callable code load address for this target
+ ///
+ /// Take \a load_addr and potentially add any address bits that are
+ /// needed to make the address callable. For ARM this can set bit
+ /// zero (if it already isn't) if \a load_addr is a thumb function.
+ /// If \a addr_class is set to eAddressClassInvalid, then the address
+ /// adjustment will always happen. If it is set to an address class
+ /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
+ /// returned.
+ //------------------------------------------------------------------
+ lldb::addr_t GetCallableLoadAddress(
+ lldb::addr_t load_addr,
+ lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const;
+
+ //------------------------------------------------------------------
+ /// Get \a load_addr as an opcode for this target.
+ ///
+ /// Take \a load_addr and potentially strip any address bits that are
+ /// needed to make the address point to an opcode. For ARM this can
+ /// clear bit zero (if it already isn't) if \a load_addr is a
+ /// thumb function and load_addr is in code.
+ /// If \a addr_class is set to eAddressClassInvalid, then the address
+ /// adjustment will always happen. If it is set to an address class
+ /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
+ /// returned.
+ //------------------------------------------------------------------
+ lldb::addr_t GetOpcodeLoadAddress(
+ lldb::addr_t load_addr,
+ lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const;
+
+ // Get load_addr as breakable load address for this target.
+ // Take a addr and check if for any reason there is a better address than this
+ // to put a breakpoint on.
+ // If there is then return that address.
+ // For MIPS, if instruction at addr is a delay slot instruction then this
+ // method will find the address of its
+ // previous instruction and return that address.
+ lldb::addr_t GetBreakableLoadAddress(lldb::addr_t addr);
+
+ void ModulesDidLoad(ModuleList &module_list);
+
+ void ModulesDidUnload(ModuleList &module_list, bool delete_locations);
+
+ void SymbolsDidLoad(ModuleList &module_list);
+
+ void ClearModules(bool delete_locations);
+
+ //------------------------------------------------------------------
+ /// Called as the last function in Process::DidExec().
+ ///
+ /// Process::DidExec() will clear a lot of state in the process,
+ /// then try to reload a dynamic loader plugin to discover what
+ /// binaries are currently available and then this function should
+ /// be called to allow the target to do any cleanup after everything
+ /// has been figured out. It can remove breakpoints that no longer
+ /// make sense as the exec might have changed the target
+ /// architecture, and unloaded some modules that might get deleted.
+ //------------------------------------------------------------------
+ void DidExec();
+
+ //------------------------------------------------------------------
+ /// Gets the module for the main executable.
+ ///
+ /// Each process has a notion of a main executable that is the file
+ /// that will be executed or attached to. Executable files can have
+ /// dependent modules that are discovered from the object files, or
+ /// discovered at runtime as things are dynamically loaded.
+ ///
+ /// @return
+ /// The shared pointer to the executable module which can
+ /// contains a nullptr Module object if no executable has been
+ /// set.
+ ///
+ /// @see DynamicLoader
+ /// @see ObjectFile::GetDependentModules (FileSpecList&)
+ /// @see Process::SetExecutableModule(lldb::ModuleSP&)
+ //------------------------------------------------------------------
+ lldb::ModuleSP GetExecutableModule();
+
+ Module *GetExecutableModulePointer();
+
+ //------------------------------------------------------------------
+ /// Set the main executable module.
+ ///
+ /// Each process has a notion of a main executable that is the file
+ /// that will be executed or attached to. Executable files can have
+ /// dependent modules that are discovered from the object files, or
+ /// discovered at runtime as things are dynamically loaded.
+ ///
+ /// Setting the executable causes any of the current dependent
+ /// image information to be cleared and replaced with the static
+ /// dependent image information found by calling
+ /// ObjectFile::GetDependentModules (FileSpecList&) on the main
+ /// executable and any modules on which it depends. Calling
+ /// Process::GetImages() will return the newly found images that
+ /// were obtained from all of the object files.
+ ///
+ /// @param[in] module_sp
+ /// A shared pointer reference to the module that will become
+ /// the main executable for this process.
+ ///
+ /// @param[in] get_dependent_files
+ /// If \b true then ask the object files to track down any
+ /// known dependent files.
+ ///
+ /// @see ObjectFile::GetDependentModules (FileSpecList&)
+ /// @see Process::GetImages()
+ //------------------------------------------------------------------
+ void SetExecutableModule(lldb::ModuleSP &module_sp, bool get_dependent_files);
+
+ bool LoadScriptingResources(std::list<Error> &errors,
+ Stream *feedback_stream = nullptr,
+ bool continue_on_error = true) {
+ return m_images.LoadScriptingResourcesInTarget(
+ this, errors, feedback_stream, continue_on_error);
+ }
+
+ //------------------------------------------------------------------
+ /// Get accessor for the images for this process.
+ ///
+ /// Each process has a notion of a main executable that is the file
+ /// that will be executed or attached to. Executable files can have
+ /// dependent modules that are discovered from the object files, or
+ /// discovered at runtime as things are dynamically loaded. After
+ /// a main executable has been set, the images will contain a list
+ /// of all the files that the executable depends upon as far as the
+ /// object files know. These images will usually contain valid file
+ /// virtual addresses only. When the process is launched or attached
+ /// to, the DynamicLoader plug-in will discover where these images
+ /// were loaded in memory and will resolve the load virtual
+ /// addresses is each image, and also in images that are loaded by
+ /// code.
+ ///
+ /// @return
+ /// A list of Module objects in a module list.
+ //------------------------------------------------------------------
+ const ModuleList &GetImages() const { return m_images; }
+
+ ModuleList &GetImages() { return m_images; }
+
+ //------------------------------------------------------------------
+ /// Return whether this FileSpec corresponds to a module that should be
+ /// considered for general searches.
+ ///
+ /// This API will be consulted by the SearchFilterForUnconstrainedSearches
+ /// and any module that returns \b true will not be searched. Note the
+ /// SearchFilterForUnconstrainedSearches is the search filter that
+ /// gets used in the CreateBreakpoint calls when no modules is provided.
+ ///
+ /// The target call at present just consults the Platform's call of the
+ /// same name.
+ ///
+ /// @param[in] module_sp
+ /// A shared pointer reference to the module that checked.
+ ///
+ /// @return \b true if the module should be excluded, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ModuleIsExcludedForUnconstrainedSearches(const FileSpec &module_spec);
+
+ //------------------------------------------------------------------
+ /// Return whether this module should be considered for general searches.
+ ///
+ /// This API will be consulted by the SearchFilterForUnconstrainedSearches
+ /// and any module that returns \b true will not be searched. Note the
+ /// SearchFilterForUnconstrainedSearches is the search filter that
+ /// gets used in the CreateBreakpoint calls when no modules is provided.
+ ///
+ /// The target call at present just consults the Platform's call of the
+ /// same name.
+ ///
+ /// FIXME: When we get time we should add a way for the user to set modules
+ /// that they
+ /// don't want searched, in addition to or instead of the platform ones.
+ ///
+ /// @param[in] module_sp
+ /// A shared pointer reference to the module that checked.
+ ///
+ /// @return \b true if the module should be excluded, \b false otherwise.
+ //------------------------------------------------------------------
+ bool
+ ModuleIsExcludedForUnconstrainedSearches(const lldb::ModuleSP &module_sp);
+
+ const ArchSpec &GetArchitecture() const { return m_arch; }
+
+ //------------------------------------------------------------------
+ /// Set the architecture for this target.
+ ///
+ /// If the current target has no Images read in, then this just sets the
+ /// architecture, which will
+ /// be used to select the architecture of the ExecutableModule when that is
+ /// set.
+ /// If the current target has an ExecutableModule, then calling
+ /// SetArchitecture with a different
+ /// architecture from the currently selected one will reset the
+ /// ExecutableModule to that slice
+ /// of the file backing the ExecutableModule. If the file backing the
+ /// ExecutableModule does not
+ /// contain a fork of this architecture, then this code will return false, and
+ /// the architecture
+ /// won't be changed.
+ /// If the input arch_spec is the same as the already set architecture, this
+ /// is a no-op.
+ ///
+ /// @param[in] arch_spec
+ /// The new architecture.
+ ///
+ /// @return
+ /// \b true if the architecture was successfully set, \bfalse otherwise.
+ //------------------------------------------------------------------
+ bool SetArchitecture(const ArchSpec &arch_spec);
+
+ bool MergeArchitecture(const ArchSpec &arch_spec);
+
+ Debugger &GetDebugger() { return m_debugger; }
+
+ size_t ReadMemoryFromFileCache(const Address &addr, void *dst, size_t dst_len,
Error &error);
-
- // Creates a FunctionCaller for the given language, the rest of the parameters have the
- // same meaning as for the FunctionCaller constructor. Since a FunctionCaller can't be
- // IR Interpreted, it makes no sense to call this with an ExecutionContextScope that lacks
- // a Process.
- // Returns a new-ed object which the caller owns.
-
- FunctionCaller *
- GetFunctionCallerForLanguage (lldb::LanguageType language,
- const CompilerType &return_type,
- const Address& function_address,
- const ValueList &arg_value_list,
- const char *name,
- Error &error);
-
- // Creates a UtilityFunction for the given language, the rest of the parameters have the
- // same meaning as for the UtilityFunction constructor.
- // Returns a new-ed object which the caller owns.
-
- UtilityFunction *
- GetUtilityFunctionForLanguage (const char *expr,
- lldb::LanguageType language,
- const char *name,
- Error &error);
-
- ClangASTContext *
- GetScratchClangASTContext(bool create_on_demand=true);
-
- lldb::ClangASTImporterSP
- GetClangASTImporter();
-
- //----------------------------------------------------------------------
- // Install any files through the platform that need be to installed
- // prior to launching or attaching.
- //----------------------------------------------------------------------
- Error
- Install(ProcessLaunchInfo *launch_info);
-
- bool
- ResolveFileAddress (lldb::addr_t load_addr,
- Address &so_addr);
-
- bool
- ResolveLoadAddress (lldb::addr_t load_addr,
- Address &so_addr,
- uint32_t stop_id = SectionLoadHistory::eStopIDNow);
-
- bool
- SetSectionLoadAddress (const lldb::SectionSP &section,
- lldb::addr_t load_addr,
- bool warn_multiple = false);
-
- size_t
- UnloadModuleSections (const lldb::ModuleSP &module_sp);
-
- size_t
- UnloadModuleSections (const ModuleList &module_list);
-
- bool
- SetSectionUnloaded (const lldb::SectionSP &section_sp);
-
- bool
- SetSectionUnloaded (const lldb::SectionSP &section_sp, lldb::addr_t load_addr);
-
- void
- ClearAllLoadedSections ();
-
- // Since expressions results can persist beyond the lifetime of a process,
- // and the const expression results are available after a process is gone,
- // we provide a way for expressions to be evaluated from the Target itself.
- // If an expression is going to be run, then it should have a frame filled
- // in in th execution context.
- lldb::ExpressionResults
- EvaluateExpression (const char *expression,
- ExecutionContextScope *exe_scope,
- lldb::ValueObjectSP &result_valobj_sp,
- const EvaluateExpressionOptions& options = EvaluateExpressionOptions(),
- std::string *fixed_expression = nullptr);
-
- lldb::ExpressionVariableSP
- GetPersistentVariable(const ConstString &name);
-
- lldb::addr_t
- GetPersistentSymbol(const ConstString &name);
-
- //------------------------------------------------------------------
- // Target Stop Hooks
- //------------------------------------------------------------------
- class StopHook : public UserID
- {
- public:
- StopHook (const StopHook &rhs);
-
- ~StopHook ();
-
- StringList *
- GetCommandPointer ()
- {
- return &m_commands;
- }
-
- const StringList &
- GetCommands()
- {
- return m_commands;
- }
-
- lldb::TargetSP &
- GetTarget()
- {
- return m_target_sp;
- }
-
- void
- SetCommands (StringList &in_commands)
- {
- m_commands = in_commands;
- }
-
- // Set the specifier. The stop hook will own the specifier, and is responsible for deleting it when we're done.
- void
- SetSpecifier (SymbolContextSpecifier *specifier);
-
- SymbolContextSpecifier *
- GetSpecifier ()
- {
- return m_specifier_sp.get();
- }
-
- // Set the Thread Specifier. The stop hook will own the thread specifier, and is responsible for deleting it when we're done.
- void
- SetThreadSpecifier (ThreadSpec *specifier);
-
- ThreadSpec *
- GetThreadSpecifier()
- {
- return m_thread_spec_ap.get();
- }
-
- bool
- IsActive()
- {
- return m_active;
- }
-
- void
- SetIsActive (bool is_active)
- {
- m_active = is_active;
- }
-
- void
- GetDescription (Stream *s, lldb::DescriptionLevel level) const;
-
- private:
- lldb::TargetSP m_target_sp;
- StringList m_commands;
- lldb::SymbolContextSpecifierSP m_specifier_sp;
- std::unique_ptr<ThreadSpec> m_thread_spec_ap;
- bool m_active;
-
- // Use CreateStopHook to make a new empty stop hook. The GetCommandPointer and fill it with commands,
- // and SetSpecifier to set the specifier shared pointer (can be null, that will match anything.)
- StopHook (lldb::TargetSP target_sp, lldb::user_id_t uid);
- friend class Target;
- };
- typedef std::shared_ptr<StopHook> StopHookSP;
-
- // Add an empty stop hook to the Target's stop hook list, and returns a shared pointer to it in new_hook.
- // Returns the id of the new hook.
- StopHookSP
- CreateStopHook ();
-
- void
- RunStopHooks ();
-
- size_t
- GetStopHookSize();
-
- bool
- SetSuppresStopHooks (bool suppress)
- {
- bool old_value = m_suppress_stop_hooks;
- m_suppress_stop_hooks = suppress;
- return old_value;
- }
-
- bool
- GetSuppressStopHooks ()
- {
- return m_suppress_stop_hooks;
- }
-// StopHookSP &
-// GetStopHookByIndex (size_t index);
-//
- bool
- RemoveStopHookByID (lldb::user_id_t uid);
-
- void
- RemoveAllStopHooks ();
-
- StopHookSP
- GetStopHookByID (lldb::user_id_t uid);
-
- bool
- SetStopHookActiveStateByID (lldb::user_id_t uid, bool active_state);
-
- void
- SetAllStopHooksActiveState (bool active_state);
-
- size_t GetNumStopHooks () const
- {
- return m_stop_hooks.size();
- }
-
- StopHookSP
- GetStopHookAtIndex (size_t index)
- {
- if (index >= GetNumStopHooks())
- return StopHookSP();
- StopHookCollection::iterator pos = m_stop_hooks.begin();
-
- while (index > 0)
- {
- pos++;
- index--;
- }
- return (*pos).second;
- }
-
- lldb::PlatformSP
- GetPlatform ()
- {
- return m_platform_sp;
- }
+ // Reading memory through the target allows us to skip going to the process
+ // for reading memory if possible and it allows us to try and read from
+ // any constant sections in our object files on disk. If you always want
+ // live program memory, read straight from the process. If you possibly
+ // want to read from const sections in object files, read from the target.
+ // This version of ReadMemory will try and read memory from the process
+ // if the process is alive. The order is:
+ // 1 - if (prefer_file_cache == true) then read from object file cache
+ // 2 - if there is a valid process, try and read from its memory
+ // 3 - if (prefer_file_cache == false) then read from object file cache
+ size_t ReadMemory(const Address &addr, bool prefer_file_cache, void *dst,
+ size_t dst_len, Error &error,
+ lldb::addr_t *load_addr_ptr = nullptr);
+
+ size_t ReadCStringFromMemory(const Address &addr, std::string &out_str,
+ Error &error);
+
+ size_t ReadCStringFromMemory(const Address &addr, char *dst,
+ size_t dst_max_len, Error &result_error);
+
+ size_t ReadScalarIntegerFromMemory(const Address &addr,
+ bool prefer_file_cache, uint32_t byte_size,
+ bool is_signed, Scalar &scalar,
+ Error &error);
+
+ uint64_t ReadUnsignedIntegerFromMemory(const Address &addr,
+ bool prefer_file_cache,
+ size_t integer_byte_size,
+ uint64_t fail_value, Error &error);
+
+ bool ReadPointerFromMemory(const Address &addr, bool prefer_file_cache,
+ Error &error, Address &pointer_addr);
+
+ SectionLoadList &GetSectionLoadList() {
+ return m_section_load_history.GetCurrentSectionLoadList();
+ }
+
+ // const SectionLoadList&
+ // GetSectionLoadList() const
+ // {
+ // return const_cast<SectionLoadHistory
+ // *>(&m_section_load_history)->GetCurrentSectionLoadList();
+ // }
+
+ static Target *GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr,
+ const SymbolContext *sc_ptr);
+
+ //------------------------------------------------------------------
+ // lldb::ExecutionContextScope pure virtual functions
+ //------------------------------------------------------------------
+ lldb::TargetSP CalculateTarget() override;
+
+ lldb::ProcessSP CalculateProcess() override;
+
+ lldb::ThreadSP CalculateThread() override;
+
+ lldb::StackFrameSP CalculateStackFrame() override;
- void
- SetPlatform (const lldb::PlatformSP &platform_sp)
- {
- m_platform_sp = platform_sp;
+ void CalculateExecutionContext(ExecutionContext &exe_ctx) override;
+
+ PathMappingList &GetImageSearchPathList();
+
+ TypeSystem *GetScratchTypeSystemForLanguage(Error *error,
+ lldb::LanguageType language,
+ bool create_on_demand = true);
+
+ PersistentExpressionState *
+ GetPersistentExpressionStateForLanguage(lldb::LanguageType language);
+
+ // Creates a UserExpression for the given language, the rest of the parameters
+ // have the
+ // same meaning as for the UserExpression constructor.
+ // Returns a new-ed object which the caller owns.
+
+ UserExpression *GetUserExpressionForLanguage(
+ llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language,
+ Expression::ResultType desired_type,
+ const EvaluateExpressionOptions &options, Error &error);
+
+ // Creates a FunctionCaller for the given language, the rest of the parameters
+ // have the
+ // same meaning as for the FunctionCaller constructor. Since a FunctionCaller
+ // can't be
+ // IR Interpreted, it makes no sense to call this with an
+ // ExecutionContextScope that lacks
+ // a Process.
+ // Returns a new-ed object which the caller owns.
+
+ FunctionCaller *GetFunctionCallerForLanguage(lldb::LanguageType language,
+ const CompilerType &return_type,
+ const Address &function_address,
+ const ValueList &arg_value_list,
+ const char *name, Error &error);
+
+ // Creates a UtilityFunction for the given language, the rest of the
+ // parameters have the
+ // same meaning as for the UtilityFunction constructor.
+ // Returns a new-ed object which the caller owns.
+
+ UtilityFunction *GetUtilityFunctionForLanguage(const char *expr,
+ lldb::LanguageType language,
+ const char *name,
+ Error &error);
+
+ ClangASTContext *GetScratchClangASTContext(bool create_on_demand = true);
+
+ lldb::ClangASTImporterSP GetClangASTImporter();
+
+ //----------------------------------------------------------------------
+ // Install any files through the platform that need be to installed
+ // prior to launching or attaching.
+ //----------------------------------------------------------------------
+ Error Install(ProcessLaunchInfo *launch_info);
+
+ bool ResolveFileAddress(lldb::addr_t load_addr, Address &so_addr);
+
+ bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr,
+ uint32_t stop_id = SectionLoadHistory::eStopIDNow);
+
+ bool SetSectionLoadAddress(const lldb::SectionSP &section,
+ lldb::addr_t load_addr,
+ bool warn_multiple = false);
+
+ size_t UnloadModuleSections(const lldb::ModuleSP &module_sp);
+
+ size_t UnloadModuleSections(const ModuleList &module_list);
+
+ bool SetSectionUnloaded(const lldb::SectionSP &section_sp);
+
+ bool SetSectionUnloaded(const lldb::SectionSP &section_sp,
+ lldb::addr_t load_addr);
+
+ void ClearAllLoadedSections();
+
+ // Since expressions results can persist beyond the lifetime of a process,
+ // and the const expression results are available after a process is gone,
+ // we provide a way for expressions to be evaluated from the Target itself.
+ // If an expression is going to be run, then it should have a frame filled
+ // in in th execution context.
+ lldb::ExpressionResults EvaluateExpression(
+ llvm::StringRef expression, ExecutionContextScope *exe_scope,
+ lldb::ValueObjectSP &result_valobj_sp,
+ const EvaluateExpressionOptions &options = EvaluateExpressionOptions(),
+ std::string *fixed_expression = nullptr);
+
+ lldb::ExpressionVariableSP GetPersistentVariable(const ConstString &name);
+
+ lldb::addr_t GetPersistentSymbol(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // Target Stop Hooks
+ //------------------------------------------------------------------
+ class StopHook : public UserID {
+ public:
+ StopHook(const StopHook &rhs);
+
+ ~StopHook();
+
+ StringList *GetCommandPointer() { return &m_commands; }
+
+ const StringList &GetCommands() { return m_commands; }
+
+ lldb::TargetSP &GetTarget() { return m_target_sp; }
+
+ void SetCommands(StringList &in_commands) { m_commands = in_commands; }
+
+ // Set the specifier. The stop hook will own the specifier, and is
+ // responsible for deleting it when we're done.
+ void SetSpecifier(SymbolContextSpecifier *specifier);
+
+ SymbolContextSpecifier *GetSpecifier() { return m_specifier_sp.get(); }
+
+ // Set the Thread Specifier. The stop hook will own the thread specifier,
+ // and is responsible for deleting it when we're done.
+ void SetThreadSpecifier(ThreadSpec *specifier);
+
+ ThreadSpec *GetThreadSpecifier() { return m_thread_spec_ap.get(); }
+
+ bool IsActive() { return m_active; }
+
+ void SetIsActive(bool is_active) { m_active = is_active; }
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) const;
+
+ private:
+ lldb::TargetSP m_target_sp;
+ StringList m_commands;
+ lldb::SymbolContextSpecifierSP m_specifier_sp;
+ std::unique_ptr<ThreadSpec> m_thread_spec_ap;
+ bool m_active;
+
+ // Use CreateStopHook to make a new empty stop hook. The GetCommandPointer
+ // and fill it with commands,
+ // and SetSpecifier to set the specifier shared pointer (can be null, that
+ // will match anything.)
+ StopHook(lldb::TargetSP target_sp, lldb::user_id_t uid);
+ friend class Target;
+ };
+ typedef std::shared_ptr<StopHook> StopHookSP;
+
+ // Add an empty stop hook to the Target's stop hook list, and returns a shared
+ // pointer to it in new_hook.
+ // Returns the id of the new hook.
+ StopHookSP CreateStopHook();
+
+ void RunStopHooks();
+
+ size_t GetStopHookSize();
+
+ bool SetSuppresStopHooks(bool suppress) {
+ bool old_value = m_suppress_stop_hooks;
+ m_suppress_stop_hooks = suppress;
+ return old_value;
+ }
+
+ bool GetSuppressStopHooks() { return m_suppress_stop_hooks; }
+
+ // StopHookSP &
+ // GetStopHookByIndex (size_t index);
+ //
+ bool RemoveStopHookByID(lldb::user_id_t uid);
+
+ void RemoveAllStopHooks();
+
+ StopHookSP GetStopHookByID(lldb::user_id_t uid);
+
+ bool SetStopHookActiveStateByID(lldb::user_id_t uid, bool active_state);
+
+ void SetAllStopHooksActiveState(bool active_state);
+
+ size_t GetNumStopHooks() const { return m_stop_hooks.size(); }
+
+ StopHookSP GetStopHookAtIndex(size_t index) {
+ if (index >= GetNumStopHooks())
+ return StopHookSP();
+ StopHookCollection::iterator pos = m_stop_hooks.begin();
+
+ while (index > 0) {
+ pos++;
+ index--;
}
+ return (*pos).second;
+ }
+
+ lldb::PlatformSP GetPlatform() { return m_platform_sp; }
+
+ void SetPlatform(const lldb::PlatformSP &platform_sp) {
+ m_platform_sp = platform_sp;
+ }
+
+ SourceManager &GetSourceManager();
+
+ ClangModulesDeclVendor *GetClangModulesDeclVendor();
+
+ //------------------------------------------------------------------
+ // Methods.
+ //------------------------------------------------------------------
+ lldb::SearchFilterSP
+ GetSearchFilterForModule(const FileSpec *containingModule);
+
+ lldb::SearchFilterSP
+ GetSearchFilterForModuleList(const FileSpecList *containingModuleList);
+
+ lldb::SearchFilterSP
+ GetSearchFilterForModuleAndCUList(const FileSpecList *containingModules,
+ const FileSpecList *containingSourceFiles);
+
+ lldb::REPLSP GetREPL(Error &err, lldb::LanguageType language,
+ const char *repl_options, bool can_create);
- SourceManager &
- GetSourceManager ();
-
- ClangModulesDeclVendor *
- GetClangModulesDeclVendor ();
-
- //------------------------------------------------------------------
- // Methods.
- //------------------------------------------------------------------
- lldb::SearchFilterSP
- GetSearchFilterForModule (const FileSpec *containingModule);
-
- lldb::SearchFilterSP
- GetSearchFilterForModuleList (const FileSpecList *containingModuleList);
-
- lldb::SearchFilterSP
- GetSearchFilterForModuleAndCUList (const FileSpecList *containingModules, const FileSpecList *containingSourceFiles);
-
- lldb::REPLSP
- GetREPL (Error &err, lldb::LanguageType language, const char *repl_options, bool can_create);
-
- void
- SetREPL (lldb::LanguageType language, lldb::REPLSP repl_sp);
+ void SetREPL(lldb::LanguageType language, lldb::REPLSP repl_sp);
protected:
- //------------------------------------------------------------------
- /// Implementing of ModuleList::Notifier.
- //------------------------------------------------------------------
-
- void
- ModuleAdded(const ModuleList& module_list, const lldb::ModuleSP& module_sp) override;
-
- void
- ModuleRemoved(const ModuleList& module_list, const lldb::ModuleSP& module_sp) override;
-
- void
- ModuleUpdated(const ModuleList& module_list,
- const lldb::ModuleSP& old_module_sp,
- const lldb::ModuleSP& new_module_sp) override;
- void
- WillClearList(const ModuleList& module_list) override;
-
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- Debugger & m_debugger;
- lldb::PlatformSP m_platform_sp; ///< The platform for this target.
- std::recursive_mutex
- m_mutex; ///< An API mutex that is used by the lldb::SB* classes make the SB interface thread safe
- ArchSpec m_arch;
- ModuleList m_images; ///< The list of images for this process (shared libraries and anything dynamically loaded).
- SectionLoadHistory m_section_load_history;
- BreakpointList m_breakpoint_list;
- BreakpointList m_internal_breakpoint_list;
- lldb::BreakpointSP m_last_created_breakpoint;
- WatchpointList m_watchpoint_list;
- lldb::WatchpointSP m_last_created_watchpoint;
- // We want to tightly control the process destruction process so
- // we can correctly tear down everything that we need to, so the only
- // class that knows about the process lifespan is this target class.
- lldb::ProcessSP m_process_sp;
- lldb::SearchFilterSP m_search_filter_sp;
- PathMappingList m_image_search_paths;
- TypeSystemMap m_scratch_type_system_map;
-
- typedef std::map<lldb::LanguageType, lldb::REPLSP> REPLMap;
- REPLMap m_repl_map;
-
- lldb::ClangASTImporterSP m_ast_importer_sp;
- lldb::ClangModulesDeclVendorUP m_clang_modules_decl_vendor_ap;
-
- lldb::SourceManagerUP m_source_manager_ap;
-
- typedef std::map<lldb::user_id_t, StopHookSP> StopHookCollection;
- StopHookCollection m_stop_hooks;
- lldb::user_id_t m_stop_hook_next_id;
- bool m_valid;
- bool m_suppress_stop_hooks;
- bool m_is_dummy_target;
-
- static void
- ImageSearchPathsChanged (const PathMappingList &path_list,
- void *baton);
+ //------------------------------------------------------------------
+ /// Implementing of ModuleList::Notifier.
+ //------------------------------------------------------------------
+
+ void ModuleAdded(const ModuleList &module_list,
+ const lldb::ModuleSP &module_sp) override;
+
+ void ModuleRemoved(const ModuleList &module_list,
+ const lldb::ModuleSP &module_sp) override;
+
+ void ModuleUpdated(const ModuleList &module_list,
+ const lldb::ModuleSP &old_module_sp,
+ const lldb::ModuleSP &new_module_sp) override;
+ void WillClearList(const ModuleList &module_list) override;
+
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ Debugger &m_debugger;
+ lldb::PlatformSP m_platform_sp; ///< The platform for this target.
+ std::recursive_mutex m_mutex; ///< An API mutex that is used by the lldb::SB*
+ /// classes make the SB interface thread safe
+ ArchSpec m_arch;
+ ModuleList m_images; ///< The list of images for this process (shared
+ /// libraries and anything dynamically loaded).
+ SectionLoadHistory m_section_load_history;
+ BreakpointList m_breakpoint_list;
+ BreakpointList m_internal_breakpoint_list;
+ lldb::BreakpointSP m_last_created_breakpoint;
+ WatchpointList m_watchpoint_list;
+ lldb::WatchpointSP m_last_created_watchpoint;
+ // We want to tightly control the process destruction process so
+ // we can correctly tear down everything that we need to, so the only
+ // class that knows about the process lifespan is this target class.
+ lldb::ProcessSP m_process_sp;
+ lldb::SearchFilterSP m_search_filter_sp;
+ PathMappingList m_image_search_paths;
+ TypeSystemMap m_scratch_type_system_map;
+
+ typedef std::map<lldb::LanguageType, lldb::REPLSP> REPLMap;
+ REPLMap m_repl_map;
+
+ lldb::ClangASTImporterSP m_ast_importer_sp;
+ lldb::ClangModulesDeclVendorUP m_clang_modules_decl_vendor_ap;
+
+ lldb::SourceManagerUP m_source_manager_ap;
+
+ typedef std::map<lldb::user_id_t, StopHookSP> StopHookCollection;
+ StopHookCollection m_stop_hooks;
+ lldb::user_id_t m_stop_hook_next_id;
+ bool m_valid;
+ bool m_suppress_stop_hooks;
+ bool m_is_dummy_target;
+
+ static void ImageSearchPathsChanged(const PathMappingList &path_list,
+ void *baton);
private:
- //------------------------------------------------------------------
- /// Construct with optional file and arch.
- ///
- /// This member is private. Clients must use
- /// TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
- /// so all targets can be tracked from the central target list.
- ///
- /// @see TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
- //------------------------------------------------------------------
- Target (Debugger &debugger,
- const ArchSpec &target_arch,
- const lldb::PlatformSP &platform_sp,
- bool is_dummy_target);
-
- // Helper function.
- bool
- ProcessIsValid ();
-
- // Copy breakpoints, stop hooks and so forth from the dummy target:
- void
- PrimeFromDummyTarget(Target *dummy_target);
-
- void
- AddBreakpoint(lldb::BreakpointSP breakpoint_sp, bool internal);
-
- DISALLOW_COPY_AND_ASSIGN (Target);
+ //------------------------------------------------------------------
+ /// Construct with optional file and arch.
+ ///
+ /// This member is private. Clients must use
+ /// TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
+ /// so all targets can be tracked from the central target list.
+ ///
+ /// @see TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
+ //------------------------------------------------------------------
+ Target(Debugger &debugger, const ArchSpec &target_arch,
+ const lldb::PlatformSP &platform_sp, bool is_dummy_target);
+
+ // Helper function.
+ bool ProcessIsValid();
+
+ // Copy breakpoints, stop hooks and so forth from the dummy target:
+ void PrimeFromDummyTarget(Target *dummy_target);
+
+ void AddBreakpoint(lldb::BreakpointSP breakpoint_sp, bool internal);
+
+ DISALLOW_COPY_AND_ASSIGN(Target);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/TargetList.h b/include/lldb/Target/TargetList.h
index d96d2f1b0e7a..81b81dba7757 100644
--- a/include/lldb/Target/TargetList.h
+++ b/include/lldb/Target/TargetList.h
@@ -22,244 +22,211 @@
namespace lldb_private {
-class TargetList : public Broadcaster
-{
+class TargetList : public Broadcaster {
private:
- friend class Debugger;
-
- //------------------------------------------------------------------
- /// Constructor
- ///
- /// The constructor for the target list is private. Clients can
- /// get ahold of of the one and only target list through the
- /// lldb_private::Debugger::GetSharedInstance().GetTargetList().
- ///
- /// @see static TargetList& lldb_private::Debugger::GetTargetList().
- //------------------------------------------------------------------
- TargetList(Debugger &debugger);
+ friend class Debugger;
+
+ //------------------------------------------------------------------
+ /// Constructor
+ ///
+ /// The constructor for the target list is private. Clients can
+ /// get ahold of of the one and only target list through the
+ /// lldb_private::Debugger::GetSharedInstance().GetTargetList().
+ ///
+ /// @see static TargetList& lldb_private::Debugger::GetTargetList().
+ //------------------------------------------------------------------
+ TargetList(Debugger &debugger);
public:
- //------------------------------------------------------------------
- /// Broadcaster event bits definitions.
- //------------------------------------------------------------------
- enum
- {
- eBroadcastBitInterrupt = (1 << 0)
- };
-
-
- // These two functions fill out the Broadcaster interface:
-
- static ConstString &GetStaticBroadcasterClass ();
-
- ConstString &GetBroadcasterClass() const override
- {
- return GetStaticBroadcasterClass();
- }
-
- ~TargetList() override;
-
- //------------------------------------------------------------------
- /// Create a new Target.
- ///
- /// Clients must use this function to create a Target. This allows
- /// a global list of targets to be maintained in a central location
- /// so signal handlers and other global functions can use it to
- /// locate an appropriate target to deliver asynchronous information
- /// to.
- ///
- /// @param[in] debugger
- /// The debugger to associate this target with
- ///
- /// @param[in] file_spec
- /// The main executable file for a debug target. This value
- /// can be nullptr and the file can be set later using:
- /// Target::SetExecutableModule (ModuleSP&)
- ///
- /// @param[in] triple_cstr
- /// A target triple string to be used for the target. This can
- /// be nullptr if the triple is not known or when attaching to a
- /// process.
- ///
- /// @param[in] get_dependent_modules
- /// Track down the dependent modules for an executable and
- /// load those into the module list.
- ///
- /// @param[in] platform_options
- /// A pointer to the platform options to use when creating this
- /// target. If this value is nullptr, then the currently selected
- /// platform will be used.
- ///
- /// @param[out] target_sp
- /// A shared pointer to a target that will be filled in if
- /// this call is successful.
- ///
- /// @return
- /// An error object that indicates success or failure
- //------------------------------------------------------------------
- Error
- CreateTarget (Debugger &debugger,
- const char *user_exe_path,
- const char *triple_cstr,
- bool get_dependent_modules,
- const OptionGroupPlatform *platform_options,
- lldb::TargetSP &target_sp);
-
- //------------------------------------------------------------------
- /// Create a new Target.
- ///
- /// Same as the function above, but used when you already know the
- /// platform you will be using
- //------------------------------------------------------------------
- Error
- CreateTarget (Debugger &debugger,
- const char *user_exe_path,
- const ArchSpec& arch,
- bool get_dependent_modules,
- lldb::PlatformSP &platform_sp,
- lldb::TargetSP &target_sp);
-
- //------------------------------------------------------------------
- /// Delete a Target object from the list.
- ///
- /// When clients are done with the Target objects, this function
- /// should be called to release the memory associated with a target
- /// object.
- ///
- /// @param[in] target_sp
- /// The shared pointer to a target.
- ///
- /// @return
- /// Returns \b true if the target was successfully removed from
- /// from this target list, \b false otherwise. The client will
- /// be left with the last remaining shared pointer to the target
- /// in \a target_sp which can then be properly released.
- //------------------------------------------------------------------
- bool
- DeleteTarget (lldb::TargetSP &target_sp);
-
- int
- GetNumTargets () const;
-
- lldb::TargetSP
- GetTargetAtIndex (uint32_t index) const;
-
- uint32_t
- GetIndexOfTarget (lldb::TargetSP target_sp) const;
-
- //------------------------------------------------------------------
- /// Find the target that contains has an executable whose path
- /// matches \a exe_file_spec, and whose architecture matches
- /// \a arch_ptr if arch_ptr is not nullptr.
- ///
- /// @param[in] exe_file_spec
- /// A file spec containing a basename, or a full path (directory
- /// and basename). If \a exe_file_spec contains only a filename
- /// (empty GetDirectory() value) then matching will be done
- /// solely based on the filenames and directories won't be
- /// compared. If \a exe_file_spec contains a filename and a
- /// directory, then both must match.
- ///
- /// @param[in] exe_arch_ptr
- /// If not nullptr then the architecture also needs to match, else
- /// the architectures will be compared.
- ///
- /// @return
- /// A shared pointer to a target object. The returned shared
- /// pointer will contain nullptr if no target objects have a
- /// executable whose full or partial path matches
- /// with a matching process ID.
- //------------------------------------------------------------------
- lldb::TargetSP
- FindTargetWithExecutableAndArchitecture(const FileSpec &exe_file_spec,
- const ArchSpec *exe_arch_ptr = nullptr) const;
-
- //------------------------------------------------------------------
- /// Find the target that contains a process with process ID \a
- /// pid.
- ///
- /// @param[in] pid
- /// The process ID to search our target list for.
- ///
- /// @return
- /// A shared pointer to a target object. The returned shared
- /// pointer will contain nullptr if no target objects own a process
- /// with a matching process ID.
- //------------------------------------------------------------------
- lldb::TargetSP
- FindTargetWithProcessID (lldb::pid_t pid) const;
-
- lldb::TargetSP
- FindTargetWithProcess (lldb_private::Process *process) const;
-
- lldb::TargetSP
- GetTargetSP (Target *target) const;
-
- //------------------------------------------------------------------
- /// Send an async interrupt to one or all processes.
- ///
- /// Find the target that contains the process with process ID \a
- /// pid and send a LLDB_EVENT_ASYNC_INTERRUPT event to the process's
- /// event queue.
- ///
- /// @param[in] pid
- /// The process ID to search our target list for, if \a pid is
- /// LLDB_INVALID_PROCESS_ID, then the interrupt will be sent to
- /// all processes.
- ///
- /// @return
- /// The number of async interrupts sent.
- //------------------------------------------------------------------
- uint32_t
- SendAsyncInterrupt (lldb::pid_t pid = LLDB_INVALID_PROCESS_ID);
-
- uint32_t
- SignalIfRunning (lldb::pid_t pid, int signo);
-
- uint32_t
- SetSelectedTarget (Target *target);
-
- lldb::TargetSP
- GetSelectedTarget ();
+ //------------------------------------------------------------------
+ /// Broadcaster event bits definitions.
+ //------------------------------------------------------------------
+ enum { eBroadcastBitInterrupt = (1 << 0) };
+
+ // These two functions fill out the Broadcaster interface:
+
+ static ConstString &GetStaticBroadcasterClass();
+
+ ConstString &GetBroadcasterClass() const override {
+ return GetStaticBroadcasterClass();
+ }
+
+ ~TargetList() override;
+
+ //------------------------------------------------------------------
+ /// Create a new Target.
+ ///
+ /// Clients must use this function to create a Target. This allows
+ /// a global list of targets to be maintained in a central location
+ /// so signal handlers and other global functions can use it to
+ /// locate an appropriate target to deliver asynchronous information
+ /// to.
+ ///
+ /// @param[in] debugger
+ /// The debugger to associate this target with
+ ///
+ /// @param[in] file_spec
+ /// The main executable file for a debug target. This value
+ /// can be nullptr and the file can be set later using:
+ /// Target::SetExecutableModule (ModuleSP&)
+ ///
+ /// @param[in] triple_cstr
+ /// A target triple string to be used for the target. This can
+ /// be nullptr if the triple is not known or when attaching to a
+ /// process.
+ ///
+ /// @param[in] get_dependent_modules
+ /// Track down the dependent modules for an executable and
+ /// load those into the module list.
+ ///
+ /// @param[in] platform_options
+ /// A pointer to the platform options to use when creating this
+ /// target. If this value is nullptr, then the currently selected
+ /// platform will be used.
+ ///
+ /// @param[out] target_sp
+ /// A shared pointer to a target that will be filled in if
+ /// this call is successful.
+ ///
+ /// @return
+ /// An error object that indicates success or failure
+ //------------------------------------------------------------------
+ Error CreateTarget(Debugger &debugger, llvm::StringRef user_exe_path,
+ llvm::StringRef triple_str, bool get_dependent_modules,
+ const OptionGroupPlatform *platform_options,
+ lldb::TargetSP &target_sp);
+
+ //------------------------------------------------------------------
+ /// Create a new Target.
+ ///
+ /// Same as the function above, but used when you already know the
+ /// platform you will be using
+ //------------------------------------------------------------------
+ Error CreateTarget(Debugger &debugger, llvm::StringRef user_exe_path,
+ const ArchSpec &arch, bool get_dependent_modules,
+ lldb::PlatformSP &platform_sp, lldb::TargetSP &target_sp);
+
+ //------------------------------------------------------------------
+ /// Delete a Target object from the list.
+ ///
+ /// When clients are done with the Target objects, this function
+ /// should be called to release the memory associated with a target
+ /// object.
+ ///
+ /// @param[in] target_sp
+ /// The shared pointer to a target.
+ ///
+ /// @return
+ /// Returns \b true if the target was successfully removed from
+ /// from this target list, \b false otherwise. The client will
+ /// be left with the last remaining shared pointer to the target
+ /// in \a target_sp which can then be properly released.
+ //------------------------------------------------------------------
+ bool DeleteTarget(lldb::TargetSP &target_sp);
+
+ int GetNumTargets() const;
+
+ lldb::TargetSP GetTargetAtIndex(uint32_t index) const;
+
+ uint32_t GetIndexOfTarget(lldb::TargetSP target_sp) const;
+
+ //------------------------------------------------------------------
+ /// Find the target that contains has an executable whose path
+ /// matches \a exe_file_spec, and whose architecture matches
+ /// \a arch_ptr if arch_ptr is not nullptr.
+ ///
+ /// @param[in] exe_file_spec
+ /// A file spec containing a basename, or a full path (directory
+ /// and basename). If \a exe_file_spec contains only a filename
+ /// (empty GetDirectory() value) then matching will be done
+ /// solely based on the filenames and directories won't be
+ /// compared. If \a exe_file_spec contains a filename and a
+ /// directory, then both must match.
+ ///
+ /// @param[in] exe_arch_ptr
+ /// If not nullptr then the architecture also needs to match, else
+ /// the architectures will be compared.
+ ///
+ /// @return
+ /// A shared pointer to a target object. The returned shared
+ /// pointer will contain nullptr if no target objects have a
+ /// executable whose full or partial path matches
+ /// with a matching process ID.
+ //------------------------------------------------------------------
+ lldb::TargetSP FindTargetWithExecutableAndArchitecture(
+ const FileSpec &exe_file_spec,
+ const ArchSpec *exe_arch_ptr = nullptr) const;
+
+ //------------------------------------------------------------------
+ /// Find the target that contains a process with process ID \a
+ /// pid.
+ ///
+ /// @param[in] pid
+ /// The process ID to search our target list for.
+ ///
+ /// @return
+ /// A shared pointer to a target object. The returned shared
+ /// pointer will contain nullptr if no target objects own a process
+ /// with a matching process ID.
+ //------------------------------------------------------------------
+ lldb::TargetSP FindTargetWithProcessID(lldb::pid_t pid) const;
+
+ lldb::TargetSP FindTargetWithProcess(lldb_private::Process *process) const;
+
+ lldb::TargetSP GetTargetSP(Target *target) const;
+
+ //------------------------------------------------------------------
+ /// Send an async interrupt to one or all processes.
+ ///
+ /// Find the target that contains the process with process ID \a
+ /// pid and send a LLDB_EVENT_ASYNC_INTERRUPT event to the process's
+ /// event queue.
+ ///
+ /// @param[in] pid
+ /// The process ID to search our target list for, if \a pid is
+ /// LLDB_INVALID_PROCESS_ID, then the interrupt will be sent to
+ /// all processes.
+ ///
+ /// @return
+ /// The number of async interrupts sent.
+ //------------------------------------------------------------------
+ uint32_t SendAsyncInterrupt(lldb::pid_t pid = LLDB_INVALID_PROCESS_ID);
+
+ uint32_t SignalIfRunning(lldb::pid_t pid, int signo);
+
+ uint32_t SetSelectedTarget(Target *target);
+
+ lldb::TargetSP GetSelectedTarget();
protected:
- typedef std::vector<lldb::TargetSP> collection;
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- collection m_target_list;
- lldb::TargetSP m_dummy_target_sp;
- mutable std::recursive_mutex m_target_list_mutex;
- uint32_t m_selected_target_idx;
+ typedef std::vector<lldb::TargetSP> collection;
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ collection m_target_list;
+ lldb::TargetSP m_dummy_target_sp;
+ mutable std::recursive_mutex m_target_list_mutex;
+ uint32_t m_selected_target_idx;
private:
- lldb::TargetSP
- GetDummyTarget (lldb_private::Debugger &debugger);
-
- Error
- CreateDummyTarget (Debugger &debugger,
- const char *specified_arch_name,
- lldb::TargetSP &target_sp);
-
- Error
- CreateTargetInternal (Debugger &debugger,
- const char *user_exe_path,
- const char *triple_cstr,
- bool get_dependent_files,
- const OptionGroupPlatform *platform_options,
- lldb::TargetSP &target_sp,
- bool is_dummy_target);
-
- Error
- CreateTargetInternal (Debugger &debugger,
- const char *user_exe_path,
- const ArchSpec& arch,
- bool get_dependent_modules,
- lldb::PlatformSP &platform_sp,
- lldb::TargetSP &target_sp,
- bool is_dummy_target);
-
- DISALLOW_COPY_AND_ASSIGN (TargetList);
+ lldb::TargetSP GetDummyTarget(lldb_private::Debugger &debugger);
+
+ Error CreateDummyTarget(Debugger &debugger,
+ llvm::StringRef specified_arch_name,
+ lldb::TargetSP &target_sp);
+
+ Error CreateTargetInternal(Debugger &debugger, llvm::StringRef user_exe_path,
+ llvm::StringRef triple_str,
+ bool get_dependent_files,
+ const OptionGroupPlatform *platform_options,
+ lldb::TargetSP &target_sp, bool is_dummy_target);
+
+ Error CreateTargetInternal(Debugger &debugger, llvm::StringRef user_exe_path,
+ const ArchSpec &arch, bool get_dependent_modules,
+ lldb::PlatformSP &platform_sp,
+ lldb::TargetSP &target_sp, bool is_dummy_target);
+
+ DISALLOW_COPY_AND_ASSIGN(TargetList);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/Thread.h b/include/lldb/Target/Thread.h
index f3cf97325e16..63449bbf930e 100644
--- a/include/lldb/Target/Thread.h
+++ b/include/lldb/Target/Thread.h
@@ -19,7 +19,6 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Event.h"
#include "lldb/Core/StructuredData.h"
@@ -28,1452 +27,1324 @@
#include "lldb/Target/ExecutionContextScope.h"
#include "lldb/Target/RegisterCheckpoint.h"
#include "lldb/Target/StackFrameList.h"
+#include "lldb/lldb-private.h"
#define LLDB_THREAD_MAX_STOP_EXC_DATA 8
namespace lldb_private {
-class ThreadProperties : public Properties
-{
+class ThreadProperties : public Properties {
public:
- ThreadProperties(bool is_global);
-
- ~ThreadProperties() override;
-
- //------------------------------------------------------------------
- /// The regular expression returned determines symbols that this
- /// thread won't stop in during "step-in" operations.
- ///
- /// @return
- /// A pointer to a regular expression to compare against symbols,
- /// or nullptr if all symbols are allowed.
- ///
- //------------------------------------------------------------------
- const RegularExpression *
- GetSymbolsToAvoidRegexp();
-
- FileSpecList &
- GetLibrariesToAvoid() const;
-
- bool
- GetTraceEnabledState() const;
-
- bool
- GetStepInAvoidsNoDebug () const;
-
- bool
- GetStepOutAvoidsNoDebug () const;
-};
-
-typedef std::shared_ptr<ThreadProperties> ThreadPropertiesSP;
-
-class Thread :
- public std::enable_shared_from_this<Thread>,
- public ThreadProperties,
- public UserID,
- public ExecutionContextScope,
- public Broadcaster
-{
-public:
- //------------------------------------------------------------------
- /// Broadcaster event bits definitions.
- //------------------------------------------------------------------
- enum
- {
- eBroadcastBitStackChanged = (1 << 0),
- eBroadcastBitThreadSuspended = (1 << 1),
- eBroadcastBitThreadResumed = (1 << 2),
- eBroadcastBitSelectedFrameChanged = (1 << 3),
- eBroadcastBitThreadSelected = (1 << 4)
- };
-
- static ConstString &GetStaticBroadcasterClass ();
-
- ConstString &GetBroadcasterClass() const override
- {
- return GetStaticBroadcasterClass();
- }
-
- class ThreadEventData :
- public EventData
- {
- public:
- ThreadEventData (const lldb::ThreadSP thread_sp);
-
- ThreadEventData (const lldb::ThreadSP thread_sp, const StackID &stack_id);
-
- ThreadEventData();
-
- ~ThreadEventData() override;
-
- static const ConstString &
- GetFlavorString ();
-
- const ConstString &
- GetFlavor() const override
- {
- return ThreadEventData::GetFlavorString ();
- }
-
- void
- Dump(Stream *s) const override;
-
- static const ThreadEventData *
- GetEventDataFromEvent (const Event *event_ptr);
-
- static lldb::ThreadSP
- GetThreadFromEvent (const Event *event_ptr);
-
- static StackID
- GetStackIDFromEvent (const Event *event_ptr);
-
- static lldb::StackFrameSP
- GetStackFrameFromEvent (const Event *event_ptr);
-
- lldb::ThreadSP
- GetThread () const
- {
- return m_thread_sp;
- }
-
- StackID
- GetStackID () const
- {
- return m_stack_id;
- }
-
- private:
- lldb::ThreadSP m_thread_sp;
- StackID m_stack_id;
-
- DISALLOW_COPY_AND_ASSIGN (ThreadEventData);
- };
-
- struct ThreadStateCheckpoint
- {
- uint32_t orig_stop_id; // Dunno if I need this yet but it is an interesting bit of data.
- lldb::StopInfoSP stop_info_sp; // You have to restore the stop info or you might continue with the wrong signals.
- lldb::RegisterCheckpointSP register_backup_sp; // You need to restore the registers, of course...
- uint32_t current_inlined_depth;
- lldb::addr_t current_inlined_pc;
- };
-
- //------------------------------------------------------------------
- /// Constructor
- ///
- /// @param [in] process
- ///
- /// @param [in] tid
- ///
- /// @param [in] use_invalid_index_id
- /// Optional parameter, defaults to false. The only subclass that
- /// is likely to set use_invalid_index_id == true is the HistoryThread
- /// class. In that case, the Thread we are constructing represents
- /// a thread from earlier in the program execution. We may have the
- /// tid of the original thread that they represent but we don't want
- /// to reuse the IndexID of that thread, or create a new one. If a
- /// client wants to know the original thread's IndexID, they should use
- /// Thread::GetExtendedBacktraceOriginatingIndexID().
- //------------------------------------------------------------------
- Thread (Process &process, lldb::tid_t tid, bool use_invalid_index_id = false);
-
- ~Thread() override;
-
- static void
- SettingsInitialize ();
-
- static void
- SettingsTerminate ();
-
- static const ThreadPropertiesSP &
- GetGlobalProperties();
-
- lldb::ProcessSP
- GetProcess() const
- {
- return m_process_wp.lock();
- }
-
- int
- GetResumeSignal () const
- {
- return m_resume_signal;
- }
-
- void
- SetResumeSignal (int signal)
- {
- m_resume_signal = signal;
- }
-
- lldb::StateType
- GetState() const;
-
- void
- SetState (lldb::StateType state);
-
- //------------------------------------------------------------------
- /// Sets the USER resume state for this thread. If you set a thread to suspended with
- /// this API, it won't take part in any of the arbitration for ShouldResume, and will stay
- /// suspended even when other threads do get to run.
- ///
- /// N.B. This is not the state that is used internally by thread plans to implement
- /// staying on one thread while stepping over a breakpoint, etc. The is the
- /// TemporaryResume state, and if you are implementing some bit of strategy in the stepping
- /// machinery you should be using that state and not the user resume state.
- ///
- /// If you are just preparing all threads to run, you should not override the threads that are
- /// marked as suspended by the debugger. In that case, pass override_suspend = false. If you want
- /// to force the thread to run (e.g. the "thread continue" command, or are resetting the state
- /// (e.g. in SBThread::Resume()), then pass true to override_suspend.
- /// @return
- /// The User resume state for this thread.
- //------------------------------------------------------------------
- void
- SetResumeState (lldb::StateType state, bool override_suspend = false)
- {
- if (m_resume_state == lldb::eStateSuspended && !override_suspend)
- return;
- m_resume_state = state;
- }
-
- //------------------------------------------------------------------
- /// Gets the USER resume state for this thread. This is not the same as what
- /// this thread is going to do for any particular step, however if this thread
- /// returns eStateSuspended, then the process control logic will never allow this
- /// thread to run.
- ///
- /// @return
- /// The User resume state for this thread.
- //------------------------------------------------------------------
- lldb::StateType
- GetResumeState () const
- {
- return m_resume_state;
- }
-
- // This function is called on all the threads before "ShouldResume" and
- // "WillResume" in case a thread needs to change its state before the
- // ThreadList polls all the threads to figure out which ones actually
- // will get to run and how.
- void
- SetupForResume ();
-
- // Do not override this function, it is for thread plan logic only
- bool
- ShouldResume (lldb::StateType resume_state);
-
- // Override this to do platform specific tasks before resume.
- virtual void
- WillResume (lldb::StateType resume_state)
- {
- }
-
- // This clears generic thread state after a resume. If you subclass this,
- // be sure to call it.
- virtual void
- DidResume ();
-
- // This notifies the thread when a private stop occurs.
- virtual void
- DidStop ();
-
- virtual void
- RefreshStateAfterStop() = 0;
-
- void
- WillStop ();
-
- bool
- ShouldStop (Event *event_ptr);
-
- Vote
- ShouldReportStop (Event *event_ptr);
-
- Vote
- ShouldReportRun (Event *event_ptr);
-
- void
- Flush ();
-
- // Return whether this thread matches the specification in ThreadSpec. This is a virtual
- // method because at some point we may extend the thread spec with a platform specific
- // dictionary of attributes, which then only the platform specific Thread implementation
- // would know how to match. For now, this just calls through to the ThreadSpec's
- // ThreadPassesBasicTests method.
- virtual bool
- MatchesSpec (const ThreadSpec *spec);
-
- lldb::StopInfoSP
- GetStopInfo ();
-
- lldb::StopReason
- GetStopReason();
-
- bool
- StopInfoIsUpToDate() const;
-
- // This sets the stop reason to a "blank" stop reason, so you can call functions on the thread
- // without having the called function run with whatever stop reason you stopped with.
- void
- SetStopInfoToNothing();
-
- bool
- ThreadStoppedForAReason ();
-
- static const char *
- RunModeAsCString (lldb::RunMode mode);
-
- static const char *
- StopReasonAsCString (lldb::StopReason reason);
-
- virtual const char *
- GetInfo ()
- {
- return nullptr;
- }
-
- //------------------------------------------------------------------
- /// Retrieve a dictionary of information about this thread
- ///
- /// On Mac OS X systems there may be voucher information.
- /// The top level dictionary returned will have an "activity" key and the
- /// value of the activity is a dictionary. Keys in that dictionary will
- /// be "name" and "id", among others.
- /// There may also be "trace_messages" (an array) with each entry in that array
- /// being a dictionary (keys include "message" with the text of the trace
- /// message).
- //------------------------------------------------------------------
- StructuredData::ObjectSP
- GetExtendedInfo ()
- {
- if (m_extended_info_fetched == false)
- {
- m_extended_info = FetchThreadExtendedInfo ();
- m_extended_info_fetched = true;
- }
- return m_extended_info;
- }
-
- virtual const char *
- GetName ()
- {
- return nullptr;
- }
-
- virtual void
- SetName (const char *name)
- {
- }
-
- //------------------------------------------------------------------
- /// Whether this thread can be associated with a libdispatch queue
- ///
- /// The Thread may know if it is associated with a libdispatch queue,
- /// it may know definitively that it is NOT associated with a libdispatch
- /// queue, or it may be unknown whether it is associated with a libdispatch
- /// queue.
- ///
- /// @return
- /// eLazyBoolNo if this thread is definitely not associated with a
- /// libdispatch queue (e.g. on a non-Darwin system where GCD aka
- /// libdispatch is not available).
- ///
- /// eLazyBoolYes this thread is associated with a libdispatch queue.
- ///
- /// eLazyBoolCalculate this thread may be associated with a libdispatch
- /// queue but the thread doesn't know one way or the other.
- //------------------------------------------------------------------
- virtual lldb_private::LazyBool
- GetAssociatedWithLibdispatchQueue ()
- {
- return eLazyBoolNo;
- }
-
- virtual void
- SetAssociatedWithLibdispatchQueue (lldb_private::LazyBool associated_with_libdispatch_queue)
- {
- }
-
- //------------------------------------------------------------------
- /// Retrieve the Queue ID for the queue currently using this Thread
- ///
- /// If this Thread is doing work on behalf of a libdispatch/GCD queue,
- /// retrieve the QueueID.
- ///
- /// This is a unique identifier for the libdispatch/GCD queue in a
- /// process. Often starting at 1 for the initial system-created
- /// queues and incrementing, a QueueID will not be reused for a
- /// different queue during the lifetime of a proces.
- ///
- /// @return
- /// A QueueID if the Thread subclass implements this, else
- /// LLDB_INVALID_QUEUE_ID.
- //------------------------------------------------------------------
- virtual lldb::queue_id_t
- GetQueueID ()
- {
- return LLDB_INVALID_QUEUE_ID;
- }
-
- virtual void
- SetQueueID (lldb::queue_id_t new_val)
- {
- }
-
- //------------------------------------------------------------------
- /// Retrieve the Queue name for the queue currently using this Thread
- ///
- /// If this Thread is doing work on behalf of a libdispatch/GCD queue,
- /// retrieve the Queue name.
- ///
- /// @return
- /// The Queue name, if the Thread subclass implements this, else
- /// nullptr.
- //------------------------------------------------------------------
- virtual const char *
- GetQueueName ()
- {
- return nullptr;
- }
+ ThreadProperties(bool is_global);
- virtual void
- SetQueueName (const char *name)
- {
- }
-
- //------------------------------------------------------------------
- /// Retrieve the Queue kind for the queue currently using this Thread
- ///
- /// If this Thread is doing work on behalf of a libdispatch/GCD queue,
- /// retrieve the Queue kind - either eQueueKindSerial or
- /// eQueueKindConcurrent, indicating that this queue processes work
- /// items serially or concurrently.
- ///
- /// @return
- /// The Queue kind, if the Thread subclass implements this, else
- /// eQueueKindUnknown.
- //------------------------------------------------------------------
- virtual lldb::QueueKind
- GetQueueKind ()
- {
- return lldb::eQueueKindUnknown;
- }
-
- virtual void
- SetQueueKind (lldb::QueueKind kind)
- {
- }
-
- //------------------------------------------------------------------
- /// Retrieve the Queue for this thread, if any.
- ///
- /// @return
- /// A QueueSP for the queue that is currently associated with this
- /// thread.
- /// An empty shared pointer indicates that this thread is not
- /// associated with a queue, or libdispatch queues are not
- /// supported on this target.
- //------------------------------------------------------------------
- virtual lldb::QueueSP
- GetQueue ()
- {
- return lldb::QueueSP();
- }
-
- //------------------------------------------------------------------
- /// Retrieve the address of the libdispatch_queue_t struct for queue
- /// currently using this Thread
- ///
- /// If this Thread is doing work on behalf of a libdispatch/GCD queue,
- /// retrieve the address of the libdispatch_queue_t structure describing
- /// the queue.
- ///
- /// This address may be reused for different queues later in the Process
- /// lifetime and should not be used to identify a queue uniquely. Use
- /// the GetQueueID() call for that.
- ///
- /// @return
- /// The Queue's libdispatch_queue_t address if the Thread subclass
- /// implements this, else LLDB_INVALID_ADDRESS.
- //------------------------------------------------------------------
- virtual lldb::addr_t
- GetQueueLibdispatchQueueAddress ()
- {
- return LLDB_INVALID_ADDRESS;
- }
+ ~ThreadProperties() override;
- virtual void
- SetQueueLibdispatchQueueAddress (lldb::addr_t dispatch_queue_t)
- {
- }
-
- //------------------------------------------------------------------
- /// Whether this Thread already has all the Queue information cached or not
- ///
- /// A Thread may be associated with a libdispatch work Queue at a given
- /// public stop event. If so, the thread can satisify requests like
- /// GetQueueLibdispatchQueueAddress, GetQueueKind, GetQueueName, and GetQueueID
- /// either from information from the remote debug stub when it is initially
- /// created, or it can query the SystemRuntime for that information.
- ///
- /// This method allows the SystemRuntime to discover if a thread has this
- /// information already, instead of calling the thread to get the information
- /// and having the thread call the SystemRuntime again.
- //------------------------------------------------------------------
- virtual bool
- ThreadHasQueueInformation () const
- {
- return false;
- }
-
- virtual uint32_t
- GetStackFrameCount()
- {
- return GetStackFrameList()->GetNumFrames();
- }
-
- virtual lldb::StackFrameSP
- GetStackFrameAtIndex (uint32_t idx)
- {
- return GetStackFrameList()->GetFrameAtIndex(idx);
- }
-
- virtual lldb::StackFrameSP
- GetFrameWithConcreteFrameIndex (uint32_t unwind_idx);
-
- bool
- DecrementCurrentInlinedDepth()
- {
- return GetStackFrameList()->DecrementCurrentInlinedDepth();
- }
-
- uint32_t
- GetCurrentInlinedDepth()
- {
- return GetStackFrameList()->GetCurrentInlinedDepth();
- }
-
- Error
- ReturnFromFrameWithIndex (uint32_t frame_idx, lldb::ValueObjectSP return_value_sp, bool broadcast = false);
-
- Error
- ReturnFromFrame (lldb::StackFrameSP frame_sp, lldb::ValueObjectSP return_value_sp, bool broadcast = false);
-
- Error
- JumpToLine(const FileSpec &file, uint32_t line, bool can_leave_function, std::string *warnings = nullptr);
-
- virtual lldb::StackFrameSP
- GetFrameWithStackID (const StackID &stack_id)
- {
- if (stack_id.IsValid())
- return GetStackFrameList()->GetFrameWithStackID (stack_id);
- return lldb::StackFrameSP();
- }
+ //------------------------------------------------------------------
+ /// The regular expression returned determines symbols that this
+ /// thread won't stop in during "step-in" operations.
+ ///
+ /// @return
+ /// A pointer to a regular expression to compare against symbols,
+ /// or nullptr if all symbols are allowed.
+ ///
+ //------------------------------------------------------------------
+ const RegularExpression *GetSymbolsToAvoidRegexp();
- uint32_t
- GetSelectedFrameIndex ()
- {
- return GetStackFrameList()->GetSelectedFrameIndex();
- }
+ FileSpecList &GetLibrariesToAvoid() const;
- lldb::StackFrameSP
- GetSelectedFrame ();
+ bool GetTraceEnabledState() const;
- uint32_t
- SetSelectedFrame (lldb_private::StackFrame *frame, bool broadcast = false);
+ bool GetStepInAvoidsNoDebug() const;
- bool
- SetSelectedFrameByIndex (uint32_t frame_idx, bool broadcast = false);
+ bool GetStepOutAvoidsNoDebug() const;
+};
- bool
- SetSelectedFrameByIndexNoisily (uint32_t frame_idx, Stream &output_stream);
+typedef std::shared_ptr<ThreadProperties> ThreadPropertiesSP;
- void
- SetDefaultFileAndLineToSelectedFrame()
- {
- GetStackFrameList()->SetDefaultFileAndLineToSelectedFrame();
- }
+class Thread : public std::enable_shared_from_this<Thread>,
+ public ThreadProperties,
+ public UserID,
+ public ExecutionContextScope,
+ public Broadcaster {
+public:
+ //------------------------------------------------------------------
+ /// Broadcaster event bits definitions.
+ //------------------------------------------------------------------
+ enum {
+ eBroadcastBitStackChanged = (1 << 0),
+ eBroadcastBitThreadSuspended = (1 << 1),
+ eBroadcastBitThreadResumed = (1 << 2),
+ eBroadcastBitSelectedFrameChanged = (1 << 3),
+ eBroadcastBitThreadSelected = (1 << 4)
+ };
- virtual lldb::RegisterContextSP
- GetRegisterContext () = 0;
+ static ConstString &GetStaticBroadcasterClass();
- virtual lldb::RegisterContextSP
- CreateRegisterContextForFrame (StackFrame *frame) = 0;
-
- virtual void
- ClearStackFrames ();
+ ConstString &GetBroadcasterClass() const override {
+ return GetStaticBroadcasterClass();
+ }
- virtual bool
- SetBackingThread (const lldb::ThreadSP &thread_sp)
- {
- return false;
- }
-
- virtual lldb::ThreadSP
- GetBackingThread () const
- {
- return lldb::ThreadSP();
- }
+ class ThreadEventData : public EventData {
+ public:
+ ThreadEventData(const lldb::ThreadSP thread_sp);
- virtual void
- ClearBackingThread ()
- {
- // Subclasses can use this function if a thread is actually backed by
- // another thread. This is currently used for the OperatingSystem plug-ins
- // where they might have a thread that is in memory, yet its registers
- // are available through the lldb_private::Thread subclass for the current
- // lldb_private::Process class. Since each time the process stops the backing
- // threads for memory threads can change, we need a way to clear the backing
- // thread for all memory threads each time we stop.
- }
+ ThreadEventData(const lldb::ThreadSP thread_sp, const StackID &stack_id);
- void
- DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx);
-
- bool
- GetDescription (Stream &s, lldb::DescriptionLevel level, bool print_json_thread, bool print_json_stopinfo);
-
- //------------------------------------------------------------------
- /// Default implementation for stepping into.
- ///
- /// This function is designed to be used by commands where the
- /// process is publicly stopped.
- ///
- /// @param[in] source_step
- /// If true and the frame has debug info, then do a source level
- /// step in, else do a single instruction step in.
- ///
- /// @param[in] step_in_avoids_code_without_debug_info
- /// If \a true, then avoid stepping into code that doesn't have
- /// debug info, else step into any code regardless of whether it
- /// has debug info.
- ///
- /// @param[in] step_out_avoids_code_without_debug_info
- /// If \a true, then if you step out to code with no debug info, keep
- /// stepping out till you get to code with debug info.
- ///
- /// @return
- /// An error that describes anything that went wrong
- //------------------------------------------------------------------
- virtual Error
- StepIn (bool source_step,
- LazyBool step_in_avoids_code_without_debug_info = eLazyBoolCalculate,
- LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
-
- //------------------------------------------------------------------
- /// Default implementation for stepping over.
- ///
- /// This function is designed to be used by commands where the
- /// process is publicly stopped.
- ///
- /// @param[in] source_step
- /// If true and the frame has debug info, then do a source level
- /// step over, else do a single instruction step over.
- ///
- /// @return
- /// An error that describes anything that went wrong
- //------------------------------------------------------------------
- virtual Error
- StepOver (bool source_step,
- LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
-
- //------------------------------------------------------------------
- /// Default implementation for stepping out.
- ///
- /// This function is designed to be used by commands where the
- /// process is publicly stopped.
- ///
- /// @return
- /// An error that describes anything that went wrong
- //------------------------------------------------------------------
- virtual Error
- StepOut ();
-
- //------------------------------------------------------------------
- /// Retrieves the per-thread data area.
- /// Most OSs maintain a per-thread pointer (e.g. the FS register on
- /// x64), which we return the value of here.
- ///
- /// @return
- /// LLDB_INVALID_ADDRESS if not supported, otherwise the thread
- /// pointer value.
- //------------------------------------------------------------------
- virtual lldb::addr_t
- GetThreadPointer ();
-
- //------------------------------------------------------------------
- /// Retrieves the per-module TLS block for a thread.
- ///
- /// @param[in] module
- /// The module to query TLS data for.
- ///
- /// @param[in] tls_file_addr
- /// The thread local address in module
- /// @return
- /// If the thread has TLS data allocated for the
- /// module, the address of the TLS block. Otherwise
- /// LLDB_INVALID_ADDRESS is returned.
- //------------------------------------------------------------------
- virtual lldb::addr_t
- GetThreadLocalData(const lldb::ModuleSP module, lldb::addr_t tls_file_addr);
-
- //------------------------------------------------------------------
- /// Check whether this thread is safe to run functions
- ///
- /// The SystemRuntime may know of certain thread states (functions in
- /// process of execution, for instance) which can make it unsafe for
- /// functions to be called.
- ///
- /// @return
- /// True if it is safe to call functions on this thread.
- /// False if function calls should be avoided on this thread.
- //------------------------------------------------------------------
- virtual bool
- SafeToCallFunctions ();
-
- //------------------------------------------------------------------
- // Thread Plan Providers:
- // This section provides the basic thread plans that the Process control
- // machinery uses to run the target. ThreadPlan.h provides more details on
- // how this mechanism works.
- // The thread provides accessors to a set of plans that perform basic operations.
- // The idea is that particular Platform plugins can override these methods to
- // provide the implementation of these basic operations appropriate to their
- // environment.
- //
- // NB: All the QueueThreadPlanXXX providers return Shared Pointers to
- // Thread plans. This is useful so that you can modify the plans after
- // creation in ways specific to that plan type. Also, it is often necessary for
- // ThreadPlans that utilize other ThreadPlans to implement their task to keep a shared
- // pointer to the sub-plan.
- // But besides that, the shared pointers should only be held onto by entities who live no longer
- // than the thread containing the ThreadPlan.
- // FIXME: If this becomes a problem, we can make a version that just returns a pointer,
- // which it is clearly unsafe to hold onto, and a shared pointer version, and only allow
- // ThreadPlan and Co. to use the latter. That is made more annoying to do because there's
- // no elegant way to friend a method to all sub-classes of a given class.
- //
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Queues the base plan for a thread.
- /// The version returned by Process does some things that are useful,
- /// like handle breakpoints and signals, so if you return a plugin specific
- /// one you probably want to call through to the Process one for anything
- /// your plugin doesn't explicitly handle.
- ///
- /// @param[in] abort_other_plans
- /// \b true if we discard the currently queued plans and replace them with this one.
- /// Otherwise this plan will go on the end of the plan stack.
- ///
- /// @return
- /// A shared pointer to the newly queued thread plan, or nullptr if the plan could not be queued.
- //------------------------------------------------------------------
- virtual lldb::ThreadPlanSP
- QueueFundamentalPlan (bool abort_other_plans);
-
- //------------------------------------------------------------------
- /// Queues the plan used to step one instruction from the current PC of \a thread.
- ///
- /// @param[in] step_over
- /// \b true if we step over calls to functions, false if we step in.
- ///
- /// @param[in] abort_other_plans
- /// \b true if we discard the currently queued plans and replace them with this one.
- /// Otherwise this plan will go on the end of the plan stack.
- ///
- /// @param[in] stop_other_threads
- /// \b true if we will stop other threads while we single step this one.
- ///
- /// @return
- /// A shared pointer to the newly queued thread plan, or nullptr if the plan could not be queued.
- //------------------------------------------------------------------
- virtual lldb::ThreadPlanSP
- QueueThreadPlanForStepSingleInstruction (bool step_over,
- bool abort_other_plans,
- bool stop_other_threads);
-
- //------------------------------------------------------------------
- /// Queues the plan used to step through an address range, stepping over
- /// function calls.
- ///
- /// @param[in] abort_other_plans
- /// \b true if we discard the currently queued plans and replace them with this one.
- /// Otherwise this plan will go on the end of the plan stack.
- ///
- /// @param[in] type
- /// Type of step to do, only eStepTypeInto and eStepTypeOver are supported by this plan.
- ///
- /// @param[in] range
- /// The address range to step through.
- ///
- /// @param[in] addr_context
- /// When dealing with stepping through inlined functions the current PC is not enough information to know
- /// what "step" means. For instance a series of nested inline functions might start at the same address.
- // The \a addr_context provides the current symbol context the step
- /// is supposed to be out of.
- // FIXME: Currently unused.
- ///
- /// @param[in] stop_other_threads
- /// \b true if we will stop other threads while we single step this one.
- ///
- /// @param[in] step_out_avoids_code_without_debug_info
- /// If eLazyBoolYes, if the step over steps out it will continue to step out till it comes to a frame with debug info.
- /// If eLazyBoolCalculate, we will consult the default set in the thread.
- ///
- /// @return
- /// A shared pointer to the newly queued thread plan, or nullptr if the plan could not be queued.
- //------------------------------------------------------------------
- virtual lldb::ThreadPlanSP
- QueueThreadPlanForStepOverRange (bool abort_other_plans,
- const AddressRange &range,
- const SymbolContext &addr_context,
- lldb::RunMode stop_other_threads,
- LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
-
- // Helper function that takes a LineEntry to step, insted of an AddressRange. This may combine multiple
- // LineEntries of the same source line number to step over a longer address range in a single operation.
- virtual lldb::ThreadPlanSP
- QueueThreadPlanForStepOverRange (bool abort_other_plans,
- const LineEntry &line_entry,
- const SymbolContext &addr_context,
- lldb::RunMode stop_other_threads,
- LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
-
- //------------------------------------------------------------------
- /// Queues the plan used to step through an address range, stepping into functions.
- ///
- /// @param[in] abort_other_plans
- /// \b true if we discard the currently queued plans and replace them with this one.
- /// Otherwise this plan will go on the end of the plan stack.
- ///
- /// @param[in] type
- /// Type of step to do, only eStepTypeInto and eStepTypeOver are supported by this plan.
- ///
- /// @param[in] range
- /// The address range to step through.
- ///
- /// @param[in] addr_context
- /// When dealing with stepping through inlined functions the current PC is not enough information to know
- /// what "step" means. For instance a series of nested inline functions might start at the same address.
- // The \a addr_context provides the current symbol context the step
- /// is supposed to be out of.
- // FIXME: Currently unused.
- ///
- /// @param[in] step_in_target
- /// Name if function we are trying to step into. We will step out if we don't land in that function.
- ///
- /// @param[in] stop_other_threads
- /// \b true if we will stop other threads while we single step this one.
- ///
- /// @param[in] step_in_avoids_code_without_debug_info
- /// If eLazyBoolYes we will step out if we step into code with no debug info.
- /// If eLazyBoolCalculate we will consult the default set in the thread.
- ///
- /// @param[in] step_out_avoids_code_without_debug_info
- /// If eLazyBoolYes, if the step over steps out it will continue to step out till it comes to a frame with debug info.
- /// If eLazyBoolCalculate, it will consult the default set in the thread.
- ///
- /// @return
- /// A shared pointer to the newly queued thread plan, or nullptr if the plan could not be queued.
- //------------------------------------------------------------------
- virtual lldb::ThreadPlanSP
- QueueThreadPlanForStepInRange (bool abort_other_plans,
- const AddressRange &range,
- const SymbolContext &addr_context,
- const char *step_in_target,
- lldb::RunMode stop_other_threads,
- LazyBool step_in_avoids_code_without_debug_info = eLazyBoolCalculate,
- LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
-
- // Helper function that takes a LineEntry to step, insted of an AddressRange. This may combine multiple
- // LineEntries of the same source line number to step over a longer address range in a single operation.
- virtual lldb::ThreadPlanSP
- QueueThreadPlanForStepInRange (bool abort_other_plans,
- const LineEntry &line_entry,
- const SymbolContext &addr_context,
- const char *step_in_target,
- lldb::RunMode stop_other_threads,
- LazyBool step_in_avoids_code_without_debug_info = eLazyBoolCalculate,
- LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
-
- //------------------------------------------------------------------
- /// Queue the plan used to step out of the function at the current PC of
- /// \a thread.
- ///
- /// @param[in] abort_other_plans
- /// \b true if we discard the currently queued plans and replace them with this one.
- /// Otherwise this plan will go on the end of the plan stack.
- ///
- /// @param[in] addr_context
- /// When dealing with stepping through inlined functions the current PC is not enough information to know
- /// what "step" means. For instance a series of nested inline functions might start at the same address.
- // The \a addr_context provides the current symbol context the step
- /// is supposed to be out of.
- // FIXME: Currently unused.
- ///
- /// @param[in] first_insn
- /// \b true if this is the first instruction of a function.
- ///
- /// @param[in] stop_other_threads
- /// \b true if we will stop other threads while we single step this one.
- ///
- /// @param[in] stop_vote
- /// @param[in] run_vote
- /// See standard meanings for the stop & run votes in ThreadPlan.h.
- ///
- /// @param[in] step_out_avoids_code_without_debug_info
- /// If eLazyBoolYes, if the step over steps out it will continue to step out till it comes to a frame with debug info.
- /// If eLazyBoolCalculate, it will consult the default set in the thread.
- ///
- /// @return
- /// A shared pointer to the newly queued thread plan, or nullptr if the plan could not be queued.
- //------------------------------------------------------------------
- virtual lldb::ThreadPlanSP
- QueueThreadPlanForStepOut (bool abort_other_plans,
- SymbolContext *addr_context,
- bool first_insn,
- bool stop_other_threads,
- Vote stop_vote, // = eVoteYes,
- Vote run_vote, // = eVoteNoOpinion);
- uint32_t frame_idx,
- LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
-
- //------------------------------------------------------------------
- /// Queue the plan used to step out of the function at the current PC of
- /// a thread. This version does not consult the should stop here callback, and should only
- /// be used by other thread plans when they need to retain control of the step out.
- ///
- /// @param[in] abort_other_plans
- /// \b true if we discard the currently queued plans and replace them with this one.
- /// Otherwise this plan will go on the end of the plan stack.
- ///
- /// @param[in] addr_context
- /// When dealing with stepping through inlined functions the current PC is not enough information to know
- /// what "step" means. For instance a series of nested inline functions might start at the same address.
- // The \a addr_context provides the current symbol context the step
- /// is supposed to be out of.
- // FIXME: Currently unused.
- ///
- /// @param[in] first_insn
- /// \b true if this is the first instruction of a function.
- ///
- /// @param[in] stop_other_threads
- /// \b true if we will stop other threads while we single step this one.
- ///
- /// @param[in] stop_vote
- /// @param[in] run_vote
- /// See standard meanings for the stop & run votes in ThreadPlan.h.
- ///
- /// @param[in] continue_to_next_branch
- /// Normally this will enqueue a plan that will put a breakpoint on the return address and continue
- /// to there. If continue_to_next_branch is true, this is an operation not involving the user --
- /// e.g. stepping "next" in a source line and we instruction stepped into another function --
- /// so instead of putting a breakpoint on the return address, advance the breakpoint to the
- /// end of the source line that is doing the call, or until the next flow control instruction.
- /// If the return value from the function call is to be retrieved / displayed to the user, you must stop
- /// on the return address. The return value may be stored in volatile registers which are overwritten
- /// before the next branch instruction.
- ///
- /// @return
- /// A shared pointer to the newly queued thread plan, or nullptr if the plan could not be queued.
- //------------------------------------------------------------------
- virtual lldb::ThreadPlanSP
- QueueThreadPlanForStepOutNoShouldStop (bool abort_other_plans,
- SymbolContext *addr_context,
- bool first_insn,
- bool stop_other_threads,
- Vote stop_vote, // = eVoteYes,
- Vote run_vote, // = eVoteNoOpinion);
- uint32_t frame_idx,
- bool continue_to_next_branch = false);
-
- //------------------------------------------------------------------
- /// Gets the plan used to step through the code that steps from a function
- /// call site at the current PC into the actual function call.
- ///
- ///
- /// @param[in] return_stack_id
- /// The stack id that we will return to (by setting backstop breakpoints on the return
- /// address to that frame) if we fail to step through.
- ///
- /// @param[in] abort_other_plans
- /// \b true if we discard the currently queued plans and replace them with this one.
- /// Otherwise this plan will go on the end of the plan stack.
- ///
- /// @param[in] stop_other_threads
- /// \b true if we will stop other threads while we single step this one.
- ///
- /// @return
- /// A shared pointer to the newly queued thread plan, or nullptr if the plan could not be queued.
- //------------------------------------------------------------------
- virtual lldb::ThreadPlanSP
- QueueThreadPlanForStepThrough (StackID &return_stack_id,
- bool abort_other_plans,
- bool stop_other_threads);
-
- //------------------------------------------------------------------
- /// Gets the plan used to continue from the current PC.
- /// This is a simple plan, mostly useful as a backstop when you are continuing
- /// for some particular purpose.
- ///
- /// @param[in] abort_other_plans
- /// \b true if we discard the currently queued plans and replace them with this one.
- /// Otherwise this plan will go on the end of the plan stack.
- ///
- /// @param[in] target_addr
- /// The address to which we're running.
- ///
- /// @param[in] stop_other_threads
- /// \b true if we will stop other threads while we single step this one.
- ///
- /// @return
- /// A shared pointer to the newly queued thread plan, or nullptr if the plan could not be queued.
- //------------------------------------------------------------------
- virtual lldb::ThreadPlanSP
- QueueThreadPlanForRunToAddress (bool abort_other_plans,
- Address &target_addr,
- bool stop_other_threads);
-
- virtual lldb::ThreadPlanSP
- QueueThreadPlanForStepUntil (bool abort_other_plans,
- lldb::addr_t *address_list,
- size_t num_addresses,
- bool stop_others,
- uint32_t frame_idx);
-
- virtual lldb::ThreadPlanSP
- QueueThreadPlanForStepScripted (bool abort_other_plans,
- const char *class_name,
- bool stop_other_threads);
-
- //------------------------------------------------------------------
- // Thread Plan accessors:
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Gets the plan which will execute next on the plan stack.
- ///
- /// @return
- /// A pointer to the next executed plan.
- //------------------------------------------------------------------
- ThreadPlan *
- GetCurrentPlan ();
-
- //------------------------------------------------------------------
- /// Unwinds the thread stack for the innermost expression plan currently
- /// on the thread plan stack.
- ///
- /// @return
- /// An error if the thread plan could not be unwound.
- //------------------------------------------------------------------
-
- Error
- UnwindInnermostExpression();
-
- //------------------------------------------------------------------
- /// Gets the outer-most plan that was popped off the plan stack in the
- /// most recent stop. Useful for printing the stop reason accurately.
- ///
- /// @return
- /// A pointer to the last completed plan.
- //------------------------------------------------------------------
- lldb::ThreadPlanSP
- GetCompletedPlan ();
-
- //------------------------------------------------------------------
- /// Gets the outer-most return value from the completed plans
- ///
- /// @return
- /// A ValueObjectSP, either empty if there is no return value,
- /// or containing the return value.
- //------------------------------------------------------------------
- lldb::ValueObjectSP
- GetReturnValueObject ();
-
- //------------------------------------------------------------------
- /// Gets the outer-most expression variable from the completed plans
- ///
- /// @return
- /// A ExpressionVariableSP, either empty if there is no
- /// plan completed an expression during the current stop
- /// or the expression variable that was made for the completed expression.
- //------------------------------------------------------------------
- lldb::ExpressionVariableSP
- GetExpressionVariable ();
-
- //------------------------------------------------------------------
- /// Checks whether the given plan is in the completed plans for this
- /// stop.
- ///
- /// @param[in] plan
- /// Pointer to the plan you're checking.
- ///
- /// @return
- /// Returns true if the input plan is in the completed plan stack,
- /// false otherwise.
- //------------------------------------------------------------------
- bool
- IsThreadPlanDone (ThreadPlan *plan);
-
- //------------------------------------------------------------------
- /// Checks whether the given plan is in the discarded plans for this
- /// stop.
- ///
- /// @param[in] plan
- /// Pointer to the plan you're checking.
- ///
- /// @return
- /// Returns true if the input plan is in the discarded plan stack,
- /// false otherwise.
- //------------------------------------------------------------------
- bool
- WasThreadPlanDiscarded (ThreadPlan *plan);
-
- //------------------------------------------------------------------
- /// Queues a generic thread plan.
- ///
- /// @param[in] plan_sp
- /// The plan to queue.
- ///
- /// @param[in] abort_other_plans
- /// \b true if we discard the currently queued plans and replace them with this one.
- /// Otherwise this plan will go on the end of the plan stack.
- ///
- /// @return
- /// A pointer to the last completed plan.
- //------------------------------------------------------------------
- void
- QueueThreadPlan (lldb::ThreadPlanSP &plan_sp, bool abort_other_plans);
-
- //------------------------------------------------------------------
- /// Discards the plans queued on the plan stack of the current thread. This is
- /// arbitrated by the "Master" ThreadPlans, using the "OkayToDiscard" call.
- // But if \a force is true, all thread plans are discarded.
- //------------------------------------------------------------------
- void
- DiscardThreadPlans (bool force);
-
- //------------------------------------------------------------------
- /// Discards the plans queued on the plan stack of the current thread up to and
- /// including up_to_plan_sp.
- //
- // @param[in] up_to_plan_sp
- // Discard all plans up to and including this one.
- //------------------------------------------------------------------
- void
- DiscardThreadPlansUpToPlan (lldb::ThreadPlanSP &up_to_plan_sp);
-
- void
- DiscardThreadPlansUpToPlan (ThreadPlan *up_to_plan_ptr);
-
- //------------------------------------------------------------------
- /// Discards the plans queued on the plan stack of the current thread up to and
- /// including the plan in that matches \a thread_index counting only
- /// the non-Private plans.
- ///
- /// @param[in] up_to_plan_sp
- /// Discard all plans up to and including this user plan given by this index.
- ///
- /// @return
- /// \b true if there was a thread plan with that user index, \b false otherwise.
- //------------------------------------------------------------------
- bool
- DiscardUserThreadPlansUpToIndex (uint32_t thread_index);
-
- //------------------------------------------------------------------
- /// Prints the current plan stack.
- ///
- /// @param[in] s
- /// The stream to which to dump the plan stack info.
- ///
- //------------------------------------------------------------------
- void
- DumpThreadPlans (Stream *s,
- lldb::DescriptionLevel desc_level = lldb::eDescriptionLevelVerbose,
- bool include_internal = true,
- bool ignore_boring = false) const;
-
- virtual bool
- CheckpointThreadState (ThreadStateCheckpoint &saved_state);
-
- virtual bool
- RestoreRegisterStateFromCheckpoint (ThreadStateCheckpoint &saved_state);
-
- virtual bool
- RestoreThreadStateFromCheckpoint (ThreadStateCheckpoint &saved_state);
-
- void
- EnableTracer (bool value, bool single_step);
-
- void
- SetTracer (lldb::ThreadPlanTracerSP &tracer_sp);
-
- //------------------------------------------------------------------
- // Get the thread index ID. The index ID that is guaranteed to not
- // be re-used by a process. They start at 1 and increase with each
- // new thread. This allows easy command line access by a unique ID
- // that is easier to type than the actual system thread ID.
- //------------------------------------------------------------------
- uint32_t
- GetIndexID () const;
-
- //------------------------------------------------------------------
- // Get the originating thread's index ID.
- // In the case of an "extended" thread -- a thread which represents
- // the stack that enqueued/spawned work that is currently executing --
- // we need to provide the IndexID of the thread that actually did
- // this work. We don't want to just masquerade as that thread's IndexID
- // by using it in our own IndexID because that way leads to madness -
- // but the driver program which is iterating over extended threads
- // may ask for the OriginatingThreadID to display that information
- // to the user.
- // Normal threads will return the same thing as GetIndexID();
- //------------------------------------------------------------------
- virtual uint32_t
- GetExtendedBacktraceOriginatingIndexID ()
- {
- return GetIndexID ();
- }
+ ThreadEventData();
- //------------------------------------------------------------------
- // The API ID is often the same as the Thread::GetID(), but not in
- // all cases. Thread::GetID() is the user visible thread ID that
- // clients would want to see. The API thread ID is the thread ID
- // that is used when sending data to/from the debugging protocol.
- //------------------------------------------------------------------
- virtual lldb::user_id_t
- GetProtocolID () const
- {
- return GetID();
- }
+ ~ThreadEventData() override;
- //------------------------------------------------------------------
- // lldb::ExecutionContextScope pure virtual functions
- //------------------------------------------------------------------
- lldb::TargetSP
- CalculateTarget() override;
-
- lldb::ProcessSP
- CalculateProcess() override;
-
- lldb::ThreadSP
- CalculateThread() override;
-
- lldb::StackFrameSP
- CalculateStackFrame() override;
-
- void
- CalculateExecutionContext(ExecutionContext &exe_ctx) override;
-
- lldb::StackFrameSP
- GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr);
-
- size_t
- GetStatus (Stream &strm,
- uint32_t start_frame,
- uint32_t num_frames,
- uint32_t num_frames_with_source);
-
- size_t
- GetStackFrameStatus (Stream& strm,
- uint32_t first_frame,
- uint32_t num_frames,
- bool show_frame_info,
- uint32_t num_frames_with_source);
-
- // We need a way to verify that even though we have a thread in a shared
- // pointer that the object itself is still valid. Currently this won't be
- // the case if DestroyThread() was called. DestroyThread is called when
- // a thread has been removed from the Process' thread list.
- bool
- IsValid () const
- {
- return !m_destroy_called;
- }
+ static const ConstString &GetFlavorString();
- // Sets and returns a valid stop info based on the process stop ID and the
- // current thread plan. If the thread stop ID does not match the process'
- // stop ID, the private stop reason is not set and an invalid StopInfoSP may
- // be returned.
- //
- // NOTE: This function must be called before the current thread plan is
- // moved to the completed plan stack (in Thread::ShouldStop()).
- //
- // NOTE: If subclasses override this function, ensure they do not overwrite
- // the m_actual_stop_info if it is valid. The stop info may be a
- // "checkpointed and restored" stop info, so if it is still around it is
- // right even if you have not calculated this yourself, or if it disagrees
- // with what you might have calculated.
- virtual lldb::StopInfoSP
- GetPrivateStopInfo ();
-
- //----------------------------------------------------------------------
- // Ask the thread subclass to set its stop info.
- //
- // Thread subclasses should call Thread::SetStopInfo(...) with the
- // reason the thread stopped.
- //
- // @return
- // True if Thread::SetStopInfo(...) was called, false otherwise.
- //----------------------------------------------------------------------
- virtual bool
- CalculateStopInfo () = 0;
-
- //----------------------------------------------------------------------
- // Gets the temporary resume state for a thread.
- //
- // This value gets set in each thread by complex debugger logic in
- // Thread::ShouldResume() and an appropriate thread resume state will get
- // set in each thread every time the process is resumed prior to calling
- // Process::DoResume(). The lldb_private::Process subclass should adhere
- // to the thread resume state request which will be one of:
- //
- // eStateRunning - thread will resume when process is resumed
- // eStateStepping - thread should step 1 instruction and stop when process
- // is resumed
- // eStateSuspended - thread should not execute any instructions when
- // process is resumed
- //----------------------------------------------------------------------
- lldb::StateType
- GetTemporaryResumeState() const
- {
- return m_temporary_resume_state;
+ const ConstString &GetFlavor() const override {
+ return ThreadEventData::GetFlavorString();
}
- void
- SetStopInfo (const lldb::StopInfoSP &stop_info_sp);
-
- void
- SetShouldReportStop (Vote vote);
-
- //----------------------------------------------------------------------
- /// Sets the extended backtrace token for this thread
- ///
- /// Some Thread subclasses may maintain a token to help with providing
- /// an extended backtrace. The SystemRuntime plugin will set/request this.
- ///
- /// @param [in] token
- //----------------------------------------------------------------------
- virtual void
- SetExtendedBacktraceToken (uint64_t token) { }
-
- //----------------------------------------------------------------------
- /// Gets the extended backtrace token for this thread
- ///
- /// Some Thread subclasses may maintain a token to help with providing
- /// an extended backtrace. The SystemRuntime plugin will set/request this.
- ///
- /// @return
- /// The token needed by the SystemRuntime to create an extended backtrace.
- /// LLDB_INVALID_ADDRESS is returned if no token is available.
- //----------------------------------------------------------------------
- virtual uint64_t
- GetExtendedBacktraceToken ()
- {
- return LLDB_INVALID_ADDRESS;
+ void Dump(Stream *s) const override;
+
+ static const ThreadEventData *GetEventDataFromEvent(const Event *event_ptr);
+
+ static lldb::ThreadSP GetThreadFromEvent(const Event *event_ptr);
+
+ static StackID GetStackIDFromEvent(const Event *event_ptr);
+
+ static lldb::StackFrameSP GetStackFrameFromEvent(const Event *event_ptr);
+
+ lldb::ThreadSP GetThread() const { return m_thread_sp; }
+
+ StackID GetStackID() const { return m_stack_id; }
+
+ private:
+ lldb::ThreadSP m_thread_sp;
+ StackID m_stack_id;
+
+ DISALLOW_COPY_AND_ASSIGN(ThreadEventData);
+ };
+
+ struct ThreadStateCheckpoint {
+ uint32_t orig_stop_id; // Dunno if I need this yet but it is an interesting
+ // bit of data.
+ lldb::StopInfoSP stop_info_sp; // You have to restore the stop info or you
+ // might continue with the wrong signals.
+ lldb::RegisterCheckpointSP
+ register_backup_sp; // You need to restore the registers, of course...
+ uint32_t current_inlined_depth;
+ lldb::addr_t current_inlined_pc;
+ };
+
+ //------------------------------------------------------------------
+ /// Constructor
+ ///
+ /// @param [in] process
+ ///
+ /// @param [in] tid
+ ///
+ /// @param [in] use_invalid_index_id
+ /// Optional parameter, defaults to false. The only subclass that
+ /// is likely to set use_invalid_index_id == true is the HistoryThread
+ /// class. In that case, the Thread we are constructing represents
+ /// a thread from earlier in the program execution. We may have the
+ /// tid of the original thread that they represent but we don't want
+ /// to reuse the IndexID of that thread, or create a new one. If a
+ /// client wants to know the original thread's IndexID, they should use
+ /// Thread::GetExtendedBacktraceOriginatingIndexID().
+ //------------------------------------------------------------------
+ Thread(Process &process, lldb::tid_t tid, bool use_invalid_index_id = false);
+
+ ~Thread() override;
+
+ static void SettingsInitialize();
+
+ static void SettingsTerminate();
+
+ static const ThreadPropertiesSP &GetGlobalProperties();
+
+ lldb::ProcessSP GetProcess() const { return m_process_wp.lock(); }
+
+ int GetResumeSignal() const { return m_resume_signal; }
+
+ void SetResumeSignal(int signal) { m_resume_signal = signal; }
+
+ lldb::StateType GetState() const;
+
+ void SetState(lldb::StateType state);
+
+ //------------------------------------------------------------------
+ /// Sets the USER resume state for this thread. If you set a thread to
+ /// suspended with
+ /// this API, it won't take part in any of the arbitration for ShouldResume,
+ /// and will stay
+ /// suspended even when other threads do get to run.
+ ///
+ /// N.B. This is not the state that is used internally by thread plans to
+ /// implement
+ /// staying on one thread while stepping over a breakpoint, etc. The is the
+ /// TemporaryResume state, and if you are implementing some bit of strategy in
+ /// the stepping
+ /// machinery you should be using that state and not the user resume state.
+ ///
+ /// If you are just preparing all threads to run, you should not override the
+ /// threads that are
+ /// marked as suspended by the debugger. In that case, pass override_suspend
+ /// = false. If you want
+ /// to force the thread to run (e.g. the "thread continue" command, or are
+ /// resetting the state
+ /// (e.g. in SBThread::Resume()), then pass true to override_suspend.
+ /// @return
+ /// The User resume state for this thread.
+ //------------------------------------------------------------------
+ void SetResumeState(lldb::StateType state, bool override_suspend = false) {
+ if (m_resume_state == lldb::eStateSuspended && !override_suspend)
+ return;
+ m_resume_state = state;
+ }
+
+ //------------------------------------------------------------------
+ /// Gets the USER resume state for this thread. This is not the same as what
+ /// this thread is going to do for any particular step, however if this thread
+ /// returns eStateSuspended, then the process control logic will never allow
+ /// this
+ /// thread to run.
+ ///
+ /// @return
+ /// The User resume state for this thread.
+ //------------------------------------------------------------------
+ lldb::StateType GetResumeState() const { return m_resume_state; }
+
+ // This function is called on all the threads before "ShouldResume" and
+ // "WillResume" in case a thread needs to change its state before the
+ // ThreadList polls all the threads to figure out which ones actually
+ // will get to run and how.
+ void SetupForResume();
+
+ // Do not override this function, it is for thread plan logic only
+ bool ShouldResume(lldb::StateType resume_state);
+
+ // Override this to do platform specific tasks before resume.
+ virtual void WillResume(lldb::StateType resume_state) {}
+
+ // This clears generic thread state after a resume. If you subclass this,
+ // be sure to call it.
+ virtual void DidResume();
+
+ // This notifies the thread when a private stop occurs.
+ virtual void DidStop();
+
+ virtual void RefreshStateAfterStop() = 0;
+
+ void WillStop();
+
+ bool ShouldStop(Event *event_ptr);
+
+ Vote ShouldReportStop(Event *event_ptr);
+
+ Vote ShouldReportRun(Event *event_ptr);
+
+ void Flush();
+
+ // Return whether this thread matches the specification in ThreadSpec. This
+ // is a virtual
+ // method because at some point we may extend the thread spec with a platform
+ // specific
+ // dictionary of attributes, which then only the platform specific Thread
+ // implementation
+ // would know how to match. For now, this just calls through to the
+ // ThreadSpec's
+ // ThreadPassesBasicTests method.
+ virtual bool MatchesSpec(const ThreadSpec *spec);
+
+ lldb::StopInfoSP GetStopInfo();
+
+ lldb::StopReason GetStopReason();
+
+ bool StopInfoIsUpToDate() const;
+
+ // This sets the stop reason to a "blank" stop reason, so you can call
+ // functions on the thread
+ // without having the called function run with whatever stop reason you
+ // stopped with.
+ void SetStopInfoToNothing();
+
+ bool ThreadStoppedForAReason();
+
+ static const char *RunModeAsCString(lldb::RunMode mode);
+
+ static const char *StopReasonAsCString(lldb::StopReason reason);
+
+ virtual const char *GetInfo() { return nullptr; }
+
+ //------------------------------------------------------------------
+ /// Retrieve a dictionary of information about this thread
+ ///
+ /// On Mac OS X systems there may be voucher information.
+ /// The top level dictionary returned will have an "activity" key and the
+ /// value of the activity is a dictionary. Keys in that dictionary will
+ /// be "name" and "id", among others.
+ /// There may also be "trace_messages" (an array) with each entry in that
+ /// array
+ /// being a dictionary (keys include "message" with the text of the trace
+ /// message).
+ //------------------------------------------------------------------
+ StructuredData::ObjectSP GetExtendedInfo() {
+ if (m_extended_info_fetched == false) {
+ m_extended_info = FetchThreadExtendedInfo();
+ m_extended_info_fetched = true;
}
+ return m_extended_info;
+ }
+
+ virtual const char *GetName() { return nullptr; }
+
+ virtual void SetName(const char *name) {}
+
+ //------------------------------------------------------------------
+ /// Whether this thread can be associated with a libdispatch queue
+ ///
+ /// The Thread may know if it is associated with a libdispatch queue,
+ /// it may know definitively that it is NOT associated with a libdispatch
+ /// queue, or it may be unknown whether it is associated with a libdispatch
+ /// queue.
+ ///
+ /// @return
+ /// eLazyBoolNo if this thread is definitely not associated with a
+ /// libdispatch queue (e.g. on a non-Darwin system where GCD aka
+ /// libdispatch is not available).
+ ///
+ /// eLazyBoolYes this thread is associated with a libdispatch queue.
+ ///
+ /// eLazyBoolCalculate this thread may be associated with a libdispatch
+ /// queue but the thread doesn't know one way or the other.
+ //------------------------------------------------------------------
+ virtual lldb_private::LazyBool GetAssociatedWithLibdispatchQueue() {
+ return eLazyBoolNo;
+ }
+
+ virtual void SetAssociatedWithLibdispatchQueue(
+ lldb_private::LazyBool associated_with_libdispatch_queue) {}
+
+ //------------------------------------------------------------------
+ /// Retrieve the Queue ID for the queue currently using this Thread
+ ///
+ /// If this Thread is doing work on behalf of a libdispatch/GCD queue,
+ /// retrieve the QueueID.
+ ///
+ /// This is a unique identifier for the libdispatch/GCD queue in a
+ /// process. Often starting at 1 for the initial system-created
+ /// queues and incrementing, a QueueID will not be reused for a
+ /// different queue during the lifetime of a process.
+ ///
+ /// @return
+ /// A QueueID if the Thread subclass implements this, else
+ /// LLDB_INVALID_QUEUE_ID.
+ //------------------------------------------------------------------
+ virtual lldb::queue_id_t GetQueueID() { return LLDB_INVALID_QUEUE_ID; }
+
+ virtual void SetQueueID(lldb::queue_id_t new_val) {}
+
+ //------------------------------------------------------------------
+ /// Retrieve the Queue name for the queue currently using this Thread
+ ///
+ /// If this Thread is doing work on behalf of a libdispatch/GCD queue,
+ /// retrieve the Queue name.
+ ///
+ /// @return
+ /// The Queue name, if the Thread subclass implements this, else
+ /// nullptr.
+ //------------------------------------------------------------------
+ virtual const char *GetQueueName() { return nullptr; }
+
+ virtual void SetQueueName(const char *name) {}
+
+ //------------------------------------------------------------------
+ /// Retrieve the Queue kind for the queue currently using this Thread
+ ///
+ /// If this Thread is doing work on behalf of a libdispatch/GCD queue,
+ /// retrieve the Queue kind - either eQueueKindSerial or
+ /// eQueueKindConcurrent, indicating that this queue processes work
+ /// items serially or concurrently.
+ ///
+ /// @return
+ /// The Queue kind, if the Thread subclass implements this, else
+ /// eQueueKindUnknown.
+ //------------------------------------------------------------------
+ virtual lldb::QueueKind GetQueueKind() { return lldb::eQueueKindUnknown; }
+
+ virtual void SetQueueKind(lldb::QueueKind kind) {}
+
+ //------------------------------------------------------------------
+ /// Retrieve the Queue for this thread, if any.
+ ///
+ /// @return
+ /// A QueueSP for the queue that is currently associated with this
+ /// thread.
+ /// An empty shared pointer indicates that this thread is not
+ /// associated with a queue, or libdispatch queues are not
+ /// supported on this target.
+ //------------------------------------------------------------------
+ virtual lldb::QueueSP GetQueue() { return lldb::QueueSP(); }
+
+ //------------------------------------------------------------------
+ /// Retrieve the address of the libdispatch_queue_t struct for queue
+ /// currently using this Thread
+ ///
+ /// If this Thread is doing work on behalf of a libdispatch/GCD queue,
+ /// retrieve the address of the libdispatch_queue_t structure describing
+ /// the queue.
+ ///
+ /// This address may be reused for different queues later in the Process
+ /// lifetime and should not be used to identify a queue uniquely. Use
+ /// the GetQueueID() call for that.
+ ///
+ /// @return
+ /// The Queue's libdispatch_queue_t address if the Thread subclass
+ /// implements this, else LLDB_INVALID_ADDRESS.
+ //------------------------------------------------------------------
+ virtual lldb::addr_t GetQueueLibdispatchQueueAddress() {
+ return LLDB_INVALID_ADDRESS;
+ }
+
+ virtual void SetQueueLibdispatchQueueAddress(lldb::addr_t dispatch_queue_t) {}
+
+ //------------------------------------------------------------------
+ /// Whether this Thread already has all the Queue information cached or not
+ ///
+ /// A Thread may be associated with a libdispatch work Queue at a given
+ /// public stop event. If so, the thread can satisify requests like
+ /// GetQueueLibdispatchQueueAddress, GetQueueKind, GetQueueName, and
+ /// GetQueueID
+ /// either from information from the remote debug stub when it is initially
+ /// created, or it can query the SystemRuntime for that information.
+ ///
+ /// This method allows the SystemRuntime to discover if a thread has this
+ /// information already, instead of calling the thread to get the information
+ /// and having the thread call the SystemRuntime again.
+ //------------------------------------------------------------------
+ virtual bool ThreadHasQueueInformation() const { return false; }
+
+ virtual uint32_t GetStackFrameCount() {
+ return GetStackFrameList()->GetNumFrames();
+ }
+
+ virtual lldb::StackFrameSP GetStackFrameAtIndex(uint32_t idx) {
+ return GetStackFrameList()->GetFrameAtIndex(idx);
+ }
+
+ virtual lldb::StackFrameSP
+ GetFrameWithConcreteFrameIndex(uint32_t unwind_idx);
+
+ bool DecrementCurrentInlinedDepth() {
+ return GetStackFrameList()->DecrementCurrentInlinedDepth();
+ }
+
+ uint32_t GetCurrentInlinedDepth() {
+ return GetStackFrameList()->GetCurrentInlinedDepth();
+ }
+
+ Error ReturnFromFrameWithIndex(uint32_t frame_idx,
+ lldb::ValueObjectSP return_value_sp,
+ bool broadcast = false);
+
+ Error ReturnFromFrame(lldb::StackFrameSP frame_sp,
+ lldb::ValueObjectSP return_value_sp,
+ bool broadcast = false);
+
+ Error JumpToLine(const FileSpec &file, uint32_t line, bool can_leave_function,
+ std::string *warnings = nullptr);
+
+ virtual lldb::StackFrameSP GetFrameWithStackID(const StackID &stack_id) {
+ if (stack_id.IsValid())
+ return GetStackFrameList()->GetFrameWithStackID(stack_id);
+ return lldb::StackFrameSP();
+ }
+
+ uint32_t GetSelectedFrameIndex() {
+ return GetStackFrameList()->GetSelectedFrameIndex();
+ }
+
+ lldb::StackFrameSP GetSelectedFrame();
+
+ uint32_t SetSelectedFrame(lldb_private::StackFrame *frame,
+ bool broadcast = false);
+
+ bool SetSelectedFrameByIndex(uint32_t frame_idx, bool broadcast = false);
+
+ bool SetSelectedFrameByIndexNoisily(uint32_t frame_idx,
+ Stream &output_stream);
+
+ void SetDefaultFileAndLineToSelectedFrame() {
+ GetStackFrameList()->SetDefaultFileAndLineToSelectedFrame();
+ }
+
+ virtual lldb::RegisterContextSP GetRegisterContext() = 0;
+
+ virtual lldb::RegisterContextSP
+ CreateRegisterContextForFrame(StackFrame *frame) = 0;
+
+ virtual void ClearStackFrames();
+
+ virtual bool SetBackingThread(const lldb::ThreadSP &thread_sp) {
+ return false;
+ }
+
+ virtual lldb::ThreadSP GetBackingThread() const { return lldb::ThreadSP(); }
+
+ virtual void ClearBackingThread() {
+ // Subclasses can use this function if a thread is actually backed by
+ // another thread. This is currently used for the OperatingSystem plug-ins
+ // where they might have a thread that is in memory, yet its registers
+ // are available through the lldb_private::Thread subclass for the current
+ // lldb_private::Process class. Since each time the process stops the
+ // backing
+ // threads for memory threads can change, we need a way to clear the backing
+ // thread for all memory threads each time we stop.
+ }
+
+ // If stop_format is true, this will be the form used when we print stop info.
+ // If false, it will be the form we use for thread list and co.
+ void DumpUsingSettingsFormat(Stream &strm, uint32_t frame_idx,
+ bool stop_format);
+
+ bool GetDescription(Stream &s, lldb::DescriptionLevel level,
+ bool print_json_thread, bool print_json_stopinfo);
+
+ //------------------------------------------------------------------
+ /// Default implementation for stepping into.
+ ///
+ /// This function is designed to be used by commands where the
+ /// process is publicly stopped.
+ ///
+ /// @param[in] source_step
+ /// If true and the frame has debug info, then do a source level
+ /// step in, else do a single instruction step in.
+ ///
+ /// @param[in] step_in_avoids_code_without_debug_info
+ /// If \a true, then avoid stepping into code that doesn't have
+ /// debug info, else step into any code regardless of whether it
+ /// has debug info.
+ ///
+ /// @param[in] step_out_avoids_code_without_debug_info
+ /// If \a true, then if you step out to code with no debug info, keep
+ /// stepping out till you get to code with debug info.
+ ///
+ /// @return
+ /// An error that describes anything that went wrong
+ //------------------------------------------------------------------
+ virtual Error
+ StepIn(bool source_step,
+ LazyBool step_in_avoids_code_without_debug_info = eLazyBoolCalculate,
+ LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
+
+ //------------------------------------------------------------------
+ /// Default implementation for stepping over.
+ ///
+ /// This function is designed to be used by commands where the
+ /// process is publicly stopped.
+ ///
+ /// @param[in] source_step
+ /// If true and the frame has debug info, then do a source level
+ /// step over, else do a single instruction step over.
+ ///
+ /// @return
+ /// An error that describes anything that went wrong
+ //------------------------------------------------------------------
+ virtual Error StepOver(
+ bool source_step,
+ LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
+
+ //------------------------------------------------------------------
+ /// Default implementation for stepping out.
+ ///
+ /// This function is designed to be used by commands where the
+ /// process is publicly stopped.
+ ///
+ /// @return
+ /// An error that describes anything that went wrong
+ //------------------------------------------------------------------
+ virtual Error StepOut();
+
+ //------------------------------------------------------------------
+ /// Retrieves the per-thread data area.
+ /// Most OSs maintain a per-thread pointer (e.g. the FS register on
+ /// x64), which we return the value of here.
+ ///
+ /// @return
+ /// LLDB_INVALID_ADDRESS if not supported, otherwise the thread
+ /// pointer value.
+ //------------------------------------------------------------------
+ virtual lldb::addr_t GetThreadPointer();
+
+ //------------------------------------------------------------------
+ /// Retrieves the per-module TLS block for a thread.
+ ///
+ /// @param[in] module
+ /// The module to query TLS data for.
+ ///
+ /// @param[in] tls_file_addr
+ /// The thread local address in module
+ /// @return
+ /// If the thread has TLS data allocated for the
+ /// module, the address of the TLS block. Otherwise
+ /// LLDB_INVALID_ADDRESS is returned.
+ //------------------------------------------------------------------
+ virtual lldb::addr_t GetThreadLocalData(const lldb::ModuleSP module,
+ lldb::addr_t tls_file_addr);
+
+ //------------------------------------------------------------------
+ /// Check whether this thread is safe to run functions
+ ///
+ /// The SystemRuntime may know of certain thread states (functions in
+ /// process of execution, for instance) which can make it unsafe for
+ /// functions to be called.
+ ///
+ /// @return
+ /// True if it is safe to call functions on this thread.
+ /// False if function calls should be avoided on this thread.
+ //------------------------------------------------------------------
+ virtual bool SafeToCallFunctions();
+
+ //------------------------------------------------------------------
+ // Thread Plan Providers:
+ // This section provides the basic thread plans that the Process control
+ // machinery uses to run the target. ThreadPlan.h provides more details on
+ // how this mechanism works.
+ // The thread provides accessors to a set of plans that perform basic
+ // operations.
+ // The idea is that particular Platform plugins can override these methods to
+ // provide the implementation of these basic operations appropriate to their
+ // environment.
+ //
+ // NB: All the QueueThreadPlanXXX providers return Shared Pointers to
+ // Thread plans. This is useful so that you can modify the plans after
+ // creation in ways specific to that plan type. Also, it is often necessary
+ // for
+ // ThreadPlans that utilize other ThreadPlans to implement their task to keep
+ // a shared
+ // pointer to the sub-plan.
+ // But besides that, the shared pointers should only be held onto by entities
+ // who live no longer
+ // than the thread containing the ThreadPlan.
+ // FIXME: If this becomes a problem, we can make a version that just returns a
+ // pointer,
+ // which it is clearly unsafe to hold onto, and a shared pointer version, and
+ // only allow
+ // ThreadPlan and Co. to use the latter. That is made more annoying to do
+ // because there's
+ // no elegant way to friend a method to all sub-classes of a given class.
+ //
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Queues the base plan for a thread.
+ /// The version returned by Process does some things that are useful,
+ /// like handle breakpoints and signals, so if you return a plugin specific
+ /// one you probably want to call through to the Process one for anything
+ /// your plugin doesn't explicitly handle.
+ ///
+ /// @param[in] abort_other_plans
+ /// \b true if we discard the currently queued plans and replace them with
+ /// this one.
+ /// Otherwise this plan will go on the end of the plan stack.
+ ///
+ /// @return
+ /// A shared pointer to the newly queued thread plan, or nullptr if the
+ /// plan could not be queued.
+ //------------------------------------------------------------------
+ virtual lldb::ThreadPlanSP QueueFundamentalPlan(bool abort_other_plans);
+
+ //------------------------------------------------------------------
+ /// Queues the plan used to step one instruction from the current PC of \a
+ /// thread.
+ ///
+ /// @param[in] step_over
+ /// \b true if we step over calls to functions, false if we step in.
+ ///
+ /// @param[in] abort_other_plans
+ /// \b true if we discard the currently queued plans and replace them with
+ /// this one.
+ /// Otherwise this plan will go on the end of the plan stack.
+ ///
+ /// @param[in] stop_other_threads
+ /// \b true if we will stop other threads while we single step this one.
+ ///
+ /// @return
+ /// A shared pointer to the newly queued thread plan, or nullptr if the
+ /// plan could not be queued.
+ //------------------------------------------------------------------
+ virtual lldb::ThreadPlanSP QueueThreadPlanForStepSingleInstruction(
+ bool step_over, bool abort_other_plans, bool stop_other_threads);
+
+ //------------------------------------------------------------------
+ /// Queues the plan used to step through an address range, stepping over
+ /// function calls.
+ ///
+ /// @param[in] abort_other_plans
+ /// \b true if we discard the currently queued plans and replace them with
+ /// this one.
+ /// Otherwise this plan will go on the end of the plan stack.
+ ///
+ /// @param[in] type
+ /// Type of step to do, only eStepTypeInto and eStepTypeOver are supported
+ /// by this plan.
+ ///
+ /// @param[in] range
+ /// The address range to step through.
+ ///
+ /// @param[in] addr_context
+ /// When dealing with stepping through inlined functions the current PC is
+ /// not enough information to know
+ /// what "step" means. For instance a series of nested inline functions
+ /// might start at the same address.
+ // The \a addr_context provides the current symbol context the step
+ /// is supposed to be out of.
+ // FIXME: Currently unused.
+ ///
+ /// @param[in] stop_other_threads
+ /// \b true if we will stop other threads while we single step this one.
+ ///
+ /// @param[in] step_out_avoids_code_without_debug_info
+ /// If eLazyBoolYes, if the step over steps out it will continue to step
+ /// out till it comes to a frame with debug info.
+ /// If eLazyBoolCalculate, we will consult the default set in the thread.
+ ///
+ /// @return
+ /// A shared pointer to the newly queued thread plan, or nullptr if the
+ /// plan could not be queued.
+ //------------------------------------------------------------------
+ virtual lldb::ThreadPlanSP QueueThreadPlanForStepOverRange(
+ bool abort_other_plans, const AddressRange &range,
+ const SymbolContext &addr_context, lldb::RunMode stop_other_threads,
+ LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
+
+ // Helper function that takes a LineEntry to step, insted of an AddressRange.
+ // This may combine multiple
+ // LineEntries of the same source line number to step over a longer address
+ // range in a single operation.
+ virtual lldb::ThreadPlanSP QueueThreadPlanForStepOverRange(
+ bool abort_other_plans, const LineEntry &line_entry,
+ const SymbolContext &addr_context, lldb::RunMode stop_other_threads,
+ LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
+
+ //------------------------------------------------------------------
+ /// Queues the plan used to step through an address range, stepping into
+ /// functions.
+ ///
+ /// @param[in] abort_other_plans
+ /// \b true if we discard the currently queued plans and replace them with
+ /// this one.
+ /// Otherwise this plan will go on the end of the plan stack.
+ ///
+ /// @param[in] type
+ /// Type of step to do, only eStepTypeInto and eStepTypeOver are supported
+ /// by this plan.
+ ///
+ /// @param[in] range
+ /// The address range to step through.
+ ///
+ /// @param[in] addr_context
+ /// When dealing with stepping through inlined functions the current PC is
+ /// not enough information to know
+ /// what "step" means. For instance a series of nested inline functions
+ /// might start at the same address.
+ // The \a addr_context provides the current symbol context the step
+ /// is supposed to be out of.
+ // FIXME: Currently unused.
+ ///
+ /// @param[in] step_in_target
+ /// Name if function we are trying to step into. We will step out if we
+ /// don't land in that function.
+ ///
+ /// @param[in] stop_other_threads
+ /// \b true if we will stop other threads while we single step this one.
+ ///
+ /// @param[in] step_in_avoids_code_without_debug_info
+ /// If eLazyBoolYes we will step out if we step into code with no debug
+ /// info.
+ /// If eLazyBoolCalculate we will consult the default set in the thread.
+ ///
+ /// @param[in] step_out_avoids_code_without_debug_info
+ /// If eLazyBoolYes, if the step over steps out it will continue to step
+ /// out till it comes to a frame with debug info.
+ /// If eLazyBoolCalculate, it will consult the default set in the thread.
+ ///
+ /// @return
+ /// A shared pointer to the newly queued thread plan, or nullptr if the
+ /// plan could not be queued.
+ //------------------------------------------------------------------
+ virtual lldb::ThreadPlanSP QueueThreadPlanForStepInRange(
+ bool abort_other_plans, const AddressRange &range,
+ const SymbolContext &addr_context, const char *step_in_target,
+ lldb::RunMode stop_other_threads,
+ LazyBool step_in_avoids_code_without_debug_info = eLazyBoolCalculate,
+ LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
+
+ // Helper function that takes a LineEntry to step, insted of an AddressRange.
+ // This may combine multiple
+ // LineEntries of the same source line number to step over a longer address
+ // range in a single operation.
+ virtual lldb::ThreadPlanSP QueueThreadPlanForStepInRange(
+ bool abort_other_plans, const LineEntry &line_entry,
+ const SymbolContext &addr_context, const char *step_in_target,
+ lldb::RunMode stop_other_threads,
+ LazyBool step_in_avoids_code_without_debug_info = eLazyBoolCalculate,
+ LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
+
+ //------------------------------------------------------------------
+ /// Queue the plan used to step out of the function at the current PC of
+ /// \a thread.
+ ///
+ /// @param[in] abort_other_plans
+ /// \b true if we discard the currently queued plans and replace them with
+ /// this one.
+ /// Otherwise this plan will go on the end of the plan stack.
+ ///
+ /// @param[in] addr_context
+ /// When dealing with stepping through inlined functions the current PC is
+ /// not enough information to know
+ /// what "step" means. For instance a series of nested inline functions
+ /// might start at the same address.
+ // The \a addr_context provides the current symbol context the step
+ /// is supposed to be out of.
+ // FIXME: Currently unused.
+ ///
+ /// @param[in] first_insn
+ /// \b true if this is the first instruction of a function.
+ ///
+ /// @param[in] stop_other_threads
+ /// \b true if we will stop other threads while we single step this one.
+ ///
+ /// @param[in] stop_vote
+ /// @param[in] run_vote
+ /// See standard meanings for the stop & run votes in ThreadPlan.h.
+ ///
+ /// @param[in] step_out_avoids_code_without_debug_info
+ /// If eLazyBoolYes, if the step over steps out it will continue to step
+ /// out till it comes to a frame with debug info.
+ /// If eLazyBoolCalculate, it will consult the default set in the thread.
+ ///
+ /// @return
+ /// A shared pointer to the newly queued thread plan, or nullptr if the
+ /// plan could not be queued.
+ //------------------------------------------------------------------
+ virtual lldb::ThreadPlanSP QueueThreadPlanForStepOut(
+ bool abort_other_plans, SymbolContext *addr_context, bool first_insn,
+ bool stop_other_threads,
+ Vote stop_vote, // = eVoteYes,
+ Vote run_vote, // = eVoteNoOpinion);
+ uint32_t frame_idx,
+ LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
+
+ //------------------------------------------------------------------
+ /// Queue the plan used to step out of the function at the current PC of
+ /// a thread. This version does not consult the should stop here callback,
+ /// and should only
+ /// be used by other thread plans when they need to retain control of the step
+ /// out.
+ ///
+ /// @param[in] abort_other_plans
+ /// \b true if we discard the currently queued plans and replace them with
+ /// this one.
+ /// Otherwise this plan will go on the end of the plan stack.
+ ///
+ /// @param[in] addr_context
+ /// When dealing with stepping through inlined functions the current PC is
+ /// not enough information to know
+ /// what "step" means. For instance a series of nested inline functions
+ /// might start at the same address.
+ // The \a addr_context provides the current symbol context the step
+ /// is supposed to be out of.
+ // FIXME: Currently unused.
+ ///
+ /// @param[in] first_insn
+ /// \b true if this is the first instruction of a function.
+ ///
+ /// @param[in] stop_other_threads
+ /// \b true if we will stop other threads while we single step this one.
+ ///
+ /// @param[in] stop_vote
+ /// @param[in] run_vote
+ /// See standard meanings for the stop & run votes in ThreadPlan.h.
+ ///
+ /// @param[in] continue_to_next_branch
+ /// Normally this will enqueue a plan that will put a breakpoint on the
+ /// return address and continue
+ /// to there. If continue_to_next_branch is true, this is an operation not
+ /// involving the user --
+ /// e.g. stepping "next" in a source line and we instruction stepped into
+ /// another function --
+ /// so instead of putting a breakpoint on the return address, advance the
+ /// breakpoint to the
+ /// end of the source line that is doing the call, or until the next flow
+ /// control instruction.
+ /// If the return value from the function call is to be retrieved /
+ /// displayed to the user, you must stop
+ /// on the return address. The return value may be stored in volatile
+ /// registers which are overwritten
+ /// before the next branch instruction.
+ ///
+ /// @return
+ /// A shared pointer to the newly queued thread plan, or nullptr if the
+ /// plan could not be queued.
+ //------------------------------------------------------------------
+ virtual lldb::ThreadPlanSP QueueThreadPlanForStepOutNoShouldStop(
+ bool abort_other_plans, SymbolContext *addr_context, bool first_insn,
+ bool stop_other_threads,
+ Vote stop_vote, // = eVoteYes,
+ Vote run_vote, // = eVoteNoOpinion);
+ uint32_t frame_idx, bool continue_to_next_branch = false);
+
+ //------------------------------------------------------------------
+ /// Gets the plan used to step through the code that steps from a function
+ /// call site at the current PC into the actual function call.
+ ///
+ ///
+ /// @param[in] return_stack_id
+ /// The stack id that we will return to (by setting backstop breakpoints on
+ /// the return
+ /// address to that frame) if we fail to step through.
+ ///
+ /// @param[in] abort_other_plans
+ /// \b true if we discard the currently queued plans and replace them with
+ /// this one.
+ /// Otherwise this plan will go on the end of the plan stack.
+ ///
+ /// @param[in] stop_other_threads
+ /// \b true if we will stop other threads while we single step this one.
+ ///
+ /// @return
+ /// A shared pointer to the newly queued thread plan, or nullptr if the
+ /// plan could not be queued.
+ //------------------------------------------------------------------
+ virtual lldb::ThreadPlanSP
+ QueueThreadPlanForStepThrough(StackID &return_stack_id,
+ bool abort_other_plans,
+ bool stop_other_threads);
+
+ //------------------------------------------------------------------
+ /// Gets the plan used to continue from the current PC.
+ /// This is a simple plan, mostly useful as a backstop when you are continuing
+ /// for some particular purpose.
+ ///
+ /// @param[in] abort_other_plans
+ /// \b true if we discard the currently queued plans and replace them with
+ /// this one.
+ /// Otherwise this plan will go on the end of the plan stack.
+ ///
+ /// @param[in] target_addr
+ /// The address to which we're running.
+ ///
+ /// @param[in] stop_other_threads
+ /// \b true if we will stop other threads while we single step this one.
+ ///
+ /// @return
+ /// A shared pointer to the newly queued thread plan, or nullptr if the
+ /// plan could not be queued.
+ //------------------------------------------------------------------
+ virtual lldb::ThreadPlanSP
+ QueueThreadPlanForRunToAddress(bool abort_other_plans, Address &target_addr,
+ bool stop_other_threads);
+
+ virtual lldb::ThreadPlanSP
+ QueueThreadPlanForStepUntil(bool abort_other_plans,
+ lldb::addr_t *address_list, size_t num_addresses,
+ bool stop_others, uint32_t frame_idx);
+
+ virtual lldb::ThreadPlanSP
+ QueueThreadPlanForStepScripted(bool abort_other_plans, const char *class_name,
+ bool stop_other_threads);
+
+ //------------------------------------------------------------------
+ // Thread Plan accessors:
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Gets the plan which will execute next on the plan stack.
+ ///
+ /// @return
+ /// A pointer to the next executed plan.
+ //------------------------------------------------------------------
+ ThreadPlan *GetCurrentPlan();
+
+ //------------------------------------------------------------------
+ /// Unwinds the thread stack for the innermost expression plan currently
+ /// on the thread plan stack.
+ ///
+ /// @return
+ /// An error if the thread plan could not be unwound.
+ //------------------------------------------------------------------
+
+ Error UnwindInnermostExpression();
+
+ //------------------------------------------------------------------
+ /// Gets the outer-most plan that was popped off the plan stack in the
+ /// most recent stop. Useful for printing the stop reason accurately.
+ ///
+ /// @return
+ /// A pointer to the last completed plan.
+ //------------------------------------------------------------------
+ lldb::ThreadPlanSP GetCompletedPlan();
+
+ //------------------------------------------------------------------
+ /// Gets the outer-most return value from the completed plans
+ ///
+ /// @return
+ /// A ValueObjectSP, either empty if there is no return value,
+ /// or containing the return value.
+ //------------------------------------------------------------------
+ lldb::ValueObjectSP GetReturnValueObject();
+
+ //------------------------------------------------------------------
+ /// Gets the outer-most expression variable from the completed plans
+ ///
+ /// @return
+ /// A ExpressionVariableSP, either empty if there is no
+ /// plan completed an expression during the current stop
+ /// or the expression variable that was made for the completed expression.
+ //------------------------------------------------------------------
+ lldb::ExpressionVariableSP GetExpressionVariable();
+
+ //------------------------------------------------------------------
+ /// Checks whether the given plan is in the completed plans for this
+ /// stop.
+ ///
+ /// @param[in] plan
+ /// Pointer to the plan you're checking.
+ ///
+ /// @return
+ /// Returns true if the input plan is in the completed plan stack,
+ /// false otherwise.
+ //------------------------------------------------------------------
+ bool IsThreadPlanDone(ThreadPlan *plan);
+
+ //------------------------------------------------------------------
+ /// Checks whether the given plan is in the discarded plans for this
+ /// stop.
+ ///
+ /// @param[in] plan
+ /// Pointer to the plan you're checking.
+ ///
+ /// @return
+ /// Returns true if the input plan is in the discarded plan stack,
+ /// false otherwise.
+ //------------------------------------------------------------------
+ bool WasThreadPlanDiscarded(ThreadPlan *plan);
+
+ //------------------------------------------------------------------
+ /// Queues a generic thread plan.
+ ///
+ /// @param[in] plan_sp
+ /// The plan to queue.
+ ///
+ /// @param[in] abort_other_plans
+ /// \b true if we discard the currently queued plans and replace them with
+ /// this one.
+ /// Otherwise this plan will go on the end of the plan stack.
+ ///
+ /// @return
+ /// A pointer to the last completed plan.
+ //------------------------------------------------------------------
+ void QueueThreadPlan(lldb::ThreadPlanSP &plan_sp, bool abort_other_plans);
+
+ //------------------------------------------------------------------
+ /// Discards the plans queued on the plan stack of the current thread. This
+ /// is
+ /// arbitrated by the "Master" ThreadPlans, using the "OkayToDiscard" call.
+ // But if \a force is true, all thread plans are discarded.
+ //------------------------------------------------------------------
+ void DiscardThreadPlans(bool force);
+
+ //------------------------------------------------------------------
+ /// Discards the plans queued on the plan stack of the current thread up to
+ /// and
+ /// including up_to_plan_sp.
+ //
+ // @param[in] up_to_plan_sp
+ // Discard all plans up to and including this one.
+ //------------------------------------------------------------------
+ void DiscardThreadPlansUpToPlan(lldb::ThreadPlanSP &up_to_plan_sp);
+
+ void DiscardThreadPlansUpToPlan(ThreadPlan *up_to_plan_ptr);
+
+ //------------------------------------------------------------------
+ /// Discards the plans queued on the plan stack of the current thread up to
+ /// and
+ /// including the plan in that matches \a thread_index counting only
+ /// the non-Private plans.
+ ///
+ /// @param[in] up_to_plan_sp
+ /// Discard all plans up to and including this user plan given by this
+ /// index.
+ ///
+ /// @return
+ /// \b true if there was a thread plan with that user index, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ bool DiscardUserThreadPlansUpToIndex(uint32_t thread_index);
+
+ //------------------------------------------------------------------
+ /// Prints the current plan stack.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the plan stack info.
+ ///
+ //------------------------------------------------------------------
+ void DumpThreadPlans(
+ Stream *s,
+ lldb::DescriptionLevel desc_level = lldb::eDescriptionLevelVerbose,
+ bool include_internal = true, bool ignore_boring = false) const;
+
+ virtual bool CheckpointThreadState(ThreadStateCheckpoint &saved_state);
+
+ virtual bool
+ RestoreRegisterStateFromCheckpoint(ThreadStateCheckpoint &saved_state);
+
+ virtual bool
+ RestoreThreadStateFromCheckpoint(ThreadStateCheckpoint &saved_state);
+
+ void EnableTracer(bool value, bool single_step);
+
+ void SetTracer(lldb::ThreadPlanTracerSP &tracer_sp);
+
+ //------------------------------------------------------------------
+ // Get the thread index ID. The index ID that is guaranteed to not
+ // be re-used by a process. They start at 1 and increase with each
+ // new thread. This allows easy command line access by a unique ID
+ // that is easier to type than the actual system thread ID.
+ //------------------------------------------------------------------
+ uint32_t GetIndexID() const;
+
+ //------------------------------------------------------------------
+ // Get the originating thread's index ID.
+ // In the case of an "extended" thread -- a thread which represents
+ // the stack that enqueued/spawned work that is currently executing --
+ // we need to provide the IndexID of the thread that actually did
+ // this work. We don't want to just masquerade as that thread's IndexID
+ // by using it in our own IndexID because that way leads to madness -
+ // but the driver program which is iterating over extended threads
+ // may ask for the OriginatingThreadID to display that information
+ // to the user.
+ // Normal threads will return the same thing as GetIndexID();
+ //------------------------------------------------------------------
+ virtual uint32_t GetExtendedBacktraceOriginatingIndexID() {
+ return GetIndexID();
+ }
+
+ //------------------------------------------------------------------
+ // The API ID is often the same as the Thread::GetID(), but not in
+ // all cases. Thread::GetID() is the user visible thread ID that
+ // clients would want to see. The API thread ID is the thread ID
+ // that is used when sending data to/from the debugging protocol.
+ //------------------------------------------------------------------
+ virtual lldb::user_id_t GetProtocolID() const { return GetID(); }
+
+ //------------------------------------------------------------------
+ // lldb::ExecutionContextScope pure virtual functions
+ //------------------------------------------------------------------
+ lldb::TargetSP CalculateTarget() override;
+
+ lldb::ProcessSP CalculateProcess() override;
+
+ lldb::ThreadSP CalculateThread() override;
+
+ lldb::StackFrameSP CalculateStackFrame() override;
+
+ void CalculateExecutionContext(ExecutionContext &exe_ctx) override;
+
+ lldb::StackFrameSP
+ GetStackFrameSPForStackFramePtr(StackFrame *stack_frame_ptr);
+
+ size_t GetStatus(Stream &strm, uint32_t start_frame, uint32_t num_frames,
+ uint32_t num_frames_with_source,
+ bool stop_format);
+
+ size_t GetStackFrameStatus(Stream &strm, uint32_t first_frame,
+ uint32_t num_frames, bool show_frame_info,
+ uint32_t num_frames_with_source);
+
+ // We need a way to verify that even though we have a thread in a shared
+ // pointer that the object itself is still valid. Currently this won't be
+ // the case if DestroyThread() was called. DestroyThread is called when
+ // a thread has been removed from the Process' thread list.
+ bool IsValid() const { return !m_destroy_called; }
+
+ // Sets and returns a valid stop info based on the process stop ID and the
+ // current thread plan. If the thread stop ID does not match the process'
+ // stop ID, the private stop reason is not set and an invalid StopInfoSP may
+ // be returned.
+ //
+ // NOTE: This function must be called before the current thread plan is
+ // moved to the completed plan stack (in Thread::ShouldStop()).
+ //
+ // NOTE: If subclasses override this function, ensure they do not overwrite
+ // the m_actual_stop_info if it is valid. The stop info may be a
+ // "checkpointed and restored" stop info, so if it is still around it is
+ // right even if you have not calculated this yourself, or if it disagrees
+ // with what you might have calculated.
+ virtual lldb::StopInfoSP GetPrivateStopInfo();
+
+ //----------------------------------------------------------------------
+ // Ask the thread subclass to set its stop info.
+ //
+ // Thread subclasses should call Thread::SetStopInfo(...) with the
+ // reason the thread stopped.
+ //
+ // @return
+ // True if Thread::SetStopInfo(...) was called, false otherwise.
+ //----------------------------------------------------------------------
+ virtual bool CalculateStopInfo() = 0;
+
+ //----------------------------------------------------------------------
+ // Gets the temporary resume state for a thread.
+ //
+ // This value gets set in each thread by complex debugger logic in
+ // Thread::ShouldResume() and an appropriate thread resume state will get
+ // set in each thread every time the process is resumed prior to calling
+ // Process::DoResume(). The lldb_private::Process subclass should adhere
+ // to the thread resume state request which will be one of:
+ //
+ // eStateRunning - thread will resume when process is resumed
+ // eStateStepping - thread should step 1 instruction and stop when process
+ // is resumed
+ // eStateSuspended - thread should not execute any instructions when
+ // process is resumed
+ //----------------------------------------------------------------------
+ lldb::StateType GetTemporaryResumeState() const {
+ return m_temporary_resume_state;
+ }
+
+ void SetStopInfo(const lldb::StopInfoSP &stop_info_sp);
+
+ void SetShouldReportStop(Vote vote);
+
+ //----------------------------------------------------------------------
+ /// Sets the extended backtrace token for this thread
+ ///
+ /// Some Thread subclasses may maintain a token to help with providing
+ /// an extended backtrace. The SystemRuntime plugin will set/request this.
+ ///
+ /// @param [in] token
+ //----------------------------------------------------------------------
+ virtual void SetExtendedBacktraceToken(uint64_t token) {}
+
+ //----------------------------------------------------------------------
+ /// Gets the extended backtrace token for this thread
+ ///
+ /// Some Thread subclasses may maintain a token to help with providing
+ /// an extended backtrace. The SystemRuntime plugin will set/request this.
+ ///
+ /// @return
+ /// The token needed by the SystemRuntime to create an extended backtrace.
+ /// LLDB_INVALID_ADDRESS is returned if no token is available.
+ //----------------------------------------------------------------------
+ virtual uint64_t GetExtendedBacktraceToken() { return LLDB_INVALID_ADDRESS; }
protected:
- friend class ThreadPlan;
- friend class ThreadList;
- friend class ThreadEventData;
- friend class StackFrameList;
- friend class StackFrame;
- friend class OperatingSystem;
-
- // This is necessary to make sure thread assets get destroyed while the thread is still in good shape
- // to call virtual thread methods. This must be called by classes that derive from Thread in their destructor.
- virtual void DestroyThread ();
-
- void
- PushPlan (lldb::ThreadPlanSP &plan_sp);
-
- void
- PopPlan ();
-
- void
- DiscardPlan ();
-
- ThreadPlan *GetPreviousPlan (ThreadPlan *plan);
-
- typedef std::vector<lldb::ThreadPlanSP> plan_stack;
-
- virtual lldb_private::Unwind *
- GetUnwinder ();
-
- // Check to see whether the thread is still at the last breakpoint hit that stopped it.
- virtual bool
- IsStillAtLastBreakpointHit();
-
- // Some threads are threads that are made up by OperatingSystem plugins that
- // are threads that exist and are context switched out into memory. The
- // OperatingSystem plug-in need a ways to know if a thread is "real" or made
- // up.
- virtual bool
- IsOperatingSystemPluginThread () const
- {
- return false;
- }
-
- // Subclasses that have a way to get an extended info dictionary for this thread should
- // fill
- virtual lldb_private::StructuredData::ObjectSP
- FetchThreadExtendedInfo ()
- {
- return StructuredData::ObjectSP();
- }
+ friend class ThreadPlan;
+ friend class ThreadList;
+ friend class ThreadEventData;
+ friend class StackFrameList;
+ friend class StackFrame;
+ friend class OperatingSystem;
+
+ // This is necessary to make sure thread assets get destroyed while the thread
+ // is still in good shape
+ // to call virtual thread methods. This must be called by classes that derive
+ // from Thread in their destructor.
+ virtual void DestroyThread();
+
+ void PushPlan(lldb::ThreadPlanSP &plan_sp);
+
+ void PopPlan();
+
+ void DiscardPlan();
+
+ ThreadPlan *GetPreviousPlan(ThreadPlan *plan);
+
+ typedef std::vector<lldb::ThreadPlanSP> plan_stack;
+
+ virtual lldb_private::Unwind *GetUnwinder();
+
+ // Check to see whether the thread is still at the last breakpoint hit that
+ // stopped it.
+ virtual bool IsStillAtLastBreakpointHit();
+
+ // Some threads are threads that are made up by OperatingSystem plugins that
+ // are threads that exist and are context switched out into memory. The
+ // OperatingSystem plug-in need a ways to know if a thread is "real" or made
+ // up.
+ virtual bool IsOperatingSystemPluginThread() const { return false; }
+
+ // Subclasses that have a way to get an extended info dictionary for this
+ // thread should
+ // fill
+ virtual lldb_private::StructuredData::ObjectSP FetchThreadExtendedInfo() {
+ return StructuredData::ObjectSP();
+ }
+
+ lldb::StackFrameListSP GetStackFrameList();
+
+ void SetTemporaryResumeState(lldb::StateType new_state) {
+ m_temporary_resume_state = new_state;
+ }
+
+ void FunctionOptimizationWarning(lldb_private::StackFrame *frame);
+
+ //------------------------------------------------------------------
+ // Classes that inherit from Process can see and modify these
+ //------------------------------------------------------------------
+ lldb::ProcessWP m_process_wp; ///< The process that owns this thread.
+ lldb::StopInfoSP m_stop_info_sp; ///< The private stop reason for this thread
+ uint32_t m_stop_info_stop_id; // This is the stop id for which the StopInfo is
+ // valid. Can use this so you know that
+ // the thread's m_stop_info_sp is current and you don't have to fetch it again
+ uint32_t m_stop_info_override_stop_id; // The stop ID containing the last time
+ // the stop info was checked against
+ // the stop info override
+ const uint32_t m_index_id; ///< A unique 1 based index assigned to each thread
+ ///for easy UI/command line access.
+ lldb::RegisterContextSP m_reg_context_sp; ///< The register context for this
+ ///thread's current register state.
+ lldb::StateType m_state; ///< The state of our process.
+ mutable std::recursive_mutex
+ m_state_mutex; ///< Multithreaded protection for m_state.
+ plan_stack m_plan_stack; ///< The stack of plans this thread is executing.
+ plan_stack m_completed_plan_stack; ///< Plans that have been completed by this
+ ///stop. They get deleted when the thread
+ ///resumes.
+ plan_stack m_discarded_plan_stack; ///< Plans that have been discarded by this
+ ///stop. They get deleted when the thread
+ ///resumes.
+ mutable std::recursive_mutex
+ m_frame_mutex; ///< Multithreaded protection for m_state.
+ lldb::StackFrameListSP m_curr_frames_sp; ///< The stack frames that get lazily
+ ///populated after a thread stops.
+ lldb::StackFrameListSP m_prev_frames_sp; ///< The previous stack frames from
+ ///the last time this thread stopped.
+ int m_resume_signal; ///< The signal that should be used when continuing this
+ ///thread.
+ lldb::StateType m_resume_state; ///< This state is used to force a thread to
+ ///be suspended from outside the ThreadPlan
+ ///logic.
+ lldb::StateType m_temporary_resume_state; ///< This state records what the
+ ///thread was told to do by the
+ ///thread plan logic for the current
+ ///resume.
+ /// It gets set in Thread::ShouldResume.
+ std::unique_ptr<lldb_private::Unwind> m_unwinder_ap;
+ bool m_destroy_called; // This is used internally to make sure derived Thread
+ // classes call DestroyThread.
+ LazyBool m_override_should_notify;
- lldb::StackFrameListSP
- GetStackFrameList ();
-
- void
- SetTemporaryResumeState(lldb::StateType new_state)
- {
- m_temporary_resume_state = new_state;
- }
-
- void
- FunctionOptimizationWarning (lldb_private::StackFrame *frame);
-
- //------------------------------------------------------------------
- // Classes that inherit from Process can see and modify these
- //------------------------------------------------------------------
- lldb::ProcessWP m_process_wp; ///< The process that owns this thread.
- lldb::StopInfoSP m_stop_info_sp; ///< The private stop reason for this thread
- uint32_t m_stop_info_stop_id; // This is the stop id for which the StopInfo is valid. Can use this so you know that
- // the thread's m_stop_info_sp is current and you don't have to fetch it again
- uint32_t m_stop_info_override_stop_id; // The stop ID containing the last time the stop info was checked against the stop info override
- const uint32_t m_index_id; ///< A unique 1 based index assigned to each thread for easy UI/command line access.
- lldb::RegisterContextSP m_reg_context_sp; ///< The register context for this thread's current register state.
- lldb::StateType m_state; ///< The state of our process.
- mutable std::recursive_mutex m_state_mutex; ///< Multithreaded protection for m_state.
- plan_stack m_plan_stack; ///< The stack of plans this thread is executing.
- plan_stack m_completed_plan_stack; ///< Plans that have been completed by this stop. They get deleted when the thread resumes.
- plan_stack m_discarded_plan_stack; ///< Plans that have been discarded by this stop. They get deleted when the thread resumes.
- mutable std::recursive_mutex m_frame_mutex; ///< Multithreaded protection for m_state.
- lldb::StackFrameListSP m_curr_frames_sp; ///< The stack frames that get lazily populated after a thread stops.
- lldb::StackFrameListSP m_prev_frames_sp; ///< The previous stack frames from the last time this thread stopped.
- int m_resume_signal; ///< The signal that should be used when continuing this thread.
- lldb::StateType m_resume_state; ///< This state is used to force a thread to be suspended from outside the ThreadPlan logic.
- lldb::StateType m_temporary_resume_state; ///< This state records what the thread was told to do by the thread plan logic for the current resume.
- /// It gets set in Thread::ShouldResume.
- std::unique_ptr<lldb_private::Unwind> m_unwinder_ap;
- bool m_destroy_called; // This is used internally to make sure derived Thread classes call DestroyThread.
- LazyBool m_override_should_notify;
private:
- bool m_extended_info_fetched; // Have we tried to retrieve the m_extended_info for this thread?
- StructuredData::ObjectSP m_extended_info; // The extended info for this thread
+ bool m_extended_info_fetched; // Have we tried to retrieve the m_extended_info
+ // for this thread?
+ StructuredData::ObjectSP m_extended_info; // The extended info for this thread
private:
- bool
- PlanIsBasePlan (ThreadPlan *plan_ptr);
+ bool PlanIsBasePlan(ThreadPlan *plan_ptr);
+
+ void BroadcastSelectedFrameChange(StackID &new_frame_id);
- void
- BroadcastSelectedFrameChange(StackID &new_frame_id);
-
- DISALLOW_COPY_AND_ASSIGN (Thread);
+ DISALLOW_COPY_AND_ASSIGN(Thread);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/ThreadCollection.h b/include/lldb/Target/ThreadCollection.h
index f24167f120a8..e3965b57e7a6 100644
--- a/include/lldb/Target/ThreadCollection.h
+++ b/include/lldb/Target/ThreadCollection.h
@@ -13,61 +13,48 @@
#include <mutex>
#include <vector>
-#include "lldb/lldb-private.h"
#include "lldb/Utility/Iterable.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-
-class ThreadCollection
-{
+
+class ThreadCollection {
public:
- typedef std::vector<lldb::ThreadSP> collection;
- typedef LockingAdaptedIterable<collection, lldb::ThreadSP, vector_adapter, std::recursive_mutex> ThreadIterable;
-
- ThreadCollection();
-
- ThreadCollection(collection threads);
-
- virtual
- ~ThreadCollection()
- {
- }
-
- uint32_t
- GetSize();
-
- void
- AddThread (const lldb::ThreadSP &thread_sp);
-
- void
- AddThreadSortedByIndexID (const lldb::ThreadSP &thread_sp);
-
- void
- InsertThread (const lldb::ThreadSP &thread_sp, uint32_t idx);
-
- // Note that "idx" is not the same as the "thread_index". It is a zero
- // based index to accessing the current threads, whereas "thread_index"
- // is a unique index assigned
- lldb::ThreadSP
- GetThreadAtIndex (uint32_t idx);
-
- virtual ThreadIterable
- Threads ()
- {
- return ThreadIterable(m_threads, GetMutex());
- }
-
- virtual std::recursive_mutex &
- GetMutex()
- {
- return m_mutex;
- }
+ typedef std::vector<lldb::ThreadSP> collection;
+ typedef LockingAdaptedIterable<collection, lldb::ThreadSP, vector_adapter,
+ std::recursive_mutex>
+ ThreadIterable;
+
+ ThreadCollection();
+
+ ThreadCollection(collection threads);
+
+ virtual ~ThreadCollection() {}
+
+ uint32_t GetSize();
+
+ void AddThread(const lldb::ThreadSP &thread_sp);
+
+ void AddThreadSortedByIndexID(const lldb::ThreadSP &thread_sp);
+
+ void InsertThread(const lldb::ThreadSP &thread_sp, uint32_t idx);
+
+ // Note that "idx" is not the same as the "thread_index". It is a zero
+ // based index to accessing the current threads, whereas "thread_index"
+ // is a unique index assigned
+ lldb::ThreadSP GetThreadAtIndex(uint32_t idx);
+
+ virtual ThreadIterable Threads() {
+ return ThreadIterable(m_threads, GetMutex());
+ }
+
+ virtual std::recursive_mutex &GetMutex() const { return m_mutex; }
protected:
- collection m_threads;
- std::recursive_mutex m_mutex;
+ collection m_threads;
+ mutable std::recursive_mutex m_mutex;
};
-
+
} // namespace lldb_private
-#endif // liblldb_ThreadCollection_h_
+#endif // liblldb_ThreadCollection_h_
diff --git a/include/lldb/Target/ThreadList.h b/include/lldb/Target/ThreadList.h
index 140fdaa444d0..9e3c940c3c2d 100644
--- a/include/lldb/Target/ThreadList.h
+++ b/include/lldb/Target/ThreadList.h
@@ -13,183 +13,149 @@
#include <mutex>
#include <vector>
-#include "lldb/lldb-private.h"
#include "lldb/Core/UserID.h"
-#include "lldb/Utility/Iterable.h"
-#include "lldb/Target/ThreadCollection.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Target/ThreadCollection.h"
+#include "lldb/Utility/Iterable.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
// This is a thread list with lots of functionality for use only by the process
// for which this is the thread list. A generic container class with iterator
// functionality is ThreadCollection.
-class ThreadList : public ThreadCollection
-{
-friend class Process;
+class ThreadList : public ThreadCollection {
+ friend class Process;
public:
+ ThreadList(Process *process);
+
+ ThreadList(const ThreadList &rhs);
+
+ ~ThreadList() override;
+
+ const ThreadList &operator=(const ThreadList &rhs);
+
+ uint32_t GetSize(bool can_update = true);
+
+ // Return the selected thread if there is one. Otherwise, return the thread
+ // selected at index 0.
+ lldb::ThreadSP GetSelectedThread();
+
+ // Manage the thread to use for running expressions. This is usually the
+ // Selected thread,
+ // but sometimes (e.g. when evaluating breakpoint conditions & stop hooks) it
+ // isn't.
+ class ExpressionExecutionThreadPusher {
+ public:
+ ExpressionExecutionThreadPusher(ThreadList &thread_list, lldb::tid_t tid)
+ : m_thread_list(&thread_list), m_tid(tid) {
+ m_thread_list->PushExpressionExecutionThread(m_tid);
+ }
+
+ ExpressionExecutionThreadPusher(lldb::ThreadSP thread_sp);
+
+ ~ExpressionExecutionThreadPusher() {
+ if (m_thread_list && m_tid != LLDB_INVALID_THREAD_ID)
+ m_thread_list->PopExpressionExecutionThread(m_tid);
+ }
+
+ private:
+ ThreadList *m_thread_list;
+ lldb::tid_t m_tid;
+ };
+
+ lldb::ThreadSP GetExpressionExecutionThread();
- ThreadList (Process *process);
-
- ThreadList (const ThreadList &rhs);
-
- ~ThreadList() override;
-
- const ThreadList&
- operator = (const ThreadList& rhs);
-
- uint32_t
- GetSize(bool can_update = true);
-
- // Return the selected thread if there is one. Otherwise, return the thread
- // selected at index 0.
- lldb::ThreadSP
- GetSelectedThread ();
-
- // Manage the thread to use for running expressions. This is usually the Selected thread,
- // but sometimes (e.g. when evaluating breakpoint conditions & stop hooks) it isn't.
- class ExpressionExecutionThreadPusher
- {
- public:
- ExpressionExecutionThreadPusher(ThreadList &thread_list, lldb::tid_t tid) :
- m_thread_list(&thread_list),
- m_tid(tid)
- {
- m_thread_list->PushExpressionExecutionThread(m_tid);
- }
-
- ExpressionExecutionThreadPusher(lldb::ThreadSP thread_sp);
-
- ~ExpressionExecutionThreadPusher()
- {
- if (m_thread_list && m_tid != LLDB_INVALID_THREAD_ID)
- m_thread_list->PopExpressionExecutionThread(m_tid);
- }
-
- private:
- ThreadList *m_thread_list;
- lldb::tid_t m_tid;
- };
-
- lldb::ThreadSP
- GetExpressionExecutionThread();
-
protected:
- void
- PushExpressionExecutionThread(lldb::tid_t tid);
-
- void
- PopExpressionExecutionThread(lldb::tid_t tid);
+ void PushExpressionExecutionThread(lldb::tid_t tid);
+
+ void PopExpressionExecutionThread(lldb::tid_t tid);
public:
- bool
- SetSelectedThreadByID (lldb::tid_t tid, bool notify = false);
-
- bool
- SetSelectedThreadByIndexID (uint32_t index_id, bool notify = false);
-
- void
- Clear();
-
- void
- Flush();
-
- void
- Destroy();
-
- // Note that "idx" is not the same as the "thread_index". It is a zero
- // based index to accessing the current threads, whereas "thread_index"
- // is a unique index assigned
- lldb::ThreadSP
- GetThreadAtIndex (uint32_t idx, bool can_update = true);
-
- lldb::ThreadSP
- FindThreadByID (lldb::tid_t tid, bool can_update = true);
-
- lldb::ThreadSP
- FindThreadByProtocolID (lldb::tid_t tid, bool can_update = true);
-
- lldb::ThreadSP
- RemoveThreadByID (lldb::tid_t tid, bool can_update = true);
-
- lldb::ThreadSP
- RemoveThreadByProtocolID (lldb::tid_t tid, bool can_update = true);
-
- lldb::ThreadSP
- FindThreadByIndexID (uint32_t index_id, bool can_update = true);
-
- lldb::ThreadSP
- GetThreadSPForThreadPtr (Thread *thread_ptr);
-
- bool
- ShouldStop (Event *event_ptr);
-
- Vote
- ShouldReportStop (Event *event_ptr);
-
- Vote
- ShouldReportRun (Event *event_ptr);
-
- void
- RefreshStateAfterStop ();
-
- //------------------------------------------------------------------
- /// The thread list asks tells all the threads it is about to resume.
- /// If a thread can "resume" without having to resume the target, it
- /// will return false for WillResume, and then the process will not be
- /// restarted.
- ///
- /// @return
- /// \b true instructs the process to resume normally,
- /// \b false means start & stopped events will be generated, but
- /// the process will not actually run. The thread must then return
- /// the correct StopInfo when asked.
- ///
- //------------------------------------------------------------------
- bool
- WillResume ();
-
- void
- DidResume ();
-
- void
- DidStop ();
-
- void
- DiscardThreadPlans();
-
- uint32_t
- GetStopID () const;
-
- void
- SetStopID (uint32_t stop_id);
-
- std::recursive_mutex &
- GetMutex() override;
-
- void
- Update (ThreadList &rhs);
-
-protected:
+ bool SetSelectedThreadByID(lldb::tid_t tid, bool notify = false);
- void
- SetShouldReportStop (Vote vote);
+ bool SetSelectedThreadByIndexID(uint32_t index_id, bool notify = false);
- void
- NotifySelectedThreadChanged (lldb::tid_t tid);
+ void Clear();
- //------------------------------------------------------------------
- // Classes that inherit from Process can see and modify these
- //------------------------------------------------------------------
- Process *m_process; ///< The process that manages this thread list.
- uint32_t m_stop_id; ///< The process stop ID that this thread list is valid for.
- lldb::tid_t m_selected_tid; ///< For targets that need the notion of a current thread.
- std::vector<lldb::tid_t> m_expression_tid_stack;
+ void Flush();
-private:
+ void Destroy();
+
+ // Note that "idx" is not the same as the "thread_index". It is a zero
+ // based index to accessing the current threads, whereas "thread_index"
+ // is a unique index assigned
+ lldb::ThreadSP GetThreadAtIndex(uint32_t idx, bool can_update = true);
+
+ lldb::ThreadSP FindThreadByID(lldb::tid_t tid, bool can_update = true);
+
+ lldb::ThreadSP FindThreadByProtocolID(lldb::tid_t tid,
+ bool can_update = true);
- ThreadList ();
+ lldb::ThreadSP RemoveThreadByID(lldb::tid_t tid, bool can_update = true);
+
+ lldb::ThreadSP RemoveThreadByProtocolID(lldb::tid_t tid,
+ bool can_update = true);
+
+ lldb::ThreadSP FindThreadByIndexID(uint32_t index_id, bool can_update = true);
+
+ lldb::ThreadSP GetThreadSPForThreadPtr(Thread *thread_ptr);
+
+ bool ShouldStop(Event *event_ptr);
+
+ Vote ShouldReportStop(Event *event_ptr);
+
+ Vote ShouldReportRun(Event *event_ptr);
+
+ void RefreshStateAfterStop();
+
+ //------------------------------------------------------------------
+ /// The thread list asks tells all the threads it is about to resume.
+ /// If a thread can "resume" without having to resume the target, it
+ /// will return false for WillResume, and then the process will not be
+ /// restarted.
+ ///
+ /// @return
+ /// \b true instructs the process to resume normally,
+ /// \b false means start & stopped events will be generated, but
+ /// the process will not actually run. The thread must then return
+ /// the correct StopInfo when asked.
+ ///
+ //------------------------------------------------------------------
+ bool WillResume();
+
+ void DidResume();
+
+ void DidStop();
+
+ void DiscardThreadPlans();
+
+ uint32_t GetStopID() const;
+
+ void SetStopID(uint32_t stop_id);
+
+ std::recursive_mutex &GetMutex() const override;
+
+ void Update(ThreadList &rhs);
+
+protected:
+ void SetShouldReportStop(Vote vote);
+
+ void NotifySelectedThreadChanged(lldb::tid_t tid);
+
+ //------------------------------------------------------------------
+ // Classes that inherit from Process can see and modify these
+ //------------------------------------------------------------------
+ Process *m_process; ///< The process that manages this thread list.
+ uint32_t
+ m_stop_id; ///< The process stop ID that this thread list is valid for.
+ lldb::tid_t
+ m_selected_tid; ///< For targets that need the notion of a current thread.
+ std::vector<lldb::tid_t> m_expression_tid_stack;
+
+private:
+ ThreadList();
};
} // namespace lldb_private
diff --git a/include/lldb/Target/ThreadPlan.h b/include/lldb/Target/ThreadPlan.h
index 6dac4a299e52..fd25cd08f2ba 100644
--- a/include/lldb/Target/ThreadPlan.h
+++ b/include/lldb/Target/ThreadPlan.h
@@ -17,13 +17,13 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/UserID.h"
#include "lldb/Target/Process.h"
+#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanTracer.h"
-#include "lldb/Target/StopInfo.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -37,613 +37,593 @@ namespace lldb_private {
//
// Plan Stack:
//
-// The thread maintaining a thread plan stack, and you program the actions of a particular thread
+// The thread maintaining a thread plan stack, and you program the actions of a
+// particular thread
// by pushing plans onto the plan stack.
-// There is always a "Current" plan, which is the head of the plan stack, though in some cases
+// There is always a "Current" plan, which is the head of the plan stack,
+// though in some cases
// a plan may defer to plans higher in the stack for some piece of information.
//
-// The plan stack is never empty, there is always a Base Plan which persists through the life
+// The plan stack is never empty, there is always a Base Plan which persists
+// through the life
// of the running process.
//
//
// Creating Plans:
//
-// The thread plan is generally created and added to the plan stack through the QueueThreadPlanFor... API
-// in lldb::Thread. Those API's will return the plan that performs the named operation in a manner
-// appropriate for the current process. The plans in lldb/source/Target are generic
+// The thread plan is generally created and added to the plan stack through the
+// QueueThreadPlanFor... API
+// in lldb::Thread. Those API's will return the plan that performs the named
+// operation in a manner
+// appropriate for the current process. The plans in lldb/source/Target are
+// generic
// implementations, but a Process plugin can override them.
//
-// ValidatePlan is then called. If it returns false, the plan is unshipped. This is a little
+// ValidatePlan is then called. If it returns false, the plan is unshipped.
+// This is a little
// convenience which keeps us from having to error out of the constructor.
//
-// Then the plan is added to the plan stack. When the plan is added to the plan stack its DidPush
-// will get called. This is useful if a plan wants to push any additional plans as it is constructed,
-// since you need to make sure you're already on the stack before you push additional plans.
+// Then the plan is added to the plan stack. When the plan is added to the
+// plan stack its DidPush
+// will get called. This is useful if a plan wants to push any additional
+// plans as it is constructed,
+// since you need to make sure you're already on the stack before you push
+// additional plans.
//
// Completed Plans:
//
-// When the target process stops the plans are queried, among other things, for whether their job is done.
-// If it is they are moved from the plan stack to the Completed Plan stack in reverse order from their position
-// on the plan stack (since multiple plans may be done at a given stop.) This is used primarily so that
-// the lldb::Thread::StopInfo for the thread can be set properly. If one plan pushes another to achieve part of
-// its job, but it doesn't want that sub-plan to be the one that sets the StopInfo, then call SetPrivate on the
-// sub-plan when you create it, and the Thread will pass over that plan in reporting the reason for the stop.
+// When the target process stops the plans are queried, among other things, for
+// whether their job is done.
+// If it is they are moved from the plan stack to the Completed Plan stack in
+// reverse order from their position
+// on the plan stack (since multiple plans may be done at a given stop.) This
+// is used primarily so that
+// the lldb::Thread::StopInfo for the thread can be set properly. If one plan
+// pushes another to achieve part of
+// its job, but it doesn't want that sub-plan to be the one that sets the
+// StopInfo, then call SetPrivate on the
+// sub-plan when you create it, and the Thread will pass over that plan in
+// reporting the reason for the stop.
//
// Discarded plans:
//
-// Your plan may also get discarded, i.e. moved from the plan stack to the "discarded plan stack". This can
-// happen, for instance, if the plan is calling a function and the function call crashes and you want
-// to unwind the attempt to call. So don't assume that your plan will always successfully stop. Which leads to:
+// Your plan may also get discarded, i.e. moved from the plan stack to the
+// "discarded plan stack". This can
+// happen, for instance, if the plan is calling a function and the function
+// call crashes and you want
+// to unwind the attempt to call. So don't assume that your plan will always
+// successfully stop. Which leads to:
//
// Cleaning up after your plans:
//
-// When the plan is moved from the plan stack its WillPop method is always called, no matter why. Once it is
-// moved off the plan stack it is done, and won't get a chance to run again. So you should
-// undo anything that affects target state in this method. But be sure to leave the plan able to correctly
+// When the plan is moved from the plan stack its WillPop method is always
+// called, no matter why. Once it is
+// moved off the plan stack it is done, and won't get a chance to run again.
+// So you should
+// undo anything that affects target state in this method. But be sure to
+// leave the plan able to correctly
// fill the StopInfo, however.
-// N.B. Don't wait to do clean up target state till the destructor, since that will usually get called when
-// the target resumes, and you want to leave the target state correct for new plans in the time between when
+// N.B. Don't wait to do clean up target state till the destructor, since that
+// will usually get called when
+// the target resumes, and you want to leave the target state correct for new
+// plans in the time between when
// your plan gets unshipped and the next resume.
//
-// Over the lifetime of the plan, various methods of the ThreadPlan are then called in response to changes of state in
+// Over the lifetime of the plan, various methods of the ThreadPlan are then
+// called in response to changes of state in
// the process we are debugging as follows:
//
// Resuming:
//
-// When the target process is about to be restarted, the plan's WillResume method is called,
-// giving the plan a chance to prepare for the run. If WillResume returns false, then the
-// process is not restarted. Be sure to set an appropriate error value in the Process if
-// you have to do this. Note, ThreadPlans actually implement DoWillResume, WillResume wraps that call.
-//
-// Next the "StopOthers" method of all the threads are polled, and if one thread's Current plan
-// returns "true" then only that thread gets to run. If more than one returns "true" the threads that want to run solo
+// When the target process is about to be restarted, the plan's WillResume
+// method is called,
+// giving the plan a chance to prepare for the run. If WillResume returns
+// false, then the
+// process is not restarted. Be sure to set an appropriate error value in the
+// Process if
+// you have to do this. Note, ThreadPlans actually implement DoWillResume,
+// WillResume wraps that call.
+//
+// Next the "StopOthers" method of all the threads are polled, and if one
+// thread's Current plan
+// returns "true" then only that thread gets to run. If more than one returns
+// "true" the threads that want to run solo
// get run one by one round robin fashion. Otherwise all are let to run.
//
-// Note, the way StopOthers is implemented, the base class implementation just asks the previous plan. So if your plan
-// has no opinion about whether it should run stopping others or not, just don't implement StopOthers, and the parent
+// Note, the way StopOthers is implemented, the base class implementation just
+// asks the previous plan. So if your plan
+// has no opinion about whether it should run stopping others or not, just
+// don't implement StopOthers, and the parent
// will be asked.
//
-// Finally, for each thread that is running, it run state is set to the return of RunState from the
+// Finally, for each thread that is running, it run state is set to the return
+// of RunState from the
// thread's Current plan.
//
// Responding to a stop:
//
// When the target process stops, the plan is called in the following stages:
//
-// First the thread asks the Current Plan if it can handle this stop by calling PlanExplainsStop.
-// If the Current plan answers "true" then it is asked if the stop should percolate all the way to the
-// user by calling the ShouldStop method. If the current plan doesn't explain the stop, then we query down
-// the plan stack for a plan that does explain the stop. The plan that does explain the stop then needs to
-// figure out what to do about the plans below it in the stack. If the stop is recoverable, then the plan that
-// understands it can just do what it needs to set up to restart, and then continue.
-// Otherwise, the plan that understood the stop should call DiscardPlanStack to clean up the stack below it.
-// Note, plans actually implement DoPlanExplainsStop, the result is cached in PlanExplainsStop so the DoPlanExplainsStop
+// First the thread asks the Current Plan if it can handle this stop by calling
+// PlanExplainsStop.
+// If the Current plan answers "true" then it is asked if the stop should
+// percolate all the way to the
+// user by calling the ShouldStop method. If the current plan doesn't explain
+// the stop, then we query down
+// the plan stack for a plan that does explain the stop. The plan that does
+// explain the stop then needs to
+// figure out what to do about the plans below it in the stack. If the stop is
+// recoverable, then the plan that
+// understands it can just do what it needs to set up to restart, and then
+// continue.
+// Otherwise, the plan that understood the stop should call DiscardPlanStack to
+// clean up the stack below it.
+// Note, plans actually implement DoPlanExplainsStop, the result is cached in
+// PlanExplainsStop so the DoPlanExplainsStop
// itself will only get called once per stop.
//
// Master plans:
//
-// In the normal case, when we decide to stop, we will collapse the plan stack up to the point of the plan that understood
-// the stop reason. However, if a plan wishes to stay on the stack after an event it didn't directly handle
-// it can designate itself a "Master" plan by responding true to IsMasterPlan, and then if it wants not to be
-// discarded, it can return true to OkayToDiscard, and it and all its dependent plans will be preserved when
+// In the normal case, when we decide to stop, we will collapse the plan stack
+// up to the point of the plan that understood
+// the stop reason. However, if a plan wishes to stay on the stack after an
+// event it didn't directly handle
+// it can designate itself a "Master" plan by responding true to IsMasterPlan,
+// and then if it wants not to be
+// discarded, it can return true to OkayToDiscard, and it and all its dependent
+// plans will be preserved when
// we resume execution.
//
-// The other effect of being a master plan is that when the Master plan is done , if it has set "OkayToDiscard" to false,
-// then it will be popped & execution will stop and return to the user. Remember that if OkayToDiscard is false, the
-// plan will be popped and control will be given to the next plan above it on the stack So setting OkayToDiscard to
+// The other effect of being a master plan is that when the Master plan is done
+// , if it has set "OkayToDiscard" to false,
+// then it will be popped & execution will stop and return to the user.
+// Remember that if OkayToDiscard is false, the
+// plan will be popped and control will be given to the next plan above it on
+// the stack So setting OkayToDiscard to
// false means the user will regain control when the MasterPlan is completed.
//
-// Between these two controls this allows things like: a MasterPlan/DontDiscard Step Over to hit a breakpoint, stop and
-// return control to the user, but then when the user continues, the step out succeeds.
-// Even more tricky, when the breakpoint is hit, the user can continue to step in/step over/etc, and finally when they
+// Between these two controls this allows things like: a MasterPlan/DontDiscard
+// Step Over to hit a breakpoint, stop and
+// return control to the user, but then when the user continues, the step out
+// succeeds.
+// Even more tricky, when the breakpoint is hit, the user can continue to step
+// in/step over/etc, and finally when they
// continue, they will finish up the Step Over.
//
-// FIXME: MasterPlan & OkayToDiscard aren't really orthogonal. MasterPlan designation means that this plan controls
-// it's fate and the fate of plans below it. OkayToDiscard tells whether the MasterPlan wants to stay on the stack. I
-// originally thought "MasterPlan-ness" would need to be a fixed characteristic of a ThreadPlan, in which case you needed
-// the extra control. But that doesn't seem to be true. So we should be able to convert to only MasterPlan status to mean
-// the current "MasterPlan/DontDiscard". Then no plans would be MasterPlans by default, and you would set the ones you
+// FIXME: MasterPlan & OkayToDiscard aren't really orthogonal. MasterPlan
+// designation means that this plan controls
+// it's fate and the fate of plans below it. OkayToDiscard tells whether the
+// MasterPlan wants to stay on the stack. I
+// originally thought "MasterPlan-ness" would need to be a fixed characteristic
+// of a ThreadPlan, in which case you needed
+// the extra control. But that doesn't seem to be true. So we should be able
+// to convert to only MasterPlan status to mean
+// the current "MasterPlan/DontDiscard". Then no plans would be MasterPlans by
+// default, and you would set the ones you
// wanted to be "user level" in this way.
//
//
// Actually Stopping:
//
-// If a plan says responds "true" to ShouldStop, then it is asked if it's job is complete by calling
-// MischiefManaged. If that returns true, the thread is popped from the plan stack and added to the
-// Completed Plan Stack. Then the next plan in the stack is asked if it ShouldStop, and it returns "true",
-// it is asked if it is done, and if yes popped, and so on till we reach a plan that is not done.
-//
-// Since you often know in the ShouldStop method whether your plan is complete, as a convenience you can call
-// SetPlanComplete and the ThreadPlan implementation of MischiefManaged will return "true", without your having
-// to redo the calculation when your sub-classes MischiefManaged is called. If you call SetPlanComplete, you can
-// later use IsPlanComplete to determine whether the plan is complete. This is only a convenience for sub-classes,
+// If a plan says responds "true" to ShouldStop, then it is asked if it's job
+// is complete by calling
+// MischiefManaged. If that returns true, the thread is popped from the plan
+// stack and added to the
+// Completed Plan Stack. Then the next plan in the stack is asked if it
+// ShouldStop, and it returns "true",
+// it is asked if it is done, and if yes popped, and so on till we reach a plan
+// that is not done.
+//
+// Since you often know in the ShouldStop method whether your plan is complete,
+// as a convenience you can call
+// SetPlanComplete and the ThreadPlan implementation of MischiefManaged will
+// return "true", without your having
+// to redo the calculation when your sub-classes MischiefManaged is called. If
+// you call SetPlanComplete, you can
+// later use IsPlanComplete to determine whether the plan is complete. This is
+// only a convenience for sub-classes,
// the logic in lldb::Thread will only call MischiefManaged.
//
-// One slightly tricky point is you have to be careful using SetPlanComplete in PlanExplainsStop because you
-// are not guaranteed that PlanExplainsStop for a plan will get called before ShouldStop gets called. If your sub-plan
-// explained the stop and then popped itself, only your ShouldStop will get called.
-//
-// If ShouldStop for any thread returns "true", then the WillStop method of the Current plan of
-// all threads will be called, the stop event is placed on the Process's public broadcaster, and
+// One slightly tricky point is you have to be careful using SetPlanComplete in
+// PlanExplainsStop because you
+// are not guaranteed that PlanExplainsStop for a plan will get called before
+// ShouldStop gets called. If your sub-plan
+// explained the stop and then popped itself, only your ShouldStop will get
+// called.
+//
+// If ShouldStop for any thread returns "true", then the WillStop method of the
+// Current plan of
+// all threads will be called, the stop event is placed on the Process's public
+// broadcaster, and
// control returns to the upper layers of the debugger.
//
// Reporting the stop:
//
-// When the process stops, the thread is given a StopReason, in the form of a StopInfo object. If there is a completed
-// plan corresponding to the stop, then the "actual" stop reason will be suppressed, and instead a StopInfoThreadPlan
-// object will be cons'ed up from the highest completed plan in the stack. However, if the plan doesn't want to be
-// the stop reason, then it can call SetPlanComplete and pass in "false" for the "success" parameter. In that case,
-// the real stop reason will be used instead. One exapmle of this is the "StepRangeStepIn" thread plan. If it stops
-// because of a crash or breakpoint hit, it wants to unship itself, because it isn't so useful to have step in keep going
-// after a breakpoint hit. But it can't be the reason for the stop or no-one would see that they had hit a breakpoint.
+// When the process stops, the thread is given a StopReason, in the form of a
+// StopInfo object. If there is a completed
+// plan corresponding to the stop, then the "actual" stop reason will be
+// suppressed, and instead a StopInfoThreadPlan
+// object will be cons'ed up from the highest completed plan in the stack.
+// However, if the plan doesn't want to be
+// the stop reason, then it can call SetPlanComplete and pass in "false" for
+// the "success" parameter. In that case,
+// the real stop reason will be used instead. One exapmle of this is the
+// "StepRangeStepIn" thread plan. If it stops
+// because of a crash or breakpoint hit, it wants to unship itself, because it
+// isn't so useful to have step in keep going
+// after a breakpoint hit. But it can't be the reason for the stop or no-one
+// would see that they had hit a breakpoint.
//
// Cleaning up the plan stack:
//
-// One of the complications of MasterPlans is that you may get past the limits of a plan without triggering it to clean
-// itself up. For instance, if you are doing a MasterPlan StepOver, and hit a breakpoint in a called function, then
-// step over enough times to step out of the initial StepOver range, each of the step overs will explain the stop &
-// take themselves off the stack, but control would never be returned to the original StepOver. Eventually, the user
-// will continue, and when that continue stops, the old stale StepOver plan that was left on the stack will get woken
-// up and notice it is done. But that can leave junk on the stack for a while. To avoid that, the plans implement a
-// "IsPlanStale" method, that can check whether it is relevant anymore. On stop, after the regular plan negotiation,
-// the remaining plan stack is consulted and if any plan says it is stale, it and the plans below it are discarded from
+// One of the complications of MasterPlans is that you may get past the limits
+// of a plan without triggering it to clean
+// itself up. For instance, if you are doing a MasterPlan StepOver, and hit a
+// breakpoint in a called function, then
+// step over enough times to step out of the initial StepOver range, each of
+// the step overs will explain the stop &
+// take themselves off the stack, but control would never be returned to the
+// original StepOver. Eventually, the user
+// will continue, and when that continue stops, the old stale StepOver plan
+// that was left on the stack will get woken
+// up and notice it is done. But that can leave junk on the stack for a while.
+// To avoid that, the plans implement a
+// "IsPlanStale" method, that can check whether it is relevant anymore. On
+// stop, after the regular plan negotiation,
+// the remaining plan stack is consulted and if any plan says it is stale, it
+// and the plans below it are discarded from
// the stack.
//
// Automatically Resuming:
//
-// If ShouldStop for all threads returns "false", then the target process will resume. This then cycles back to
+// If ShouldStop for all threads returns "false", then the target process will
+// resume. This then cycles back to
// Resuming above.
//
// Reporting eStateStopped events when the target is restarted:
//
-// If a plan decides to auto-continue the target by returning "false" from ShouldStop, then it will be asked
-// whether the Stopped event should still be reported. For instance, if you hit a breakpoint that is a User set
-// breakpoint, but the breakpoint callback said to continue the target process, you might still want to inform
+// If a plan decides to auto-continue the target by returning "false" from
+// ShouldStop, then it will be asked
+// whether the Stopped event should still be reported. For instance, if you
+// hit a breakpoint that is a User set
+// breakpoint, but the breakpoint callback said to continue the target process,
+// you might still want to inform
// the upper layers of lldb that the stop had happened.
-// The way this works is every thread gets to vote on whether to report the stop. If all votes are eVoteNoOpinion,
-// then the thread list will decide what to do (at present it will pretty much always suppress these stopped events.)
-// If there is an eVoteYes, then the event will be reported regardless of the other votes. If there is an eVoteNo
+// The way this works is every thread gets to vote on whether to report the
+// stop. If all votes are eVoteNoOpinion,
+// then the thread list will decide what to do (at present it will pretty much
+// always suppress these stopped events.)
+// If there is an eVoteYes, then the event will be reported regardless of the
+// other votes. If there is an eVoteNo
// and no eVoteYes's, then the event won't be reported.
//
-// One other little detail here, sometimes a plan will push another plan onto the plan stack to do some part of
-// the first plan's job, and it would be convenient to tell that plan how it should respond to ShouldReportStop.
-// You can do that by setting the stop_vote in the child plan when you create it.
+// One other little detail here, sometimes a plan will push another plan onto
+// the plan stack to do some part of
+// the first plan's job, and it would be convenient to tell that plan how it
+// should respond to ShouldReportStop.
+// You can do that by setting the stop_vote in the child plan when you create
+// it.
//
// Suppressing the initial eStateRunning event:
//
-// The private process running thread will take care of ensuring that only one "eStateRunning" event will be
-// delivered to the public Process broadcaster per public eStateStopped event. However there are some cases
-// where the public state of this process is eStateStopped, but a thread plan needs to restart the target, but
-// doesn't want the running event to be publically broadcast. The obvious example of this is running functions
-// by hand as part of expression evaluation. To suppress the running event return eVoteNo from ShouldReportStop,
-// to force a running event to be reported return eVoteYes, in general though you should return eVoteNoOpinion
+// The private process running thread will take care of ensuring that only one
+// "eStateRunning" event will be
+// delivered to the public Process broadcaster per public eStateStopped event.
+// However there are some cases
+// where the public state of this process is eStateStopped, but a thread plan
+// needs to restart the target, but
+// doesn't want the running event to be publicly broadcast. The obvious
+// example of this is running functions
+// by hand as part of expression evaluation. To suppress the running event
+// return eVoteNo from ShouldReportStop,
+// to force a running event to be reported return eVoteYes, in general though
+// you should return eVoteNoOpinion
// which will allow the ThreadList to figure out the right thing to do.
-// The run_vote argument to the constructor works like stop_vote, and is a way for a plan to instruct a sub-plan
+// The run_vote argument to the constructor works like stop_vote, and is a way
+// for a plan to instruct a sub-plan
// on how to respond to ShouldReportStop.
//
//------------------------------------------------------------------
-class ThreadPlan :
- public std::enable_shared_from_this<ThreadPlan>,
- public UserID
-{
+class ThreadPlan : public std::enable_shared_from_this<ThreadPlan>,
+ public UserID {
public:
- typedef enum
- {
- eAllThreads,
- eSomeThreads,
- eThisThread
- } ThreadScope;
-
- // We use these enums so that we can cast a base thread plan to it's real type without having to resort
- // to dynamic casting.
- typedef enum
- {
- eKindGeneric,
- eKindNull,
- eKindBase,
- eKindCallFunction,
- eKindPython,
- eKindStepInstruction,
- eKindStepOut,
- eKindStepOverBreakpoint,
- eKindStepOverRange,
- eKindStepInRange,
- eKindRunToAddress,
- eKindStepThrough,
- eKindStepUntil,
- eKindTestCondition
-
- } ThreadPlanKind;
-
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- ThreadPlan (ThreadPlanKind kind,
- const char *name,
- Thread &thread,
- Vote stop_vote,
- Vote run_vote);
-
- virtual
- ~ThreadPlan();
-
- //------------------------------------------------------------------
- /// Returns the name of this thread plan.
- ///
- /// @return
- /// A const char * pointer to the thread plan's name.
- //------------------------------------------------------------------
- const char *
- GetName () const
- {
- return m_name.c_str();
- }
-
- //------------------------------------------------------------------
- /// Returns the Thread that is using this thread plan.
- ///
- /// @return
- /// A pointer to the thread plan's owning thread.
- //------------------------------------------------------------------
- Thread &
- GetThread()
- {
- return m_thread;
- }
+ typedef enum { eAllThreads, eSomeThreads, eThisThread } ThreadScope;
+
+ // We use these enums so that we can cast a base thread plan to it's real type
+ // without having to resort
+ // to dynamic casting.
+ typedef enum {
+ eKindGeneric,
+ eKindNull,
+ eKindBase,
+ eKindCallFunction,
+ eKindPython,
+ eKindStepInstruction,
+ eKindStepOut,
+ eKindStepOverBreakpoint,
+ eKindStepOverRange,
+ eKindStepInRange,
+ eKindRunToAddress,
+ eKindStepThrough,
+ eKindStepUntil,
+ eKindTestCondition
+
+ } ThreadPlanKind;
+
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread,
+ Vote stop_vote, Vote run_vote);
+
+ virtual ~ThreadPlan();
+
+ //------------------------------------------------------------------
+ /// Returns the name of this thread plan.
+ ///
+ /// @return
+ /// A const char * pointer to the thread plan's name.
+ //------------------------------------------------------------------
+ const char *GetName() const { return m_name.c_str(); }
+
+ //------------------------------------------------------------------
+ /// Returns the Thread that is using this thread plan.
+ ///
+ /// @return
+ /// A pointer to the thread plan's owning thread.
+ //------------------------------------------------------------------
+ Thread &GetThread() { return m_thread; }
+
+ const Thread &GetThread() const { return m_thread; }
+
+ Target &GetTarget() { return m_thread.GetProcess()->GetTarget(); }
- const Thread &
- GetThread() const
- {
- return m_thread;
- }
-
- Target &
- GetTarget()
- {
- return m_thread.GetProcess()->GetTarget();
- }
+ const Target &GetTarget() const { return m_thread.GetProcess()->GetTarget(); }
- const Target &
- GetTarget() const
- {
- return m_thread.GetProcess()->GetTarget();
- }
+ //------------------------------------------------------------------
+ /// Print a description of this thread to the stream \a s.
+ /// \a thread.
+ ///
+ /// @param[in] s
+ /// The stream to which to print the description.
+ ///
+ /// @param[in] level
+ /// The level of description desired. Note that eDescriptionLevelBrief
+ /// will be used in the stop message printed when the plan is complete.
+ //------------------------------------------------------------------
+ virtual void GetDescription(Stream *s, lldb::DescriptionLevel level) = 0;
- //------------------------------------------------------------------
- /// Print a description of this thread to the stream \a s.
- /// \a thread.
- ///
- /// @param[in] s
- /// The stream to which to print the description.
- ///
- /// @param[in] level
- /// The level of description desired. Note that eDescriptionLevelBrief
- /// will be used in the stop message printed when the plan is complete.
- //------------------------------------------------------------------
- virtual void
- GetDescription (Stream *s,
- lldb::DescriptionLevel level) = 0;
-
- //------------------------------------------------------------------
- /// Returns whether this plan could be successfully created.
- ///
- /// @param[in] error
- /// A stream to which to print some reason why the plan could not be created.
- /// Can be NULL.
- ///
- /// @return
- /// \b true if the plan should be queued, \b false otherwise.
- //------------------------------------------------------------------
- virtual bool
- ValidatePlan (Stream *error) = 0;
-
- bool
- TracerExplainsStop ()
- {
- if (!m_tracer_sp)
- return false;
- else
- return m_tracer_sp->TracerExplainsStop();
- }
+ //------------------------------------------------------------------
+ /// Returns whether this plan could be successfully created.
+ ///
+ /// @param[in] error
+ /// A stream to which to print some reason why the plan could not be
+ /// created.
+ /// Can be NULL.
+ ///
+ /// @return
+ /// \b true if the plan should be queued, \b false otherwise.
+ //------------------------------------------------------------------
+ virtual bool ValidatePlan(Stream *error) = 0;
+ bool TracerExplainsStop() {
+ if (!m_tracer_sp)
+ return false;
+ else
+ return m_tracer_sp->TracerExplainsStop();
+ }
- lldb::StateType
- RunState ();
+ lldb::StateType RunState();
- bool
- PlanExplainsStop (Event *event_ptr);
-
- virtual bool
- ShouldStop (Event *event_ptr) = 0;
-
- virtual bool
- ShouldAutoContinue (Event *event_ptr)
- {
- return false;
- }
+ bool PlanExplainsStop(Event *event_ptr);
- // Whether a "stop class" event should be reported to the "outside world". In general
- // if a thread plan is active, events should not be reported.
-
- virtual Vote
- ShouldReportStop (Event *event_ptr);
-
- virtual Vote
- ShouldReportRun (Event *event_ptr);
-
- virtual void
- SetStopOthers (bool new_value);
-
- virtual bool
- StopOthers ();
-
- // This is the wrapper for DoWillResume that does generic ThreadPlan logic, then
- // calls DoWillResume.
- bool
- WillResume (lldb::StateType resume_state, bool current_plan);
-
- virtual bool
- WillStop () = 0;
-
- bool
- IsMasterPlan()
- {
- return m_is_master_plan;
- }
-
- bool
- SetIsMasterPlan (bool value)
- {
- bool old_value = m_is_master_plan;
- m_is_master_plan = value;
- return old_value;
- }
+ virtual bool ShouldStop(Event *event_ptr) = 0;
+
+ virtual bool ShouldAutoContinue(Event *event_ptr) { return false; }
+
+ // Whether a "stop class" event should be reported to the "outside world". In
+ // general
+ // if a thread plan is active, events should not be reported.
+
+ virtual Vote ShouldReportStop(Event *event_ptr);
+
+ virtual Vote ShouldReportRun(Event *event_ptr);
+
+ virtual void SetStopOthers(bool new_value);
+
+ virtual bool StopOthers();
+
+ // This is the wrapper for DoWillResume that does generic ThreadPlan logic,
+ // then
+ // calls DoWillResume.
+ bool WillResume(lldb::StateType resume_state, bool current_plan);
- virtual bool
- OkayToDiscard();
+ virtual bool WillStop() = 0;
- void
- SetOkayToDiscard (bool value)
- {
- m_okay_to_discard = value;
- }
-
- // The base class MischiefManaged does some cleanup - so you have to call it
- // in your MischiefManaged derived class.
- virtual bool
- MischiefManaged ();
-
- virtual void
- ThreadDestroyed ()
- {
- // Any cleanup that a plan might want to do in case the thread goes away
- // in the middle of the plan being queued on a thread can be done here.
- }
+ bool IsMasterPlan() { return m_is_master_plan; }
- bool
- GetPrivate ()
- {
- return m_plan_private;
- }
+ bool SetIsMasterPlan(bool value) {
+ bool old_value = m_is_master_plan;
+ m_is_master_plan = value;
+ return old_value;
+ }
- void
- SetPrivate (bool input)
- {
- m_plan_private = input;
- }
+ virtual bool OkayToDiscard();
- virtual void
- DidPush();
+ void SetOkayToDiscard(bool value) { m_okay_to_discard = value; }
- virtual void
- WillPop();
+ // The base class MischiefManaged does some cleanup - so you have to call it
+ // in your MischiefManaged derived class.
+ virtual bool MischiefManaged();
- // This pushes a plan onto the plan stack of the current plan's thread.
- void
- PushPlan (lldb::ThreadPlanSP &thread_plan_sp)
- {
- m_thread.PushPlan (thread_plan_sp);
- }
-
- ThreadPlanKind GetKind() const
- {
- return m_kind;
- }
-
- bool
- IsPlanComplete();
-
- void
- SetPlanComplete (bool success = true);
-
- virtual bool
- IsPlanStale ()
- {
- return false;
- }
-
- bool
- PlanSucceeded ()
- {
- return m_plan_succeeded;
- }
-
- virtual bool
- IsBasePlan()
- {
- return false;
- }
-
- lldb::ThreadPlanTracerSP &
- GetThreadPlanTracer()
- {
- return m_tracer_sp;
- }
-
- void
- SetThreadPlanTracer (lldb::ThreadPlanTracerSP new_tracer_sp)
- {
- m_tracer_sp = new_tracer_sp;
- }
-
- void
- DoTraceLog ()
- {
- if (m_tracer_sp && m_tracer_sp->TracingEnabled())
- m_tracer_sp->Log();
- }
+ virtual void ThreadDestroyed() {
+ // Any cleanup that a plan might want to do in case the thread goes away
+ // in the middle of the plan being queued on a thread can be done here.
+ }
- // Some thread plans hide away the actual stop info which caused any particular stop. For
- // instance the ThreadPlanCallFunction restores the original stop reason so that stopping and
- // calling a few functions won't lose the history of the run.
- // This call can be implemented to get you back to the real stop info.
- virtual lldb::StopInfoSP
- GetRealStopInfo ()
- {
- return m_thread.GetStopInfo ();
- }
-
- // If the completion of the thread plan stepped out of a function, the return value of the function
- // might have been captured by the thread plan (currently only ThreadPlanStepOut does this.)
- // If so, the ReturnValueObject can be retrieved from here.
-
- virtual lldb::ValueObjectSP
- GetReturnValueObject ()
- {
- return lldb::ValueObjectSP();
- }
+ bool GetPrivate() { return m_plan_private; }
- // If the thread plan managing the evaluation of a user expression lives longer than the command
- // that instigated the expression (generally because the expression evaluation hit a breakpoint, and
- // the user regained control at that point) a subsequent process control command step/continue/etc. might
- // complete the expression evaluations. If so, the result of the expression evaluation will show up here.
-
- virtual lldb::ExpressionVariableSP
- GetExpressionVariable ()
- {
- return lldb::ExpressionVariableSP();
- }
-
- // If a thread plan stores the state before it was run, then you might
- // want to restore the state when it is done. This will do that job.
- // This is mostly useful for artificial plans like CallFunction plans.
-
- virtual bool
- RestoreThreadState()
- {
- // Nothing to do in general.
- return true;
- }
+ void SetPrivate(bool input) { m_plan_private = input; }
+
+ virtual void DidPush();
+
+ virtual void WillPop();
+
+ // This pushes a plan onto the plan stack of the current plan's thread.
+ void PushPlan(lldb::ThreadPlanSP &thread_plan_sp) {
+ m_thread.PushPlan(thread_plan_sp);
+ }
+
+ ThreadPlanKind GetKind() const { return m_kind; }
+
+ bool IsPlanComplete();
- virtual bool
- IsVirtualStep()
- {
+ void SetPlanComplete(bool success = true);
+
+ virtual bool IsPlanStale() { return false; }
+
+ bool PlanSucceeded() { return m_plan_succeeded; }
+
+ virtual bool IsBasePlan() { return false; }
+
+ lldb::ThreadPlanTracerSP &GetThreadPlanTracer() { return m_tracer_sp; }
+
+ void SetThreadPlanTracer(lldb::ThreadPlanTracerSP new_tracer_sp) {
+ m_tracer_sp = new_tracer_sp;
+ }
+
+ void DoTraceLog() {
+ if (m_tracer_sp && m_tracer_sp->TracingEnabled())
+ m_tracer_sp->Log();
+ }
+
+ // Some thread plans hide away the actual stop info which caused any
+ // particular stop. For
+ // instance the ThreadPlanCallFunction restores the original stop reason so
+ // that stopping and
+ // calling a few functions won't lose the history of the run.
+ // This call can be implemented to get you back to the real stop info.
+ virtual lldb::StopInfoSP GetRealStopInfo() { return m_thread.GetStopInfo(); }
+
+ // If the completion of the thread plan stepped out of a function, the return
+ // value of the function
+ // might have been captured by the thread plan (currently only
+ // ThreadPlanStepOut does this.)
+ // If so, the ReturnValueObject can be retrieved from here.
+
+ virtual lldb::ValueObjectSP GetReturnValueObject() {
+ return lldb::ValueObjectSP();
+ }
+
+ // If the thread plan managing the evaluation of a user expression lives
+ // longer than the command
+ // that instigated the expression (generally because the expression evaluation
+ // hit a breakpoint, and
+ // the user regained control at that point) a subsequent process control
+ // command step/continue/etc. might
+ // complete the expression evaluations. If so, the result of the expression
+ // evaluation will show up here.
+
+ virtual lldb::ExpressionVariableSP GetExpressionVariable() {
+ return lldb::ExpressionVariableSP();
+ }
+
+ // If a thread plan stores the state before it was run, then you might
+ // want to restore the state when it is done. This will do that job.
+ // This is mostly useful for artificial plans like CallFunction plans.
+
+ virtual bool RestoreThreadState() {
+ // Nothing to do in general.
+ return true;
+ }
+
+ virtual bool IsVirtualStep() { return false; }
+
+ virtual bool SetIterationCount(size_t count) {
+ if (m_takes_iteration_count) {
+ // Don't tell me to do something 0 times...
+ if (count == 0)
return false;
+ m_iteration_count = count;
}
-
- virtual bool
- SetIterationCount (size_t count)
- {
- if (m_takes_iteration_count)
- {
- // Don't tell me to do something 0 times...
- if (count == 0)
- return false;
- m_iteration_count = count;
- }
- return m_takes_iteration_count;
- }
-
- virtual size_t
- GetIterationCount ()
- {
- if (!m_takes_iteration_count)
- return 0;
- else
- return m_iteration_count;
- }
+ return m_takes_iteration_count;
+ }
+
+ virtual size_t GetIterationCount() {
+ if (!m_takes_iteration_count)
+ return 0;
+ else
+ return m_iteration_count;
+ }
protected:
- //------------------------------------------------------------------
- // Classes that inherit from ThreadPlan can see and modify these
- //------------------------------------------------------------------
-
- virtual bool
- DoWillResume (lldb::StateType resume_state, bool current_plan) { return true; }
-
- virtual bool
- DoPlanExplainsStop (Event *event_ptr) = 0;
-
- // This gets the previous plan to the current plan (for forwarding requests).
- // This is mostly a formal requirement, it allows us to make the Thread's
- // GetPreviousPlan protected, but only friend ThreadPlan to thread.
-
- ThreadPlan *
- GetPreviousPlan ()
- {
- return m_thread.GetPreviousPlan (this);
- }
-
- // This forwards the private Thread::GetPrivateStopInfo which is generally what
- // ThreadPlan's need to know.
-
- lldb::StopInfoSP
- GetPrivateStopInfo()
- {
- return m_thread.GetPrivateStopInfo ();
- }
-
- void
- SetStopInfo (lldb::StopInfoSP stop_reason_sp)
- {
- m_thread.SetStopInfo (stop_reason_sp);
- }
-
- void
- CachePlanExplainsStop (bool does_explain)
- {
- m_cached_plan_explains_stop = does_explain ? eLazyBoolYes : eLazyBoolNo;
- }
-
- LazyBool
- GetCachedPlanExplainsStop () const
- {
- return m_cached_plan_explains_stop;
- }
-
- virtual lldb::StateType
- GetPlanRunState () = 0;
+ //------------------------------------------------------------------
+ // Classes that inherit from ThreadPlan can see and modify these
+ //------------------------------------------------------------------
+
+ virtual bool DoWillResume(lldb::StateType resume_state, bool current_plan) {
+ return true;
+ }
+
+ virtual bool DoPlanExplainsStop(Event *event_ptr) = 0;
+
+ // This gets the previous plan to the current plan (for forwarding requests).
+ // This is mostly a formal requirement, it allows us to make the Thread's
+ // GetPreviousPlan protected, but only friend ThreadPlan to thread.
+
+ ThreadPlan *GetPreviousPlan() { return m_thread.GetPreviousPlan(this); }
+
+ // This forwards the private Thread::GetPrivateStopInfo which is generally
+ // what
+ // ThreadPlan's need to know.
+
+ lldb::StopInfoSP GetPrivateStopInfo() {
+ return m_thread.GetPrivateStopInfo();
+ }
+
+ void SetStopInfo(lldb::StopInfoSP stop_reason_sp) {
+ m_thread.SetStopInfo(stop_reason_sp);
+ }
- bool
- IsUsuallyUnexplainedStopReason(lldb::StopReason);
+ void CachePlanExplainsStop(bool does_explain) {
+ m_cached_plan_explains_stop = does_explain ? eLazyBoolYes : eLazyBoolNo;
+ }
- Thread &m_thread;
- Vote m_stop_vote;
- Vote m_run_vote;
- bool m_takes_iteration_count = false;
- int32_t m_iteration_count = 1;
+ LazyBool GetCachedPlanExplainsStop() const {
+ return m_cached_plan_explains_stop;
+ }
+
+ virtual lldb::StateType GetPlanRunState() = 0;
+
+ bool IsUsuallyUnexplainedStopReason(lldb::StopReason);
+
+ Thread &m_thread;
+ Vote m_stop_vote;
+ Vote m_run_vote;
+ bool m_takes_iteration_count = false;
+ int32_t m_iteration_count = 1;
private:
- //------------------------------------------------------------------
- // For ThreadPlan only
- //------------------------------------------------------------------
- static lldb::user_id_t GetNextID ();
-
- ThreadPlanKind m_kind;
- std::string m_name;
- std::recursive_mutex m_plan_complete_mutex;
- LazyBool m_cached_plan_explains_stop;
- bool m_plan_complete;
- bool m_plan_private;
- bool m_okay_to_discard;
- bool m_is_master_plan;
- bool m_plan_succeeded;
-
- lldb::ThreadPlanTracerSP m_tracer_sp;
+ //------------------------------------------------------------------
+ // For ThreadPlan only
+ //------------------------------------------------------------------
+ static lldb::user_id_t GetNextID();
+
+ ThreadPlanKind m_kind;
+ std::string m_name;
+ std::recursive_mutex m_plan_complete_mutex;
+ LazyBool m_cached_plan_explains_stop;
+ bool m_plan_complete;
+ bool m_plan_private;
+ bool m_okay_to_discard;
+ bool m_is_master_plan;
+ bool m_plan_succeeded;
+
+ lldb::ThreadPlanTracerSP m_tracer_sp;
private:
- DISALLOW_COPY_AND_ASSIGN(ThreadPlan);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPlan);
};
//----------------------------------------------------------------------
@@ -654,48 +634,31 @@ private:
// But asking questions of the ThreadPlanNull is definitely an error.
//----------------------------------------------------------------------
-class ThreadPlanNull : public ThreadPlan
-{
+class ThreadPlanNull : public ThreadPlan {
public:
- ThreadPlanNull (Thread &thread);
- ~ThreadPlanNull() override;
-
- void
- GetDescription(Stream *s,
- lldb::DescriptionLevel level) override;
+ ThreadPlanNull(Thread &thread);
+ ~ThreadPlanNull() override;
- bool
- ValidatePlan(Stream *error) override;
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
- bool
- ShouldStop(Event *event_ptr) override;
+ bool ValidatePlan(Stream *error) override;
- bool
- MischiefManaged() override;
+ bool ShouldStop(Event *event_ptr) override;
- bool
- WillStop() override;
+ bool MischiefManaged() override;
- bool
- IsBasePlan() override
- {
- return true;
- }
-
- bool
- OkayToDiscard() override
- {
- return false;
- }
+ bool WillStop() override;
+
+ bool IsBasePlan() override { return true; }
+
+ bool OkayToDiscard() override { return false; }
protected:
- bool
- DoPlanExplainsStop(Event *event_ptr) override;
-
- lldb::StateType
- GetPlanRunState() override;
+ bool DoPlanExplainsStop(Event *event_ptr) override;
+
+ lldb::StateType GetPlanRunState() override;
- DISALLOW_COPY_AND_ASSIGN(ThreadPlanNull);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPlanNull);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/ThreadPlanBase.h b/include/lldb/Target/ThreadPlanBase.h
index a0d30b5f0b67..7a8b7eb20bb2 100644
--- a/include/lldb/Target/ThreadPlanBase.h
+++ b/include/lldb/Target/ThreadPlanBase.h
@@ -20,50 +20,41 @@
namespace lldb_private {
-
//------------------------------------------------------------------
// Base thread plans:
-// This is the generic version of the bottom most plan on the plan stack. It should
+// This is the generic version of the bottom most plan on the plan stack. It
+// should
// be able to handle generic breakpoint hitting, and signals and exceptions.
//------------------------------------------------------------------
-class ThreadPlanBase : public ThreadPlan
-{
-friend class Process; // RunThreadPlan manages "stopper" base plans.
+class ThreadPlanBase : public ThreadPlan {
+ friend class Process; // RunThreadPlan manages "stopper" base plans.
public:
- ~ThreadPlanBase() override;
+ ~ThreadPlanBase() override;
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
+ bool ValidatePlan(Stream *error) override;
+ bool ShouldStop(Event *event_ptr) override;
+ Vote ShouldReportStop(Event *event_ptr) override;
+ bool StopOthers() override;
+ lldb::StateType GetPlanRunState() override;
+ bool WillStop() override;
+ bool MischiefManaged() override;
- void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
- bool ValidatePlan(Stream *error) override;
- bool ShouldStop(Event *event_ptr) override;
- Vote ShouldReportStop(Event *event_ptr) override;
- bool StopOthers() override;
- lldb::StateType GetPlanRunState() override;
- bool WillStop() override;
- bool MischiefManaged() override;
+ bool OkayToDiscard() override { return false; }
- bool
- OkayToDiscard() override
- {
- return false;
- }
+ bool IsBasePlan() override { return true; }
- bool
- IsBasePlan() override
- {
- return true;
- }
-
protected:
- bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
- bool DoPlanExplainsStop(Event *event_ptr) override;
- ThreadPlanBase (Thread &thread);
+ bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
+ bool DoPlanExplainsStop(Event *event_ptr) override;
+ ThreadPlanBase(Thread &thread);
private:
- friend lldb::ThreadPlanSP
- Thread::QueueFundamentalPlan(bool abort_other_plans);
+ friend lldb::ThreadPlanSP
+ Thread::QueueFundamentalPlan(bool abort_other_plans);
- DISALLOW_COPY_AND_ASSIGN (ThreadPlanBase);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPlanBase);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/ThreadPlanCallFunction.h b/include/lldb/Target/ThreadPlanCallFunction.h
index 47eee2808f1e..3d43491af9af 100644
--- a/include/lldb/Target/ThreadPlanCallFunction.h
+++ b/include/lldb/Target/ThreadPlanCallFunction.h
@@ -14,177 +14,149 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
+#include "lldb/lldb-private.h"
#include "llvm/ADT/ArrayRef.h"
namespace lldb_private {
-class ThreadPlanCallFunction : public ThreadPlan
-{
- // Create a thread plan to call a function at the address passed in the "function"
- // argument. If you plan to call GetReturnValueObject, then pass in the
- // return type, otherwise just pass in an invalid CompilerType.
+class ThreadPlanCallFunction : public ThreadPlan {
+ // Create a thread plan to call a function at the address passed in the
+ // "function"
+ // argument. If you plan to call GetReturnValueObject, then pass in the
+ // return type, otherwise just pass in an invalid CompilerType.
public:
- ThreadPlanCallFunction (Thread &thread,
- const Address &function,
- const CompilerType &return_type,
- llvm::ArrayRef<lldb::addr_t> args,
- const EvaluateExpressionOptions &options);
-
- ThreadPlanCallFunction(Thread &thread,
- const Address &function,
- const EvaluateExpressionOptions &options);
-
- ~ThreadPlanCallFunction() override;
-
- void
- GetDescription(Stream *s, lldb::DescriptionLevel level) override;
-
- bool
- ValidatePlan(Stream *error) override;
-
- bool
- ShouldStop(Event *event_ptr) override;
-
- Vote
- ShouldReportStop(Event *event_ptr) override;
-
- bool
- StopOthers() override;
-
- lldb::StateType
- GetPlanRunState() override;
-
- void
- DidPush() override;
-
- bool
- WillStop() override;
-
- bool
- MischiefManaged() override;
-
- // To get the return value from a function call you must create a
- // lldb::ValueSP that contains a valid clang type in its context and call
- // RequestReturnValue. The ValueSP will be stored and when the function is
- // done executing, the object will check if there is a requested return
- // value. If there is, the return value will be retrieved using the
- // ABI::GetReturnValue() for the ABI in the process. Then after the thread
- // plan is complete, you can call "GetReturnValue()" to retrieve the value
- // that was extracted.
-
- lldb::ValueObjectSP
- GetReturnValueObject() override
- {
- return m_return_valobj_sp;
- }
-
- // Return the stack pointer that the function received
- // on entry. Any stack address below this should be
- // considered invalid after the function has been
- // cleaned up.
- lldb::addr_t
- GetFunctionStackPointer()
- {
- return m_function_sp;
- }
-
- // Classes that derive from FunctionCaller, and implement
- // their own WillPop methods should call this so that the
- // thread state gets restored if the plan gets discarded.
- void
- WillPop() override;
-
- // If the thread plan stops mid-course, this will be the stop reason that interrupted us.
- // Once DoTakedown is called, this will be the real stop reason at the end of the function call.
- // If it hasn't been set for one or the other of these reasons, we'll return the PrivateStopReason.
- // This is needed because we want the CallFunction thread plans not to show up as the stop reason.
- // But if something bad goes wrong, it is nice to be able to tell the user what really happened.
-
- lldb::StopInfoSP
- GetRealStopInfo() override
- {
- if (m_real_stop_info_sp)
- return m_real_stop_info_sp;
- else
- return GetPrivateStopInfo ();
- }
-
- lldb::addr_t
- GetStopAddress ()
- {
- return m_stop_address;
- }
-
- bool
- RestoreThreadState() override;
-
- void
- ThreadDestroyed() override
- {
- m_takedown_done = true;
- }
-
- void
- SetStopOthers(bool new_value) override;
-
+ ThreadPlanCallFunction(Thread &thread, const Address &function,
+ const CompilerType &return_type,
+ llvm::ArrayRef<lldb::addr_t> args,
+ const EvaluateExpressionOptions &options);
+
+ ThreadPlanCallFunction(Thread &thread, const Address &function,
+ const EvaluateExpressionOptions &options);
+
+ ~ThreadPlanCallFunction() override;
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
+
+ bool ValidatePlan(Stream *error) override;
+
+ bool ShouldStop(Event *event_ptr) override;
+
+ Vote ShouldReportStop(Event *event_ptr) override;
+
+ bool StopOthers() override;
+
+ lldb::StateType GetPlanRunState() override;
+
+ void DidPush() override;
+
+ bool WillStop() override;
+
+ bool MischiefManaged() override;
+
+ // To get the return value from a function call you must create a
+ // lldb::ValueSP that contains a valid clang type in its context and call
+ // RequestReturnValue. The ValueSP will be stored and when the function is
+ // done executing, the object will check if there is a requested return
+ // value. If there is, the return value will be retrieved using the
+ // ABI::GetReturnValue() for the ABI in the process. Then after the thread
+ // plan is complete, you can call "GetReturnValue()" to retrieve the value
+ // that was extracted.
+
+ lldb::ValueObjectSP GetReturnValueObject() override {
+ return m_return_valobj_sp;
+ }
+
+ // Return the stack pointer that the function received
+ // on entry. Any stack address below this should be
+ // considered invalid after the function has been
+ // cleaned up.
+ lldb::addr_t GetFunctionStackPointer() { return m_function_sp; }
+
+ // Classes that derive from FunctionCaller, and implement
+ // their own WillPop methods should call this so that the
+ // thread state gets restored if the plan gets discarded.
+ void WillPop() override;
+
+ // If the thread plan stops mid-course, this will be the stop reason that
+ // interrupted us.
+ // Once DoTakedown is called, this will be the real stop reason at the end of
+ // the function call.
+ // If it hasn't been set for one or the other of these reasons, we'll return
+ // the PrivateStopReason.
+ // This is needed because we want the CallFunction thread plans not to show up
+ // as the stop reason.
+ // But if something bad goes wrong, it is nice to be able to tell the user
+ // what really happened.
+
+ lldb::StopInfoSP GetRealStopInfo() override {
+ if (m_real_stop_info_sp)
+ return m_real_stop_info_sp;
+ else
+ return GetPrivateStopInfo();
+ }
+
+ lldb::addr_t GetStopAddress() { return m_stop_address; }
+
+ bool RestoreThreadState() override;
+
+ void ThreadDestroyed() override { m_takedown_done = true; }
+
+ void SetStopOthers(bool new_value) override;
+
protected:
- void ReportRegisterState (const char *message);
-
- bool
- DoPlanExplainsStop(Event *event_ptr) override;
-
- virtual void
- SetReturnValue();
-
- bool
- ConstructorSetup (Thread &thread,
- ABI *& abi,
- lldb::addr_t &start_load_addr,
- lldb::addr_t &function_load_addr);
-
- void
- DoTakedown (bool success);
-
- void
- SetBreakpoints ();
-
- void
- ClearBreakpoints ();
-
- bool
- BreakpointsExplainStop ();
-
- bool m_valid;
- bool m_stop_other_threads;
- bool m_unwind_on_error;
- bool m_ignore_breakpoints;
- bool m_debug_execution;
- bool m_trap_exceptions;
- Address m_function_addr;
- Address m_start_addr;
- lldb::addr_t m_function_sp;
- lldb::ThreadPlanSP m_subplan_sp;
- LanguageRuntime *m_cxx_language_runtime;
- LanguageRuntime *m_objc_language_runtime;
- Thread::ThreadStateCheckpoint m_stored_thread_state;
- lldb::StopInfoSP m_real_stop_info_sp; // In general we want to hide call function
- // thread plans, but for reporting purposes,
- // it's nice to know the real stop reason.
- // This gets set in DoTakedown.
- StreamString m_constructor_errors;
- lldb::ValueObjectSP m_return_valobj_sp; // If this contains a valid pointer, use the ABI to extract values when complete
- bool m_takedown_done; // We want to ensure we only do the takedown once. This ensures that.
- bool m_should_clear_objc_exception_bp;
- bool m_should_clear_cxx_exception_bp;
- lldb::addr_t m_stop_address; // This is the address we stopped at. Also set in DoTakedown;
+ void ReportRegisterState(const char *message);
+
+ bool DoPlanExplainsStop(Event *event_ptr) override;
+
+ virtual void SetReturnValue();
+
+ bool ConstructorSetup(Thread &thread, ABI *&abi,
+ lldb::addr_t &start_load_addr,
+ lldb::addr_t &function_load_addr);
+
+ void DoTakedown(bool success);
+
+ void SetBreakpoints();
+
+ void ClearBreakpoints();
+
+ bool BreakpointsExplainStop();
+
+ bool m_valid;
+ bool m_stop_other_threads;
+ bool m_unwind_on_error;
+ bool m_ignore_breakpoints;
+ bool m_debug_execution;
+ bool m_trap_exceptions;
+ Address m_function_addr;
+ Address m_start_addr;
+ lldb::addr_t m_function_sp;
+ lldb::ThreadPlanSP m_subplan_sp;
+ LanguageRuntime *m_cxx_language_runtime;
+ LanguageRuntime *m_objc_language_runtime;
+ Thread::ThreadStateCheckpoint m_stored_thread_state;
+ lldb::StopInfoSP
+ m_real_stop_info_sp; // In general we want to hide call function
+ // thread plans, but for reporting purposes,
+ // it's nice to know the real stop reason.
+ // This gets set in DoTakedown.
+ StreamString m_constructor_errors;
+ lldb::ValueObjectSP m_return_valobj_sp; // If this contains a valid pointer,
+ // use the ABI to extract values when
+ // complete
+ bool m_takedown_done; // We want to ensure we only do the takedown once. This
+ // ensures that.
+ bool m_should_clear_objc_exception_bp;
+ bool m_should_clear_cxx_exception_bp;
+ lldb::addr_t m_stop_address; // This is the address we stopped at. Also set
+ // in DoTakedown;
private:
- CompilerType m_return_type;
- DISALLOW_COPY_AND_ASSIGN (ThreadPlanCallFunction);
+ CompilerType m_return_type;
+ DISALLOW_COPY_AND_ASSIGN(ThreadPlanCallFunction);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h b/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h
index 3506ebab6ce0..1c67ddd5cdda 100644
--- a/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h
+++ b/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h
@@ -1,4 +1,5 @@
-//===-- ThreadPlanCallFunctionUsingABI.h --------------------------------*- C++ -*-===//
+//===-- ThreadPlanCallFunctionUsingABI.h --------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,42 +15,43 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanCallFunction.h"
+#include "lldb/lldb-private.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/IR/DerivedTypes.h"
namespace lldb_private {
-class ThreadPlanCallFunctionUsingABI : public ThreadPlanCallFunction
-{
- // Create a thread plan to call a function at the address passed in the "function"
- // argument, this function is executed using register manipulation instead of JIT.
- // Class derives from ThreadPlanCallFunction and differs by calling a alternative
- // ABI interface ABI::PrepareTrivialCall() which provides more detailed information.
+class ThreadPlanCallFunctionUsingABI : public ThreadPlanCallFunction {
+ // Create a thread plan to call a function at the address passed in the
+ // "function"
+ // argument, this function is executed using register manipulation instead of
+ // JIT.
+ // Class derives from ThreadPlanCallFunction and differs by calling a
+ // alternative
+ // ABI interface ABI::PrepareTrivialCall() which provides more detailed
+ // information.
public:
- ThreadPlanCallFunctionUsingABI (Thread &thread,
+ ThreadPlanCallFunctionUsingABI(Thread &thread,
const Address &function_address,
llvm::Type &function_prototype,
llvm::Type &return_type,
llvm::ArrayRef<ABI::CallArgument> args,
const EvaluateExpressionOptions &options);
- ~ThreadPlanCallFunctionUsingABI() override;
+ ~ThreadPlanCallFunctionUsingABI() override;
- void
- GetDescription (Stream *s, lldb::DescriptionLevel level) override;
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
protected:
- void
- SetReturnValue () override;
+ void SetReturnValue() override;
private:
- llvm::Type &m_return_type;
- DISALLOW_COPY_AND_ASSIGN (ThreadPlanCallFunctionUsingABI);
+ llvm::Type &m_return_type;
+ DISALLOW_COPY_AND_ASSIGN(ThreadPlanCallFunctionUsingABI);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/ThreadPlanCallOnFunctionExit.h b/include/lldb/Target/ThreadPlanCallOnFunctionExit.h
new file mode 100644
index 000000000000..c7ea368cca6a
--- /dev/null
+++ b/include/lldb/Target/ThreadPlanCallOnFunctionExit.h
@@ -0,0 +1,56 @@
+//===-- ThreadPlanCallOnFunctionExit.h --------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef ThreadPlanCallOnFunctionExit_h
+#define ThreadPlanCallOnFunctionExit_h
+
+#include "lldb/Target/ThreadPlan.h"
+
+#include <functional>
+
+namespace lldb_private {
+
+// =============================================================================
+/// This thread plan calls a function object when the current function exits.
+// =============================================================================
+
+class ThreadPlanCallOnFunctionExit : public ThreadPlan {
+public:
+ /// Definition for the callback made when the currently executing thread
+ /// finishes executing its function.
+ using Callback = std::function<void()>;
+
+ ThreadPlanCallOnFunctionExit(Thread &thread, const Callback &callback);
+
+ void DidPush() override;
+
+ // -------------------------------------------------------------------------
+ // ThreadPlan API
+ // -------------------------------------------------------------------------
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
+
+ bool ValidatePlan(Stream *error) override;
+
+ bool ShouldStop(Event *event_ptr) override;
+
+ bool WillStop() override;
+
+protected:
+ bool DoPlanExplainsStop(Event *event_ptr) override;
+
+ lldb::StateType GetPlanRunState() override;
+
+private:
+ Callback m_callback;
+ lldb::ThreadPlanSP m_step_out_threadplan_sp;
+};
+}
+
+#endif /* ThreadPlanCallOnFunctionExit_h */
diff --git a/include/lldb/Target/ThreadPlanCallUserExpression.h b/include/lldb/Target/ThreadPlanCallUserExpression.h
index bb261d9c96b4..f1425b2f97e1 100644
--- a/include/lldb/Target/ThreadPlanCallUserExpression.h
+++ b/include/lldb/Target/ThreadPlanCallUserExpression.h
@@ -1,4 +1,5 @@
-//===-- ThreadPlanCallUserExpression.h --------------------------------*- C++ -*-===//
+//===-- ThreadPlanCallUserExpression.h --------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,60 +15,50 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
#include "lldb/Target/ThreadPlanCallFunction.h"
+#include "lldb/lldb-private.h"
#include "llvm/ADT/ArrayRef.h"
namespace lldb_private {
-class ThreadPlanCallUserExpression : public ThreadPlanCallFunction
-{
+class ThreadPlanCallUserExpression : public ThreadPlanCallFunction {
public:
- ThreadPlanCallUserExpression (Thread &thread,
- Address &function,
- llvm::ArrayRef<lldb::addr_t> args,
- const EvaluateExpressionOptions &options,
- lldb::UserExpressionSP &user_expression_sp);
-
- ~ThreadPlanCallUserExpression() override;
-
- void
- GetDescription(Stream *s, lldb::DescriptionLevel level) override;
-
- void
- WillPop() override;
-
- lldb::StopInfoSP
- GetRealStopInfo() override;
-
- bool
- MischiefManaged() override;
-
- void
- TransferExpressionOwnership ()
- {
- m_manage_materialization = true;
- }
-
- lldb::ExpressionVariableSP
- GetExpressionVariable() override
- {
- return m_result_var_sp;
- }
-
+ ThreadPlanCallUserExpression(Thread &thread, Address &function,
+ llvm::ArrayRef<lldb::addr_t> args,
+ const EvaluateExpressionOptions &options,
+ lldb::UserExpressionSP &user_expression_sp);
+
+ ~ThreadPlanCallUserExpression() override;
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
+
+ void WillPop() override;
+
+ lldb::StopInfoSP GetRealStopInfo() override;
+
+ bool MischiefManaged() override;
+
+ void TransferExpressionOwnership() { m_manage_materialization = true; }
+
+ lldb::ExpressionVariableSP GetExpressionVariable() override {
+ return m_result_var_sp;
+ }
+
protected:
private:
- lldb::UserExpressionSP m_user_expression_sp; // This is currently just used to ensure the
- // User expression the initiated this ThreadPlan
- // lives as long as the thread plan does.
- bool m_manage_materialization = false;
- lldb::ExpressionVariableSP m_result_var_sp; // If we are left to manage the materialization,
- // then stuff the result expression variable here.
-
- DISALLOW_COPY_AND_ASSIGN (ThreadPlanCallUserExpression);
+ lldb::UserExpressionSP
+ m_user_expression_sp; // This is currently just used to ensure the
+ // User expression the initiated this ThreadPlan
+ // lives as long as the thread plan does.
+ bool m_manage_materialization = false;
+ lldb::ExpressionVariableSP
+ m_result_var_sp; // If we are left to manage the materialization,
+ // then stuff the result expression variable here.
+
+ DISALLOW_COPY_AND_ASSIGN(ThreadPlanCallUserExpression);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/ThreadPlanPython.h b/include/lldb/Target/ThreadPlanPython.h
index 8d5b217226f1..a053b5bcb77d 100644
--- a/include/lldb/Target/ThreadPlanPython.h
+++ b/include/lldb/Target/ThreadPlanPython.h
@@ -1,4 +1,5 @@
-//===-- ThreadPlanPython.h --------------------------------------------*- C++ -*-===//
+//===-- ThreadPlanPython.h --------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,15 +17,15 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/StructuredData.h"
#include "lldb/Core/UserID.h"
#include "lldb/Target/Process.h"
+#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
#include "lldb/Target/ThreadPlanTracer.h"
-#include "lldb/Target/StopInfo.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -33,46 +34,37 @@ namespace lldb_private {
//
//------------------------------------------------------------------
-class ThreadPlanPython : public ThreadPlan
-{
+class ThreadPlanPython : public ThreadPlan {
public:
- ThreadPlanPython (Thread &thread, const char *class_name);
- ~ThreadPlanPython() override;
-
- void
- GetDescription(Stream *s,
- lldb::DescriptionLevel level) override;
+ ThreadPlanPython(Thread &thread, const char *class_name);
+ ~ThreadPlanPython() override;
- bool
- ValidatePlan(Stream *error) override;
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
- bool
- ShouldStop(Event *event_ptr) override;
+ bool ValidatePlan(Stream *error) override;
- bool
- MischiefManaged() override;
+ bool ShouldStop(Event *event_ptr) override;
- bool
- WillStop() override;
+ bool MischiefManaged() override;
- bool
- StopOthers() override;
+ bool WillStop() override;
- void
- DidPush() override;
+ bool StopOthers() override;
+
+ void DidPush() override;
+
+ bool IsPlanStale() override;
protected:
- bool
- DoPlanExplainsStop(Event *event_ptr) override;
-
- lldb::StateType
- GetPlanRunState() override;
+ bool DoPlanExplainsStop(Event *event_ptr) override;
+
+ lldb::StateType GetPlanRunState() override;
private:
- std::string m_class_name;
- StructuredData::ObjectSP m_implementation_sp;
+ std::string m_class_name;
+ StructuredData::ObjectSP m_implementation_sp;
- DISALLOW_COPY_AND_ASSIGN(ThreadPlanPython);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPlanPython);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/ThreadPlanRunToAddress.h b/include/lldb/Target/ThreadPlanRunToAddress.h
index a1b974605ffb..8e91fb9472a7 100644
--- a/include/lldb/Target/ThreadPlanRunToAddress.h
+++ b/include/lldb/Target/ThreadPlanRunToAddress.h
@@ -16,65 +16,55 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Target/ThreadPlan.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class ThreadPlanRunToAddress : public ThreadPlan
-{
+class ThreadPlanRunToAddress : public ThreadPlan {
public:
- ThreadPlanRunToAddress (Thread &thread,
- Address &address,
- bool stop_others);
+ ThreadPlanRunToAddress(Thread &thread, Address &address, bool stop_others);
+
+ ThreadPlanRunToAddress(Thread &thread, lldb::addr_t address,
+ bool stop_others);
- ThreadPlanRunToAddress (Thread &thread,
- lldb::addr_t address,
- bool stop_others);
+ ThreadPlanRunToAddress(Thread &thread,
+ const std::vector<lldb::addr_t> &addresses,
+ bool stop_others);
- ThreadPlanRunToAddress (Thread &thread,
- const std::vector<lldb::addr_t> &addresses,
- bool stop_others);
+ ~ThreadPlanRunToAddress() override;
- ~ThreadPlanRunToAddress() override;
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
- void
- GetDescription(Stream *s, lldb::DescriptionLevel level) override;
+ bool ValidatePlan(Stream *error) override;
- bool
- ValidatePlan(Stream *error) override;
+ bool ShouldStop(Event *event_ptr) override;
- bool
- ShouldStop(Event *event_ptr) override;
+ bool StopOthers() override;
- bool
- StopOthers() override;
-
- void
- SetStopOthers(bool new_value) override;
-
- lldb::StateType
- GetPlanRunState() override;
+ void SetStopOthers(bool new_value) override;
- bool
- WillStop() override;
+ lldb::StateType GetPlanRunState() override;
- bool
- MischiefManaged() override;
+ bool WillStop() override;
+
+ bool MischiefManaged() override;
protected:
- bool
- DoPlanExplainsStop(Event *event_ptr) override;
+ bool DoPlanExplainsStop(Event *event_ptr) override;
- void SetInitialBreakpoints();
- bool AtOurAddress();
-private:
- bool m_stop_others;
- std::vector<lldb::addr_t> m_addresses; // This is the address we are going to run to.
- // TODO: Would it be useful to have multiple addresses?
- std::vector<lldb::break_id_t> m_break_ids; // This is the breakpoint we are using to stop us at m_address.
+ void SetInitialBreakpoints();
+ bool AtOurAddress();
- DISALLOW_COPY_AND_ASSIGN (ThreadPlanRunToAddress);
+private:
+ bool m_stop_others;
+ std::vector<lldb::addr_t>
+ m_addresses; // This is the address we are going to run to.
+ // TODO: Would it be useful to have multiple addresses?
+ std::vector<lldb::break_id_t> m_break_ids; // This is the breakpoint we are
+ // using to stop us at m_address.
+
+ DISALLOW_COPY_AND_ASSIGN(ThreadPlanRunToAddress);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/ThreadPlanShouldStopHere.h b/include/lldb/Target/ThreadPlanShouldStopHere.h
index a52d9e42effd..60c0e3866707 100644
--- a/include/lldb/Target/ThreadPlanShouldStopHere.h
+++ b/include/lldb/Target/ThreadPlanShouldStopHere.h
@@ -18,134 +18,128 @@
namespace lldb_private {
-// This is an interface that ThreadPlans can adopt to allow flexible modifications of the behavior
-// when a thread plan comes to a place where it would ordinarily stop. If such modification makes
-// sense for your plan, inherit from this class, and when you would be about to stop (in your ShouldStop
-// method), call InvokeShouldStopHereCallback, passing in the frame comparison between where the step operation
-// started and where you arrived. If it returns true, then QueueStepOutFromHere will queue the plan
+// This is an interface that ThreadPlans can adopt to allow flexible
+// modifications of the behavior
+// when a thread plan comes to a place where it would ordinarily stop. If such
+// modification makes
+// sense for your plan, inherit from this class, and when you would be about to
+// stop (in your ShouldStop
+// method), call InvokeShouldStopHereCallback, passing in the frame comparison
+// between where the step operation
+// started and where you arrived. If it returns true, then QueueStepOutFromHere
+// will queue the plan
// to execute instead of stopping.
//
-// The classic example of the use of this is ThreadPlanStepInRange not stopping in frames that have
+// The classic example of the use of this is ThreadPlanStepInRange not stopping
+// in frames that have
// no debug information.
//
-// This class also defines a set of flags to control general aspects of this "ShouldStop" behavior.
-// A class implementing this protocol needs to define a default set of flags, and can provide access to
+// This class also defines a set of flags to control general aspects of this
+// "ShouldStop" behavior.
+// A class implementing this protocol needs to define a default set of flags,
+// and can provide access to
// changing that default flag set if it wishes.
-class ThreadPlanShouldStopHere
-{
+class ThreadPlanShouldStopHere {
public:
- struct ThreadPlanShouldStopHereCallbacks
- {
- ThreadPlanShouldStopHereCallbacks()
- {
- should_stop_here_callback = nullptr;
- step_from_here_callback = nullptr;
- }
-
- ThreadPlanShouldStopHereCallbacks(ThreadPlanShouldStopHereCallback should_stop,
- ThreadPlanStepFromHereCallback step_from_here)
- {
- should_stop_here_callback = should_stop;
- step_from_here_callback = step_from_here;
- }
-
- void
- Clear()
- {
- should_stop_here_callback = nullptr;
- step_from_here_callback = nullptr;
- }
-
- ThreadPlanShouldStopHereCallback should_stop_here_callback;
- ThreadPlanStepFromHereCallback step_from_here_callback;
- };
-
- enum
- {
- eNone = 0,
- eAvoidInlines = (1 << 0),
- eStepInAvoidNoDebug = (1 << 1),
- eStepOutAvoidNoDebug = (1 << 2)
- };
-
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- ThreadPlanShouldStopHere (ThreadPlan *owner);
-
- ThreadPlanShouldStopHere(ThreadPlan *owner,
- const ThreadPlanShouldStopHereCallbacks *callbacks,
- void *baton = nullptr);
- virtual
- ~ThreadPlanShouldStopHere();
-
- // Set the ShouldStopHere callbacks. Pass in null to clear them and have no special behavior (though you
- // can also call ClearShouldStopHereCallbacks for that purpose. If you pass in a valid pointer, it will
- // adopt the non-null fields, and any null fields will be set to the default values.
-
- void
- SetShouldStopHereCallbacks (const ThreadPlanShouldStopHereCallbacks *callbacks, void *baton)
- {
- if (callbacks)
- {
- m_callbacks = *callbacks;
- if (!m_callbacks.should_stop_here_callback)
- m_callbacks.should_stop_here_callback = ThreadPlanShouldStopHere::DefaultShouldStopHereCallback;
- if (!m_callbacks.step_from_here_callback)
- m_callbacks.step_from_here_callback = ThreadPlanShouldStopHere::DefaultStepFromHereCallback;
- }
- else
- {
- ClearShouldStopHereCallbacks ();
- }
- m_baton = baton;
- }
-
- void
- ClearShouldStopHereCallbacks()
- {
- m_callbacks.Clear();
+ struct ThreadPlanShouldStopHereCallbacks {
+ ThreadPlanShouldStopHereCallbacks() {
+ should_stop_here_callback = nullptr;
+ step_from_here_callback = nullptr;
}
- bool
- InvokeShouldStopHereCallback (lldb::FrameComparison operation);
-
- lldb::ThreadPlanSP
- CheckShouldStopHereAndQueueStepOut (lldb::FrameComparison operation);
+ ThreadPlanShouldStopHereCallbacks(
+ ThreadPlanShouldStopHereCallback should_stop,
+ ThreadPlanStepFromHereCallback step_from_here) {
+ should_stop_here_callback = should_stop;
+ step_from_here_callback = step_from_here;
+ }
- lldb_private::Flags &
- GetFlags ()
- {
- return m_flags;
+ void Clear() {
+ should_stop_here_callback = nullptr;
+ step_from_here_callback = nullptr;
}
- const lldb_private::Flags &
- GetFlags () const
- {
- return m_flags;
+ ThreadPlanShouldStopHereCallback should_stop_here_callback;
+ ThreadPlanStepFromHereCallback step_from_here_callback;
+ };
+
+ enum {
+ eNone = 0,
+ eAvoidInlines = (1 << 0),
+ eStepInAvoidNoDebug = (1 << 1),
+ eStepOutAvoidNoDebug = (1 << 2)
+ };
+
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ ThreadPlanShouldStopHere(ThreadPlan *owner);
+
+ ThreadPlanShouldStopHere(ThreadPlan *owner,
+ const ThreadPlanShouldStopHereCallbacks *callbacks,
+ void *baton = nullptr);
+ virtual ~ThreadPlanShouldStopHere();
+
+ // Set the ShouldStopHere callbacks. Pass in null to clear them and have no
+ // special behavior (though you
+ // can also call ClearShouldStopHereCallbacks for that purpose. If you pass
+ // in a valid pointer, it will
+ // adopt the non-null fields, and any null fields will be set to the default
+ // values.
+
+ void
+ SetShouldStopHereCallbacks(const ThreadPlanShouldStopHereCallbacks *callbacks,
+ void *baton) {
+ if (callbacks) {
+ m_callbacks = *callbacks;
+ if (!m_callbacks.should_stop_here_callback)
+ m_callbacks.should_stop_here_callback =
+ ThreadPlanShouldStopHere::DefaultShouldStopHereCallback;
+ if (!m_callbacks.step_from_here_callback)
+ m_callbacks.step_from_here_callback =
+ ThreadPlanShouldStopHere::DefaultStepFromHereCallback;
+ } else {
+ ClearShouldStopHereCallbacks();
}
+ m_baton = baton;
+ }
+
+ void ClearShouldStopHereCallbacks() { m_callbacks.Clear(); }
+
+ bool InvokeShouldStopHereCallback(lldb::FrameComparison operation);
+
+ lldb::ThreadPlanSP
+ CheckShouldStopHereAndQueueStepOut(lldb::FrameComparison operation);
+
+ lldb_private::Flags &GetFlags() { return m_flags; }
+
+ const lldb_private::Flags &GetFlags() const { return m_flags; }
protected:
- static bool
- DefaultShouldStopHereCallback (ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, void *baton);
-
- static lldb::ThreadPlanSP
- DefaultStepFromHereCallback (ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, void *baton);
-
- virtual lldb::ThreadPlanSP
- QueueStepOutFromHerePlan (Flags &flags, lldb::FrameComparison operation);
-
- // Implement this, and call it in the plan's constructor to set the default flags.
- virtual void SetFlagsToDefault () = 0;
-
- ThreadPlanShouldStopHereCallbacks m_callbacks;
- void * m_baton;
- ThreadPlan *m_owner;
- lldb_private::Flags m_flags;
+ static bool DefaultShouldStopHereCallback(ThreadPlan *current_plan,
+ Flags &flags,
+ lldb::FrameComparison operation,
+ void *baton);
+
+ static lldb::ThreadPlanSP
+ DefaultStepFromHereCallback(ThreadPlan *current_plan, Flags &flags,
+ lldb::FrameComparison operation, void *baton);
+
+ virtual lldb::ThreadPlanSP
+ QueueStepOutFromHerePlan(Flags &flags, lldb::FrameComparison operation);
+
+ // Implement this, and call it in the plan's constructor to set the default
+ // flags.
+ virtual void SetFlagsToDefault() = 0;
+
+ ThreadPlanShouldStopHereCallbacks m_callbacks;
+ void *m_baton;
+ ThreadPlan *m_owner;
+ lldb_private::Flags m_flags;
private:
- DISALLOW_COPY_AND_ASSIGN (ThreadPlanShouldStopHere);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPlanShouldStopHere);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/ThreadPlanStepInRange.h b/include/lldb/Target/ThreadPlanStepInRange.h
index b31d35508271..c3116eac81b5 100644
--- a/include/lldb/Target/ThreadPlanStepInRange.h
+++ b/include/lldb/Target/ThreadPlanStepInRange.h
@@ -17,107 +17,94 @@
#include "lldb/Core/AddressRange.h"
#include "lldb/Target/StackID.h"
#include "lldb/Target/Thread.h"
-#include "lldb/Target/ThreadPlanStepRange.h"
#include "lldb/Target/ThreadPlanShouldStopHere.h"
+#include "lldb/Target/ThreadPlanStepRange.h"
namespace lldb_private {
-class ThreadPlanStepInRange :
- public ThreadPlanStepRange,
- public ThreadPlanShouldStopHere
-{
+class ThreadPlanStepInRange : public ThreadPlanStepRange,
+ public ThreadPlanShouldStopHere {
public:
- ThreadPlanStepInRange (Thread &thread,
- const AddressRange &range,
- const SymbolContext &addr_context,
- lldb::RunMode stop_others,
- LazyBool step_in_avoids_code_without_debug_info,
- LazyBool step_out_avoids_code_without_debug_info);
-
- ThreadPlanStepInRange (Thread &thread,
- const AddressRange &range,
- const SymbolContext &addr_context,
- const char *step_into_function_name,
- lldb::RunMode stop_others,
- LazyBool step_in_avoids_code_without_debug_info,
- LazyBool step_out_avoids_code_without_debug_info);
-
- ~ThreadPlanStepInRange() override;
-
- void
- GetDescription(Stream *s, lldb::DescriptionLevel level) override;
-
- bool
- ShouldStop(Event *event_ptr) override;
-
- void SetAvoidRegexp(const char *name);
-
- void SetStepInTarget (const char *target)
- {
- m_step_into_target.SetCString(target);
- }
-
- static void
- SetDefaultFlagValue (uint32_t new_value);
-
- bool
- IsVirtualStep() override;
+ ThreadPlanStepInRange(Thread &thread, const AddressRange &range,
+ const SymbolContext &addr_context,
+ lldb::RunMode stop_others,
+ LazyBool step_in_avoids_code_without_debug_info,
+ LazyBool step_out_avoids_code_without_debug_info);
+
+ ThreadPlanStepInRange(Thread &thread, const AddressRange &range,
+ const SymbolContext &addr_context,
+ const char *step_into_function_name,
+ lldb::RunMode stop_others,
+ LazyBool step_in_avoids_code_without_debug_info,
+ LazyBool step_out_avoids_code_without_debug_info);
+
+ ~ThreadPlanStepInRange() override;
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
+
+ bool ShouldStop(Event *event_ptr) override;
+
+ void SetAvoidRegexp(const char *name);
+
+ void SetStepInTarget(const char *target) {
+ m_step_into_target.SetCString(target);
+ }
+
+ static void SetDefaultFlagValue(uint32_t new_value);
+
+ bool IsVirtualStep() override;
protected:
- static bool
- DefaultShouldStopHereCallback (ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, void *baton);
-
- bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
-
- bool
- DoPlanExplainsStop(Event *event_ptr) override;
-
- void
- SetFlagsToDefault() override
- {
- GetFlags().Set(ThreadPlanStepInRange::s_default_flag_values);
- }
-
- void
- SetCallbacks()
- {
- ThreadPlanShouldStopHere::ThreadPlanShouldStopHereCallbacks callbacks(ThreadPlanStepInRange::DefaultShouldStopHereCallback, nullptr);
- SetShouldStopHereCallbacks (&callbacks, nullptr);
- }
-
- bool
- FrameMatchesAvoidCriteria ();
+ static bool DefaultShouldStopHereCallback(ThreadPlan *current_plan,
+ Flags &flags,
+ lldb::FrameComparison operation,
+ void *baton);
-private:
+ bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
+
+ bool DoPlanExplainsStop(Event *event_ptr) override;
- friend lldb::ThreadPlanSP
- Thread::QueueThreadPlanForStepOverRange (bool abort_other_plans,
- const AddressRange &range,
- const SymbolContext &addr_context,
- lldb::RunMode stop_others,
- LazyBool avoid_code_without_debug_info);
- friend lldb::ThreadPlanSP
- Thread::QueueThreadPlanForStepInRange (bool abort_other_plans,
- const AddressRange &range,
- const SymbolContext &addr_context,
- const char *step_in_target,
- lldb::RunMode stop_others,
- LazyBool step_in_avoids_code_without_debug_info,
- LazyBool step_out_avoids_code_without_debug_info);
-
- void SetupAvoidNoDebug(LazyBool step_in_avoids_code_without_debug_info,
- LazyBool step_out_avoids_code_without_debug_info);
- // Need an appropriate marker for the current stack so we can tell step out
- // from step in.
-
- static uint32_t s_default_flag_values; // These are the default flag values for the ThreadPlanStepThrough.
- lldb::ThreadPlanSP m_sub_plan_sp; // Keep track of the last plan we were running. If it fails, we should stop.
- std::unique_ptr<RegularExpression> m_avoid_regexp_ap;
- bool m_step_past_prologue; // FIXME: For now hard-coded to true, we could put a switch in for this if there's
- // demand for that.
- bool m_virtual_step; // true if we've just done a "virtual step", i.e. just moved the inline stack depth.
- ConstString m_step_into_target;
- DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepInRange);
+ void SetFlagsToDefault() override {
+ GetFlags().Set(ThreadPlanStepInRange::s_default_flag_values);
+ }
+
+ void SetCallbacks() {
+ ThreadPlanShouldStopHere::ThreadPlanShouldStopHereCallbacks callbacks(
+ ThreadPlanStepInRange::DefaultShouldStopHereCallback, nullptr);
+ SetShouldStopHereCallbacks(&callbacks, nullptr);
+ }
+
+ bool FrameMatchesAvoidCriteria();
+
+private:
+ friend lldb::ThreadPlanSP Thread::QueueThreadPlanForStepOverRange(
+ bool abort_other_plans, const AddressRange &range,
+ const SymbolContext &addr_context, lldb::RunMode stop_others,
+ LazyBool avoid_code_without_debug_info);
+ friend lldb::ThreadPlanSP Thread::QueueThreadPlanForStepInRange(
+ bool abort_other_plans, const AddressRange &range,
+ const SymbolContext &addr_context, const char *step_in_target,
+ lldb::RunMode stop_others,
+ LazyBool step_in_avoids_code_without_debug_info,
+ LazyBool step_out_avoids_code_without_debug_info);
+
+ void SetupAvoidNoDebug(LazyBool step_in_avoids_code_without_debug_info,
+ LazyBool step_out_avoids_code_without_debug_info);
+ // Need an appropriate marker for the current stack so we can tell step out
+ // from step in.
+
+ static uint32_t s_default_flag_values; // These are the default flag values
+ // for the ThreadPlanStepThrough.
+ lldb::ThreadPlanSP m_sub_plan_sp; // Keep track of the last plan we were
+ // running. If it fails, we should stop.
+ std::unique_ptr<RegularExpression> m_avoid_regexp_ap;
+ bool m_step_past_prologue; // FIXME: For now hard-coded to true, we could put
+ // a switch in for this if there's
+ // demand for that.
+ bool m_virtual_step; // true if we've just done a "virtual step", i.e. just
+ // moved the inline stack depth.
+ ConstString m_step_into_target;
+ DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepInRange);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/ThreadPlanStepInstruction.h b/include/lldb/Target/ThreadPlanStepInstruction.h
index 27b9bf1133fe..8b56e41ad64f 100644
--- a/include/lldb/Target/ThreadPlanStepInstruction.h
+++ b/include/lldb/Target/ThreadPlanStepInstruction.h
@@ -14,50 +14,46 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class ThreadPlanStepInstruction : public ThreadPlan
-{
+class ThreadPlanStepInstruction : public ThreadPlan {
public:
- ThreadPlanStepInstruction (Thread &thread,
- bool step_over,
- bool stop_others,
- Vote stop_vote,
- Vote run_vote);
+ ThreadPlanStepInstruction(Thread &thread, bool step_over, bool stop_others,
+ Vote stop_vote, Vote run_vote);
- ~ThreadPlanStepInstruction() override;
+ ~ThreadPlanStepInstruction() override;
- void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
- bool ValidatePlan(Stream *error) override;
- bool ShouldStop(Event *event_ptr) override;
- bool StopOthers() override;
- lldb::StateType GetPlanRunState() override;
- bool WillStop() override;
- bool MischiefManaged() override;
- bool IsPlanStale() override;
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
+ bool ValidatePlan(Stream *error) override;
+ bool ShouldStop(Event *event_ptr) override;
+ bool StopOthers() override;
+ lldb::StateType GetPlanRunState() override;
+ bool WillStop() override;
+ bool MischiefManaged() override;
+ bool IsPlanStale() override;
protected:
- bool DoPlanExplainsStop(Event *event_ptr) override;
+ bool DoPlanExplainsStop(Event *event_ptr) override;
- void SetUpState ();
+ void SetUpState();
private:
- friend lldb::ThreadPlanSP
- Thread::QueueThreadPlanForStepSingleInstruction (bool step_over, bool abort_other_plans, bool stop_other_threads);
-
- lldb::addr_t m_instruction_addr;
- bool m_stop_other_threads;
- bool m_step_over;
- // These two are used only for the step over case.
- bool m_start_has_symbol;
- StackID m_stack_id;
- StackID m_parent_frame_id;
-
- DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepInstruction);
+ friend lldb::ThreadPlanSP Thread::QueueThreadPlanForStepSingleInstruction(
+ bool step_over, bool abort_other_plans, bool stop_other_threads);
+
+ lldb::addr_t m_instruction_addr;
+ bool m_stop_other_threads;
+ bool m_step_over;
+ // These two are used only for the step over case.
+ bool m_start_has_symbol;
+ StackID m_stack_id;
+ StackID m_parent_frame_id;
+
+ DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepInstruction);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/ThreadPlanStepOut.h b/include/lldb/Target/ThreadPlanStepOut.h
index ccf829f636df..285f4cab13a2 100644
--- a/include/lldb/Target/ThreadPlanStepOut.h
+++ b/include/lldb/Target/ThreadPlanStepOut.h
@@ -20,82 +20,75 @@
namespace lldb_private {
-class ThreadPlanStepOut : public ThreadPlan,
- public ThreadPlanShouldStopHere
-{
+class ThreadPlanStepOut : public ThreadPlan, public ThreadPlanShouldStopHere {
public:
- ThreadPlanStepOut (Thread &thread,
- SymbolContext *addr_context,
- bool first_insn,
- bool stop_others,
- Vote stop_vote,
- Vote run_vote,
- uint32_t frame_idx,
- LazyBool step_out_avoids_code_without_debug_info,
- bool continue_to_next_branch = false);
-
- ~ThreadPlanStepOut() override;
-
- void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
- bool ValidatePlan(Stream *error) override;
- bool ShouldStop(Event *event_ptr) override;
- bool StopOthers() override;
- lldb::StateType GetPlanRunState() override;
- bool WillStop() override;
- bool MischiefManaged() override;
- void DidPush() override;
- bool IsPlanStale() override;
-
- lldb::ValueObjectSP GetReturnValueObject() override
- {
- return m_return_valobj_sp;
- }
+ ThreadPlanStepOut(Thread &thread, SymbolContext *addr_context,
+ bool first_insn, bool stop_others, Vote stop_vote,
+ Vote run_vote, uint32_t frame_idx,
+ LazyBool step_out_avoids_code_without_debug_info,
+ bool continue_to_next_branch = false,
+ bool gather_return_value = true);
+
+ ~ThreadPlanStepOut() override;
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
+ bool ValidatePlan(Stream *error) override;
+ bool ShouldStop(Event *event_ptr) override;
+ bool StopOthers() override;
+ lldb::StateType GetPlanRunState() override;
+ bool WillStop() override;
+ bool MischiefManaged() override;
+ void DidPush() override;
+ bool IsPlanStale() override;
+
+ lldb::ValueObjectSP GetReturnValueObject() override {
+ return m_return_valobj_sp;
+ }
protected:
- void
- SetFlagsToDefault() override
- {
- GetFlags().Set(ThreadPlanStepOut::s_default_flag_values);
- }
-
- bool DoPlanExplainsStop (Event *event_ptr) override;
- bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
- bool QueueInlinedStepPlan (bool queue_now);
+ void SetFlagsToDefault() override {
+ GetFlags().Set(ThreadPlanStepOut::s_default_flag_values);
+ }
+
+ bool DoPlanExplainsStop(Event *event_ptr) override;
+ bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
+ bool QueueInlinedStepPlan(bool queue_now);
private:
- static uint32_t s_default_flag_values; // These are the default flag values for the ThreadPlanStepThrough.
-
- lldb::addr_t m_step_from_insn;
- StackID m_step_out_to_id;
- StackID m_immediate_step_from_id;
- lldb::break_id_t m_return_bp_id;
- lldb::addr_t m_return_addr;
- bool m_stop_others;
- lldb::ThreadPlanSP m_step_out_to_inline_plan_sp; // This plan implements step out to the real function containing
- // an inlined frame so we can then step out of that.
- lldb::ThreadPlanSP m_step_through_inline_plan_sp; // This plan then steps past the inlined frame(s).
- lldb::ThreadPlanSP m_step_out_further_plan_sp; // This plan keeps stepping out if ShouldStopHere told us to.
- Function *m_immediate_step_from_function;
- lldb::ValueObjectSP m_return_valobj_sp;
-
- friend lldb::ThreadPlanSP
- Thread::QueueThreadPlanForStepOut (bool abort_other_plans,
- SymbolContext *addr_context,
- bool first_insn,
- bool stop_others,
- Vote stop_vote,
- Vote run_vote,
- uint32_t frame_idx,
- LazyBool step_out_avoids_code_without_debug_info);
-
- void SetupAvoidNoDebug(LazyBool step_out_avoids_code_without_debug_info);
- // Need an appropriate marker for the current stack so we can tell step out
- // from step in.
-
- void
- CalculateReturnValue();
-
- DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepOut);
+ static uint32_t s_default_flag_values; // These are the default flag values
+ // for the ThreadPlanStepThrough.
+
+ lldb::addr_t m_step_from_insn;
+ StackID m_step_out_to_id;
+ StackID m_immediate_step_from_id;
+ lldb::break_id_t m_return_bp_id;
+ lldb::addr_t m_return_addr;
+ bool m_stop_others;
+ lldb::ThreadPlanSP m_step_out_to_inline_plan_sp; // This plan implements step
+ // out to the real function
+ // containing
+ // an inlined frame so we can then step out of that.
+ lldb::ThreadPlanSP m_step_through_inline_plan_sp; // This plan then steps past
+ // the inlined frame(s).
+ lldb::ThreadPlanSP m_step_out_further_plan_sp; // This plan keeps stepping out
+ // if ShouldStopHere told us
+ // to.
+ Function *m_immediate_step_from_function;
+ lldb::ValueObjectSP m_return_valobj_sp;
+ bool m_calculate_return_value;
+
+ friend lldb::ThreadPlanSP Thread::QueueThreadPlanForStepOut(
+ bool abort_other_plans, SymbolContext *addr_context, bool first_insn,
+ bool stop_others, Vote stop_vote, Vote run_vote, uint32_t frame_idx,
+ LazyBool step_out_avoids_code_without_debug_info);
+
+ void SetupAvoidNoDebug(LazyBool step_out_avoids_code_without_debug_info);
+ // Need an appropriate marker for the current stack so we can tell step out
+ // from step in.
+
+ void CalculateReturnValue();
+
+ DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepOut);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/ThreadPlanStepOverBreakpoint.h b/include/lldb/Target/ThreadPlanStepOverBreakpoint.h
index 944f0e0455ee..969c008f67d1 100644
--- a/include/lldb/Target/ThreadPlanStepOverBreakpoint.h
+++ b/include/lldb/Target/ThreadPlanStepOverBreakpoint.h
@@ -19,44 +19,39 @@
namespace lldb_private {
-class ThreadPlanStepOverBreakpoint : public ThreadPlan
-{
+class ThreadPlanStepOverBreakpoint : public ThreadPlan {
public:
- ThreadPlanStepOverBreakpoint (Thread &thread);
+ ThreadPlanStepOverBreakpoint(Thread &thread);
- ~ThreadPlanStepOverBreakpoint() override;
+ ~ThreadPlanStepOverBreakpoint() override;
- void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
- bool ValidatePlan(Stream *error) override;
- bool ShouldStop(Event *event_ptr) override;
- bool StopOthers() override;
- lldb::StateType GetPlanRunState() override;
- bool WillStop() override;
- bool MischiefManaged() override;
- void ThreadDestroyed() override;
- void SetAutoContinue(bool do_it);
- bool ShouldAutoContinue(Event *event_ptr) override;
- bool IsPlanStale() override;
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
+ bool ValidatePlan(Stream *error) override;
+ bool ShouldStop(Event *event_ptr) override;
+ bool StopOthers() override;
+ lldb::StateType GetPlanRunState() override;
+ bool WillStop() override;
+ bool MischiefManaged() override;
+ void ThreadDestroyed() override;
+ void SetAutoContinue(bool do_it);
+ bool ShouldAutoContinue(Event *event_ptr) override;
+ bool IsPlanStale() override;
- lldb::addr_t
- GetBreakpointLoadAddress() const
- {
- return m_breakpoint_addr;
- }
+ lldb::addr_t GetBreakpointLoadAddress() const { return m_breakpoint_addr; }
protected:
- bool DoPlanExplainsStop(Event *event_ptr) override;
- bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
+ bool DoPlanExplainsStop(Event *event_ptr) override;
+ bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
- void ReenableBreakpointSite ();
-private:
+ void ReenableBreakpointSite();
- lldb::addr_t m_breakpoint_addr;
- lldb::user_id_t m_breakpoint_site_id;
- bool m_auto_continue;
- bool m_reenabled_breakpoint_site;
+private:
+ lldb::addr_t m_breakpoint_addr;
+ lldb::user_id_t m_breakpoint_site_id;
+ bool m_auto_continue;
+ bool m_reenabled_breakpoint_site;
- DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepOverBreakpoint);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepOverBreakpoint);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/ThreadPlanStepOverRange.h b/include/lldb/Target/ThreadPlanStepOverRange.h
index 7defaef7d07d..84fdb0ddcf99 100644
--- a/include/lldb/Target/ThreadPlanStepOverRange.h
+++ b/include/lldb/Target/ThreadPlanStepOverRange.h
@@ -22,39 +22,35 @@
namespace lldb_private {
class ThreadPlanStepOverRange : public ThreadPlanStepRange,
- ThreadPlanShouldStopHere
-{
+ ThreadPlanShouldStopHere {
public:
- ThreadPlanStepOverRange (Thread &thread,
- const AddressRange &range,
- const SymbolContext &addr_context,
- lldb::RunMode stop_others,
- LazyBool step_out_avoids_no_debug);
-
- ~ThreadPlanStepOverRange() override;
-
- void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
- bool ShouldStop(Event *event_ptr) override;
-
+ ThreadPlanStepOverRange(Thread &thread, const AddressRange &range,
+ const SymbolContext &addr_context,
+ lldb::RunMode stop_others,
+ LazyBool step_out_avoids_no_debug);
+
+ ~ThreadPlanStepOverRange() override;
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
+ bool ShouldStop(Event *event_ptr) override;
+
protected:
- bool DoPlanExplainsStop(Event *event_ptr) override;
- bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
-
- void
- SetFlagsToDefault() override
- {
- GetFlags().Set(ThreadPlanStepOverRange::s_default_flag_values);
- }
+ bool DoPlanExplainsStop(Event *event_ptr) override;
+ bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
+
+ void SetFlagsToDefault() override {
+ GetFlags().Set(ThreadPlanStepOverRange::s_default_flag_values);
+ }
private:
- static uint32_t s_default_flag_values;
-
- void SetupAvoidNoDebug(LazyBool step_out_avoids_code_without_debug_info);
- bool IsEquivalentContext(const SymbolContext &context);
+ static uint32_t s_default_flag_values;
+
+ void SetupAvoidNoDebug(LazyBool step_out_avoids_code_without_debug_info);
+ bool IsEquivalentContext(const SymbolContext &context);
- bool m_first_resume;
+ bool m_first_resume;
- DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepOverRange);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepOverRange);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/ThreadPlanStepRange.h b/include/lldb/Target/ThreadPlanStepRange.h
index 8f6685f82aab..ffb27d02e2d0 100644
--- a/include/lldb/Target/ThreadPlanStepRange.h
+++ b/include/lldb/Target/ThreadPlanStepRange.h
@@ -22,72 +22,71 @@
namespace lldb_private {
-class ThreadPlanStepRange : public ThreadPlan
-{
+class ThreadPlanStepRange : public ThreadPlan {
public:
- ThreadPlanStepRange (ThreadPlanKind kind,
- const char *name,
- Thread &thread,
- const AddressRange &range,
- const SymbolContext &addr_context,
- lldb::RunMode stop_others,
- bool given_ranges_only = false);
-
- ~ThreadPlanStepRange() override;
-
- void GetDescription(Stream *s, lldb::DescriptionLevel level) override = 0;
- bool ValidatePlan(Stream *error) override;
- bool ShouldStop(Event *event_ptr) override = 0;
- Vote ShouldReportStop(Event *event_ptr) override;
- bool StopOthers() override;
- lldb::StateType GetPlanRunState() override;
- bool WillStop() override;
- bool MischiefManaged() override;
- void DidPush() override;
- bool IsPlanStale() override;
-
- void AddRange(const AddressRange &new_range);
+ ThreadPlanStepRange(ThreadPlanKind kind, const char *name, Thread &thread,
+ const AddressRange &range,
+ const SymbolContext &addr_context,
+ lldb::RunMode stop_others,
+ bool given_ranges_only = false);
+
+ ~ThreadPlanStepRange() override;
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override = 0;
+ bool ValidatePlan(Stream *error) override;
+ bool ShouldStop(Event *event_ptr) override = 0;
+ Vote ShouldReportStop(Event *event_ptr) override;
+ bool StopOthers() override;
+ lldb::StateType GetPlanRunState() override;
+ bool WillStop() override;
+ bool MischiefManaged() override;
+ void DidPush() override;
+ bool IsPlanStale() override;
+
+ void AddRange(const AddressRange &new_range);
protected:
- bool InRange();
- lldb::FrameComparison CompareCurrentFrameToStartFrame();
- bool InSymbol();
- void DumpRanges (Stream *s);
-
- Disassembler *
- GetDisassembler ();
-
- InstructionList *
- GetInstructionsForAddress(lldb::addr_t addr, size_t &range_index, size_t &insn_offset);
-
- // Pushes a plan to proceed through the next section of instructions in the range - usually just a RunToAddress
- // plan to run to the next branch. Returns true if it pushed such a plan. If there was no available 'quick run'
- // plan, then just single step.
- bool
- SetNextBranchBreakpoint ();
-
- void
- ClearNextBranchBreakpoint();
-
- bool
- NextRangeBreakpointExplainsStop (lldb::StopInfoSP stop_info_sp);
-
- SymbolContext m_addr_context;
- std::vector<AddressRange> m_address_ranges;
- lldb::RunMode m_stop_others;
- StackID m_stack_id; // Use the stack ID so we can tell step out from step in.
- StackID m_parent_stack_id; // Use the parent stack ID so we can identify tail calls and the like.
- bool m_no_more_plans; // Need this one so we can tell if we stepped into a call,
- // but can't continue, in which case we are done.
- bool m_first_run_event; // We want to broadcast only one running event, our first.
- lldb::BreakpointSP m_next_branch_bp_sp;
- bool m_use_fast_step;
- bool m_given_ranges_only;
+ bool InRange();
+ lldb::FrameComparison CompareCurrentFrameToStartFrame();
+ bool InSymbol();
+ void DumpRanges(Stream *s);
+
+ Disassembler *GetDisassembler();
+
+ InstructionList *GetInstructionsForAddress(lldb::addr_t addr,
+ size_t &range_index,
+ size_t &insn_offset);
+
+ // Pushes a plan to proceed through the next section of instructions in the
+ // range - usually just a RunToAddress
+ // plan to run to the next branch. Returns true if it pushed such a plan. If
+ // there was no available 'quick run'
+ // plan, then just single step.
+ bool SetNextBranchBreakpoint();
+
+ void ClearNextBranchBreakpoint();
+
+ bool NextRangeBreakpointExplainsStop(lldb::StopInfoSP stop_info_sp);
+
+ SymbolContext m_addr_context;
+ std::vector<AddressRange> m_address_ranges;
+ lldb::RunMode m_stop_others;
+ StackID m_stack_id; // Use the stack ID so we can tell step out from step in.
+ StackID m_parent_stack_id; // Use the parent stack ID so we can identify tail
+ // calls and the like.
+ bool m_no_more_plans; // Need this one so we can tell if we stepped into a
+ // call,
+ // but can't continue, in which case we are done.
+ bool m_first_run_event; // We want to broadcast only one running event, our
+ // first.
+ lldb::BreakpointSP m_next_branch_bp_sp;
+ bool m_use_fast_step;
+ bool m_given_ranges_only;
private:
- std::vector<lldb::DisassemblerSP> m_instruction_ranges;
+ std::vector<lldb::DisassemblerSP> m_instruction_ranges;
- DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepRange);
+ DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepRange);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/ThreadPlanStepThrough.h b/include/lldb/Target/ThreadPlanStepThrough.h
index 43af37c84a06..41aa7b21abe0 100644
--- a/include/lldb/Target/ThreadPlanStepThrough.h
+++ b/include/lldb/Target/ThreadPlanStepThrough.h
@@ -19,51 +19,47 @@
namespace lldb_private {
-class ThreadPlanStepThrough : public ThreadPlan
-{
+class ThreadPlanStepThrough : public ThreadPlan {
public:
- ~ThreadPlanStepThrough() override;
+ ~ThreadPlanStepThrough() override;
- void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
- bool ValidatePlan(Stream *error) override;
- bool ShouldStop(Event *event_ptr) override;
- bool StopOthers() override;
- lldb::StateType GetPlanRunState() override;
- bool WillStop() override;
- bool MischiefManaged() override;
- void DidPush() override;
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
+ bool ValidatePlan(Stream *error) override;
+ bool ShouldStop(Event *event_ptr) override;
+ bool StopOthers() override;
+ lldb::StateType GetPlanRunState() override;
+ bool WillStop() override;
+ bool MischiefManaged() override;
+ void DidPush() override;
protected:
- bool DoPlanExplainsStop(Event *event_ptr) override;
- bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
+ bool DoPlanExplainsStop(Event *event_ptr) override;
+ bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
- ThreadPlanStepThrough (Thread &thread,
- StackID &return_stack_id,
- bool stop_others);
+ ThreadPlanStepThrough(Thread &thread, StackID &return_stack_id,
+ bool stop_others);
- void
- LookForPlanToStepThroughFromCurrentPC ();
-
- bool
- HitOurBackstopBreakpoint();
+ void LookForPlanToStepThroughFromCurrentPC();
+
+ bool HitOurBackstopBreakpoint();
private:
- friend lldb::ThreadPlanSP
-
- Thread::QueueThreadPlanForStepThrough (StackID &return_stack_id,
- bool abort_other_plans,
- bool stop_others);
-
- void ClearBackstopBreakpoint();
-
- lldb::ThreadPlanSP m_sub_plan_sp;
- lldb::addr_t m_start_address;
- lldb::break_id_t m_backstop_bkpt_id;
- lldb::addr_t m_backstop_addr;
- StackID m_return_stack_id;
- bool m_stop_others;
-
- DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepThrough);
+ friend lldb::ThreadPlanSP
+
+ Thread::QueueThreadPlanForStepThrough(StackID &return_stack_id,
+ bool abort_other_plans,
+ bool stop_others);
+
+ void ClearBackstopBreakpoint();
+
+ lldb::ThreadPlanSP m_sub_plan_sp;
+ lldb::addr_t m_start_address;
+ lldb::break_id_t m_backstop_bkpt_id;
+ lldb::addr_t m_backstop_addr;
+ StackID m_return_stack_id;
+ bool m_stop_others;
+
+ DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepThrough);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/ThreadPlanStepUntil.h b/include/lldb/Target/ThreadPlanStepUntil.h
index 3c1bd8c6665d..bdc630bcf8de 100644
--- a/include/lldb/Target/ThreadPlanStepUntil.h
+++ b/include/lldb/Target/ThreadPlanStepUntil.h
@@ -19,58 +19,52 @@
namespace lldb_private {
-class ThreadPlanStepUntil : public ThreadPlan
-{
+class ThreadPlanStepUntil : public ThreadPlan {
public:
- ~ThreadPlanStepUntil() override;
+ ~ThreadPlanStepUntil() override;
- void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
- bool ValidatePlan(Stream *error) override;
- bool ShouldStop(Event *event_ptr) override;
- bool StopOthers() override;
- lldb::StateType GetPlanRunState() override;
- bool WillStop() override;
- bool MischiefManaged() override;
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
+ bool ValidatePlan(Stream *error) override;
+ bool ShouldStop(Event *event_ptr) override;
+ bool StopOthers() override;
+ lldb::StateType GetPlanRunState() override;
+ bool WillStop() override;
+ bool MischiefManaged() override;
protected:
- bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
- bool DoPlanExplainsStop(Event *event_ptr) override;
+ bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
+ bool DoPlanExplainsStop(Event *event_ptr) override;
- ThreadPlanStepUntil (Thread &thread,
- lldb::addr_t *address_list,
- size_t num_addresses,
- bool stop_others,
- uint32_t frame_idx = 0);
+ ThreadPlanStepUntil(Thread &thread, lldb::addr_t *address_list,
+ size_t num_addresses, bool stop_others,
+ uint32_t frame_idx = 0);
- void AnalyzeStop();
+ void AnalyzeStop();
private:
- StackID m_stack_id;
- lldb::addr_t m_step_from_insn;
- lldb::break_id_t m_return_bp_id;
- lldb::addr_t m_return_addr;
- bool m_stepped_out;
- bool m_should_stop;
- bool m_ran_analyze;
- bool m_explains_stop;
-
- typedef std::map<lldb::addr_t,lldb::break_id_t> until_collection;
- until_collection m_until_points;
- bool m_stop_others;
-
- void Clear();
-
- friend lldb::ThreadPlanSP
- Thread::QueueThreadPlanForStepUntil (bool abort_other_plans,
- lldb::addr_t *address_list,
- size_t num_addresses,
- bool stop_others,
- uint32_t frame_idx);
-
- // Need an appropriate marker for the current stack so we can tell step out
- // from step in.
-
- DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepUntil);
+ StackID m_stack_id;
+ lldb::addr_t m_step_from_insn;
+ lldb::break_id_t m_return_bp_id;
+ lldb::addr_t m_return_addr;
+ bool m_stepped_out;
+ bool m_should_stop;
+ bool m_ran_analyze;
+ bool m_explains_stop;
+
+ typedef std::map<lldb::addr_t, lldb::break_id_t> until_collection;
+ until_collection m_until_points;
+ bool m_stop_others;
+
+ void Clear();
+
+ friend lldb::ThreadPlanSP Thread::QueueThreadPlanForStepUntil(
+ bool abort_other_plans, lldb::addr_t *address_list, size_t num_addresses,
+ bool stop_others, uint32_t frame_idx);
+
+ // Need an appropriate marker for the current stack so we can tell step out
+ // from step in.
+
+ DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepUntil);
};
} // namespace lldb_private
diff --git a/include/lldb/Target/ThreadPlanTracer.h b/include/lldb/Target/ThreadPlanTracer.h
index 6d064133fa91..65115383efaa 100644
--- a/include/lldb/Target/ThreadPlanTracer.h
+++ b/include/lldb/Target/ThreadPlanTracer.h
@@ -1,4 +1,5 @@
-//===-- ThreadPlanTracer.h --------------------------------------------*- C++ -*-===//
+//===-- ThreadPlanTracer.h --------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,111 +15,88 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Symbol/TaggedASTType.h"
#include "lldb/Target/Thread.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class ThreadPlanTracer
-{
-friend class ThreadPlan;
+class ThreadPlanTracer {
+ friend class ThreadPlan;
public:
- typedef enum ThreadPlanTracerStyle
- {
- eLocation = 0,
- eStateChange,
- eCheckFrames,
- ePython
- } ThreadPlanTracerStyle;
-
- ThreadPlanTracer (Thread &thread, lldb::StreamSP &stream_sp);
- ThreadPlanTracer (Thread &thread);
-
- virtual ~ThreadPlanTracer() = default;
-
- virtual void TracingStarted ()
- {
- }
-
- virtual void TracingEnded ()
- {
- }
-
- bool
- EnableTracing(bool value)
- {
- bool old_value = m_enabled;
- m_enabled = value;
- if (old_value == false && value == true)
- TracingStarted();
- else if (old_value == true && value == false)
- TracingEnded();
-
- return old_value;
- }
-
- bool
- TracingEnabled()
- {
- return m_enabled;
- }
-
- bool
- EnableSingleStep (bool value)
- {
- bool old_value = m_single_step;
- m_single_step = value;
- return old_value;
- }
-
- bool
- SingleStepEnabled ()
- {
- return m_single_step;
- }
+ typedef enum ThreadPlanTracerStyle {
+ eLocation = 0,
+ eStateChange,
+ eCheckFrames,
+ ePython
+ } ThreadPlanTracerStyle;
+
+ ThreadPlanTracer(Thread &thread, lldb::StreamSP &stream_sp);
+ ThreadPlanTracer(Thread &thread);
+
+ virtual ~ThreadPlanTracer() = default;
+
+ virtual void TracingStarted() {}
+
+ virtual void TracingEnded() {}
+
+ bool EnableTracing(bool value) {
+ bool old_value = m_enabled;
+ m_enabled = value;
+ if (old_value == false && value == true)
+ TracingStarted();
+ else if (old_value == true && value == false)
+ TracingEnded();
+
+ return old_value;
+ }
+
+ bool TracingEnabled() { return m_enabled; }
+
+ bool EnableSingleStep(bool value) {
+ bool old_value = m_single_step;
+ m_single_step = value;
+ return old_value;
+ }
+
+ bool SingleStepEnabled() { return m_single_step; }
protected:
- Thread &m_thread;
+ Thread &m_thread;
+
+ Stream *GetLogStream();
+
+ virtual void Log();
- Stream *
- GetLogStream ();
-
- virtual void Log();
-
private:
- bool
- TracerExplainsStop ();
-
- bool m_single_step;
- bool m_enabled;
- lldb::StreamSP m_stream_sp;
+ bool TracerExplainsStop();
+
+ bool m_single_step;
+ bool m_enabled;
+ lldb::StreamSP m_stream_sp;
};
-
-class ThreadPlanAssemblyTracer : public ThreadPlanTracer
-{
+
+class ThreadPlanAssemblyTracer : public ThreadPlanTracer {
public:
- ThreadPlanAssemblyTracer (Thread &thread, lldb::StreamSP &stream_sp);
- ThreadPlanAssemblyTracer (Thread &thread);
- ~ThreadPlanAssemblyTracer() override;
+ ThreadPlanAssemblyTracer(Thread &thread, lldb::StreamSP &stream_sp);
+ ThreadPlanAssemblyTracer(Thread &thread);
+ ~ThreadPlanAssemblyTracer() override;
- void TracingStarted() override;
- void TracingEnded() override;
- void Log() override;
+ void TracingStarted() override;
+ void TracingEnded() override;
+ void Log() override;
private:
- Disassembler *
- GetDisassembler ();
+ Disassembler *GetDisassembler();
- TypeFromUser
- GetIntPointerType();
+ TypeFromUser GetIntPointerType();
- lldb::DisassemblerSP m_disassembler_sp;
- TypeFromUser m_intptr_type;
- std::vector<RegisterValue> m_register_values;
- lldb::DataBufferSP m_buffer_sp;
+ lldb::DisassemblerSP m_disassembler_sp;
+ TypeFromUser m_intptr_type;
+ std::vector<RegisterValue> m_register_values;
+ lldb::DataBufferSP m_buffer_sp;
};
} // namespace lldb_private
diff --git a/include/lldb/Target/ThreadSpec.h b/include/lldb/Target/ThreadSpec.h
index 95f509a5cb9d..204f1f9fbd70 100644
--- a/include/lldb/Target/ThreadSpec.h
+++ b/include/lldb/Target/ThreadSpec.h
@@ -26,130 +26,111 @@ namespace lldb_private {
// Thread Name
// Thread Queue Name
//
-// But if we need more generality, we can hang a key/value map off of this structure.
-// That's why the thread matches spec test is done as a virtual method in Thread::MatchesSpec,
+// But if we need more generality, we can hang a key/value map off of this
+// structure.
+// That's why the thread matches spec test is done as a virtual method in
+// Thread::MatchesSpec,
// since it is the native thread that would know how to interpret the keys.
-// I was going to do the Queue Name this way out of sheer orneriness, but that seems a
+// I was going to do the Queue Name this way out of sheer orneriness, but that
+// seems a
// sufficiently general concept, so I put it in here on its own.
-class ThreadSpec
-{
+class ThreadSpec {
public:
- ThreadSpec ();
-
- ThreadSpec (const ThreadSpec &rhs);
-
- const ThreadSpec &
- operator=(const ThreadSpec &rhs);
-
- void
- SetIndex (uint32_t index)
- {
- m_index = index;
- }
-
- void
- SetTID (lldb::tid_t tid)
- {
- m_tid = tid;
- }
-
- void
- SetName (const char *name)
- {
- m_name = name;
- }
-
- void
- SetQueueName (const char *queue_name)
- {
- m_queue_name = queue_name;
- }
-
- uint32_t
- GetIndex () const
- {
- return m_index;
- }
-
- lldb::tid_t
- GetTID () const
- {
- return m_tid;
- }
-
- const char *
- GetName () const;
-
- const char *
- GetQueueName () const;
-
- bool
- TIDMatches (lldb::tid_t thread_id) const
- {
- if (m_tid == LLDB_INVALID_THREAD_ID || thread_id == LLDB_INVALID_THREAD_ID)
- return true;
- else
- return thread_id == m_tid;
- }
-
- bool
- TIDMatches (Thread &thread) const;
-
- bool
- IndexMatches (uint32_t index) const
- {
- if (m_index == UINT32_MAX || index == UINT32_MAX)
- return true;
- else
- return index == m_index;
- }
-
- bool
- IndexMatches (Thread &thread) const;
-
- bool
- NameMatches (const char *name) const
- {
- if (m_name.empty())
- return true;
- else if (name == nullptr)
- return false;
- else
- return m_name == name;
- }
-
- bool
- NameMatches (Thread &thread) const;
-
- bool
- QueueNameMatches (const char *queue_name) const
- {
- if (m_queue_name.empty())
- return true;
- else if (queue_name == nullptr)
- return false;
- else
- return m_queue_name == queue_name;
- }
-
- bool
- QueueNameMatches (Thread &thread) const;
-
- bool
- ThreadPassesBasicTests (Thread &thread) const;
-
- bool
- HasSpecification () const;
-
- void
- GetDescription (Stream *s, lldb::DescriptionLevel level) const;
+ ThreadSpec();
+
+ ThreadSpec(const ThreadSpec &rhs);
+
+ const ThreadSpec &operator=(const ThreadSpec &rhs);
+
+ static std::unique_ptr<ThreadSpec>
+ CreateFromStructuredData(const StructuredData::Dictionary &data_dict,
+ Error &error);
+
+ StructuredData::ObjectSP SerializeToStructuredData();
+
+ static const char *GetSerializationKey() { return "ThreadSpec"; }
+
+ void SetIndex(uint32_t index) { m_index = index; }
+
+ void SetTID(lldb::tid_t tid) { m_tid = tid; }
+
+ void SetName(const char *name) { m_name = name; }
+
+ void SetQueueName(const char *queue_name) { m_queue_name = queue_name; }
+
+ uint32_t GetIndex() const { return m_index; }
+
+ lldb::tid_t GetTID() const { return m_tid; }
+
+ const char *GetName() const;
+
+ const char *GetQueueName() const;
+
+ bool TIDMatches(lldb::tid_t thread_id) const {
+ if (m_tid == LLDB_INVALID_THREAD_ID || thread_id == LLDB_INVALID_THREAD_ID)
+ return true;
+ else
+ return thread_id == m_tid;
+ }
+
+ bool TIDMatches(Thread &thread) const;
+
+ bool IndexMatches(uint32_t index) const {
+ if (m_index == UINT32_MAX || index == UINT32_MAX)
+ return true;
+ else
+ return index == m_index;
+ }
+
+ bool IndexMatches(Thread &thread) const;
+
+ bool NameMatches(const char *name) const {
+ if (m_name.empty())
+ return true;
+ else if (name == nullptr)
+ return false;
+ else
+ return m_name == name;
+ }
+
+ bool NameMatches(Thread &thread) const;
+
+ bool QueueNameMatches(const char *queue_name) const {
+ if (m_queue_name.empty())
+ return true;
+ else if (queue_name == nullptr)
+ return false;
+ else
+ return m_queue_name == queue_name;
+ }
+
+ bool QueueNameMatches(Thread &thread) const;
+
+ bool ThreadPassesBasicTests(Thread &thread) const;
+
+ bool HasSpecification() const;
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) const;
private:
- uint32_t m_index;
- lldb::tid_t m_tid;
- std::string m_name;
- std::string m_queue_name;
+ enum class OptionNames {
+ ThreadIndex = 0,
+ ThreadID,
+ ThreadName,
+ QueueName,
+ LastOptionName
+ };
+ static const char *g_option_names[(size_t)OptionNames::LastOptionName];
+
+ static const char *GetKey(OptionNames enum_value) {
+ return g_option_names[(size_t) enum_value];
+ }
+
+ uint32_t m_index;
+ lldb::tid_t m_tid;
+ std::string m_name;
+ std::string m_queue_name;
};
} // namespace lldb_private
diff --git a/include/lldb/Target/UnixSignals.h b/include/lldb/Target/UnixSignals.h
index 7a02f557067b..1c58d6452b5f 100644
--- a/include/lldb/Target/UnixSignals.h
+++ b/include/lldb/Target/UnixSignals.h
@@ -12,149 +12,110 @@
// C Includes
// C++ Includes
-#include <string>
#include <map>
+#include <string>
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/ConstString.h"
+#include "lldb/lldb-private.h"
-namespace lldb_private
-{
+namespace lldb_private {
-class UnixSignals
-{
+class UnixSignals {
public:
- static lldb::UnixSignalsSP
- Create(const ArchSpec &arch);
+ static lldb::UnixSignalsSP Create(const ArchSpec &arch);
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- UnixSignals();
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ UnixSignals();
- virtual
- ~UnixSignals();
+ virtual ~UnixSignals();
- const char *
- GetSignalAsCString (int32_t signo) const;
+ const char *GetSignalAsCString(int32_t signo) const;
- bool
- SignalIsValid (int32_t signo) const;
+ bool SignalIsValid(int32_t signo) const;
- int32_t
- GetSignalNumberFromName (const char *name) const;
+ int32_t GetSignalNumberFromName(const char *name) const;
- const char *
- GetSignalInfo (int32_t signo,
- bool &should_suppress,
- bool &should_stop,
- bool &should_notify) const;
+ const char *GetSignalInfo(int32_t signo, bool &should_suppress,
+ bool &should_stop, bool &should_notify) const;
- bool
- GetShouldSuppress (int32_t signo) const;
+ bool GetShouldSuppress(int32_t signo) const;
- bool
- SetShouldSuppress (int32_t signo,
- bool value);
+ bool SetShouldSuppress(int32_t signo, bool value);
- bool
- SetShouldSuppress (const char *signal_name,
- bool value);
+ bool SetShouldSuppress(const char *signal_name, bool value);
- bool
- GetShouldStop (int32_t signo) const;
+ bool GetShouldStop(int32_t signo) const;
- bool
- SetShouldStop (int32_t signo,
- bool value);
- bool
- SetShouldStop (const char *signal_name,
- bool value);
+ bool SetShouldStop(int32_t signo, bool value);
+ bool SetShouldStop(const char *signal_name, bool value);
- bool
- GetShouldNotify (int32_t signo) const;
+ bool GetShouldNotify(int32_t signo) const;
- bool
- SetShouldNotify (int32_t signo, bool value);
+ bool SetShouldNotify(int32_t signo, bool value);
- bool
- SetShouldNotify (const char *signal_name,
- bool value);
+ bool SetShouldNotify(const char *signal_name, bool value);
- // These provide an iterator through the signals available on this system.
- // Call GetFirstSignalNumber to get the first entry, then iterate on GetNextSignalNumber
- // till you get back LLDB_INVALID_SIGNAL_NUMBER.
- int32_t
- GetFirstSignalNumber () const;
+ // These provide an iterator through the signals available on this system.
+ // Call GetFirstSignalNumber to get the first entry, then iterate on
+ // GetNextSignalNumber
+ // till you get back LLDB_INVALID_SIGNAL_NUMBER.
+ int32_t GetFirstSignalNumber() const;
- int32_t
- GetNextSignalNumber (int32_t current_signal) const;
+ int32_t GetNextSignalNumber(int32_t current_signal) const;
- int32_t
- GetNumSignals() const;
+ int32_t GetNumSignals() const;
- int32_t
- GetSignalAtIndex(int32_t index) const;
+ int32_t GetSignalAtIndex(int32_t index) const;
- ConstString
- GetShortName(ConstString name) const;
+ ConstString GetShortName(ConstString name) const;
- // We assume that the elements of this object are constant once it is constructed,
- // since a process should never need to add or remove symbols as it runs. So don't
- // call these functions anywhere but the constructor of your subclass of UnixSignals or in
- // your Process Plugin's GetUnixSignals method before you return the UnixSignal object.
+ // We assume that the elements of this object are constant once it is
+ // constructed,
+ // since a process should never need to add or remove symbols as it runs. So
+ // don't
+ // call these functions anywhere but the constructor of your subclass of
+ // UnixSignals or in
+ // your Process Plugin's GetUnixSignals method before you return the
+ // UnixSignal object.
- void
- AddSignal (int signo,
- const char *name,
- bool default_suppress,
- bool default_stop,
- bool default_notify,
- const char *description,
- const char *alias = nullptr);
+ void AddSignal(int signo, const char *name, bool default_suppress,
+ bool default_stop, bool default_notify,
+ const char *description, const char *alias = nullptr);
- void
- RemoveSignal (int signo);
+ void RemoveSignal(int signo);
protected:
- //------------------------------------------------------------------
- // Classes that inherit from UnixSignals can see and modify these
- //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ // Classes that inherit from UnixSignals can see and modify these
+ //------------------------------------------------------------------
- struct Signal
- {
- ConstString m_name;
- ConstString m_alias;
- std::string m_description;
- bool m_suppress:1,
- m_stop:1,
- m_notify:1;
+ struct Signal {
+ ConstString m_name;
+ ConstString m_alias;
+ std::string m_description;
+ bool m_suppress : 1, m_stop : 1, m_notify : 1;
- Signal (const char *name,
- bool default_suppress,
- bool default_stop,
- bool default_notify,
- const char *description,
- const char *alias);
+ Signal(const char *name, bool default_suppress, bool default_stop,
+ bool default_notify, const char *description, const char *alias);
- ~Signal () {}
- };
+ ~Signal() {}
+ };
- virtual void
- Reset ();
+ virtual void Reset();
- typedef std::map <int32_t, Signal> collection;
+ typedef std::map<int32_t, Signal> collection;
- collection m_signals;
+ collection m_signals;
- // GDBRemote signals need to be copyable.
- UnixSignals(const UnixSignals &rhs);
+ // GDBRemote signals need to be copyable.
+ UnixSignals(const UnixSignals &rhs);
- const UnixSignals &
- operator=(const UnixSignals &rhs) = delete;
+ const UnixSignals &operator=(const UnixSignals &rhs) = delete;
};
} // Namespace lldb
-#endif // lldb_UnixSignals_h_
+#endif // lldb_UnixSignals_h_
diff --git a/include/lldb/Target/Unwind.h b/include/lldb/Target/Unwind.h
index 09ba87a42bbe..a50e8d4a7bdd 100644
--- a/include/lldb/Target/Unwind.h
+++ b/include/lldb/Target/Unwind.h
@@ -20,96 +20,73 @@
namespace lldb_private {
-class Unwind
-{
+class Unwind {
protected:
- //------------------------------------------------------------------
- // Classes that inherit from Unwind can see and modify these
- //------------------------------------------------------------------
- Unwind(Thread &thread) : m_thread(thread), m_unwind_mutex() {}
+ //------------------------------------------------------------------
+ // Classes that inherit from Unwind can see and modify these
+ //------------------------------------------------------------------
+ Unwind(Thread &thread) : m_thread(thread), m_unwind_mutex() {}
public:
- virtual
- ~Unwind()
- {
+ virtual ~Unwind() {}
+
+ void Clear() {
+ std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
+ DoClear();
+ }
+
+ uint32_t GetFrameCount() {
+ std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
+ return DoGetFrameCount();
+ }
+
+ uint32_t GetFramesUpTo(uint32_t end_idx) {
+ lldb::addr_t cfa;
+ lldb::addr_t pc;
+ uint32_t idx;
+
+ for (idx = 0; idx < end_idx; idx++) {
+ if (!DoGetFrameInfoAtIndex(idx, cfa, pc)) {
+ break;
+ }
}
+ return idx;
+ }
- void
- Clear()
- {
- std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
- DoClear();
- }
+ bool GetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa,
+ lldb::addr_t &pc) {
+ std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
+ return DoGetFrameInfoAtIndex(frame_idx, cfa, pc);
+ }
- uint32_t
- GetFrameCount()
- {
- std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
- return DoGetFrameCount();
- }
+ lldb::RegisterContextSP CreateRegisterContextForFrame(StackFrame *frame) {
+ std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
+ return DoCreateRegisterContextForFrame(frame);
+ }
- uint32_t
- GetFramesUpTo (uint32_t end_idx)
- {
- lldb::addr_t cfa;
- lldb::addr_t pc;
- uint32_t idx;
-
- for (idx = 0; idx < end_idx; idx++)
- {
- if (!DoGetFrameInfoAtIndex (idx, cfa, pc))
- {
- break;
- }
- }
- return idx;
- }
+ Thread &GetThread() { return m_thread; }
- bool
- GetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa, lldb::addr_t &pc)
- {
- std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
- return DoGetFrameInfoAtIndex(frame_idx, cfa, pc);
- }
+protected:
+ //------------------------------------------------------------------
+ // Classes that inherit from Unwind can see and modify these
+ //------------------------------------------------------------------
+ virtual void DoClear() = 0;
- lldb::RegisterContextSP
- CreateRegisterContextForFrame(StackFrame *frame)
- {
- std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
- return DoCreateRegisterContextForFrame(frame);
- }
+ virtual uint32_t DoGetFrameCount() = 0;
- Thread &
- GetThread()
- {
- return m_thread;
- }
+ virtual bool DoGetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa,
+ lldb::addr_t &pc) = 0;
-protected:
- //------------------------------------------------------------------
- // Classes that inherit from Unwind can see and modify these
- //------------------------------------------------------------------
- virtual void
- DoClear() = 0;
-
- virtual uint32_t
- DoGetFrameCount() = 0;
-
- virtual bool
- DoGetFrameInfoAtIndex (uint32_t frame_idx,
- lldb::addr_t& cfa,
- lldb::addr_t& pc) = 0;
-
- virtual lldb::RegisterContextSP
- DoCreateRegisterContextForFrame (StackFrame *frame) = 0;
-
- Thread &m_thread;
- std::recursive_mutex m_unwind_mutex;
+ virtual lldb::RegisterContextSP
+ DoCreateRegisterContextForFrame(StackFrame *frame) = 0;
+
+ Thread &m_thread;
+ std::recursive_mutex m_unwind_mutex;
private:
- DISALLOW_COPY_AND_ASSIGN (Unwind);
+ DISALLOW_COPY_AND_ASSIGN(Unwind);
};
} // namespace lldb_private
-#endif // liblldb_Unwind_h_
+#endif // liblldb_Unwind_h_
diff --git a/include/lldb/Target/UnwindAssembly.h b/include/lldb/Target/UnwindAssembly.h
index 6f53e7e710f5..66fc27f71aa1 100644
--- a/include/lldb/Target/UnwindAssembly.h
+++ b/include/lldb/Target/UnwindAssembly.h
@@ -10,50 +10,43 @@
#ifndef utility_UnwindAssembly_h_
#define utility_UnwindAssembly_h_
-#include "lldb/lldb-private.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/PluginInterface.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class UnwindAssembly :
- public std::enable_shared_from_this<UnwindAssembly>,
- public PluginInterface
-{
+class UnwindAssembly : public std::enable_shared_from_this<UnwindAssembly>,
+ public PluginInterface {
public:
- static lldb::UnwindAssemblySP
- FindPlugin (const ArchSpec &arch);
+ static lldb::UnwindAssemblySP FindPlugin(const ArchSpec &arch);
- ~UnwindAssembly() override;
+ ~UnwindAssembly() override;
- virtual bool
- GetNonCallSiteUnwindPlanFromAssembly (AddressRange& func,
- Thread& thread,
- UnwindPlan& unwind_plan) = 0;
+ virtual bool
+ GetNonCallSiteUnwindPlanFromAssembly(AddressRange &func, Thread &thread,
+ UnwindPlan &unwind_plan) = 0;
- virtual bool
- AugmentUnwindPlanFromCallSite (AddressRange& func,
- Thread& thread,
- UnwindPlan& unwind_plan) = 0;
+ virtual bool AugmentUnwindPlanFromCallSite(AddressRange &func, Thread &thread,
+ UnwindPlan &unwind_plan) = 0;
- virtual bool
- GetFastUnwindPlan (AddressRange& func,
- Thread& thread,
- UnwindPlan &unwind_plan) = 0;
+ virtual bool GetFastUnwindPlan(AddressRange &func, Thread &thread,
+ UnwindPlan &unwind_plan) = 0;
- // thread may be NULL in which case we only use the Target (e.g. if this is called pre-process-launch).
- virtual bool
- FirstNonPrologueInsn (AddressRange& func,
- const lldb_private::ExecutionContext &exe_ctx,
- Address& first_non_prologue_insn) = 0;
+ // thread may be NULL in which case we only use the Target (e.g. if this is
+ // called pre-process-launch).
+ virtual bool
+ FirstNonPrologueInsn(AddressRange &func,
+ const lldb_private::ExecutionContext &exe_ctx,
+ Address &first_non_prologue_insn) = 0;
protected:
- UnwindAssembly (const ArchSpec &arch);
- ArchSpec m_arch;
+ UnwindAssembly(const ArchSpec &arch);
+ ArchSpec m_arch;
private:
- UnwindAssembly(); // Outlaw default constructor
- DISALLOW_COPY_AND_ASSIGN (UnwindAssembly);
+ UnwindAssembly(); // Outlaw default constructor
+ DISALLOW_COPY_AND_ASSIGN(UnwindAssembly);
};
} // namespace lldb_private
diff --git a/include/lldb/Utility/AnsiTerminal.h b/include/lldb/Utility/AnsiTerminal.h
index a43dd1ba4325..5eaf2fd0e069 100644
--- a/include/lldb/Utility/AnsiTerminal.h
+++ b/include/lldb/Utility/AnsiTerminal.h
@@ -7,124 +7,130 @@
//
//===----------------------------------------------------------------------===//
+#define ANSI_FG_COLOR_BLACK 30
+#define ANSI_FG_COLOR_RED 31
+#define ANSI_FG_COLOR_GREEN 32
+#define ANSI_FG_COLOR_YELLOW 33
+#define ANSI_FG_COLOR_BLUE 34
+#define ANSI_FG_COLOR_PURPLE 35
+#define ANSI_FG_COLOR_CYAN 36
+#define ANSI_FG_COLOR_WHITE 37
+
+#define ANSI_BG_COLOR_BLACK 40
+#define ANSI_BG_COLOR_RED 41
+#define ANSI_BG_COLOR_GREEN 42
+#define ANSI_BG_COLOR_YELLOW 43
+#define ANSI_BG_COLOR_BLUE 44
+#define ANSI_BG_COLOR_PURPLE 45
+#define ANSI_BG_COLOR_CYAN 46
+#define ANSI_BG_COLOR_WHITE 47
+
+#define ANSI_SPECIAL_FRAMED 51
+#define ANSI_SPECIAL_ENCIRCLED 52
+
+#define ANSI_CTRL_NORMAL 0
+#define ANSI_CTRL_BOLD 1
+#define ANSI_CTRL_FAINT 2
+#define ANSI_CTRL_ITALIC 3
+#define ANSI_CTRL_UNDERLINE 4
+#define ANSI_CTRL_SLOW_BLINK 5
+#define ANSI_CTRL_FAST_BLINK 6
+#define ANSI_CTRL_IMAGE_NEGATIVE 7
+#define ANSI_CTRL_CONCEAL 8
+#define ANSI_CTRL_CROSSED_OUT 9
+
+#define ANSI_ESC_START "\033["
+#define ANSI_ESC_END "m"
+
+#define ANSI_STR(s) #s
+#define ANSI_DEF_STR(s) ANSI_STR(s)
+
+#define ANSI_ESCAPE1(s) ANSI_ESC_START ANSI_DEF_STR(s) ANSI_ESC_END
+
+#define ANSI_1_CTRL(ctrl1) "\033["##ctrl1 ANSI_ESC_END
+#define ANSI_2_CTRL(ctrl1, ctrl2) "\033["##ctrl1 ";"##ctrl2 ANSI_ESC_END
+
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
+
+#include <string>
+namespace lldb_utility {
-#define ANSI_FG_COLOR_BLACK 30
-#define ANSI_FG_COLOR_RED 31
-#define ANSI_FG_COLOR_GREEN 32
-#define ANSI_FG_COLOR_YELLOW 33
-#define ANSI_FG_COLOR_BLUE 34
-#define ANSI_FG_COLOR_PURPLE 35
-#define ANSI_FG_COLOR_CYAN 36
-#define ANSI_FG_COLOR_WHITE 37
-
-#define ANSI_BG_COLOR_BLACK 40
-#define ANSI_BG_COLOR_RED 41
-#define ANSI_BG_COLOR_GREEN 42
-#define ANSI_BG_COLOR_YELLOW 43
-#define ANSI_BG_COLOR_BLUE 44
-#define ANSI_BG_COLOR_PURPLE 45
-#define ANSI_BG_COLOR_CYAN 46
-#define ANSI_BG_COLOR_WHITE 47
-
-#define ANSI_SPECIAL_FRAMED 51
-#define ANSI_SPECIAL_ENCIRCLED 52
-
-#define ANSI_CTRL_NORMAL 0
-#define ANSI_CTRL_BOLD 1
-#define ANSI_CTRL_FAINT 2
-#define ANSI_CTRL_ITALIC 3
-#define ANSI_CTRL_UNDERLINE 4
-#define ANSI_CTRL_SLOW_BLINK 5
-#define ANSI_CTRL_FAST_BLINK 6
-#define ANSI_CTRL_IMAGE_NEGATIVE 7
-#define ANSI_CTRL_CONCEAL 8
-#define ANSI_CTRL_CROSSED_OUT 9
-
-#define ANSI_ESC_START "\033["
-#define ANSI_ESC_END "m"
-
-#define ANSI_STR(s) #s
-#define ANSI_DEF_STR(s) ANSI_STR(s)
-
-#define ANSI_ESCAPE1(s) ANSI_ESC_START ANSI_DEF_STR(s) ANSI_ESC_END
-
-#define ANSI_1_CTRL(ctrl1) "\033["##ctrl1 ANSI_ESC_END
-#define ANSI_2_CTRL(ctrl1,ctrl2) "\033["##ctrl1";"##ctrl2 ANSI_ESC_END
+namespace ansi {
+
+inline std::string FormatAnsiTerminalCodes(llvm::StringRef format,
+ bool do_color = true) {
+ // Convert "${ansi.XXX}" tokens to ansi values or clear them if do_color is
+ // false.
+ static const struct {
+ const char *name;
+ const char *value;
+ } g_color_tokens[] = {
+#define _TO_STR2(_val) #_val
+#define _TO_STR(_val) _TO_STR2(_val)
+ {"fg.black}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_BLACK) ANSI_ESC_END},
+ {"fg.red}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_RED) ANSI_ESC_END},
+ {"fg.green}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_GREEN) ANSI_ESC_END},
+ {"fg.yellow}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_YELLOW) ANSI_ESC_END},
+ {"fg.blue}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_BLUE) ANSI_ESC_END},
+ {"fg.purple}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_PURPLE) ANSI_ESC_END},
+ {"fg.cyan}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_CYAN) ANSI_ESC_END},
+ {"fg.white}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_WHITE) ANSI_ESC_END},
+ {"bg.black}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_BLACK) ANSI_ESC_END},
+ {"bg.red}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_RED) ANSI_ESC_END},
+ {"bg.green}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_GREEN) ANSI_ESC_END},
+ {"bg.yellow}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_YELLOW) ANSI_ESC_END},
+ {"bg.blue}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_BLUE) ANSI_ESC_END},
+ {"bg.purple}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_PURPLE) ANSI_ESC_END},
+ {"bg.cyan}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_CYAN) ANSI_ESC_END},
+ {"bg.white}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_WHITE) ANSI_ESC_END},
+ {"normal}", ANSI_ESC_START _TO_STR(ANSI_CTRL_NORMAL) ANSI_ESC_END},
+ {"bold}", ANSI_ESC_START _TO_STR(ANSI_CTRL_BOLD) ANSI_ESC_END},
+ {"faint}", ANSI_ESC_START _TO_STR(ANSI_CTRL_FAINT) ANSI_ESC_END},
+ {"italic}", ANSI_ESC_START _TO_STR(ANSI_CTRL_ITALIC) ANSI_ESC_END},
+ {"underline}", ANSI_ESC_START _TO_STR(ANSI_CTRL_UNDERLINE) ANSI_ESC_END},
+ {"slow-blink}",
+ ANSI_ESC_START _TO_STR(ANSI_CTRL_SLOW_BLINK) ANSI_ESC_END},
+ {"fast-blink}",
+ ANSI_ESC_START _TO_STR(ANSI_CTRL_FAST_BLINK) ANSI_ESC_END},
+ {"negative}",
+ ANSI_ESC_START _TO_STR(ANSI_CTRL_IMAGE_NEGATIVE) ANSI_ESC_END},
+ {"conceal}", ANSI_ESC_START _TO_STR(ANSI_CTRL_CONCEAL) ANSI_ESC_END},
+ {"crossed-out}",
+ ANSI_ESC_START _TO_STR(ANSI_CTRL_CROSSED_OUT) ANSI_ESC_END},
+#undef _TO_STR
+#undef _TO_STR2
+ };
+ auto codes = llvm::makeArrayRef(g_color_tokens);
+
+ static const char tok_hdr[] = "${ansi.";
+
+ std::string fmt;
+ while (!format.empty()) {
+ llvm::StringRef left, right;
+ std::tie(left, right) = format.split(tok_hdr);
+
+ fmt.append(left);
+
+ if (left == format && right.empty()) {
+ // The header was not found. Just exit.
+ break;
+ }
-namespace lldb_utility {
+ for (const auto &code : codes) {
+ if (!right.consume_front(code.name))
+ continue;
- namespace ansi {
-
- inline std::string
- FormatAnsiTerminalCodes(const char *format, bool do_color = true)
- {
- // Convert "${ansi.XXX}" tokens to ansi values or clear them if do_color is false.
- static const struct
- {
- const char *name;
- const char *value;
- } g_color_tokens[] =
- {
- #define _TO_STR2(_val) #_val
- #define _TO_STR(_val) _TO_STR2(_val)
- { "fg.black}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_BLACK) ANSI_ESC_END },
- { "fg.red}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_RED) ANSI_ESC_END },
- { "fg.green}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_GREEN) ANSI_ESC_END },
- { "fg.yellow}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_YELLOW) ANSI_ESC_END },
- { "fg.blue}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_BLUE) ANSI_ESC_END },
- { "fg.purple}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_PURPLE) ANSI_ESC_END },
- { "fg.cyan}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_CYAN) ANSI_ESC_END },
- { "fg.white}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_WHITE) ANSI_ESC_END },
- { "bg.black}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_BLACK) ANSI_ESC_END },
- { "bg.red}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_RED) ANSI_ESC_END },
- { "bg.green}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_GREEN) ANSI_ESC_END },
- { "bg.yellow}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_YELLOW) ANSI_ESC_END },
- { "bg.blue}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_BLUE) ANSI_ESC_END },
- { "bg.purple}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_PURPLE) ANSI_ESC_END },
- { "bg.cyan}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_CYAN) ANSI_ESC_END },
- { "bg.white}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_WHITE) ANSI_ESC_END },
- { "normal}", ANSI_ESC_START _TO_STR(ANSI_CTRL_NORMAL) ANSI_ESC_END },
- { "bold}", ANSI_ESC_START _TO_STR(ANSI_CTRL_BOLD) ANSI_ESC_END },
- { "faint}", ANSI_ESC_START _TO_STR(ANSI_CTRL_FAINT) ANSI_ESC_END },
- { "italic}", ANSI_ESC_START _TO_STR(ANSI_CTRL_ITALIC) ANSI_ESC_END },
- { "underline}", ANSI_ESC_START _TO_STR(ANSI_CTRL_UNDERLINE) ANSI_ESC_END },
- { "slow-blink}", ANSI_ESC_START _TO_STR(ANSI_CTRL_SLOW_BLINK) ANSI_ESC_END },
- { "fast-blink}", ANSI_ESC_START _TO_STR(ANSI_CTRL_FAST_BLINK) ANSI_ESC_END },
- { "negative}", ANSI_ESC_START _TO_STR(ANSI_CTRL_IMAGE_NEGATIVE) ANSI_ESC_END },
- { "conceal}", ANSI_ESC_START _TO_STR(ANSI_CTRL_CONCEAL) ANSI_ESC_END },
- { "crossed-out}", ANSI_ESC_START _TO_STR(ANSI_CTRL_CROSSED_OUT) ANSI_ESC_END },
- #undef _TO_STR
- #undef _TO_STR2
- };
- static const char tok_hdr[] = "${ansi.";
-
- std::string fmt;
- for (const char *p = format; *p; ++p)
- {
- const char *tok_start = strstr (p, tok_hdr);
- if (!tok_start)
- {
- fmt.append (p, strlen(p));
- break;
- }
-
- fmt.append (p, tok_start - p);
- p = tok_start;
-
- const char *tok_str = tok_start + sizeof(tok_hdr) - 1;
- for (size_t i = 0; i < sizeof(g_color_tokens) / sizeof(g_color_tokens[0]); ++i)
- {
- if (!strncmp (tok_str, g_color_tokens[i].name, strlen(g_color_tokens[i].name)))
- {
- if (do_color)
- fmt.append (g_color_tokens[i].value);
- p = tok_str + strlen (g_color_tokens[i].name) - 1;
- break;
- }
- }
- }
- return fmt;
- }
+ if (do_color)
+ fmt.append(code.value);
+ format = right;
+ break;
}
+
+ format = format.drop_front();
+ }
+ return fmt;
+}
+}
}
diff --git a/include/lldb/Utility/CleanUp.h b/include/lldb/Utility/CleanUp.h
index 9ffe5de27df1..0d7bc8d99219 100644
--- a/include/lldb/Utility/CleanUp.h
+++ b/include/lldb/Utility/CleanUp.h
@@ -17,33 +17,33 @@ namespace lldb_utility {
//----------------------------------------------------------------------
// Templated class that guarantees that a cleanup callback function will
-// be called. The cleanup function will be called once under the
+// be called. The cleanup function will be called once under the
// following conditions:
// - when the object goes out of scope
-// - when the user explicitly calls clean.
+// - when the user explicitly calls clean.
// - the current value will be cleaned up when a new value is set using
// set(T value) as long as the current value hasn't already been cleaned.
//
// This class is designed to be used with simple types for type T (like
-// file descriptors, opaque handles, pointers, etc). If more complex
+// file descriptors, opaque handles, pointers, etc). If more complex
// type T objects are desired, we need to probably specialize this class
-// to take "const T&" for all input T parameters. Yet if a type T is
-// complex already it might be better to build the cleanup functionality
+// to take "const T&" for all input T parameters. Yet if a type T is
+// complex already it might be better to build the cleanup functionality
// into T.
//
-// The cleanup function must take one argument that is of type T.
+// The cleanup function must take one argument that is of type T.
// The calback function return type is R. The return value is currently
// needed for "CallbackType". If there is an easy way to get around the
// need for the return value we can change this class.
//
// The two template parameters are:
-// T - The variable type of value that will be stored and used as the
+// T - The variable type of value that will be stored and used as the
// sole argument for the cleanup callback.
// R - The return type for the cleanup function.
//
// EXAMPLES
-// // Use with file handles that get opened where you want to close
-// // them. Below we use "int open(const char *path, int oflag, ...)"
+// // Use with file handles that get opened where you want to close
+// // them. Below we use "int open(const char *path, int oflag, ...)"
// // which returns an integer file descriptor. -1 is the invalid file
// // descriptor so to make an object that will call "int close(int fd)"
// // automatically we can use:
@@ -53,269 +53,207 @@ namespace lldb_utility {
// // malloc/free example
// CleanUp <void *, void> malloced_bytes(malloc(32), NULL, free);
//----------------------------------------------------------------------
-template <typename T, typename R = void>
-class CleanUp
-{
+template <typename T, typename R = void> class CleanUp {
public:
- typedef T value_type;
- typedef std::function<R(value_type)> CallbackType;
+ typedef T value_type;
+ typedef std::function<R(value_type)> CallbackType;
- //----------------------------------------------------------------------
- // Constructor that sets the current value only. No values are
- // considered to be invalid and the cleanup function will be called
- // regardless of the value of m_current_value.
- //----------------------------------------------------------------------
- CleanUp (value_type value, CallbackType callback) :
- m_current_value (value),
- m_invalid_value (),
- m_callback (callback),
- m_callback_called (false),
- m_invalid_value_is_valid (false)
- {
- }
+ //----------------------------------------------------------------------
+ // Constructor that sets the current value only. No values are
+ // considered to be invalid and the cleanup function will be called
+ // regardless of the value of m_current_value.
+ //----------------------------------------------------------------------
+ CleanUp(value_type value, CallbackType callback)
+ : m_current_value(value), m_invalid_value(), m_callback(callback),
+ m_callback_called(false), m_invalid_value_is_valid(false) {}
- //----------------------------------------------------------------------
- // Constructor that sets the current value and also the invalid value.
- // The cleanup function will be called on "m_value" as long as it isn't
- // equal to "m_invalid_value".
- //----------------------------------------------------------------------
- CleanUp (value_type value, value_type invalid, CallbackType callback) :
- m_current_value (value),
- m_invalid_value (invalid),
- m_callback (callback),
- m_callback_called (false),
- m_invalid_value_is_valid (true)
- {
- }
+ //----------------------------------------------------------------------
+ // Constructor that sets the current value and also the invalid value.
+ // The cleanup function will be called on "m_value" as long as it isn't
+ // equal to "m_invalid_value".
+ //----------------------------------------------------------------------
+ CleanUp(value_type value, value_type invalid, CallbackType callback)
+ : m_current_value(value), m_invalid_value(invalid), m_callback(callback),
+ m_callback_called(false), m_invalid_value_is_valid(true) {}
- //----------------------------------------------------------------------
- // Automatically cleanup when this object goes out of scope.
- //----------------------------------------------------------------------
- ~CleanUp ()
- {
- clean();
- }
+ //----------------------------------------------------------------------
+ // Automatically cleanup when this object goes out of scope.
+ //----------------------------------------------------------------------
+ ~CleanUp() { clean(); }
- //----------------------------------------------------------------------
- // Access the value stored in this class
- //----------------------------------------------------------------------
- value_type get()
- {
- return m_current_value;
- }
+ //----------------------------------------------------------------------
+ // Access the value stored in this class
+ //----------------------------------------------------------------------
+ value_type get() { return m_current_value; }
- //----------------------------------------------------------------------
- // Access the value stored in this class
- //----------------------------------------------------------------------
- const value_type
- get() const
- {
- return m_current_value;
- }
+ //----------------------------------------------------------------------
+ // Access the value stored in this class
+ //----------------------------------------------------------------------
+ const value_type get() const { return m_current_value; }
- //----------------------------------------------------------------------
- // Reset the owned value to "value". If a current value is valid and
- // the cleanup callback hasn't been called, the previous value will
- // be cleaned up (see void CleanUp::clean()).
- //----------------------------------------------------------------------
- void
- set (const value_type value)
- {
- // Cleanup the current value if needed
- clean ();
- // Now set the new value and mark our callback as not called
- m_callback_called = false;
- m_current_value = value;
- }
+ //----------------------------------------------------------------------
+ // Reset the owned value to "value". If a current value is valid and
+ // the cleanup callback hasn't been called, the previous value will
+ // be cleaned up (see void CleanUp::clean()).
+ //----------------------------------------------------------------------
+ void set(const value_type value) {
+ // Cleanup the current value if needed
+ clean();
+ // Now set the new value and mark our callback as not called
+ m_callback_called = false;
+ m_current_value = value;
+ }
- //----------------------------------------------------------------------
- // Checks is "m_current_value" is valid. The value is considered valid
- // no invalid value was supplied during construction of this object or
- // if an invalid value was supplied and "m_current_value" is not equal
- // to "m_invalid_value".
- //
- // Returns true if "m_current_value" is valid, false otherwise.
- //----------------------------------------------------------------------
- bool
- is_valid() const
- {
- if (m_invalid_value_is_valid)
- return m_current_value != m_invalid_value;
- return true;
- }
+ //----------------------------------------------------------------------
+ // Checks is "m_current_value" is valid. The value is considered valid
+ // no invalid value was supplied during construction of this object or
+ // if an invalid value was supplied and "m_current_value" is not equal
+ // to "m_invalid_value".
+ //
+ // Returns true if "m_current_value" is valid, false otherwise.
+ //----------------------------------------------------------------------
+ bool is_valid() const {
+ if (m_invalid_value_is_valid)
+ return m_current_value != m_invalid_value;
+ return true;
+ }
- //----------------------------------------------------------------------
- // This function will call the cleanup callback provided in the
- // constructor one time if the value is considered valid (See is_valid()).
- // This function sets m_callback_called to true so we don't call the
- // cleanup callback multiple times on the same value.
- //----------------------------------------------------------------------
- void
- clean()
- {
- if (m_callback && !m_callback_called)
- {
- m_callback_called = true;
- if (is_valid())
- m_callback(m_current_value);
- }
+ //----------------------------------------------------------------------
+ // This function will call the cleanup callback provided in the
+ // constructor one time if the value is considered valid (See is_valid()).
+ // This function sets m_callback_called to true so we don't call the
+ // cleanup callback multiple times on the same value.
+ //----------------------------------------------------------------------
+ void clean() {
+ if (m_callback && !m_callback_called) {
+ m_callback_called = true;
+ if (is_valid())
+ m_callback(m_current_value);
}
+ }
- //----------------------------------------------------------------------
- // Cancels the cleanup that would have been called on "m_current_value"
- // if it was valid. This function can be used to release the value
- // contained in this object so ownership can be transferred to the caller.
- //----------------------------------------------------------------------
- value_type
- release ()
- {
- m_callback_called = true;
- return m_current_value;
- }
+ //----------------------------------------------------------------------
+ // Cancels the cleanup that would have been called on "m_current_value"
+ // if it was valid. This function can be used to release the value
+ // contained in this object so ownership can be transferred to the caller.
+ //----------------------------------------------------------------------
+ value_type release() {
+ m_callback_called = true;
+ return m_current_value;
+ }
private:
- value_type m_current_value;
- const value_type m_invalid_value;
- CallbackType m_callback;
- bool m_callback_called;
- bool m_invalid_value_is_valid;
+ value_type m_current_value;
+ const value_type m_invalid_value;
+ CallbackType m_callback;
+ bool m_callback_called;
+ bool m_invalid_value_is_valid;
- // Outlaw default constructor, copy constructor and the assignment operator
- DISALLOW_COPY_AND_ASSIGN (CleanUp);
+ // Outlaw default constructor, copy constructor and the assignment operator
+ DISALLOW_COPY_AND_ASSIGN(CleanUp);
};
-
-template <typename T, typename R, typename A0>
-class CleanUp2
-{
+
+template <typename T, typename R, typename A0> class CleanUp2 {
public:
- typedef T value_type;
- typedef std::function<R(value_type,A0)> CallbackType;
-
- //----------------------------------------------------------------------
- // Constructor that sets the current value only. No values are
- // considered to be invalid and the cleanup function will be called
- // regardless of the value of m_current_value.
- //----------------------------------------------------------------------
- CleanUp2 (value_type value, CallbackType callback, A0 arg) :
- m_current_value (value),
- m_invalid_value (),
- m_callback (callback),
- m_callback_called (false),
- m_invalid_value_is_valid (false),
- m_argument(arg)
- {
- }
-
- //----------------------------------------------------------------------
- // Constructor that sets the current value and also the invalid value.
- // The cleanup function will be called on "m_value" as long as it isn't
- // equal to "m_invalid_value".
- //----------------------------------------------------------------------
- CleanUp2 (value_type value, value_type invalid, CallbackType callback, A0 arg) :
- m_current_value (value),
- m_invalid_value (invalid),
- m_callback (callback),
- m_callback_called (false),
- m_invalid_value_is_valid (true),
- m_argument(arg)
- {
- }
-
- //----------------------------------------------------------------------
- // Automatically cleanup when this object goes out of scope.
- //----------------------------------------------------------------------
- ~CleanUp2 ()
- {
- clean();
- }
-
- //----------------------------------------------------------------------
- // Access the value stored in this class
- //----------------------------------------------------------------------
- value_type get()
- {
- return m_current_value;
- }
-
- //----------------------------------------------------------------------
- // Access the value stored in this class
- //----------------------------------------------------------------------
- const value_type
- get() const
- {
- return m_current_value;
- }
-
- //----------------------------------------------------------------------
- // Reset the owned value to "value". If a current value is valid and
- // the cleanup callback hasn't been called, the previous value will
- // be cleaned up (see void CleanUp::clean()).
- //----------------------------------------------------------------------
- void
- set (const value_type value)
- {
- // Cleanup the current value if needed
- clean ();
- // Now set the new value and mark our callback as not called
- m_callback_called = false;
- m_current_value = value;
- }
-
- //----------------------------------------------------------------------
- // Checks is "m_current_value" is valid. The value is considered valid
- // no invalid value was supplied during construction of this object or
- // if an invalid value was supplied and "m_current_value" is not equal
- // to "m_invalid_value".
- //
- // Returns true if "m_current_value" is valid, false otherwise.
- //----------------------------------------------------------------------
- bool
- is_valid() const
- {
- if (m_invalid_value_is_valid)
- return m_current_value != m_invalid_value;
- return true;
- }
-
- //----------------------------------------------------------------------
- // This function will call the cleanup callback provided in the
- // constructor one time if the value is considered valid (See is_valid()).
- // This function sets m_callback_called to true so we don't call the
- // cleanup callback multiple times on the same value.
- //----------------------------------------------------------------------
- void
- clean()
- {
- if (m_callback && !m_callback_called)
- {
- m_callback_called = true;
- if (is_valid())
- m_callback(m_current_value, m_argument);
- }
- }
-
- //----------------------------------------------------------------------
- // Cancels the cleanup that would have been called on "m_current_value"
- // if it was valid. This function can be used to release the value
- // contained in this object so ownership can be transferred to the caller.
- //----------------------------------------------------------------------
- value_type
- release ()
- {
- m_callback_called = true;
- return m_current_value;
+ typedef T value_type;
+ typedef std::function<R(value_type, A0)> CallbackType;
+
+ //----------------------------------------------------------------------
+ // Constructor that sets the current value only. No values are
+ // considered to be invalid and the cleanup function will be called
+ // regardless of the value of m_current_value.
+ //----------------------------------------------------------------------
+ CleanUp2(value_type value, CallbackType callback, A0 arg)
+ : m_current_value(value), m_invalid_value(), m_callback(callback),
+ m_callback_called(false), m_invalid_value_is_valid(false),
+ m_argument(arg) {}
+
+ //----------------------------------------------------------------------
+ // Constructor that sets the current value and also the invalid value.
+ // The cleanup function will be called on "m_value" as long as it isn't
+ // equal to "m_invalid_value".
+ //----------------------------------------------------------------------
+ CleanUp2(value_type value, value_type invalid, CallbackType callback, A0 arg)
+ : m_current_value(value), m_invalid_value(invalid), m_callback(callback),
+ m_callback_called(false), m_invalid_value_is_valid(true),
+ m_argument(arg) {}
+
+ //----------------------------------------------------------------------
+ // Automatically cleanup when this object goes out of scope.
+ //----------------------------------------------------------------------
+ ~CleanUp2() { clean(); }
+
+ //----------------------------------------------------------------------
+ // Access the value stored in this class
+ //----------------------------------------------------------------------
+ value_type get() { return m_current_value; }
+
+ //----------------------------------------------------------------------
+ // Access the value stored in this class
+ //----------------------------------------------------------------------
+ const value_type get() const { return m_current_value; }
+
+ //----------------------------------------------------------------------
+ // Reset the owned value to "value". If a current value is valid and
+ // the cleanup callback hasn't been called, the previous value will
+ // be cleaned up (see void CleanUp::clean()).
+ //----------------------------------------------------------------------
+ void set(const value_type value) {
+ // Cleanup the current value if needed
+ clean();
+ // Now set the new value and mark our callback as not called
+ m_callback_called = false;
+ m_current_value = value;
+ }
+
+ //----------------------------------------------------------------------
+ // Checks is "m_current_value" is valid. The value is considered valid
+ // no invalid value was supplied during construction of this object or
+ // if an invalid value was supplied and "m_current_value" is not equal
+ // to "m_invalid_value".
+ //
+ // Returns true if "m_current_value" is valid, false otherwise.
+ //----------------------------------------------------------------------
+ bool is_valid() const {
+ if (m_invalid_value_is_valid)
+ return m_current_value != m_invalid_value;
+ return true;
+ }
+
+ //----------------------------------------------------------------------
+ // This function will call the cleanup callback provided in the
+ // constructor one time if the value is considered valid (See is_valid()).
+ // This function sets m_callback_called to true so we don't call the
+ // cleanup callback multiple times on the same value.
+ //----------------------------------------------------------------------
+ void clean() {
+ if (m_callback && !m_callback_called) {
+ m_callback_called = true;
+ if (is_valid())
+ m_callback(m_current_value, m_argument);
}
-
+ }
+
+ //----------------------------------------------------------------------
+ // Cancels the cleanup that would have been called on "m_current_value"
+ // if it was valid. This function can be used to release the value
+ // contained in this object so ownership can be transferred to the caller.
+ //----------------------------------------------------------------------
+ value_type release() {
+ m_callback_called = true;
+ return m_current_value;
+ }
+
private:
- value_type m_current_value;
- const value_type m_invalid_value;
- CallbackType m_callback;
- bool m_callback_called;
- bool m_invalid_value_is_valid;
- A0 m_argument;
-
- // Outlaw default constructor, copy constructor and the assignment operator
- DISALLOW_COPY_AND_ASSIGN (CleanUp2);
+ value_type m_current_value;
+ const value_type m_invalid_value;
+ CallbackType m_callback;
+ bool m_callback_called;
+ bool m_invalid_value_is_valid;
+ A0 m_argument;
+
+ // Outlaw default constructor, copy constructor and the assignment operator
+ DISALLOW_COPY_AND_ASSIGN(CleanUp2);
};
} // namespace lldb_utility
diff --git a/include/lldb/Utility/ConvertEnum.h b/include/lldb/Utility/ConvertEnum.h
index 6d37484b0112..239247d6a1da 100644
--- a/include/lldb/Utility/ConvertEnum.h
+++ b/include/lldb/Utility/ConvertEnum.h
@@ -12,8 +12,7 @@
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-private-enumerations.h"
-namespace lldb_private
-{
+namespace lldb_private {
const char *GetVoteAsCString(Vote vote);
const char *GetSectionTypeAsCString(lldb::SectionType sect_type);
diff --git a/include/lldb/Utility/Either.h b/include/lldb/Utility/Either.h
index ae647363512d..0dc340b64e86 100644
--- a/include/lldb/Utility/Either.h
+++ b/include/lldb/Utility/Either.h
@@ -15,140 +15,112 @@
#include <functional>
namespace lldb_utility {
- template <typename T1, typename T2>
- class Either
- {
- private:
- enum class Selected
- {
- One, Two
- };
-
- Selected m_selected;
- union
- {
- T1 m_t1;
- T2 m_t2;
- };
-
- public:
- Either (const T1& t1)
- {
- m_t1 = t1;
- m_selected = Selected::One;
- }
-
- Either (const T2& t2)
- {
- m_t2 = t2;
- m_selected = Selected::Two;
- }
-
- Either (const Either<T1,T2>& rhs)
- {
- switch (rhs.m_selected)
- {
- case Selected::One:
- m_t1 = rhs.GetAs<T1>().getValue();
- m_selected = Selected::One;
- break;
- case Selected::Two:
- m_t2 = rhs.GetAs<T2>().getValue();
- m_selected = Selected::Two;
- break;
- }
- }
-
- template <class X, typename std::enable_if<std::is_same<T1,X>::value>::type * = nullptr>
- llvm::Optional<T1>
- GetAs() const
- {
- switch (m_selected)
- {
- case Selected::One:
- return m_t1;
- default:
- return llvm::Optional<T1>();
- }
- }
-
- template <class X, typename std::enable_if<std::is_same<T2,X>::value>::type * = nullptr>
- llvm::Optional<T2>
- GetAs() const
- {
- switch (m_selected)
- {
- case Selected::Two:
- return m_t2;
- default:
- return llvm::Optional<T2>();
- }
- }
-
- template <class ResultType>
- ResultType
- Apply (std::function<ResultType(T1)> if_T1,
- std::function<ResultType(T2)> if_T2) const
- {
- switch (m_selected)
- {
- case Selected::One:
- return if_T1(m_t1);
- case Selected::Two:
- return if_T2(m_t2);
- }
- }
-
- bool
- operator == (const Either<T1,T2>& rhs)
- {
- return (GetAs<T1>() == rhs.GetAs<T1>()) && (GetAs<T2>() == rhs.GetAs<T2>());
- }
-
- explicit
- operator bool ()
- {
- switch (m_selected)
- {
- case Selected::One:
- return (bool)m_t1;
- case Selected::Two:
- return (bool)m_t2;
- }
- }
-
- Either<T1,T2>&
- operator = (const Either<T1,T2>& rhs)
- {
- switch (rhs.m_selected)
- {
- case Selected::One:
- m_t1 = rhs.GetAs<T1>().getValue();
- m_selected = Selected::One;
- break;
- case Selected::Two:
- m_t2 = rhs.GetAs<T2>().getValue();
- m_selected = Selected::Two;
- break;
- }
- return *this;
- }
-
- ~Either ()
- {
- switch (m_selected)
- {
- case Selected::One:
- m_t1.T1::~T1();
- break;
- case Selected::Two:
- m_t2.T2::~T2();
- break;
- }
- }
- };
-
+template <typename T1, typename T2> class Either {
+private:
+ enum class Selected { One, Two };
+
+ Selected m_selected;
+ union {
+ T1 m_t1;
+ T2 m_t2;
+ };
+
+public:
+ Either(const T1 &t1) {
+ m_t1 = t1;
+ m_selected = Selected::One;
+ }
+
+ Either(const T2 &t2) {
+ m_t2 = t2;
+ m_selected = Selected::Two;
+ }
+
+ Either(const Either<T1, T2> &rhs) {
+ switch (rhs.m_selected) {
+ case Selected::One:
+ m_t1 = rhs.GetAs<T1>().getValue();
+ m_selected = Selected::One;
+ break;
+ case Selected::Two:
+ m_t2 = rhs.GetAs<T2>().getValue();
+ m_selected = Selected::Two;
+ break;
+ }
+ }
+
+ template <class X, typename std::enable_if<std::is_same<T1, X>::value>::type
+ * = nullptr>
+ llvm::Optional<T1> GetAs() const {
+ switch (m_selected) {
+ case Selected::One:
+ return m_t1;
+ default:
+ return llvm::Optional<T1>();
+ }
+ }
+
+ template <class X, typename std::enable_if<std::is_same<T2, X>::value>::type
+ * = nullptr>
+ llvm::Optional<T2> GetAs() const {
+ switch (m_selected) {
+ case Selected::Two:
+ return m_t2;
+ default:
+ return llvm::Optional<T2>();
+ }
+ }
+
+ template <class ResultType>
+ ResultType Apply(std::function<ResultType(T1)> if_T1,
+ std::function<ResultType(T2)> if_T2) const {
+ switch (m_selected) {
+ case Selected::One:
+ return if_T1(m_t1);
+ case Selected::Two:
+ return if_T2(m_t2);
+ }
+ }
+
+ bool operator==(const Either<T1, T2> &rhs) {
+ return (GetAs<T1>() == rhs.GetAs<T1>()) && (GetAs<T2>() == rhs.GetAs<T2>());
+ }
+
+ explicit operator bool() {
+ switch (m_selected) {
+ case Selected::One:
+ return (bool)m_t1;
+ case Selected::Two:
+ return (bool)m_t2;
+ }
+ }
+
+ Either<T1, T2> &operator=(const Either<T1, T2> &rhs) {
+ switch (rhs.m_selected) {
+ case Selected::One:
+ m_t1 = rhs.GetAs<T1>().getValue();
+ m_selected = Selected::One;
+ break;
+ case Selected::Two:
+ m_t2 = rhs.GetAs<T2>().getValue();
+ m_selected = Selected::Two;
+ break;
+ }
+ return *this;
+ }
+
+ ~Either() {
+ switch (m_selected) {
+ case Selected::One:
+ m_t1.T1::~T1();
+ break;
+ case Selected::Two:
+ m_t2.T2::~T2();
+ break;
+ }
+ }
+};
+
} // namespace lldb_utility
#endif // #ifndef liblldb_Either_h_
-
diff --git a/include/lldb/Utility/Iterable.h b/include/lldb/Utility/Iterable.h
index 0c16a251b7a7..dcb340a05ef1 100644
--- a/include/lldb/Utility/Iterable.h
+++ b/include/lldb/Utility/Iterable.h
@@ -17,220 +17,184 @@
// Other libraries and framework includes
// Project includes
-namespace lldb_private
-{
-
-template <typename I, typename E> E map_adapter(I &iter)
-{
- return iter->second;
-}
-
-template <typename I, typename E> E vector_adapter(I &iter)
-{
- return *iter;
-}
-
-template <typename I, typename E> E list_adapter(I &iter)
-{
- return *iter;
+namespace lldb_private {
+
+template <typename I, typename E> E map_adapter(I &iter) {
+ return iter->second;
}
-
-template <typename C, typename E, E (*A)(typename C::const_iterator &)> class AdaptedConstIterator
-{
+
+template <typename I, typename E> E vector_adapter(I &iter) { return *iter; }
+
+template <typename I, typename E> E list_adapter(I &iter) { return *iter; }
+
+template <typename C, typename E, E (*A)(typename C::const_iterator &)>
+class AdaptedConstIterator {
public:
- typedef typename C::const_iterator BackingIterator;
-
- // Wrapping constructor
- AdaptedConstIterator (BackingIterator backing_iterator) :
- m_iter(backing_iterator)
- {
- }
-
- // Default-constructible
- AdaptedConstIterator () :
- m_iter()
- {
- }
-
- // Copy-constructible
- AdaptedConstIterator (const AdaptedConstIterator &rhs) :
- m_iter(rhs.m_iter)
- {
- }
-
- // Copy-assignable
- AdaptedConstIterator &operator= (const AdaptedConstIterator &rhs)
- {
- m_iter = rhs.m_iter;
- return *this;
- }
-
- // Destructible
- ~AdaptedConstIterator() = default;
-
- // Comparable
- bool operator== (const AdaptedConstIterator &rhs)
- {
- return m_iter == rhs.m_iter;
- }
-
- bool operator!= (const AdaptedConstIterator &rhs)
- {
- return m_iter != rhs.m_iter;
- }
-
- // Rvalue dereferenceable
- E operator* ()
- {
- return (*A)(m_iter);
- }
-
- E operator-> ()
- {
- return (*A)(m_iter);
- }
-
- // Offset dereferenceable
- E operator[] (typename BackingIterator::difference_type offset)
- {
- return AdaptedConstIterator(m_iter + offset);
- }
-
- // Incrementable
- AdaptedConstIterator &operator++ ()
- {
- m_iter++;
- return *this;
- }
-
- // Decrementable
- AdaptedConstIterator &operator-- ()
- {
- m_iter--;
- return *this;
- }
-
- // Compound assignment
- AdaptedConstIterator &operator+= (typename BackingIterator::difference_type offset)
- {
- m_iter += offset;
- return *this;
- }
-
- AdaptedConstIterator &operator-= (typename BackingIterator::difference_type offset)
- {
- m_iter -= offset;
- return *this;
- }
-
- // Arithmetic
- AdaptedConstIterator operator+ (typename BackingIterator::difference_type offset)
- {
- return AdaptedConstIterator(m_iter + offset);
- }
-
- AdaptedConstIterator operator- (typename BackingIterator::difference_type offset)
- {
- return AdaptedConstIterator(m_iter - offset);
- }
-
- // Comparable
- bool operator< (AdaptedConstIterator &rhs)
- {
- return m_iter < rhs.m_iter;
- }
-
- bool operator<= (AdaptedConstIterator &rhs)
- {
- return m_iter <= rhs.m_iter;
- }
-
- bool operator> (AdaptedConstIterator &rhs)
- {
- return m_iter > rhs.m_iter;
- }
-
- bool operator>= (AdaptedConstIterator &rhs)
- {
- return m_iter >= rhs.m_iter;
- }
-
- template <typename C1, typename E1, E1 (*A1)(typename C1::const_iterator &)>
- friend AdaptedConstIterator<C1, E1, A1> operator+(typename C1::const_iterator::difference_type, AdaptedConstIterator<C1, E1, A1> &);
-
- template <typename C1, typename E1, E1 (*A1)(typename C1::const_iterator &)>
- friend typename C1::const_iterator::difference_type operator-(AdaptedConstIterator<C1, E1, A1> &, AdaptedConstIterator<C1, E1, A1> &);
-
- template <typename C1, typename E1, E1 (*A1)(typename C1::const_iterator &)>
- friend void swap(AdaptedConstIterator<C1, E1, A1> &, AdaptedConstIterator<C1, E1, A1> &);
+ typedef typename C::const_iterator BackingIterator;
+
+ // Wrapping constructor
+ AdaptedConstIterator(BackingIterator backing_iterator)
+ : m_iter(backing_iterator) {}
+
+ // Default-constructible
+ AdaptedConstIterator() : m_iter() {}
+
+ // Copy-constructible
+ AdaptedConstIterator(const AdaptedConstIterator &rhs) : m_iter(rhs.m_iter) {}
+
+ // Copy-assignable
+ AdaptedConstIterator &operator=(const AdaptedConstIterator &rhs) {
+ m_iter = rhs.m_iter;
+ return *this;
+ }
+
+ // Destructible
+ ~AdaptedConstIterator() = default;
+
+ // Comparable
+ bool operator==(const AdaptedConstIterator &rhs) {
+ return m_iter == rhs.m_iter;
+ }
+
+ bool operator!=(const AdaptedConstIterator &rhs) {
+ return m_iter != rhs.m_iter;
+ }
+
+ // Rvalue dereferenceable
+ E operator*() { return (*A)(m_iter); }
+
+ E operator->() { return (*A)(m_iter); }
+
+ // Offset dereferenceable
+ E operator[](typename BackingIterator::difference_type offset) {
+ return AdaptedConstIterator(m_iter + offset);
+ }
+
+ // Incrementable
+ AdaptedConstIterator &operator++() {
+ m_iter++;
+ return *this;
+ }
+
+ // Decrementable
+ AdaptedConstIterator &operator--() {
+ m_iter--;
+ return *this;
+ }
+
+ // Compound assignment
+ AdaptedConstIterator &
+ operator+=(typename BackingIterator::difference_type offset) {
+ m_iter += offset;
+ return *this;
+ }
+
+ AdaptedConstIterator &
+ operator-=(typename BackingIterator::difference_type offset) {
+ m_iter -= offset;
+ return *this;
+ }
+
+ // Arithmetic
+ AdaptedConstIterator
+ operator+(typename BackingIterator::difference_type offset) {
+ return AdaptedConstIterator(m_iter + offset);
+ }
+
+ AdaptedConstIterator
+ operator-(typename BackingIterator::difference_type offset) {
+ return AdaptedConstIterator(m_iter - offset);
+ }
+
+ // Comparable
+ bool operator<(AdaptedConstIterator &rhs) { return m_iter < rhs.m_iter; }
+
+ bool operator<=(AdaptedConstIterator &rhs) { return m_iter <= rhs.m_iter; }
+
+ bool operator>(AdaptedConstIterator &rhs) { return m_iter > rhs.m_iter; }
+
+ bool operator>=(AdaptedConstIterator &rhs) { return m_iter >= rhs.m_iter; }
+
+ template <typename C1, typename E1, E1 (*A1)(typename C1::const_iterator &)>
+ friend AdaptedConstIterator<C1, E1, A1>
+ operator+(typename C1::const_iterator::difference_type,
+ AdaptedConstIterator<C1, E1, A1> &);
+
+ template <typename C1, typename E1, E1 (*A1)(typename C1::const_iterator &)>
+ friend typename C1::const_iterator::difference_type
+ operator-(AdaptedConstIterator<C1, E1, A1> &,
+ AdaptedConstIterator<C1, E1, A1> &);
+
+ template <typename C1, typename E1, E1 (*A1)(typename C1::const_iterator &)>
+ friend void swap(AdaptedConstIterator<C1, E1, A1> &,
+ AdaptedConstIterator<C1, E1, A1> &);
private:
- BackingIterator m_iter;
+ BackingIterator m_iter;
};
-
+
template <typename C, typename E, E (*A)(typename C::const_iterator &)>
-AdaptedConstIterator<C, E, A> operator+ (typename AdaptedConstIterator<C, E, A>::BackingIterator::difference_type offset, AdaptedConstIterator<C, E, A> &rhs)
-{
- return rhs.operator+(offset);
+AdaptedConstIterator<C, E, A> operator+(
+ typename AdaptedConstIterator<C, E, A>::BackingIterator::difference_type
+ offset,
+ AdaptedConstIterator<C, E, A> &rhs) {
+ return rhs.operator+(offset);
}
template <typename C, typename E, E (*A)(typename C::const_iterator &)>
-typename AdaptedConstIterator<C, E, A>::BackingIterator::difference_type operator- (AdaptedConstIterator<C, E, A> &lhs, AdaptedConstIterator<C, E, A> &rhs)
-{
- return(lhs.m_iter - rhs.m_iter);
+typename AdaptedConstIterator<C, E, A>::BackingIterator::difference_type
+operator-(AdaptedConstIterator<C, E, A> &lhs,
+ AdaptedConstIterator<C, E, A> &rhs) {
+ return (lhs.m_iter - rhs.m_iter);
}
template <typename C, typename E, E (*A)(typename C::const_iterator &)>
-void swap (AdaptedConstIterator<C, E, A> &lhs, AdaptedConstIterator<C, E, A> &rhs)
-{
- std::swap(lhs.m_iter, rhs.m_iter);
+void swap(AdaptedConstIterator<C, E, A> &lhs,
+ AdaptedConstIterator<C, E, A> &rhs) {
+ std::swap(lhs.m_iter, rhs.m_iter);
}
-
-template <typename C, typename E, E (*A)(typename C::const_iterator &)> class AdaptedIterable
-{
+
+template <typename C, typename E, E (*A)(typename C::const_iterator &)>
+class AdaptedIterable {
private:
- const C &m_container;
+ const C &m_container;
+
public:
- AdaptedIterable (const C &container) :
- m_container(container)
- {
- }
-
- AdaptedConstIterator<C, E, A> begin ()
- {
- return AdaptedConstIterator<C, E, A>(m_container.begin());
- }
-
- AdaptedConstIterator<C, E, A> end ()
- {
- return AdaptedConstIterator<C, E, A>(m_container.end());
- }
+ AdaptedIterable(const C &container) : m_container(container) {}
+
+ AdaptedConstIterator<C, E, A> begin() {
+ return AdaptedConstIterator<C, E, A>(m_container.begin());
+ }
+
+ AdaptedConstIterator<C, E, A> end() {
+ return AdaptedConstIterator<C, E, A>(m_container.end());
+ }
};
-template <typename C, typename E, E (*A)(typename C::const_iterator &), typename MutexType>
-class LockingAdaptedIterable : public AdaptedIterable<C, E, A>
-{
+template <typename C, typename E, E (*A)(typename C::const_iterator &),
+ typename MutexType>
+class LockingAdaptedIterable : public AdaptedIterable<C, E, A> {
public:
- LockingAdaptedIterable(C &container, MutexType &mutex) : AdaptedIterable<C, E, A>(container), m_mutex(&mutex)
- {
- m_mutex->lock();
- }
-
- LockingAdaptedIterable(LockingAdaptedIterable &&rhs) : AdaptedIterable<C, E, A>(rhs), m_mutex(rhs.m_mutex)
- {
- rhs.m_mutex = nullptr;
- }
-
- ~LockingAdaptedIterable()
- {
- if (m_mutex)
- m_mutex->unlock();
- }
+ LockingAdaptedIterable(C &container, MutexType &mutex)
+ : AdaptedIterable<C, E, A>(container), m_mutex(&mutex) {
+ m_mutex->lock();
+ }
+
+ LockingAdaptedIterable(LockingAdaptedIterable &&rhs)
+ : AdaptedIterable<C, E, A>(rhs), m_mutex(rhs.m_mutex) {
+ rhs.m_mutex = nullptr;
+ }
+
+ ~LockingAdaptedIterable() {
+ if (m_mutex)
+ m_mutex->unlock();
+ }
private:
- MutexType *m_mutex = nullptr;
+ MutexType *m_mutex = nullptr;
- DISALLOW_COPY_AND_ASSIGN(LockingAdaptedIterable);
+ LockingAdaptedIterable(const LockingAdaptedIterable &) = delete;
+ LockingAdaptedIterable &operator=(const LockingAdaptedIterable &) = delete;
};
} // namespace lldb_private
diff --git a/include/lldb/Utility/JSON.h b/include/lldb/Utility/JSON.h
index e61c5ee85017..145ef4868d2f 100644
--- a/include/lldb/Utility/JSON.h
+++ b/include/lldb/Utility/JSON.h
@@ -24,338 +24,263 @@
namespace lldb_private {
- class JSONValue
- {
- public:
- virtual void
- Write (Stream& s) = 0;
-
- typedef std::shared_ptr<JSONValue> SP;
-
- enum class Kind
- {
- String,
- Number,
- True,
- False,
- Null,
- Object,
- Array
- };
-
- JSONValue (Kind k) :
- m_kind(k)
- {}
-
- Kind
- GetKind() const
- {
- return m_kind;
- }
-
- virtual
- ~JSONValue () = default;
-
- private:
- const Kind m_kind;
- };
-
- class JSONString : public JSONValue
- {
- public:
- JSONString ();
- JSONString (const char* s);
- JSONString (const std::string& s);
-
- JSONString (const JSONString& s) = delete;
- JSONString&
- operator = (const JSONString& s) = delete;
-
- void
- Write(Stream& s) override;
-
- typedef std::shared_ptr<JSONString> SP;
-
- std::string
- GetData () { return m_data; }
-
- static bool classof(const JSONValue *V)
- {
- return V->GetKind() == JSONValue::Kind::String;
- }
-
- ~JSONString() override = default;
-
- private:
-
- static std::string
- json_string_quote_metachars (const std::string&);
-
- std::string m_data;
- };
-
- class JSONNumber : public JSONValue
- {
- public:
- typedef std::shared_ptr<JSONNumber> SP;
-
- // We cretae a constructor for all integer and floating point type with using templates and
- // SFINAE to avoid having ambiguous overloads because of the implicit type promotion. If we
- // would have constructors only with int64_t, uint64_t and double types then constructing a
- // JSONNumber from an int32_t (or any other similar type) would fail to compile.
-
- template <typename T,
- typename std::enable_if<std::is_integral<T>::value &&
- std::is_unsigned<T>::value>::type* = nullptr>
- explicit JSONNumber (T u) :
- JSONValue(JSONValue::Kind::Number),
- m_data_type(DataType::Unsigned)
- {
- m_data.m_unsigned = u;
- }
-
- template <typename T,
- typename std::enable_if<std::is_integral<T>::value &&
- std::is_signed<T>::value>::type* = nullptr>
- explicit JSONNumber (T s) :
- JSONValue(JSONValue::Kind::Number),
- m_data_type(DataType::Signed)
- {
- m_data.m_signed = s;
- }
-
- template <typename T,
- typename std::enable_if<std::is_floating_point<T>::value>::type* = nullptr>
- explicit JSONNumber (T d) :
- JSONValue(JSONValue::Kind::Number),
- m_data_type(DataType::Double)
- {
- m_data.m_double = d;
- }
-
- ~JSONNumber() override = default;
-
- JSONNumber (const JSONNumber& s) = delete;
- JSONNumber&
- operator = (const JSONNumber& s) = delete;
-
- void
- Write(Stream& s) override;
-
- uint64_t
- GetAsUnsigned() const;
-
- int64_t
- GetAsSigned() const;
-
- double
- GetAsDouble() const;
-
- static bool classof(const JSONValue *V)
- {
- return V->GetKind() == JSONValue::Kind::Number;
- }
-
- private:
- enum class DataType : uint8_t
- {
- Unsigned,
- Signed,
- Double
- } m_data_type;
-
- union
- {
- uint64_t m_unsigned;
- int64_t m_signed;
- double m_double;
- } m_data;
- };
-
- class JSONTrue : public JSONValue
- {
- public:
- JSONTrue ();
-
- JSONTrue (const JSONTrue& s) = delete;
- JSONTrue&
- operator = (const JSONTrue& s) = delete;
-
- void
- Write(Stream& s) override;
-
- typedef std::shared_ptr<JSONTrue> SP;
-
- static bool classof(const JSONValue *V)
- {
- return V->GetKind() == JSONValue::Kind::True;
- }
-
- ~JSONTrue() override = default;
- };
-
- class JSONFalse : public JSONValue
- {
- public:
- JSONFalse ();
-
- JSONFalse (const JSONFalse& s) = delete;
- JSONFalse&
- operator = (const JSONFalse& s) = delete;
-
- void
- Write(Stream& s) override;
-
- typedef std::shared_ptr<JSONFalse> SP;
-
- static bool classof(const JSONValue *V)
- {
- return V->GetKind() == JSONValue::Kind::False;
- }
-
- ~JSONFalse() override = default;
- };
-
- class JSONNull : public JSONValue
- {
- public:
- JSONNull ();
-
- JSONNull (const JSONNull& s) = delete;
- JSONNull&
- operator = (const JSONNull& s) = delete;
-
- void
- Write(Stream& s) override;
-
- typedef std::shared_ptr<JSONNull> SP;
-
- static bool classof(const JSONValue *V)
- {
- return V->GetKind() == JSONValue::Kind::Null;
- }
-
- ~JSONNull() override = default;
- };
-
- class JSONObject : public JSONValue
- {
- public:
- JSONObject ();
-
- JSONObject (const JSONObject& s) = delete;
- JSONObject&
- operator = (const JSONObject& s) = delete;
-
- void
- Write(Stream& s) override;
-
- typedef std::shared_ptr<JSONObject> SP;
-
- static bool classof(const JSONValue *V)
- {
- return V->GetKind() == JSONValue::Kind::Object;
- }
-
- bool
- SetObject (const std::string& key,
- JSONValue::SP value);
-
- JSONValue::SP
- GetObject (const std::string& key);
-
- ~JSONObject() override = default;
-
- private:
- typedef std::map<std::string, JSONValue::SP> Map;
- typedef Map::iterator Iterator;
- Map m_elements;
- };
-
- class JSONArray : public JSONValue
- {
- public:
- JSONArray ();
-
- JSONArray (const JSONArray& s) = delete;
- JSONArray&
- operator = (const JSONArray& s) = delete;
-
- void
- Write(Stream& s) override;
-
- typedef std::shared_ptr<JSONArray> SP;
-
- static bool classof(const JSONValue *V)
- {
- return V->GetKind() == JSONValue::Kind::Array;
- }
-
- private:
- typedef std::vector<JSONValue::SP> Vector;
- typedef Vector::iterator Iterator;
- typedef Vector::size_type Index;
- typedef Vector::size_type Size;
-
- public:
- bool
- SetObject (Index i,
- JSONValue::SP value);
-
- bool
- AppendObject (JSONValue::SP value);
-
- JSONValue::SP
- GetObject (Index i);
-
- Size
- GetNumElements ();
-
- ~JSONArray() override = default;
-
- Vector m_elements;
- };
-
- class JSONParser : public StringExtractor
- {
- public:
- enum Token
- {
- Invalid,
- Error,
- ObjectStart,
- ObjectEnd,
- ArrayStart,
- ArrayEnd,
- Comma,
- Colon,
- String,
- Integer,
- Float,
- True,
- False,
- Null,
- EndOfFile
- };
-
- JSONParser (const char *cstr);
-
- int
- GetEscapedChar (bool &was_escaped);
-
- Token
- GetToken (std::string &value);
-
- JSONValue::SP
- ParseJSONValue ();
-
- protected:
- JSONValue::SP
- ParseJSONObject ();
-
- JSONValue::SP
- ParseJSONArray ();
- };
+class JSONValue {
+public:
+ virtual void Write(Stream &s) = 0;
+
+ typedef std::shared_ptr<JSONValue> SP;
+
+ enum class Kind { String, Number, True, False, Null, Object, Array };
+
+ JSONValue(Kind k) : m_kind(k) {}
+
+ Kind GetKind() const { return m_kind; }
+
+ virtual ~JSONValue() = default;
+
+private:
+ const Kind m_kind;
+};
+
+class JSONString : public JSONValue {
+public:
+ JSONString();
+ JSONString(const char *s);
+ JSONString(const std::string &s);
+
+ JSONString(const JSONString &s) = delete;
+ JSONString &operator=(const JSONString &s) = delete;
+
+ void Write(Stream &s) override;
+
+ typedef std::shared_ptr<JSONString> SP;
+
+ std::string GetData() { return m_data; }
+
+ static bool classof(const JSONValue *V) {
+ return V->GetKind() == JSONValue::Kind::String;
+ }
+
+ ~JSONString() override = default;
+
+private:
+ static std::string json_string_quote_metachars(const std::string &);
+
+ std::string m_data;
+};
+
+class JSONNumber : public JSONValue {
+public:
+ typedef std::shared_ptr<JSONNumber> SP;
+
+ // We cretae a constructor for all integer and floating point type with using
+ // templates and
+ // SFINAE to avoid having ambiguous overloads because of the implicit type
+ // promotion. If we
+ // would have constructors only with int64_t, uint64_t and double types then
+ // constructing a
+ // JSONNumber from an int32_t (or any other similar type) would fail to
+ // compile.
+
+ template <typename T, typename std::enable_if<
+ std::is_integral<T>::value &&
+ std::is_unsigned<T>::value>::type * = nullptr>
+ explicit JSONNumber(T u)
+ : JSONValue(JSONValue::Kind::Number), m_data_type(DataType::Unsigned) {
+ m_data.m_unsigned = u;
+ }
+
+ template <typename T,
+ typename std::enable_if<std::is_integral<T>::value &&
+ std::is_signed<T>::value>::type * = nullptr>
+ explicit JSONNumber(T s)
+ : JSONValue(JSONValue::Kind::Number), m_data_type(DataType::Signed) {
+ m_data.m_signed = s;
+ }
+
+ template <typename T, typename std::enable_if<
+ std::is_floating_point<T>::value>::type * = nullptr>
+ explicit JSONNumber(T d)
+ : JSONValue(JSONValue::Kind::Number), m_data_type(DataType::Double) {
+ m_data.m_double = d;
+ }
+
+ ~JSONNumber() override = default;
+
+ JSONNumber(const JSONNumber &s) = delete;
+ JSONNumber &operator=(const JSONNumber &s) = delete;
+
+ void Write(Stream &s) override;
+
+ uint64_t GetAsUnsigned() const;
+
+ int64_t GetAsSigned() const;
+
+ double GetAsDouble() const;
+
+ static bool classof(const JSONValue *V) {
+ return V->GetKind() == JSONValue::Kind::Number;
+ }
+
+private:
+ enum class DataType : uint8_t { Unsigned, Signed, Double } m_data_type;
+
+ union {
+ uint64_t m_unsigned;
+ int64_t m_signed;
+ double m_double;
+ } m_data;
+};
+
+class JSONTrue : public JSONValue {
+public:
+ JSONTrue();
+
+ JSONTrue(const JSONTrue &s) = delete;
+ JSONTrue &operator=(const JSONTrue &s) = delete;
+
+ void Write(Stream &s) override;
+
+ typedef std::shared_ptr<JSONTrue> SP;
+
+ static bool classof(const JSONValue *V) {
+ return V->GetKind() == JSONValue::Kind::True;
+ }
+
+ ~JSONTrue() override = default;
+};
+
+class JSONFalse : public JSONValue {
+public:
+ JSONFalse();
+
+ JSONFalse(const JSONFalse &s) = delete;
+ JSONFalse &operator=(const JSONFalse &s) = delete;
+
+ void Write(Stream &s) override;
+
+ typedef std::shared_ptr<JSONFalse> SP;
+
+ static bool classof(const JSONValue *V) {
+ return V->GetKind() == JSONValue::Kind::False;
+ }
+
+ ~JSONFalse() override = default;
+};
+
+class JSONNull : public JSONValue {
+public:
+ JSONNull();
+
+ JSONNull(const JSONNull &s) = delete;
+ JSONNull &operator=(const JSONNull &s) = delete;
+
+ void Write(Stream &s) override;
+
+ typedef std::shared_ptr<JSONNull> SP;
+
+ static bool classof(const JSONValue *V) {
+ return V->GetKind() == JSONValue::Kind::Null;
+ }
+
+ ~JSONNull() override = default;
+};
+
+class JSONObject : public JSONValue {
+public:
+ JSONObject();
+
+ JSONObject(const JSONObject &s) = delete;
+ JSONObject &operator=(const JSONObject &s) = delete;
+
+ void Write(Stream &s) override;
+
+ typedef std::shared_ptr<JSONObject> SP;
+
+ static bool classof(const JSONValue *V) {
+ return V->GetKind() == JSONValue::Kind::Object;
+ }
+
+ bool SetObject(const std::string &key, JSONValue::SP value);
+
+ JSONValue::SP GetObject(const std::string &key);
+
+ ~JSONObject() override = default;
+
+private:
+ typedef std::map<std::string, JSONValue::SP> Map;
+ typedef Map::iterator Iterator;
+ Map m_elements;
+};
+
+class JSONArray : public JSONValue {
+public:
+ JSONArray();
+
+ JSONArray(const JSONArray &s) = delete;
+ JSONArray &operator=(const JSONArray &s) = delete;
+
+ void Write(Stream &s) override;
+
+ typedef std::shared_ptr<JSONArray> SP;
+
+ static bool classof(const JSONValue *V) {
+ return V->GetKind() == JSONValue::Kind::Array;
+ }
+
+private:
+ typedef std::vector<JSONValue::SP> Vector;
+ typedef Vector::iterator Iterator;
+ typedef Vector::size_type Index;
+ typedef Vector::size_type Size;
+
+public:
+ bool SetObject(Index i, JSONValue::SP value);
+
+ bool AppendObject(JSONValue::SP value);
+
+ JSONValue::SP GetObject(Index i);
+
+ Size GetNumElements();
+
+ ~JSONArray() override = default;
+
+ Vector m_elements;
+};
+
+class JSONParser : public StringExtractor {
+public:
+ enum Token {
+ Invalid,
+ Error,
+ ObjectStart,
+ ObjectEnd,
+ ArrayStart,
+ ArrayEnd,
+ Comma,
+ Colon,
+ String,
+ Integer,
+ Float,
+ True,
+ False,
+ Null,
+ EndOfFile
+ };
+
+ JSONParser(const char *cstr);
+
+ int GetEscapedChar(bool &was_escaped);
+
+ Token GetToken(std::string &value);
+
+ JSONValue::SP ParseJSONValue();
+
+protected:
+ JSONValue::SP ParseJSONObject();
+
+ JSONValue::SP ParseJSONArray();
+};
} // namespace lldb_private
#endif // utility_JSON_h_
diff --git a/include/lldb/Utility/LLDBAssert.h b/include/lldb/Utility/LLDBAssert.h
index 5ca252f20032..328a4d4f9258 100644
--- a/include/lldb/Utility/LLDBAssert.h
+++ b/include/lldb/Utility/LLDBAssert.h
@@ -1,4 +1,5 @@
-//===----------------- LLDBAssert.h --------------------------------*- C++ -*-===//
+//===----------------- LLDBAssert.h --------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -15,16 +16,13 @@
#ifdef LLDB_CONFIGURATION_DEBUG
#define lldbassert(x) assert(x)
#else
-#define lldbassert(x) lldb_private::lldb_assert(x, #x, __FUNCTION__, __FILE__, __LINE__)
+#define lldbassert(x) \
+ lldb_private::lldb_assert(x, #x, __FUNCTION__, __FILE__, __LINE__)
#endif
namespace lldb_private {
- void
- lldb_assert (bool expression,
- const char* expr_text,
- const char* func,
- const char* file,
- unsigned int line);
+void lldb_assert(bool expression, const char *expr_text, const char *func,
+ const char *file, unsigned int line);
}
#endif // utility_LLDBAssert_h_
diff --git a/include/lldb/Utility/NameMatches.h b/include/lldb/Utility/NameMatches.h
index 5fe6565d06f9..50ea7ba7f887 100644
--- a/include/lldb/Utility/NameMatches.h
+++ b/include/lldb/Utility/NameMatches.h
@@ -11,9 +11,11 @@
#include "lldb/lldb-private-enumerations.h"
-namespace lldb_private
-{
-bool NameMatches(const char *name, NameMatchType match_type, const char *match);
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+bool NameMatches(llvm::StringRef name, NameMatchType match_type,
+ llvm::StringRef match);
}
#endif
diff --git a/include/lldb/Utility/PriorityPointerPair.h b/include/lldb/Utility/PriorityPointerPair.h
index 49f0765d0f96..2bd369e78a9a 100644
--- a/include/lldb/Utility/PriorityPointerPair.h
+++ b/include/lldb/Utility/PriorityPointerPair.h
@@ -1,4 +1,5 @@
-//===-- PriorityPointerPair.h ----------------------------------------*- C++ -*-===//
+//===-- PriorityPointerPair.h ----------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,8 +11,8 @@
#ifndef liblldb_PriorityPointerPair_h_
#define liblldb_PriorityPointerPair_h_
-#include "lldb/lldb-public.h"
#include "lldb/Utility/SharingPtr.h"
+#include "lldb/lldb-public.h"
namespace lldb_utility {
@@ -22,127 +23,62 @@ namespace lldb_utility {
// otherwise, low is returned (even if *low == NULL)
//----------------------------------------------------------------------
-template<typename T>
-class PriorityPointerPair
-{
+template <typename T> class PriorityPointerPair {
public:
-
- typedef T& reference_type;
- typedef T* pointer_type;
-
- typedef typename std::shared_ptr<T> T_SP;
-
- PriorityPointerPair() :
- m_high(),
- m_low()
- {}
-
- PriorityPointerPair(pointer_type high,
- pointer_type low) :
- m_high(high),
- m_low(low)
- {}
-
- PriorityPointerPair(pointer_type low) :
- m_high(),
- m_low(low)
- {}
-
- PriorityPointerPair(T_SP& high,
- T_SP& low) :
- m_high(high),
- m_low(low)
- {}
-
- PriorityPointerPair(T_SP& low) :
- m_high(),
- m_low(low)
- {}
-
- void
- SwapLow(pointer_type l)
- {
- m_low.swap(l);
- }
-
- void
- SwapHigh(pointer_type h)
- {
- m_high.swap(h);
- }
-
- void
- SwapLow(T_SP l)
- {
- m_low.swap(l);
- }
-
- void
- SwapHigh(T_SP h)
- {
- m_high.swap(h);
- }
-
- T_SP
- GetLow()
- {
- return m_low;
- }
-
- T_SP
- GetHigh()
- {
- return m_high;
- }
-
- T_SP
- Get()
- {
- if (m_high.get())
- return m_high;
- return m_low;
- }
-
- void
- ResetHigh()
- {
- m_high.reset();
- }
-
- void
- ResetLow()
- {
- m_low.reset();
- }
-
- void
- Reset()
- {
- ResetLow();
- ResetHigh();
- }
-
- reference_type
- operator*() const
- {
- return Get().operator*();
- }
-
- pointer_type
- operator->() const
- {
- return Get().operator->();
- }
-
- ~PriorityPointerPair();
-
+ typedef T &reference_type;
+ typedef T *pointer_type;
+
+ typedef typename std::shared_ptr<T> T_SP;
+
+ PriorityPointerPair() : m_high(), m_low() {}
+
+ PriorityPointerPair(pointer_type high, pointer_type low)
+ : m_high(high), m_low(low) {}
+
+ PriorityPointerPair(pointer_type low) : m_high(), m_low(low) {}
+
+ PriorityPointerPair(T_SP &high, T_SP &low) : m_high(high), m_low(low) {}
+
+ PriorityPointerPair(T_SP &low) : m_high(), m_low(low) {}
+
+ void SwapLow(pointer_type l) { m_low.swap(l); }
+
+ void SwapHigh(pointer_type h) { m_high.swap(h); }
+
+ void SwapLow(T_SP l) { m_low.swap(l); }
+
+ void SwapHigh(T_SP h) { m_high.swap(h); }
+
+ T_SP GetLow() { return m_low; }
+
+ T_SP GetHigh() { return m_high; }
+
+ T_SP Get() {
+ if (m_high.get())
+ return m_high;
+ return m_low;
+ }
+
+ void ResetHigh() { m_high.reset(); }
+
+ void ResetLow() { m_low.reset(); }
+
+ void Reset() {
+ ResetLow();
+ ResetHigh();
+ }
+
+ reference_type operator*() const { return Get().operator*(); }
+
+ pointer_type operator->() const { return Get().operator->(); }
+
+ ~PriorityPointerPair();
+
private:
+ T_SP m_high;
+ T_SP m_low;
- T_SP m_high;
- T_SP m_low;
-
- DISALLOW_COPY_AND_ASSIGN (PriorityPointerPair);
-
+ DISALLOW_COPY_AND_ASSIGN(PriorityPointerPair);
};
} // namespace lldb_utility
diff --git a/include/lldb/Utility/ProcessStructReader.h b/include/lldb/Utility/ProcessStructReader.h
index bbb497cd51cb..eb5126329bc0 100644
--- a/include/lldb/Utility/ProcessStructReader.h
+++ b/include/lldb/Utility/ProcessStructReader.h
@@ -1,4 +1,5 @@
-//===---------------------ProcessStructReader.h ------------------*- C++ -*-===//
+//===---------------------ProcessStructReader.h ------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -24,86 +25,79 @@
#include <string>
namespace lldb_private {
- class ProcessStructReader
- {
- protected:
- struct FieldImpl
- {
- CompilerType type;
- size_t offset;
- size_t size;
- };
-
- std::map<ConstString, FieldImpl> m_fields;
- DataExtractor m_data;
- lldb::ByteOrder m_byte_order;
- size_t m_addr_byte_size;
-
- public:
- ProcessStructReader (Process *process, lldb::addr_t base_addr, CompilerType struct_type)
- {
- if (!process)
- return;
- if (base_addr == 0 || base_addr == LLDB_INVALID_ADDRESS)
- return;
- m_byte_order = process->GetByteOrder();
- m_addr_byte_size = process->GetAddressByteSize();
+class ProcessStructReader {
+protected:
+ struct FieldImpl {
+ CompilerType type;
+ size_t offset;
+ size_t size;
+ };
- for (size_t idx = 0; idx < struct_type.GetNumFields(); idx++)
- {
- std::string name;
- uint64_t bit_offset;
- uint32_t bitfield_bit_size;
- bool is_bitfield;
- CompilerType field_type = struct_type.GetFieldAtIndex(idx,name,&bit_offset,&bitfield_bit_size,&is_bitfield);
- // no support for bitfields in here (yet)
- if (is_bitfield)
- return;
- auto size = field_type.GetByteSize(nullptr);
- // no support for things larger than a uint64_t (yet)
- if (size > 8)
- return;
- ConstString const_name = ConstString(name.c_str());
- size_t byte_index = static_cast<size_t>(bit_offset / 8);
- m_fields[const_name] = FieldImpl{field_type, byte_index, static_cast<size_t>(size)};
- }
- size_t total_size = struct_type.GetByteSize(nullptr);
- lldb::DataBufferSP buffer_sp(new DataBufferHeap(total_size,0));
- Error error;
- process->ReadMemoryFromInferior(base_addr,
- buffer_sp->GetBytes(),
- total_size,
- error);
- if (error.Fail())
- return;
- m_data = DataExtractor(buffer_sp,m_byte_order,m_addr_byte_size);
- }
-
- template<typename RetType>
- RetType
- GetField (ConstString name, RetType fail_value = RetType())
- {
- auto iter = m_fields.find(name), end = m_fields.end();
- if (iter == end)
- return fail_value;
- auto size = iter->second.size;
- if (sizeof(RetType) < size)
- return fail_value;
- lldb::offset_t offset = iter->second.offset;
- if (offset + size > m_data.GetByteSize())
- return fail_value;
- return (RetType)(m_data.GetMaxU64(&offset, size));
- }
+ std::map<ConstString, FieldImpl> m_fields;
+ DataExtractor m_data;
+ lldb::ByteOrder m_byte_order;
+ size_t m_addr_byte_size;
- size_t
- GetOffsetOf(ConstString name, size_t fail_value = SIZE_MAX)
- {
- auto iter = m_fields.find(name), end = m_fields.end();
- if (iter == end)
- return fail_value;
- return iter->second.offset;
- }
- };
+public:
+ ProcessStructReader(Process *process, lldb::addr_t base_addr,
+ CompilerType struct_type) {
+ if (!process)
+ return;
+ if (base_addr == 0 || base_addr == LLDB_INVALID_ADDRESS)
+ return;
+ m_byte_order = process->GetByteOrder();
+ m_addr_byte_size = process->GetAddressByteSize();
+
+ for (size_t idx = 0; idx < struct_type.GetNumFields(); idx++) {
+ std::string name;
+ uint64_t bit_offset;
+ uint32_t bitfield_bit_size;
+ bool is_bitfield;
+ CompilerType field_type = struct_type.GetFieldAtIndex(
+ idx, name, &bit_offset, &bitfield_bit_size, &is_bitfield);
+ // no support for bitfields in here (yet)
+ if (is_bitfield)
+ return;
+ auto size = field_type.GetByteSize(nullptr);
+ // no support for things larger than a uint64_t (yet)
+ if (size > 8)
+ return;
+ ConstString const_name = ConstString(name.c_str());
+ size_t byte_index = static_cast<size_t>(bit_offset / 8);
+ m_fields[const_name] =
+ FieldImpl{field_type, byte_index, static_cast<size_t>(size)};
+ }
+ size_t total_size = struct_type.GetByteSize(nullptr);
+ lldb::DataBufferSP buffer_sp(new DataBufferHeap(total_size, 0));
+ Error error;
+ process->ReadMemoryFromInferior(base_addr, buffer_sp->GetBytes(),
+ total_size, error);
+ if (error.Fail())
+ return;
+ m_data = DataExtractor(buffer_sp, m_byte_order, m_addr_byte_size);
+ }
+
+ template <typename RetType>
+ RetType GetField(ConstString name, RetType fail_value = RetType()) {
+ auto iter = m_fields.find(name), end = m_fields.end();
+ if (iter == end)
+ return fail_value;
+ auto size = iter->second.size;
+ if (sizeof(RetType) < size)
+ return fail_value;
+ lldb::offset_t offset = iter->second.offset;
+ if (offset + size > m_data.GetByteSize())
+ return fail_value;
+ return (RetType)(m_data.GetMaxU64(&offset, size));
+ }
+
+ size_t GetOffsetOf(ConstString name, size_t fail_value = SIZE_MAX) {
+ auto iter = m_fields.find(name), end = m_fields.end();
+ if (iter == end)
+ return fail_value;
+ return iter->second.offset;
+ }
+};
}
#endif // utility_ProcessStructReader_h_
diff --git a/include/lldb/Utility/PseudoTerminal.h b/include/lldb/Utility/PseudoTerminal.h
index d73253497746..fbe93343452e 100644
--- a/include/lldb/Utility/PseudoTerminal.h
+++ b/include/lldb/Utility/PseudoTerminal.h
@@ -11,7 +11,6 @@
#define liblldb_PseudoTerminal_h_
#if defined(__cplusplus)
-
#include <fcntl.h>
#include <string>
@@ -26,241 +25,228 @@ namespace lldb_utility {
/// The pseudo terminal class abstracts the use of pseudo terminals on
/// the host system.
//----------------------------------------------------------------------
-class PseudoTerminal
-{
+class PseudoTerminal {
public:
- enum
- {
- invalid_fd = -1 ///< Invalid file descriptor value
- };
-
- //------------------------------------------------------------------
- /// Default constructor
- ///
- /// Constructs this object with invalid master and slave file
- /// descriptors.
- //------------------------------------------------------------------
- PseudoTerminal ();
-
- //------------------------------------------------------------------
- /// Destructor
- ///
- /// The destructor will close the master and slave file descriptors
- /// if they are valid and ownership has not been released using
- /// one of:
- /// @li PseudoTerminal::ReleaseMasterFileDescriptor()
- /// @li PseudoTerminal::ReleaseSaveFileDescriptor()
- //------------------------------------------------------------------
- ~PseudoTerminal ();
-
- //------------------------------------------------------------------
- /// Close the master file descriptor if it is valid.
- //------------------------------------------------------------------
- void
- CloseMasterFileDescriptor ();
-
- //------------------------------------------------------------------
- /// Close the slave file descriptor if it is valid.
- //------------------------------------------------------------------
- void
- CloseSlaveFileDescriptor ();
-
- //------------------------------------------------------------------
- /// Fork a child process that uses pseudo terminals for its stdio.
- ///
- /// In the parent process, a call to this function results in a pid
- /// being returned. If the pid is valid, the master file descriptor
- /// can be used for read/write access to stdio of the child process.
- ///
- /// In the child process the stdin/stdout/stderr will already be
- /// routed to the slave pseudo terminal and the master file
- /// descriptor will be closed as it is no longer needed by the child
- /// process.
- ///
- /// This class will close the file descriptors for the master/slave
- /// when the destructor is called. The file handles can be released
- /// using either:
- /// @li PseudoTerminal::ReleaseMasterFileDescriptor()
- /// @li PseudoTerminal::ReleaseSaveFileDescriptor()
- ///
- /// @param[out] error
- /// An pointer to an error that can describe any errors that
- /// occur. This can be NULL if no error status is desired.
- ///
- /// @return
- /// @li \b Parent process: a child process ID that is greater
- /// than zero, or -1 if the fork fails.
- /// @li \b Child process: zero.
- //------------------------------------------------------------------
- lldb::pid_t
- Fork (char *error_str, size_t error_len);
-
- //------------------------------------------------------------------
- /// The master file descriptor accessor.
- ///
- /// This object retains ownership of the master file descriptor when
- /// this accessor is used. Users can call the member function
- /// PseudoTerminal::ReleaseMasterFileDescriptor() if this
- /// object should release ownership of the slave file descriptor.
- ///
- /// @return
- /// The master file descriptor, or PseudoTerminal::invalid_fd
- /// if the master file descriptor is not currently valid.
- ///
- /// @see PseudoTerminal::ReleaseMasterFileDescriptor()
- //------------------------------------------------------------------
- int
- GetMasterFileDescriptor () const;
-
- //------------------------------------------------------------------
- /// The slave file descriptor accessor.
- ///
- /// This object retains ownership of the slave file descriptor when
- /// this accessor is used. Users can call the member function
- /// PseudoTerminal::ReleaseSlaveFileDescriptor() if this
- /// object should release ownership of the slave file descriptor.
- ///
- /// @return
- /// The slave file descriptor, or PseudoTerminal::invalid_fd
- /// if the slave file descriptor is not currently valid.
- ///
- /// @see PseudoTerminal::ReleaseSlaveFileDescriptor()
- //------------------------------------------------------------------
- int
- GetSlaveFileDescriptor () const;
-
- //------------------------------------------------------------------
- /// Get the name of the slave pseudo terminal.
- ///
- /// A master pseudo terminal should already be valid prior to
- /// calling this function.
- ///
- /// @param[out] error
- /// An pointer to an error that can describe any errors that
- /// occur. This can be NULL if no error status is desired.
- ///
- /// @return
- /// The name of the slave pseudo terminal as a NULL terminated
- /// C. This string that comes from static memory, so a copy of
- /// the string should be made as subsequent calls can change
- /// this value. NULL is returned if this object doesn't have
- /// a valid master pseudo terminal opened or if the call to
- /// \c ptsname() fails.
- ///
- /// @see PseudoTerminal::OpenFirstAvailableMaster()
- //------------------------------------------------------------------
- const char*
- GetSlaveName (char *error_str, size_t error_len) const;
-
- //------------------------------------------------------------------
- /// Open the first available pseudo terminal.
- ///
- /// Opens the first available pseudo terminal with \a oflag as the
- /// permissions. The opened master file descriptor is stored in this
- /// object and can be accessed by calling the
- /// PseudoTerminal::GetMasterFileDescriptor() accessor. Clients
- /// can call the PseudoTerminal::ReleaseMasterFileDescriptor()
- /// accessor function if they wish to use the master file descriptor
- /// beyond the lifespan of this object.
- ///
- /// If this object still has a valid master file descriptor when its
- /// destructor is called, it will close it.
- ///
- /// @param[in] oflag
- /// Flags to use when calling \c posix_openpt(\a oflag).
- /// A value of "O_RDWR|O_NOCTTY" is suggested.
- ///
- /// @param[out] error
- /// An pointer to an error that can describe any errors that
- /// occur. This can be NULL if no error status is desired.
- ///
- /// @return
- /// @li \b true when the master files descriptor is
- /// successfully opened.
- /// @li \b false if anything goes wrong.
- ///
- /// @see PseudoTerminal::GetMasterFileDescriptor()
- /// @see PseudoTerminal::ReleaseMasterFileDescriptor()
- //------------------------------------------------------------------
- bool
- OpenFirstAvailableMaster (int oflag, char *error_str, size_t error_len);
-
- //------------------------------------------------------------------
- /// Open the slave for the current master pseudo terminal.
- ///
- /// A master pseudo terminal should already be valid prior to
- /// calling this function. The opened slave file descriptor is
- /// stored in this object and can be accessed by calling the
- /// PseudoTerminal::GetSlaveFileDescriptor() accessor. Clients
- /// can call the PseudoTerminal::ReleaseSlaveFileDescriptor()
- /// accessor function if they wish to use the slave file descriptor
- /// beyond the lifespan of this object.
- ///
- /// If this object still has a valid slave file descriptor when its
- /// destructor is called, it will close it.
- ///
- /// @param[in] oflag
- /// Flags to use when calling \c open(\a oflag).
- ///
- /// @param[out] error
- /// An pointer to an error that can describe any errors that
- /// occur. This can be NULL if no error status is desired.
- ///
- /// @return
- /// @li \b true when the master files descriptor is
- /// successfully opened.
- /// @li \b false if anything goes wrong.
- ///
- /// @see PseudoTerminal::OpenFirstAvailableMaster()
- /// @see PseudoTerminal::GetSlaveFileDescriptor()
- /// @see PseudoTerminal::ReleaseSlaveFileDescriptor()
- //------------------------------------------------------------------
- bool
- OpenSlave (int oflag, char *error_str, size_t error_len);
-
- //------------------------------------------------------------------
- /// Release the master file descriptor.
- ///
- /// Releases ownership of the master pseudo terminal file descriptor
- /// without closing it. The destructor for this class will close the
- /// master file descriptor if the ownership isn't released using this
- /// call and the master file descriptor has been opened.
- ///
- /// @return
- /// The master file descriptor, or PseudoTerminal::invalid_fd
- /// if the mast file descriptor is not currently valid.
- //------------------------------------------------------------------
- int
- ReleaseMasterFileDescriptor ();
-
- //------------------------------------------------------------------
- /// Release the slave file descriptor.
- ///
- /// Release ownership of the slave pseudo terminal file descriptor
- /// without closing it. The destructor for this class will close the
- /// slave file descriptor if the ownership isn't released using this
- /// call and the slave file descriptor has been opened.
- ///
- /// @return
- /// The slave file descriptor, or PseudoTerminal::invalid_fd
- /// if the slave file descriptor is not currently valid.
- //------------------------------------------------------------------
- int
- ReleaseSlaveFileDescriptor ();
+ enum {
+ invalid_fd = -1 ///< Invalid file descriptor value
+ };
+
+ //------------------------------------------------------------------
+ /// Default constructor
+ ///
+ /// Constructs this object with invalid master and slave file
+ /// descriptors.
+ //------------------------------------------------------------------
+ PseudoTerminal();
+
+ //------------------------------------------------------------------
+ /// Destructor
+ ///
+ /// The destructor will close the master and slave file descriptors
+ /// if they are valid and ownership has not been released using
+ /// one of:
+ /// @li PseudoTerminal::ReleaseMasterFileDescriptor()
+ /// @li PseudoTerminal::ReleaseSaveFileDescriptor()
+ //------------------------------------------------------------------
+ ~PseudoTerminal();
+
+ //------------------------------------------------------------------
+ /// Close the master file descriptor if it is valid.
+ //------------------------------------------------------------------
+ void CloseMasterFileDescriptor();
+
+ //------------------------------------------------------------------
+ /// Close the slave file descriptor if it is valid.
+ //------------------------------------------------------------------
+ void CloseSlaveFileDescriptor();
+
+ //------------------------------------------------------------------
+ /// Fork a child process that uses pseudo terminals for its stdio.
+ ///
+ /// In the parent process, a call to this function results in a pid
+ /// being returned. If the pid is valid, the master file descriptor
+ /// can be used for read/write access to stdio of the child process.
+ ///
+ /// In the child process the stdin/stdout/stderr will already be
+ /// routed to the slave pseudo terminal and the master file
+ /// descriptor will be closed as it is no longer needed by the child
+ /// process.
+ ///
+ /// This class will close the file descriptors for the master/slave
+ /// when the destructor is called. The file handles can be released
+ /// using either:
+ /// @li PseudoTerminal::ReleaseMasterFileDescriptor()
+ /// @li PseudoTerminal::ReleaseSaveFileDescriptor()
+ ///
+ /// @param[out] error
+ /// An pointer to an error that can describe any errors that
+ /// occur. This can be NULL if no error status is desired.
+ ///
+ /// @return
+ /// @li \b Parent process: a child process ID that is greater
+ /// than zero, or -1 if the fork fails.
+ /// @li \b Child process: zero.
+ //------------------------------------------------------------------
+ lldb::pid_t Fork(char *error_str, size_t error_len);
+
+ //------------------------------------------------------------------
+ /// The master file descriptor accessor.
+ ///
+ /// This object retains ownership of the master file descriptor when
+ /// this accessor is used. Users can call the member function
+ /// PseudoTerminal::ReleaseMasterFileDescriptor() if this
+ /// object should release ownership of the slave file descriptor.
+ ///
+ /// @return
+ /// The master file descriptor, or PseudoTerminal::invalid_fd
+ /// if the master file descriptor is not currently valid.
+ ///
+ /// @see PseudoTerminal::ReleaseMasterFileDescriptor()
+ //------------------------------------------------------------------
+ int GetMasterFileDescriptor() const;
+
+ //------------------------------------------------------------------
+ /// The slave file descriptor accessor.
+ ///
+ /// This object retains ownership of the slave file descriptor when
+ /// this accessor is used. Users can call the member function
+ /// PseudoTerminal::ReleaseSlaveFileDescriptor() if this
+ /// object should release ownership of the slave file descriptor.
+ ///
+ /// @return
+ /// The slave file descriptor, or PseudoTerminal::invalid_fd
+ /// if the slave file descriptor is not currently valid.
+ ///
+ /// @see PseudoTerminal::ReleaseSlaveFileDescriptor()
+ //------------------------------------------------------------------
+ int GetSlaveFileDescriptor() const;
+
+ //------------------------------------------------------------------
+ /// Get the name of the slave pseudo terminal.
+ ///
+ /// A master pseudo terminal should already be valid prior to
+ /// calling this function.
+ ///
+ /// @param[out] error
+ /// An pointer to an error that can describe any errors that
+ /// occur. This can be NULL if no error status is desired.
+ ///
+ /// @return
+ /// The name of the slave pseudo terminal as a NULL terminated
+ /// C. This string that comes from static memory, so a copy of
+ /// the string should be made as subsequent calls can change
+ /// this value. NULL is returned if this object doesn't have
+ /// a valid master pseudo terminal opened or if the call to
+ /// \c ptsname() fails.
+ ///
+ /// @see PseudoTerminal::OpenFirstAvailableMaster()
+ //------------------------------------------------------------------
+ const char *GetSlaveName(char *error_str, size_t error_len) const;
+
+ //------------------------------------------------------------------
+ /// Open the first available pseudo terminal.
+ ///
+ /// Opens the first available pseudo terminal with \a oflag as the
+ /// permissions. The opened master file descriptor is stored in this
+ /// object and can be accessed by calling the
+ /// PseudoTerminal::GetMasterFileDescriptor() accessor. Clients
+ /// can call the PseudoTerminal::ReleaseMasterFileDescriptor()
+ /// accessor function if they wish to use the master file descriptor
+ /// beyond the lifespan of this object.
+ ///
+ /// If this object still has a valid master file descriptor when its
+ /// destructor is called, it will close it.
+ ///
+ /// @param[in] oflag
+ /// Flags to use when calling \c posix_openpt(\a oflag).
+ /// A value of "O_RDWR|O_NOCTTY" is suggested.
+ ///
+ /// @param[out] error
+ /// An pointer to an error that can describe any errors that
+ /// occur. This can be NULL if no error status is desired.
+ ///
+ /// @return
+ /// @li \b true when the master files descriptor is
+ /// successfully opened.
+ /// @li \b false if anything goes wrong.
+ ///
+ /// @see PseudoTerminal::GetMasterFileDescriptor()
+ /// @see PseudoTerminal::ReleaseMasterFileDescriptor()
+ //------------------------------------------------------------------
+ bool OpenFirstAvailableMaster(int oflag, char *error_str, size_t error_len);
+
+ //------------------------------------------------------------------
+ /// Open the slave for the current master pseudo terminal.
+ ///
+ /// A master pseudo terminal should already be valid prior to
+ /// calling this function. The opened slave file descriptor is
+ /// stored in this object and can be accessed by calling the
+ /// PseudoTerminal::GetSlaveFileDescriptor() accessor. Clients
+ /// can call the PseudoTerminal::ReleaseSlaveFileDescriptor()
+ /// accessor function if they wish to use the slave file descriptor
+ /// beyond the lifespan of this object.
+ ///
+ /// If this object still has a valid slave file descriptor when its
+ /// destructor is called, it will close it.
+ ///
+ /// @param[in] oflag
+ /// Flags to use when calling \c open(\a oflag).
+ ///
+ /// @param[out] error
+ /// An pointer to an error that can describe any errors that
+ /// occur. This can be NULL if no error status is desired.
+ ///
+ /// @return
+ /// @li \b true when the master files descriptor is
+ /// successfully opened.
+ /// @li \b false if anything goes wrong.
+ ///
+ /// @see PseudoTerminal::OpenFirstAvailableMaster()
+ /// @see PseudoTerminal::GetSlaveFileDescriptor()
+ /// @see PseudoTerminal::ReleaseSlaveFileDescriptor()
+ //------------------------------------------------------------------
+ bool OpenSlave(int oflag, char *error_str, size_t error_len);
+
+ //------------------------------------------------------------------
+ /// Release the master file descriptor.
+ ///
+ /// Releases ownership of the master pseudo terminal file descriptor
+ /// without closing it. The destructor for this class will close the
+ /// master file descriptor if the ownership isn't released using this
+ /// call and the master file descriptor has been opened.
+ ///
+ /// @return
+ /// The master file descriptor, or PseudoTerminal::invalid_fd
+ /// if the mast file descriptor is not currently valid.
+ //------------------------------------------------------------------
+ int ReleaseMasterFileDescriptor();
+
+ //------------------------------------------------------------------
+ /// Release the slave file descriptor.
+ ///
+ /// Release ownership of the slave pseudo terminal file descriptor
+ /// without closing it. The destructor for this class will close the
+ /// slave file descriptor if the ownership isn't released using this
+ /// call and the slave file descriptor has been opened.
+ ///
+ /// @return
+ /// The slave file descriptor, or PseudoTerminal::invalid_fd
+ /// if the slave file descriptor is not currently valid.
+ //------------------------------------------------------------------
+ int ReleaseSlaveFileDescriptor();
protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- int m_master_fd; ///< The file descriptor for the master.
- int m_slave_fd; ///< The file descriptor for the slave.
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ int m_master_fd; ///< The file descriptor for the master.
+ int m_slave_fd; ///< The file descriptor for the slave.
private:
- DISALLOW_COPY_AND_ASSIGN (PseudoTerminal);
-
+ DISALLOW_COPY_AND_ASSIGN(PseudoTerminal);
};
} // namespace lldb_utility
-#endif // #if defined(__cplusplus)
+#endif // #if defined(__cplusplus)
#endif // #ifndef liblldb_PseudoTerminal_h_
diff --git a/include/lldb/Utility/Range.h b/include/lldb/Utility/Range.h
index 1257adb719a1..c13bc0d08bd6 100644
--- a/include/lldb/Utility/Range.h
+++ b/include/lldb/Utility/Range.h
@@ -10,80 +10,52 @@
#ifndef utility_Range_h_
#define utility_Range_h_
-#include <stdint.h>
#include <algorithm>
+#include <stdint.h>
namespace lldb_utility {
-
-class Range
-{
+
+class Range {
public:
-
- typedef uint64_t ValueType;
-
- static const ValueType OPEN_END = UINT64_MAX;
-
- Range (const Range& rng);
-
- Range (ValueType low = 0,
- ValueType high = OPEN_END);
-
- Range&
- operator = (const Range& rhs);
-
- ValueType
- GetLow ()
- {
- return m_low;
- }
-
- ValueType
- GetHigh ()
- {
- return m_high;
- }
-
- void
- SetLow (ValueType low)
- {
- m_low = low;
- }
-
- void
- SetHigh (ValueType high)
- {
- m_high = high;
- }
-
- void
- Flip ();
-
- void
- Intersection (const Range& other);
-
- void
- Union (const Range& other);
-
- typedef bool (*RangeCallback)(ValueType index);
-
- void
- Iterate (RangeCallback callback);
-
- ValueType
- GetSize ();
-
- bool
- IsEmpty ();
-
+ typedef uint64_t ValueType;
+
+ static const ValueType OPEN_END = UINT64_MAX;
+
+ Range(const Range &rng);
+
+ Range(ValueType low = 0, ValueType high = OPEN_END);
+
+ Range &operator=(const Range &rhs);
+
+ ValueType GetLow() { return m_low; }
+
+ ValueType GetHigh() { return m_high; }
+
+ void SetLow(ValueType low) { m_low = low; }
+
+ void SetHigh(ValueType high) { m_high = high; }
+
+ void Flip();
+
+ void Intersection(const Range &other);
+
+ void Union(const Range &other);
+
+ typedef bool (*RangeCallback)(ValueType index);
+
+ void Iterate(RangeCallback callback);
+
+ ValueType GetSize();
+
+ bool IsEmpty();
+
private:
-
- void
- InitRange ();
-
- ValueType m_low;
- ValueType m_high;
+ void InitRange();
+
+ ValueType m_low;
+ ValueType m_high;
};
-
+
} // namespace lldb_private
#endif // #ifndef utility_Range_h_
diff --git a/include/lldb/Utility/RegisterNumber.h b/include/lldb/Utility/RegisterNumber.h
index 89d52fd4a967..b3845ac0d46b 100644
--- a/include/lldb/Utility/RegisterNumber.h
+++ b/include/lldb/Utility/RegisterNumber.h
@@ -21,49 +21,42 @@
class RegisterNumber {
public:
- RegisterNumber (lldb_private::Thread &thread, lldb::RegisterKind kind, uint32_t num);
+ RegisterNumber(lldb_private::Thread &thread, lldb::RegisterKind kind,
+ uint32_t num);
- // This constructor plus the init() method below allow for the placeholder
- // creation of an invalid object initially, possibly to be filled in. It
- // would be more consistent to have three Set* methods to set the three
- // data that the object needs.
- RegisterNumber ();
+ // This constructor plus the init() method below allow for the placeholder
+ // creation of an invalid object initially, possibly to be filled in. It
+ // would be more consistent to have three Set* methods to set the three
+ // data that the object needs.
+ RegisterNumber();
- void
- init (lldb_private::Thread &thread, lldb::RegisterKind kind, uint32_t num);
+ void init(lldb_private::Thread &thread, lldb::RegisterKind kind,
+ uint32_t num);
- const RegisterNumber &
- operator = (const RegisterNumber &rhs);
+ const RegisterNumber &operator=(const RegisterNumber &rhs);
- bool
- operator == (RegisterNumber &rhs);
+ bool operator==(RegisterNumber &rhs);
- bool
- operator != (RegisterNumber &rhs);
+ bool operator!=(RegisterNumber &rhs);
- bool
- IsValid () const;
+ bool IsValid() const;
- uint32_t
- GetAsKind (lldb::RegisterKind kind);
+ uint32_t GetAsKind(lldb::RegisterKind kind);
- uint32_t
- GetRegisterNumber () const;
+ uint32_t GetRegisterNumber() const;
- lldb::RegisterKind
- GetRegisterKind () const;
+ lldb::RegisterKind GetRegisterKind() const;
- const char *
- GetName ();
+ const char *GetName();
private:
- typedef std::map<lldb::RegisterKind, uint32_t> Collection;
+ typedef std::map<lldb::RegisterKind, uint32_t> Collection;
- lldb::RegisterContextSP m_reg_ctx_sp;
- uint32_t m_regnum;
- lldb::RegisterKind m_kind;
- Collection m_kind_regnum_map;
- const char *m_name;
+ lldb::RegisterContextSP m_reg_ctx_sp;
+ uint32_t m_regnum;
+ lldb::RegisterKind m_kind;
+ Collection m_kind_regnum_map;
+ const char *m_name;
};
#endif // liblldb_RegisterNumber_h
diff --git a/include/lldb/Utility/SafeMachO.h b/include/lldb/Utility/SafeMachO.h
index 2a831ed89b80..5da03c15da94 100644
--- a/include/lldb/Utility/SafeMachO.h
+++ b/include/lldb/Utility/SafeMachO.h
@@ -9,104 +9,110 @@
#ifndef liblldb_SafeMachO_h_
#define liblldb_SafeMachO_h_
-// This header file is required to work around collisions between the defines in mach/machine.h, and enum members
-// of the same name in llvm's MachO.h. If you want to use llvm/Support/MachO.h, use this file instead.
+// This header file is required to work around collisions between the defines in
+// mach/machine.h, and enum members
+// of the same name in llvm's MachO.h. If you want to use llvm/Support/MachO.h,
+// use this file instead.
// The caveats are:
-// 1) You can only use the MachO.h enums, you can't use the defines. That won't make a difference since the values
+// 1) You can only use the MachO.h enums, you can't use the defines. That won't
+// make a difference since the values
// are the same.
-// 2) If you need any header file that relies on mach/machine.h, you must include that first.
-// 3) This isn't a total solution, it doesn't undef every define that MachO.h has borrowed from various system headers,
-// only the ones that come from mach/machine.h because that is the one we ended up pulling in from various places.
+// 2) If you need any header file that relies on mach/machine.h, you must
+// include that first.
+// 3) This isn't a total solution, it doesn't undef every define that MachO.h
+// has borrowed from various system headers,
+// only the ones that come from mach/machine.h because that is the one we
+// ended up pulling in from various places.
//
#undef CPU_ARCH_MASK
-#undef CPU_ARCH_ABI64
-
-#undef CPU_TYPE_ANY
-#undef CPU_TYPE_X86
-#undef CPU_TYPE_I386
-#undef CPU_TYPE_X86_64
-#undef CPU_TYPE_MC98000
-#undef CPU_TYPE_ARM
-#undef CPU_TYPE_ARM64
-#undef CPU_TYPE_SPARC
-#undef CPU_TYPE_POWERPC
-#undef CPU_TYPE_POWERPC64
-
-#undef CPU_SUB_TYPE_MASK
-#undef CPU_SUB_TYPE_LIB64
-
-#undef CPU_SUBTYPE_MULTIPLE
-
-#undef CPU_SUBTYPE_I386_ALL
-#undef CPU_SUBTYPE_386
-#undef CPU_SUBTYPE_486
-#undef CPU_SUBTYPE_486SX
-#undef CPU_SUBTYPE_586
-#undef CPU_SUBTYPE_PENT
-#undef CPU_SUBTYPE_PENTPRO
-#undef CPU_SUBTYPE_PENTII_M3
-#undef CPU_SUBTYPE_PENTII_M5
-#undef CPU_SUBTYPE_CELERON
-#undef CPU_SUBTYPE_CELERON_MOBILE
-#undef CPU_SUBTYPE_PENTIUM_3
-#undef CPU_SUBTYPE_PENTIUM_3_M
-#undef CPU_SUBTYPE_PENTIUM_3_XEON
-#undef CPU_SUBTYPE_PENTIUM_M
-#undef CPU_SUBTYPE_PENTIUM_4
-#undef CPU_SUBTYPE_PENTIUM_4_M
-#undef CPU_SUBTYPE_ITANIUM
-#undef CPU_SUBTYPE_ITANIUM_2
-#undef CPU_SUBTYPE_XEON
-#undef CPU_SUBTYPE_XEON_MP
-
-#undef CPU_SUBTYPE_X86_ALL
-#undef CPU_SUBTYPE_X86_64_ALL
-#undef CPU_SUBTYPE_X86_ARCH1
-#undef CPU_SUBTYPE_X86_64_H
+#undef CPU_ARCH_ABI64
+
+#undef CPU_TYPE_ANY
+#undef CPU_TYPE_X86
+#undef CPU_TYPE_I386
+#undef CPU_TYPE_X86_64
+#undef CPU_TYPE_MC98000
+#undef CPU_TYPE_ARM
+#undef CPU_TYPE_ARM64
+#undef CPU_TYPE_SPARC
+#undef CPU_TYPE_POWERPC
+#undef CPU_TYPE_POWERPC64
+
+#undef CPU_SUB_TYPE_MASK
+#undef CPU_SUB_TYPE_LIB64
+
+#undef CPU_SUBTYPE_MULTIPLE
+
+#undef CPU_SUBTYPE_I386_ALL
+#undef CPU_SUBTYPE_386
+#undef CPU_SUBTYPE_486
+#undef CPU_SUBTYPE_486SX
+#undef CPU_SUBTYPE_586
+#undef CPU_SUBTYPE_PENT
+#undef CPU_SUBTYPE_PENTPRO
+#undef CPU_SUBTYPE_PENTII_M3
+#undef CPU_SUBTYPE_PENTII_M5
+#undef CPU_SUBTYPE_CELERON
+#undef CPU_SUBTYPE_CELERON_MOBILE
+#undef CPU_SUBTYPE_PENTIUM_3
+#undef CPU_SUBTYPE_PENTIUM_3_M
+#undef CPU_SUBTYPE_PENTIUM_3_XEON
+#undef CPU_SUBTYPE_PENTIUM_M
+#undef CPU_SUBTYPE_PENTIUM_4
+#undef CPU_SUBTYPE_PENTIUM_4_M
+#undef CPU_SUBTYPE_ITANIUM
+#undef CPU_SUBTYPE_ITANIUM_2
+#undef CPU_SUBTYPE_XEON
+#undef CPU_SUBTYPE_XEON_MP
+
+#undef CPU_SUBTYPE_X86_ALL
+#undef CPU_SUBTYPE_X86_64_ALL
+#undef CPU_SUBTYPE_X86_ARCH1
+#undef CPU_SUBTYPE_X86_64_H
#undef CPU_SUBTYPE_INTEL
#undef CPU_SUBTYPE_INTEL_FAMILY
#undef CPU_SUBTYPE_INTEL_FAMILY_MAX
-#undef CPU_SUBTYPE_INTEL_MODEL
-#undef CPU_SUBTYPE_INTEL_MODEL_ALL
+#undef CPU_SUBTYPE_INTEL_MODEL
+#undef CPU_SUBTYPE_INTEL_MODEL_ALL
#undef CPU_SUBTYPE_ARM
-#undef CPU_SUBTYPE_ARM_ALL
-#undef CPU_SUBTYPE_ARM_V4T
-#undef CPU_SUBTYPE_ARM_V6
-#undef CPU_SUBTYPE_ARM_V5
-#undef CPU_SUBTYPE_ARM_V5TEJ
-#undef CPU_SUBTYPE_ARM_XSCALE
-#undef CPU_SUBTYPE_ARM_V7
+#undef CPU_SUBTYPE_ARM_ALL
+#undef CPU_SUBTYPE_ARM_V4T
+#undef CPU_SUBTYPE_ARM_V6
+#undef CPU_SUBTYPE_ARM_V5
+#undef CPU_SUBTYPE_ARM_V5TEJ
+#undef CPU_SUBTYPE_ARM_XSCALE
+#undef CPU_SUBTYPE_ARM_V7
-#undef CPU_SUBTYPE_ARM_V7S
-#undef CPU_SUBTYPE_ARM_V7K
-#undef CPU_SUBTYPE_ARM_V6M
-#undef CPU_SUBTYPE_ARM_V7M
-#undef CPU_SUBTYPE_ARM_V7EM
+#undef CPU_SUBTYPE_ARM_V7S
+#undef CPU_SUBTYPE_ARM_V7K
+#undef CPU_SUBTYPE_ARM_V6M
+#undef CPU_SUBTYPE_ARM_V7M
+#undef CPU_SUBTYPE_ARM_V7EM
-#undef CPU_SUBTYPE_ARM64_ALL
+#undef CPU_SUBTYPE_ARM64_ALL
-#undef CPU_SUBTYPE_SPARC_ALL
+#undef CPU_SUBTYPE_SPARC_ALL
#undef CPU_SUBTYPE_POWERPC
-#undef CPU_SUBTYPE_POWERPC_ALL
-#undef CPU_SUBTYPE_POWERPC_601
-#undef CPU_SUBTYPE_POWERPC_602
-#undef CPU_SUBTYPE_POWERPC_603
-#undef CPU_SUBTYPE_POWERPC_603e
-#undef CPU_SUBTYPE_POWERPC_603ev
-#undef CPU_SUBTYPE_POWERPC_604
-#undef CPU_SUBTYPE_POWERPC_604e
-#undef CPU_SUBTYPE_POWERPC_620
-#undef CPU_SUBTYPE_POWERPC_750
-#undef CPU_SUBTYPE_POWERPC_7400
-#undef CPU_SUBTYPE_POWERPC_7450
-#undef CPU_SUBTYPE_POWERPC_970
-
-#undef CPU_SUBTYPE_MC980000_ALL
-#undef CPU_SUBTYPE_MC98601
+#undef CPU_SUBTYPE_POWERPC_ALL
+#undef CPU_SUBTYPE_POWERPC_601
+#undef CPU_SUBTYPE_POWERPC_602
+#undef CPU_SUBTYPE_POWERPC_603
+#undef CPU_SUBTYPE_POWERPC_603e
+#undef CPU_SUBTYPE_POWERPC_603ev
+#undef CPU_SUBTYPE_POWERPC_604
+#undef CPU_SUBTYPE_POWERPC_604e
+#undef CPU_SUBTYPE_POWERPC_620
+#undef CPU_SUBTYPE_POWERPC_750
+#undef CPU_SUBTYPE_POWERPC_7400
+#undef CPU_SUBTYPE_POWERPC_7450
+#undef CPU_SUBTYPE_POWERPC_970
+
+#undef CPU_SUBTYPE_MC980000_ALL
+#undef CPU_SUBTYPE_MC98601
#include "llvm/Support/MachO.h"
diff --git a/include/lldb/Utility/SelectHelper.h b/include/lldb/Utility/SelectHelper.h
new file mode 100644
index 000000000000..0251c8e72cde
--- /dev/null
+++ b/include/lldb/Utility/SelectHelper.h
@@ -0,0 +1,76 @@
+//===-- SelectHelper.h ------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_SelectHelper_h_
+#define liblldb_SelectHelper_h_
+
+// C Includes
+// C++ Includes
+#include <chrono>
+
+// Other libraries and framework includes
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/Optional.h"
+
+// Project includes
+#include "lldb/lldb-forward.h"
+
+class SelectHelper {
+public:
+ // Defaults to infinite wait for select unless you call SetTimeout()
+ SelectHelper();
+
+ // Call SetTimeout() before calling SelectHelper::Select() to set the
+ // timeout based on the current time + the timeout. This allows multiple
+ // calls to SelectHelper::Select() without having to worry about the
+ // absolute timeout as this class manages to set the relative timeout
+ // correctly.
+ void SetTimeout(const std::chrono::microseconds &timeout);
+
+ // Call the FDSet*() functions before calling SelectHelper::Select() to
+ // set the file descriptors that we will watch for when calling
+ // select. This will cause FD_SET() to be called prior to calling select
+ // using the "fd" provided.
+ void FDSetRead(lldb::socket_t fd);
+ void FDSetWrite(lldb::socket_t fd);
+ void FDSetError(lldb::socket_t fd);
+
+ // Call the FDIsSet*() functions after calling SelectHelper::Select()
+ // to check which file descriptors are ready for read/write/error. This
+ // will contain the result of FD_ISSET after calling select for a given
+ // file descriptor.
+ bool FDIsSetRead(lldb::socket_t fd) const;
+ bool FDIsSetWrite(lldb::socket_t fd) const;
+ bool FDIsSetError(lldb::socket_t fd) const;
+
+ // Call the system's select() to wait for descriptors using
+ // timeout provided in a call the SelectHelper::SetTimeout(),
+ // or infinite wait if no timeout was set.
+ lldb_private::Error Select();
+
+protected:
+ struct FDInfo {
+ FDInfo()
+ : read_set(false), write_set(false), error_set(false),
+ read_is_set(false), write_is_set(false), error_is_set(false) {}
+
+ void PrepareForSelect() {
+ read_is_set = false;
+ write_is_set = false;
+ error_is_set = false;
+ }
+
+ bool read_set : 1, write_set : 1, error_set : 1, read_is_set : 1,
+ write_is_set : 1, error_is_set : 1;
+ };
+ llvm::DenseMap<lldb::socket_t, FDInfo> m_fd_map;
+ llvm::Optional<std::chrono::steady_clock::time_point> m_end_time;
+};
+
+#endif // liblldb_SelectHelper_h_
diff --git a/include/lldb/Utility/SharedCluster.h b/include/lldb/Utility/SharedCluster.h
index dfcc119e14bf..b01f702c2787 100644
--- a/include/lldb/Utility/SharedCluster.h
+++ b/include/lldb/Utility/SharedCluster.h
@@ -17,91 +17,76 @@
namespace lldb_private {
-namespace imp
-{
- template <typename T>
- class shared_ptr_refcount : public lldb_private::imp::shared_count
- {
- public:
- template<class Y> shared_ptr_refcount (Y *in) : shared_count (0), manager(in) {}
-
- shared_ptr_refcount() : shared_count (0) {}
-
- ~shared_ptr_refcount() override
- {
- }
-
- void on_zero_shared() override
- {
- manager->DecrementRefCount();
- }
-
- private:
- T *manager;
- };
+namespace imp {
+template <typename T>
+class shared_ptr_refcount : public lldb_private::imp::shared_count {
+public:
+ template <class Y>
+ shared_ptr_refcount(Y *in) : shared_count(0), manager(in) {}
+
+ shared_ptr_refcount() : shared_count(0) {}
+
+ ~shared_ptr_refcount() override {}
+
+ void on_zero_shared() override { manager->DecrementRefCount(); }
+
+private:
+ T *manager;
+};
} // namespace imp
-template <class T>
-class ClusterManager
-{
+template <class T> class ClusterManager {
public:
- ClusterManager() : m_objects(), m_external_ref(0), m_mutex() {}
-
- ~ClusterManager()
- {
- for (typename llvm::SmallPtrSet<T *, 16>::iterator pos = m_objects.begin(), end = m_objects.end(); pos != end;
- ++pos)
- {
- T *object = *pos;
- delete object;
- }
-
- // Decrement refcount should have been called on this ClusterManager,
- // and it should have locked the mutex, now we will unlock it before
- // we destroy it...
- m_mutex.unlock();
+ ClusterManager() : m_objects(), m_external_ref(0), m_mutex() {}
+
+ ~ClusterManager() {
+ for (typename llvm::SmallPtrSet<T *, 16>::iterator pos = m_objects.begin(),
+ end = m_objects.end();
+ pos != end; ++pos) {
+ T *object = *pos;
+ delete object;
}
- void
- ManageObject(T *new_object)
- {
- std::lock_guard<std::mutex> guard(m_mutex);
- m_objects.insert(new_object);
- }
+ // Decrement refcount should have been called on this ClusterManager,
+ // and it should have locked the mutex, now we will unlock it before
+ // we destroy it...
+ m_mutex.unlock();
+ }
- typename lldb_private::SharingPtr<T>
- GetSharedPointer(T *desired_object)
- {
- {
- std::lock_guard<std::mutex> guard(m_mutex);
- m_external_ref++;
- if (0 == m_objects.count(desired_object))
- {
- lldbassert(false && "object not found in shared cluster when expected");
- desired_object = nullptr;
- }
- }
- return typename lldb_private::SharingPtr<T>(desired_object, new imp::shared_ptr_refcount<ClusterManager>(this));
- }
+ void ManageObject(T *new_object) {
+ std::lock_guard<std::mutex> guard(m_mutex);
+ m_objects.insert(new_object);
+ }
-private:
- void
- DecrementRefCount()
+ typename lldb_private::SharingPtr<T> GetSharedPointer(T *desired_object) {
{
- m_mutex.lock();
- m_external_ref--;
- if (m_external_ref == 0)
- delete this;
- else
- m_mutex.unlock();
+ std::lock_guard<std::mutex> guard(m_mutex);
+ m_external_ref++;
+ if (0 == m_objects.count(desired_object)) {
+ lldbassert(false && "object not found in shared cluster when expected");
+ desired_object = nullptr;
+ }
}
+ return typename lldb_private::SharingPtr<T>(
+ desired_object, new imp::shared_ptr_refcount<ClusterManager>(this));
+ }
- friend class imp::shared_ptr_refcount<ClusterManager>;
-
- llvm::SmallPtrSet<T *, 16> m_objects;
- int m_external_ref;
- std::mutex m_mutex;
+private:
+ void DecrementRefCount() {
+ m_mutex.lock();
+ m_external_ref--;
+ if (m_external_ref == 0)
+ delete this;
+ else
+ m_mutex.unlock();
+ }
+
+ friend class imp::shared_ptr_refcount<ClusterManager>;
+
+ llvm::SmallPtrSet<T *, 16> m_objects;
+ int m_external_ref;
+ std::mutex m_mutex;
};
} // namespace lldb_private
diff --git a/include/lldb/Utility/SharingPtr.h b/include/lldb/Utility/SharingPtr.h
index 29538bc7dc03..4e91222b3c31 100644
--- a/include/lldb/Utility/SharingPtr.h
+++ b/include/lldb/Utility/SharingPtr.h
@@ -28,813 +28,595 @@
// Project includes
//#define ENABLE_SP_LOGGING 1 // DON'T CHECK THIS LINE IN UNLESS COMMENTED OUT
-#if defined (ENABLE_SP_LOGGING)
+#if defined(ENABLE_SP_LOGGING)
-extern "C" void track_sp (void *sp_this, void *ptr, long count);
+extern "C" void track_sp(void *sp_this, void *ptr, long count);
#endif
namespace lldb_private {
namespace imp {
-
-class shared_count
-{
- shared_count(const shared_count&);
- shared_count& operator=(const shared_count&);
+
+class shared_count {
+ shared_count(const shared_count &);
+ shared_count &operator=(const shared_count &);
public:
- explicit shared_count(long refs = 0)
- : shared_owners_(refs) {}
+ explicit shared_count(long refs = 0) : shared_owners_(refs) {}
+
+ void add_shared();
+ void release_shared();
+ long use_count() const { return shared_owners_ + 1; }
- void add_shared();
- void release_shared();
- long use_count() const {return shared_owners_ + 1;}
protected:
#ifdef _MSC_VER
- long shared_owners_;
+ long shared_owners_;
#else
- std::atomic<long> shared_owners_;
+ std::atomic<long> shared_owners_;
#endif
- virtual ~shared_count();
+ virtual ~shared_count();
private:
- virtual void on_zero_shared() = 0;
+ virtual void on_zero_shared() = 0;
};
-template <class T>
-class shared_ptr_pointer
- : public shared_count
-{
- T data_;
+template <class T> class shared_ptr_pointer : public shared_count {
+ T data_;
+
public:
- shared_ptr_pointer(T p)
- : data_(p) {}
+ shared_ptr_pointer(T p) : data_(p) {}
private:
- void on_zero_shared() override;
+ void on_zero_shared() override;
- // Outlaw copy constructor and assignment operator to keep effective C++
- // warnings down to a minimum
- shared_ptr_pointer (const shared_ptr_pointer &);
- shared_ptr_pointer & operator=(const shared_ptr_pointer &);
+ // Outlaw copy constructor and assignment operator to keep effective C++
+ // warnings down to a minimum
+ shared_ptr_pointer(const shared_ptr_pointer &);
+ shared_ptr_pointer &operator=(const shared_ptr_pointer &);
};
-template <class T>
-void
-shared_ptr_pointer<T>::on_zero_shared()
-{
- delete data_;
+template <class T> void shared_ptr_pointer<T>::on_zero_shared() {
+ delete data_;
}
-template <class T>
-class shared_ptr_emplace
- : public shared_count
-{
- T data_;
-public:
+template <class T> class shared_ptr_emplace : public shared_count {
+ T data_;
- shared_ptr_emplace()
- : data_() {}
+public:
+ shared_ptr_emplace() : data_() {}
- template <class A0>
- shared_ptr_emplace(A0& a0)
- : data_(a0) {}
+ template <class A0> shared_ptr_emplace(A0 &a0) : data_(a0) {}
- template <class A0, class A1>
- shared_ptr_emplace(A0& a0, A1& a1)
- : data_(a0, a1) {}
+ template <class A0, class A1>
+ shared_ptr_emplace(A0 &a0, A1 &a1) : data_(a0, a1) {}
- template <class A0, class A1, class A2>
- shared_ptr_emplace(A0& a0, A1& a1, A2& a2)
- : data_(a0, a1, a2) {}
+ template <class A0, class A1, class A2>
+ shared_ptr_emplace(A0 &a0, A1 &a1, A2 &a2) : data_(a0, a1, a2) {}
- template <class A0, class A1, class A2, class A3>
- shared_ptr_emplace(A0& a0, A1& a1, A2& a2, A3& a3)
- : data_(a0, a1, a2, a3) {}
+ template <class A0, class A1, class A2, class A3>
+ shared_ptr_emplace(A0 &a0, A1 &a1, A2 &a2, A3 &a3) : data_(a0, a1, a2, a3) {}
- template <class A0, class A1, class A2, class A3, class A4>
- shared_ptr_emplace(A0& a0, A1& a1, A2& a2, A3& a3, A4& a4)
- : data_(a0, a1, a2, a3, a4) {}
+ template <class A0, class A1, class A2, class A3, class A4>
+ shared_ptr_emplace(A0 &a0, A1 &a1, A2 &a2, A3 &a3, A4 &a4)
+ : data_(a0, a1, a2, a3, a4) {}
private:
- void on_zero_shared() override;
+ void on_zero_shared() override;
public:
- T* get() {return &data_;}
+ T *get() { return &data_; }
};
-template <class T>
-void
-shared_ptr_emplace<T>::on_zero_shared()
-{
-}
+template <class T> void shared_ptr_emplace<T>::on_zero_shared() {}
} // namespace imp
-template<class T>
-class SharingPtr
-{
-public:
- typedef T element_type;
+template <class T> class SharingPtr {
+public:
+ typedef T element_type;
private:
- element_type* ptr_;
- imp::shared_count* cntrl_;
+ element_type *ptr_;
+ imp::shared_count *cntrl_;
- struct nat {int for_bool_;};
+ struct nat {
+ int for_bool_;
+ };
public:
- SharingPtr();
- SharingPtr(std::nullptr_t);
- template<class Y> explicit SharingPtr(Y* p);
- template<class Y> explicit SharingPtr(Y* p, imp::shared_count *ctrl_block);
- template<class Y> SharingPtr(const SharingPtr<Y>& r, element_type *p);
- SharingPtr(const SharingPtr& r);
- template<class Y>
- SharingPtr(const SharingPtr<Y>& r);
+ SharingPtr();
+ SharingPtr(std::nullptr_t);
+ template <class Y> explicit SharingPtr(Y *p);
+ template <class Y> explicit SharingPtr(Y *p, imp::shared_count *ctrl_block);
+ template <class Y> SharingPtr(const SharingPtr<Y> &r, element_type *p);
+ SharingPtr(const SharingPtr &r);
+ template <class Y> SharingPtr(const SharingPtr<Y> &r);
- ~SharingPtr();
+ ~SharingPtr();
- SharingPtr& operator=(const SharingPtr& r);
- template<class Y> SharingPtr& operator=(const SharingPtr<Y>& r);
+ SharingPtr &operator=(const SharingPtr &r);
+ template <class Y> SharingPtr &operator=(const SharingPtr<Y> &r);
- void swap(SharingPtr& r);
- void reset();
- template<class Y> void reset(Y* p);
- void reset(std::nullptr_t);
+ void swap(SharingPtr &r);
+ void reset();
+ template <class Y> void reset(Y *p);
+ void reset(std::nullptr_t);
- element_type* get() const {return ptr_;}
- element_type& operator*() const {return *ptr_;}
- element_type* operator->() const {return ptr_;}
- long use_count() const {return cntrl_ ? cntrl_->use_count() : 0;}
- bool unique() const {return use_count() == 1;}
- bool empty() const {return cntrl_ == nullptr;}
- operator nat*() const {return (nat*)get();}
+ element_type *get() const { return ptr_; }
+ element_type &operator*() const { return *ptr_; }
+ element_type *operator->() const { return ptr_; }
+ long use_count() const { return cntrl_ ? cntrl_->use_count() : 0; }
+ bool unique() const { return use_count() == 1; }
+ bool empty() const { return cntrl_ == nullptr; }
+ operator nat *() const { return (nat *)get(); }
- static SharingPtr<T> make_shared();
+ static SharingPtr<T> make_shared();
- template<class A0>
- static SharingPtr<T> make_shared(A0&);
+ template <class A0> static SharingPtr<T> make_shared(A0 &);
- template<class A0, class A1>
- static SharingPtr<T> make_shared(A0&, A1&);
+ template <class A0, class A1> static SharingPtr<T> make_shared(A0 &, A1 &);
- template<class A0, class A1, class A2>
- static SharingPtr<T> make_shared(A0&, A1&, A2&);
+ template <class A0, class A1, class A2>
+ static SharingPtr<T> make_shared(A0 &, A1 &, A2 &);
- template<class A0, class A1, class A2, class A3>
- static SharingPtr<T> make_shared(A0&, A1&, A2&, A3&);
+ template <class A0, class A1, class A2, class A3>
+ static SharingPtr<T> make_shared(A0 &, A1 &, A2 &, A3 &);
- template<class A0, class A1, class A2, class A3, class A4>
- static SharingPtr<T> make_shared(A0&, A1&, A2&, A3&, A4&);
+ template <class A0, class A1, class A2, class A3, class A4>
+ static SharingPtr<T> make_shared(A0 &, A1 &, A2 &, A3 &, A4 &);
private:
- template <class U> friend class SharingPtr;
+ template <class U> friend class SharingPtr;
};
-template<class T>
-inline
-SharingPtr<T>::SharingPtr()
- : ptr_(nullptr),
- cntrl_(nullptr)
-{
-}
-
-template<class T>
-inline
-SharingPtr<T>::SharingPtr(std::nullptr_t)
-: ptr_(nullptr),
-cntrl_(nullptr)
-{
-}
-
-template<class T>
-template<class Y>
-SharingPtr<T>::SharingPtr(Y* p)
- : ptr_(p), cntrl_(nullptr)
-{
- std::unique_ptr<Y> hold(p);
- typedef imp::shared_ptr_pointer<Y*> _CntrlBlk;
- cntrl_ = new _CntrlBlk(p);
- hold.release();
-}
-
-template<class T>
-template<class Y>
-SharingPtr<T>::SharingPtr(Y* p, imp::shared_count *cntrl_block)
- : ptr_(p), cntrl_(cntrl_block)
-{
-}
-
-template<class T>
-template<class Y>
-inline
-SharingPtr<T>::SharingPtr(const SharingPtr<Y>& r, element_type *p)
- : ptr_(p),
- cntrl_(r.cntrl_)
-{
- if (cntrl_)
- cntrl_->add_shared();
-}
-
-template<class T>
-inline
-SharingPtr<T>::SharingPtr(const SharingPtr& r)
- : ptr_(r.ptr_),
- cntrl_(r.cntrl_)
-{
- if (cntrl_)
- cntrl_->add_shared();
-}
-
-template<class T>
-template<class Y>
-inline
-SharingPtr<T>::SharingPtr(const SharingPtr<Y>& r)
- : ptr_(r.ptr_),
- cntrl_(r.cntrl_)
-{
- if (cntrl_)
- cntrl_->add_shared();
-}
-
-template<class T>
-SharingPtr<T>::~SharingPtr()
-{
- if (cntrl_)
- cntrl_->release_shared();
-}
-
-template<class T>
-inline
-SharingPtr<T>&
-SharingPtr<T>::operator=(const SharingPtr& r)
-{
- SharingPtr(r).swap(*this);
- return *this;
+template <class T>
+inline SharingPtr<T>::SharingPtr() : ptr_(nullptr), cntrl_(nullptr) {}
+
+template <class T>
+inline SharingPtr<T>::SharingPtr(std::nullptr_t)
+ : ptr_(nullptr), cntrl_(nullptr) {}
+
+template <class T>
+template <class Y>
+SharingPtr<T>::SharingPtr(Y *p) : ptr_(p), cntrl_(nullptr) {
+ std::unique_ptr<Y> hold(p);
+ typedef imp::shared_ptr_pointer<Y *> _CntrlBlk;
+ cntrl_ = new _CntrlBlk(p);
+ hold.release();
}
-template<class T>
-template<class Y>
-inline
-SharingPtr<T>&
-SharingPtr<T>::operator=(const SharingPtr<Y>& r)
-{
- SharingPtr(r).swap(*this);
- return *this;
+template <class T>
+template <class Y>
+SharingPtr<T>::SharingPtr(Y *p, imp::shared_count *cntrl_block)
+ : ptr_(p), cntrl_(cntrl_block) {}
+
+template <class T>
+template <class Y>
+inline SharingPtr<T>::SharingPtr(const SharingPtr<Y> &r, element_type *p)
+ : ptr_(p), cntrl_(r.cntrl_) {
+ if (cntrl_)
+ cntrl_->add_shared();
+}
+
+template <class T>
+inline SharingPtr<T>::SharingPtr(const SharingPtr &r)
+ : ptr_(r.ptr_), cntrl_(r.cntrl_) {
+ if (cntrl_)
+ cntrl_->add_shared();
+}
+
+template <class T>
+template <class Y>
+inline SharingPtr<T>::SharingPtr(const SharingPtr<Y> &r)
+ : ptr_(r.ptr_), cntrl_(r.cntrl_) {
+ if (cntrl_)
+ cntrl_->add_shared();
}
-template<class T>
-inline
-void
-SharingPtr<T>::swap(SharingPtr& r)
-{
- std::swap(ptr_, r.ptr_);
- std::swap(cntrl_, r.cntrl_);
-}
-
-template<class T>
-inline
-void
-SharingPtr<T>::reset()
-{
- SharingPtr().swap(*this);
-}
-
-template<class T>
-inline
-void
-SharingPtr<T>::reset (std::nullptr_t p)
-{
- reset();
-}
-
-template<class T>
-template<class Y>
-inline
-void
-SharingPtr<T>::reset(Y* p)
-{
- SharingPtr(p).swap(*this);
-}
-
-template<class T>
-SharingPtr<T>
-SharingPtr<T>::make_shared()
-{
- typedef imp::shared_ptr_emplace<T> CntrlBlk;
- SharingPtr<T> r;
- r.cntrl_ = new CntrlBlk();
- r.ptr_ = static_cast<CntrlBlk*>(r.cntrl_)->get();
- return r;
-}
-
-template<class T>
-template<class A0>
-SharingPtr<T>
-SharingPtr<T>::make_shared(A0& a0)
-{
- typedef imp::shared_ptr_emplace<T> CntrlBlk;
- SharingPtr<T> r;
- r.cntrl_ = new CntrlBlk(a0);
- r.ptr_ = static_cast<CntrlBlk*>(r.cntrl_)->get();
- return r;
-}
-
-template<class T>
-template<class A0, class A1>
-SharingPtr<T>
-SharingPtr<T>::make_shared(A0& a0, A1& a1)
-{
- typedef imp::shared_ptr_emplace<T> CntrlBlk;
- SharingPtr<T> r;
- r.cntrl_ = new CntrlBlk(a0, a1);
- r.ptr_ = static_cast<CntrlBlk*>(r.cntrl_)->get();
- return r;
-}
-
-template<class T>
-template<class A0, class A1, class A2>
-SharingPtr<T>
-SharingPtr<T>::make_shared(A0& a0, A1& a1, A2& a2)
-{
- typedef imp::shared_ptr_emplace<T> CntrlBlk;
- SharingPtr<T> r;
- r.cntrl_ = new CntrlBlk(a0, a1, a2);
- r.ptr_ = static_cast<CntrlBlk*>(r.cntrl_)->get();
- return r;
-}
-
-template<class T>
-template<class A0, class A1, class A2, class A3>
-SharingPtr<T>
-SharingPtr<T>::make_shared(A0& a0, A1& a1, A2& a2, A3& a3)
-{
- typedef imp::shared_ptr_emplace<T> CntrlBlk;
- SharingPtr<T> r;
- r.cntrl_ = new CntrlBlk(a0, a1, a2, a3);
- r.ptr_ = static_cast<CntrlBlk*>(r.cntrl_)->get();
- return r;
-}
-
-template<class T>
-template<class A0, class A1, class A2, class A3, class A4>
-SharingPtr<T>
-SharingPtr<T>::make_shared(A0& a0, A1& a1, A2& a2, A3& a3, A4& a4)
-{
- typedef imp::shared_ptr_emplace<T> CntrlBlk;
- SharingPtr<T> r;
- r.cntrl_ = new CntrlBlk(a0, a1, a2, a3, a4);
- r.ptr_ = static_cast<CntrlBlk*>(r.cntrl_)->get();
- return r;
-}
-
-template<class T>
-inline
-SharingPtr<T>
-make_shared()
-{
- return SharingPtr<T>::make_shared();
-}
-
-template<class T, class A0>
-inline
-SharingPtr<T>
-make_shared(A0& a0)
-{
- return SharingPtr<T>::make_shared(a0);
-}
-
-template<class T, class A0, class A1>
-inline
-SharingPtr<T>
-make_shared(A0& a0, A1& a1)
-{
- return SharingPtr<T>::make_shared(a0, a1);
-}
-
-template<class T, class A0, class A1, class A2>
-inline
-SharingPtr<T>
-make_shared(A0& a0, A1& a1, A2& a2)
-{
- return SharingPtr<T>::make_shared(a0, a1, a2);
-}
-
-template<class T, class A0, class A1, class A2, class A3>
-inline
-SharingPtr<T>
-make_shared(A0& a0, A1& a1, A2& a2, A3& a3)
-{
- return SharingPtr<T>::make_shared(a0, a1, a2, a3);
-}
-
-template<class T, class A0, class A1, class A2, class A3, class A4>
-inline
-SharingPtr<T>
-make_shared(A0& a0, A1& a1, A2& a2, A3& a3, A4& a4)
-{
- return SharingPtr<T>::make_shared(a0, a1, a2, a3, a4);
-}
-
-template<class T, class U>
-inline
-bool
-operator==(const SharingPtr<T>& __x, const SharingPtr<U>& __y)
-{
- return __x.get() == __y.get();
-}
-
-template<class T, class U>
-inline
-bool
-operator!=(const SharingPtr<T>& __x, const SharingPtr<U>& __y)
-{
- return !(__x == __y);
-}
-
-template<class T, class U>
-inline
-bool
-operator<(const SharingPtr<T>& __x, const SharingPtr<U>& __y)
-{
- return __x.get() < __y.get();
-}
-
-template<class T>
-inline
-void
-swap(SharingPtr<T>& __x, SharingPtr<T>& __y)
-{
- __x.swap(__y);
-}
-
-template<class T, class U>
-inline
-SharingPtr<T>
-static_pointer_cast(const SharingPtr<U>& r)
-{
- return SharingPtr<T>(r, static_cast<T*>(r.get()));
+template <class T> SharingPtr<T>::~SharingPtr() {
+ if (cntrl_)
+ cntrl_->release_shared();
}
-template<class T, class U>
-SharingPtr<T>
-const_pointer_cast(const SharingPtr<U>& r)
-{
- return SharingPtr<T>(r, const_cast<T*>(r.get()));
+template <class T>
+inline SharingPtr<T> &SharingPtr<T>::operator=(const SharingPtr &r) {
+ SharingPtr(r).swap(*this);
+ return *this;
}
template <class T>
-class LoggingSharingPtr
- : public SharingPtr<T>
-{
- typedef SharingPtr<T> base;
+template <class Y>
+inline SharingPtr<T> &SharingPtr<T>::operator=(const SharingPtr<Y> &r) {
+ SharingPtr(r).swap(*this);
+ return *this;
+}
-public:
- typedef void (*Callback)(void*, const LoggingSharingPtr&, bool action);
- // action: false means increment just happened
- // true means decrement is about to happen
+template <class T> inline void SharingPtr<T>::swap(SharingPtr &r) {
+ std::swap(ptr_, r.ptr_);
+ std::swap(cntrl_, r.cntrl_);
+}
- LoggingSharingPtr() : cb_(0), baton_(nullptr) {}
+template <class T> inline void SharingPtr<T>::reset() {
+ SharingPtr().swap(*this);
+}
- LoggingSharingPtr(Callback cb, void* baton)
- : cb_(cb), baton_(baton)
- {
- if (cb_)
- cb_(baton_, *this, false);
- }
+template <class T> inline void SharingPtr<T>::reset(std::nullptr_t p) {
+ reset();
+}
- template <class Y>
- LoggingSharingPtr(Y* p)
- : base(p), cb_(0), baton_(nullptr) {}
+template <class T> template <class Y> inline void SharingPtr<T>::reset(Y *p) {
+ SharingPtr(p).swap(*this);
+}
- template <class Y>
- LoggingSharingPtr(Y* p, Callback cb, void* baton)
- : base(p), cb_(cb), baton_(baton)
- {
- if (cb_)
- cb_(baton_, *this, false);
- }
+template <class T> SharingPtr<T> SharingPtr<T>::make_shared() {
+ typedef imp::shared_ptr_emplace<T> CntrlBlk;
+ SharingPtr<T> r;
+ r.cntrl_ = new CntrlBlk();
+ r.ptr_ = static_cast<CntrlBlk *>(r.cntrl_)->get();
+ return r;
+}
- ~LoggingSharingPtr()
- {
- if (cb_)
- cb_(baton_, *this, true);
- }
+template <class T>
+template <class A0>
+SharingPtr<T> SharingPtr<T>::make_shared(A0 &a0) {
+ typedef imp::shared_ptr_emplace<T> CntrlBlk;
+ SharingPtr<T> r;
+ r.cntrl_ = new CntrlBlk(a0);
+ r.ptr_ = static_cast<CntrlBlk *>(r.cntrl_)->get();
+ return r;
+}
- LoggingSharingPtr(const LoggingSharingPtr& p)
- : base(p), cb_(p.cb_), baton_(p.baton_)
- {
- if (cb_)
- cb_(baton_, *this, false);
- }
+template <class T>
+template <class A0, class A1>
+SharingPtr<T> SharingPtr<T>::make_shared(A0 &a0, A1 &a1) {
+ typedef imp::shared_ptr_emplace<T> CntrlBlk;
+ SharingPtr<T> r;
+ r.cntrl_ = new CntrlBlk(a0, a1);
+ r.ptr_ = static_cast<CntrlBlk *>(r.cntrl_)->get();
+ return r;
+}
- LoggingSharingPtr& operator=(const LoggingSharingPtr& p)
- {
- if (cb_)
- cb_(baton_, *this, true);
- base::operator=(p);
- cb_ = p.cb_;
- baton_ = p.baton_;
- if (cb_)
- cb_(baton_, *this, false);
- return *this;
- }
+template <class T>
+template <class A0, class A1, class A2>
+SharingPtr<T> SharingPtr<T>::make_shared(A0 &a0, A1 &a1, A2 &a2) {
+ typedef imp::shared_ptr_emplace<T> CntrlBlk;
+ SharingPtr<T> r;
+ r.cntrl_ = new CntrlBlk(a0, a1, a2);
+ r.ptr_ = static_cast<CntrlBlk *>(r.cntrl_)->get();
+ return r;
+}
- void reset()
- {
- if (cb_)
- cb_(baton_, *this, true);
- base::reset();
- }
+template <class T>
+template <class A0, class A1, class A2, class A3>
+SharingPtr<T> SharingPtr<T>::make_shared(A0 &a0, A1 &a1, A2 &a2, A3 &a3) {
+ typedef imp::shared_ptr_emplace<T> CntrlBlk;
+ SharingPtr<T> r;
+ r.cntrl_ = new CntrlBlk(a0, a1, a2, a3);
+ r.ptr_ = static_cast<CntrlBlk *>(r.cntrl_)->get();
+ return r;
+}
- template <class Y>
- void reset(Y* p)
- {
- if (cb_)
- cb_(baton_, *this, true);
- base::reset(p);
- if (cb_)
- cb_(baton_, *this, false);
- }
-
- void SetCallback(Callback cb, void* baton)
- {
- cb_ = cb;
- baton_ = baton;
- }
+template <class T>
+template <class A0, class A1, class A2, class A3, class A4>
+SharingPtr<T> SharingPtr<T>::make_shared(A0 &a0, A1 &a1, A2 &a2, A3 &a3,
+ A4 &a4) {
+ typedef imp::shared_ptr_emplace<T> CntrlBlk;
+ SharingPtr<T> r;
+ r.cntrl_ = new CntrlBlk(a0, a1, a2, a3, a4);
+ r.ptr_ = static_cast<CntrlBlk *>(r.cntrl_)->get();
+ return r;
+}
- void ClearCallback()
- {
- cb_ = 0;
- baton_ = 0;
- }
+template <class T> inline SharingPtr<T> make_shared() {
+ return SharingPtr<T>::make_shared();
+}
+
+template <class T, class A0> inline SharingPtr<T> make_shared(A0 &a0) {
+ return SharingPtr<T>::make_shared(a0);
+}
+
+template <class T, class A0, class A1>
+inline SharingPtr<T> make_shared(A0 &a0, A1 &a1) {
+ return SharingPtr<T>::make_shared(a0, a1);
+}
+
+template <class T, class A0, class A1, class A2>
+inline SharingPtr<T> make_shared(A0 &a0, A1 &a1, A2 &a2) {
+ return SharingPtr<T>::make_shared(a0, a1, a2);
+}
+
+template <class T, class A0, class A1, class A2, class A3>
+inline SharingPtr<T> make_shared(A0 &a0, A1 &a1, A2 &a2, A3 &a3) {
+ return SharingPtr<T>::make_shared(a0, a1, a2, a3);
+}
+
+template <class T, class A0, class A1, class A2, class A3, class A4>
+inline SharingPtr<T> make_shared(A0 &a0, A1 &a1, A2 &a2, A3 &a3, A4 &a4) {
+ return SharingPtr<T>::make_shared(a0, a1, a2, a3, a4);
+}
+
+template <class T, class U>
+inline bool operator==(const SharingPtr<T> &__x, const SharingPtr<U> &__y) {
+ return __x.get() == __y.get();
+}
+
+template <class T, class U>
+inline bool operator!=(const SharingPtr<T> &__x, const SharingPtr<U> &__y) {
+ return !(__x == __y);
+}
+
+template <class T, class U>
+inline bool operator<(const SharingPtr<T> &__x, const SharingPtr<U> &__y) {
+ return __x.get() < __y.get();
+}
+
+template <class T> inline void swap(SharingPtr<T> &__x, SharingPtr<T> &__y) {
+ __x.swap(__y);
+}
+
+template <class T, class U>
+inline SharingPtr<T> static_pointer_cast(const SharingPtr<U> &r) {
+ return SharingPtr<T>(r, static_cast<T *>(r.get()));
+}
+
+template <class T, class U>
+SharingPtr<T> const_pointer_cast(const SharingPtr<U> &r) {
+ return SharingPtr<T>(r, const_cast<T *>(r.get()));
+}
+
+template <class T> class LoggingSharingPtr : public SharingPtr<T> {
+ typedef SharingPtr<T> base;
+
+public:
+ typedef void (*Callback)(void *, const LoggingSharingPtr &, bool action);
+ // action: false means increment just happened
+ // true means decrement is about to happen
+
+ LoggingSharingPtr() : cb_(0), baton_(nullptr) {}
+
+ LoggingSharingPtr(Callback cb, void *baton) : cb_(cb), baton_(baton) {
+ if (cb_)
+ cb_(baton_, *this, false);
+ }
+
+ template <class Y>
+ LoggingSharingPtr(Y *p) : base(p), cb_(0), baton_(nullptr) {}
+
+ template <class Y>
+ LoggingSharingPtr(Y *p, Callback cb, void *baton)
+ : base(p), cb_(cb), baton_(baton) {
+ if (cb_)
+ cb_(baton_, *this, false);
+ }
+
+ ~LoggingSharingPtr() {
+ if (cb_)
+ cb_(baton_, *this, true);
+ }
+
+ LoggingSharingPtr(const LoggingSharingPtr &p)
+ : base(p), cb_(p.cb_), baton_(p.baton_) {
+ if (cb_)
+ cb_(baton_, *this, false);
+ }
+
+ LoggingSharingPtr &operator=(const LoggingSharingPtr &p) {
+ if (cb_)
+ cb_(baton_, *this, true);
+ base::operator=(p);
+ cb_ = p.cb_;
+ baton_ = p.baton_;
+ if (cb_)
+ cb_(baton_, *this, false);
+ return *this;
+ }
+
+ void reset() {
+ if (cb_)
+ cb_(baton_, *this, true);
+ base::reset();
+ }
+
+ template <class Y> void reset(Y *p) {
+ if (cb_)
+ cb_(baton_, *this, true);
+ base::reset(p);
+ if (cb_)
+ cb_(baton_, *this, false);
+ }
+
+ void SetCallback(Callback cb, void *baton) {
+ cb_ = cb;
+ baton_ = baton;
+ }
+
+ void ClearCallback() {
+ cb_ = 0;
+ baton_ = 0;
+ }
private:
- Callback cb_;
- void* baton_;
+ Callback cb_;
+ void *baton_;
};
-template <class T>
-class IntrusiveSharingPtr;
+template <class T> class IntrusiveSharingPtr;
-template <class T>
-class ReferenceCountedBase
-{
+template <class T> class ReferenceCountedBase {
public:
- explicit ReferenceCountedBase()
- : shared_owners_(-1)
- {
- }
-
- void
- add_shared();
+ explicit ReferenceCountedBase() : shared_owners_(-1) {}
- void
- release_shared();
+ void add_shared();
+
+ void release_shared();
+
+ long use_count() const { return shared_owners_ + 1; }
- long
- use_count() const
- {
- return shared_owners_ + 1;
- }
-
protected:
- long shared_owners_;
-
- friend class IntrusiveSharingPtr<T>;
-
+ long shared_owners_;
+
+ friend class IntrusiveSharingPtr<T>;
+
private:
- ReferenceCountedBase(const ReferenceCountedBase&);
- ReferenceCountedBase& operator=(const ReferenceCountedBase&);
+ ReferenceCountedBase(const ReferenceCountedBase &);
+ ReferenceCountedBase &operator=(const ReferenceCountedBase &);
};
- template <class T>
- void
- lldb_private::ReferenceCountedBase<T>::add_shared()
- {
+template <class T> void lldb_private::ReferenceCountedBase<T>::add_shared() {
#ifdef _MSC_VER
- _InterlockedIncrement(&shared_owners_);
+ _InterlockedIncrement(&shared_owners_);
#else
- ++shared_owners_;
+ ++shared_owners_;
#endif
- }
-
- template <class T>
- void
- lldb_private::ReferenceCountedBase<T>::release_shared()
- {
+}
+
+template <class T>
+void lldb_private::ReferenceCountedBase<T>::release_shared() {
#ifdef _MSC_VER
- if (_InterlockedDecrement(&shared_owners_) == -1)
+ if (_InterlockedDecrement(&shared_owners_) == -1)
#else
- if (--shared_owners_ == -1)
+ if (--shared_owners_ == -1)
#endif
- delete static_cast<T*>(this);
- }
+ delete static_cast<T *>(this);
+}
-
template <class T>
-class ReferenceCountedBaseVirtual : public imp::shared_count
-{
+class ReferenceCountedBaseVirtual : public imp::shared_count {
public:
- explicit ReferenceCountedBaseVirtual () :
- imp::shared_count(-1)
- {
- }
+ explicit ReferenceCountedBaseVirtual() : imp::shared_count(-1) {}
- ~ReferenceCountedBaseVirtual() override = default;
+ ~ReferenceCountedBaseVirtual() override = default;
- void on_zero_shared() override;
+ void on_zero_shared() override;
};
-template <class T>
-void
-ReferenceCountedBaseVirtual<T>::on_zero_shared()
-{
-}
+template <class T> void ReferenceCountedBaseVirtual<T>::on_zero_shared() {}
-template <typename T>
-class IntrusiveSharingPtr
-{
+template <typename T> class IntrusiveSharingPtr {
public:
- typedef T element_type;
-
- explicit
- IntrusiveSharingPtr () :
- ptr_(0)
- {
- }
-
- explicit
- IntrusiveSharingPtr (T* ptr) :
- ptr_(ptr)
- {
- add_shared();
- }
-
- IntrusiveSharingPtr (const IntrusiveSharingPtr& rhs) :
- ptr_(rhs.ptr_)
- {
- add_shared();
- }
-
- template <class X>
- IntrusiveSharingPtr (const IntrusiveSharingPtr<X>& rhs)
- : ptr_(rhs.get())
- {
- add_shared();
- }
-
- IntrusiveSharingPtr&
- operator= (const IntrusiveSharingPtr& rhs)
- {
- reset(rhs.get());
- return *this;
- }
-
- template <class X> IntrusiveSharingPtr&
- operator= (const IntrusiveSharingPtr<X>& rhs)
- {
- reset(rhs.get());
- return *this;
- }
-
- IntrusiveSharingPtr&
- operator= (T *ptr)
- {
- reset(ptr);
- return *this;
- }
-
- ~IntrusiveSharingPtr()
- {
- release_shared();
-#if defined (LLDB_CONFIGURATION_DEBUG) || defined (LLDB_CONFIGURATION_RELEASE)
- // NULL out the pointer in objects which can help with leaks detection.
- // We don't enable this for LLDB_CONFIGURATION_BUILD_AND_INTEGRATION or
- // when none of the LLDB_CONFIGURATION_XXX macros are defined since
- // those would be builds for release. But for debug and release builds
- // that are for development, we NULL out the pointers to catch potential
- // issues.
- ptr_ = nullptr;
-#endif // #if defined (LLDB_CONFIGURATION_DEBUG) || defined (LLDB_CONFIGURATION_RELEASE)
- }
-
- T&
- operator*() const
- {
- return *ptr_;
- }
-
- T*
- operator->() const
- {
- return ptr_;
- }
-
- T*
- get() const
- {
- return ptr_;
- }
-
- explicit operator bool() const
- {
- return ptr_ != 0;
- }
-
- void
- swap (IntrusiveSharingPtr& rhs)
- {
- std::swap(ptr_, rhs.ptr_);
-#if defined (ENABLE_SP_LOGGING)
- track_sp (this, ptr_, use_count());
- track_sp (&rhs, rhs.ptr_, rhs.use_count());
+ typedef T element_type;
+
+ explicit IntrusiveSharingPtr() : ptr_(0) {}
+
+ explicit IntrusiveSharingPtr(T *ptr) : ptr_(ptr) { add_shared(); }
+
+ IntrusiveSharingPtr(const IntrusiveSharingPtr &rhs) : ptr_(rhs.ptr_) {
+ add_shared();
+ }
+
+ template <class X>
+ IntrusiveSharingPtr(const IntrusiveSharingPtr<X> &rhs) : ptr_(rhs.get()) {
+ add_shared();
+ }
+
+ IntrusiveSharingPtr &operator=(const IntrusiveSharingPtr &rhs) {
+ reset(rhs.get());
+ return *this;
+ }
+
+ template <class X>
+ IntrusiveSharingPtr &operator=(const IntrusiveSharingPtr<X> &rhs) {
+ reset(rhs.get());
+ return *this;
+ }
+
+ IntrusiveSharingPtr &operator=(T *ptr) {
+ reset(ptr);
+ return *this;
+ }
+
+ ~IntrusiveSharingPtr() {
+ release_shared();
+#if defined(LLDB_CONFIGURATION_DEBUG) || defined(LLDB_CONFIGURATION_RELEASE)
+ // NULL out the pointer in objects which can help with leaks detection.
+ // We don't enable this for LLDB_CONFIGURATION_BUILD_AND_INTEGRATION or
+ // when none of the LLDB_CONFIGURATION_XXX macros are defined since
+ // those would be builds for release. But for debug and release builds
+ // that are for development, we NULL out the pointers to catch potential
+ // issues.
+ ptr_ = nullptr;
+#endif // #if defined (LLDB_CONFIGURATION_DEBUG) || defined
+ // (LLDB_CONFIGURATION_RELEASE)
+ }
+
+ T &operator*() const { return *ptr_; }
+
+ T *operator->() const { return ptr_; }
+
+ T *get() const { return ptr_; }
+
+ explicit operator bool() const { return ptr_ != 0; }
+
+ void swap(IntrusiveSharingPtr &rhs) {
+ std::swap(ptr_, rhs.ptr_);
+#if defined(ENABLE_SP_LOGGING)
+ track_sp(this, ptr_, use_count());
+ track_sp(&rhs, rhs.ptr_, rhs.use_count());
#endif
- }
+ }
- void
- reset(T* ptr = nullptr)
- {
- IntrusiveSharingPtr(ptr).swap(*this);
- }
+ void reset(T *ptr = nullptr) { IntrusiveSharingPtr(ptr).swap(*this); }
- long
- use_count () const
- {
- if (ptr_)
- return ptr_->use_count();
- return 0;
- }
-
- bool
- unique () const
- {
- return use_count () == 1;
- }
+ long use_count() const {
+ if (ptr_)
+ return ptr_->use_count();
+ return 0;
+ }
+
+ bool unique() const { return use_count() == 1; }
private:
- element_type *ptr_;
-
- void
- add_shared()
- {
- if (ptr_)
- {
- ptr_->add_shared();
-#if defined (ENABLE_SP_LOGGING)
- track_sp (this, ptr_, ptr_->use_count());
+ element_type *ptr_;
+
+ void add_shared() {
+ if (ptr_) {
+ ptr_->add_shared();
+#if defined(ENABLE_SP_LOGGING)
+ track_sp(this, ptr_, ptr_->use_count());
#endif
- }
}
- void
- release_shared()
- {
- if (ptr_)
- {
-#if defined (ENABLE_SP_LOGGING)
- track_sp (this, nullptr, ptr_->use_count() - 1);
+ }
+ void release_shared() {
+ if (ptr_) {
+#if defined(ENABLE_SP_LOGGING)
+ track_sp(this, nullptr, ptr_->use_count() - 1);
#endif
- ptr_->release_shared();
- }
+ ptr_->release_shared();
}
+ }
};
-template<class T, class U>
-inline bool operator== (const IntrusiveSharingPtr<T>& lhs, const IntrusiveSharingPtr<U>& rhs)
-{
- return lhs.get() == rhs.get();
+template <class T, class U>
+inline bool operator==(const IntrusiveSharingPtr<T> &lhs,
+ const IntrusiveSharingPtr<U> &rhs) {
+ return lhs.get() == rhs.get();
}
-template<class T, class U>
-inline bool operator!= (const IntrusiveSharingPtr<T>& lhs, const IntrusiveSharingPtr<U>& rhs)
-{
- return lhs.get() != rhs.get();
+template <class T, class U>
+inline bool operator!=(const IntrusiveSharingPtr<T> &lhs,
+ const IntrusiveSharingPtr<U> &rhs) {
+ return lhs.get() != rhs.get();
}
-template<class T, class U>
-inline bool operator== (const IntrusiveSharingPtr<T>& lhs, U* rhs)
-{
- return lhs.get() == rhs;
+template <class T, class U>
+inline bool operator==(const IntrusiveSharingPtr<T> &lhs, U *rhs) {
+ return lhs.get() == rhs;
}
-template<class T, class U>
-inline bool operator!= (const IntrusiveSharingPtr<T>& lhs, U* rhs)
-{
- return lhs.get() != rhs;
+template <class T, class U>
+inline bool operator!=(const IntrusiveSharingPtr<T> &lhs, U *rhs) {
+ return lhs.get() != rhs;
}
-template<class T, class U>
-inline bool operator== (T* lhs, const IntrusiveSharingPtr<U>& rhs)
-{
- return lhs == rhs.get();
+template <class T, class U>
+inline bool operator==(T *lhs, const IntrusiveSharingPtr<U> &rhs) {
+ return lhs == rhs.get();
}
-template<class T, class U>
-inline bool operator!= (T* lhs, const IntrusiveSharingPtr<U>& rhs)
-{
- return lhs != rhs.get();
+template <class T, class U>
+inline bool operator!=(T *lhs, const IntrusiveSharingPtr<U> &rhs) {
+ return lhs != rhs.get();
}
} // namespace lldb_private
diff --git a/include/lldb/Utility/StringExtractor.h b/include/lldb/Utility/StringExtractor.h
index db1b83b07694..624d1ef3edfd 100644
--- a/include/lldb/Utility/StringExtractor.h
+++ b/include/lldb/Utility/StringExtractor.h
@@ -12,168 +12,125 @@
// C Includes
// C++ Includes
-#include <string>
#include <stdint.h>
+#include <string>
// Other libraries and framework includes
// Project includes
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
-class StringExtractor
-{
+class StringExtractor {
public:
+ enum { BigEndian = 0, LittleEndian = 1 };
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ StringExtractor();
+ StringExtractor(llvm::StringRef packet_str);
+ StringExtractor(const char *packet_cstr);
+ StringExtractor(const StringExtractor &rhs);
+ virtual ~StringExtractor();
+
+ //------------------------------------------------------------------
+ // Operators
+ //------------------------------------------------------------------
+ const StringExtractor &operator=(const StringExtractor &rhs);
+
+ void Reset(llvm::StringRef str) {
+ m_packet = str;
+ m_index = 0;
+ }
+
+ // Returns true if the file position is still valid for the data
+ // contained in this string extractor object.
+ bool IsGood() const { return m_index != UINT64_MAX; }
+
+ uint64_t GetFilePos() const { return m_index; }
+
+ void SetFilePos(uint32_t idx) { m_index = idx; }
+
+ void Clear() {
+ m_packet.clear();
+ m_index = 0;
+ }
+
+ void SkipSpaces();
+
+ std::string &GetStringRef() { return m_packet; }
+
+ const std::string &GetStringRef() const { return m_packet; }
+
+ bool Empty() { return m_packet.empty(); }
+
+ size_t GetBytesLeft() {
+ if (m_index < m_packet.size())
+ return m_packet.size() - m_index;
+ return 0;
+ }
+
+ char GetChar(char fail_value = '\0');
+
+ char PeekChar(char fail_value = '\0') {
+ const char *cstr = Peek();
+ if (cstr)
+ return cstr[0];
+ return fail_value;
+ }
+
+ int DecodeHexU8();
+
+ uint8_t GetHexU8(uint8_t fail_value = 0, bool set_eof_on_fail = true);
+
+ bool GetHexU8Ex(uint8_t &ch, bool set_eof_on_fail = true);
+
+ bool GetNameColonValue(llvm::StringRef &name, llvm::StringRef &value);
+
+ int32_t GetS32(int32_t fail_value, int base = 0);
+
+ uint32_t GetU32(uint32_t fail_value, int base = 0);
+
+ int64_t GetS64(int64_t fail_value, int base = 0);
+
+ uint64_t GetU64(uint64_t fail_value, int base = 0);
+
+ uint32_t GetHexMaxU32(bool little_endian, uint32_t fail_value);
+
+ uint64_t GetHexMaxU64(bool little_endian, uint64_t fail_value);
+
+ size_t GetHexBytes(llvm::MutableArrayRef<uint8_t> dest,
+ uint8_t fail_fill_value);
+
+ size_t GetHexBytesAvail(llvm::MutableArrayRef<uint8_t> dest);
+
+ uint64_t GetHexWithFixedSize(uint32_t byte_size, bool little_endian,
+ uint64_t fail_value);
+
+ size_t GetHexByteString(std::string &str);
+
+ size_t GetHexByteStringFixedLength(std::string &str, uint32_t nibble_length);
+
+ size_t GetHexByteStringTerminatedBy(std::string &str, char terminator);
- enum {
- BigEndian = 0,
- LittleEndian = 1
- };
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- StringExtractor();
- StringExtractor(const char *packet_cstr);
- StringExtractor(const StringExtractor& rhs);
- virtual ~StringExtractor();
-
- //------------------------------------------------------------------
- // Operators
- //------------------------------------------------------------------
- const StringExtractor&
- operator=(const StringExtractor& rhs);
-
- // Returns true if the file position is still valid for the data
- // contained in this string extractor object.
- bool
- IsGood() const
- {
- return m_index != UINT64_MAX;
- }
-
- uint64_t
- GetFilePos () const
- {
- return m_index;
- }
-
- void
- SetFilePos (uint32_t idx)
- {
- m_index = idx;
- }
-
- void
- Clear ()
- {
- m_packet.clear();
- m_index = 0;
- }
-
- void
- SkipSpaces ();
-
- std::string &
- GetStringRef ()
- {
- return m_packet;
- }
-
- const std::string &
- GetStringRef () const
- {
- return m_packet;
- }
-
- bool
- Empty()
- {
- return m_packet.empty();
- }
-
- size_t
- GetBytesLeft ()
- {
- if (m_index < m_packet.size())
- return m_packet.size() - m_index;
- return 0;
- }
-
- char
- GetChar (char fail_value = '\0');
-
- char
- PeekChar (char fail_value = '\0')
- {
- const char *cstr = Peek();
- if (cstr)
- return cstr[0];
- return fail_value;
- }
-
- int
- DecodeHexU8();
-
- uint8_t
- GetHexU8 (uint8_t fail_value = 0, bool set_eof_on_fail = true);
-
- bool
- GetHexU8Ex (uint8_t& ch, bool set_eof_on_fail = true);
-
- bool
- GetNameColonValue (std::string &name, std::string &value);
-
- int32_t
- GetS32 (int32_t fail_value, int base = 0);
-
- uint32_t
- GetU32 (uint32_t fail_value, int base = 0);
-
- int64_t
- GetS64 (int64_t fail_value, int base = 0);
-
- uint64_t
- GetU64 (uint64_t fail_value, int base = 0);
-
- uint32_t
- GetHexMaxU32 (bool little_endian, uint32_t fail_value);
-
- uint64_t
- GetHexMaxU64 (bool little_endian, uint64_t fail_value);
-
- size_t
- GetHexBytes (void *dst, size_t dst_len, uint8_t fail_fill_value);
-
- size_t
- GetHexBytesAvail (void *dst, size_t dst_len);
-
- uint64_t
- GetHexWithFixedSize (uint32_t byte_size, bool little_endian, uint64_t fail_value);
-
- size_t
- GetHexByteString (std::string &str);
-
- size_t
- GetHexByteStringFixedLength (std::string &str, uint32_t nibble_length);
-
- size_t
- GetHexByteStringTerminatedBy (std::string &str,
- char terminator);
-
- const char *
- Peek ()
- {
- if (m_index < m_packet.size())
- return m_packet.c_str() + m_index;
- return nullptr;
- }
+ const char *Peek() {
+ if (m_index < m_packet.size())
+ return m_packet.c_str() + m_index;
+ return nullptr;
+ }
protected:
- //------------------------------------------------------------------
- // For StringExtractor only
- //------------------------------------------------------------------
- std::string m_packet; // The string in which to extract data.
- uint64_t m_index; // When extracting data from a packet, this index
- // will march along as things get extracted. If set
- // to UINT64_MAX the end of the packet data was
- // reached when decoding information
+ bool fail() {
+ m_index = UINT64_MAX;
+ return false;
+ }
+ //------------------------------------------------------------------
+ // For StringExtractor only
+ //------------------------------------------------------------------
+ std::string m_packet; // The string in which to extract data.
+ uint64_t m_index; // When extracting data from a packet, this index
+ // will march along as things get extracted. If set
+ // to UINT64_MAX the end of the packet data was
+ // reached when decoding information
};
-#endif // utility_StringExtractor_h_
+#endif // utility_StringExtractor_h_
diff --git a/include/lldb/Utility/StringLexer.h b/include/lldb/Utility/StringLexer.h
index ae6b393b0eb6..3a399dfd7812 100644
--- a/include/lldb/Utility/StringLexer.h
+++ b/include/lldb/Utility/StringLexer.h
@@ -1,4 +1,5 @@
-//===--------------------- StringLexer.h -------------------------*- C++ -*-===//
+//===--------------------- StringLexer.h -------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -15,57 +16,45 @@
#include <string>
namespace lldb_utility {
-
-class StringLexer
-{
+
+class StringLexer {
public:
- typedef std::string::size_type Position;
- typedef std::string::size_type Size;
-
- typedef std::string::value_type Character;
-
- StringLexer (std::string s);
-
- StringLexer (const StringLexer& rhs);
-
- // These APIs are not bounds-checked. Use HasAtLeast() if you're not sure.
- Character
- Peek ();
-
- bool
- NextIf (Character c);
-
- std::pair<bool, Character>
- NextIf (std::initializer_list<Character> cs);
-
- bool
- AdvanceIf (const std::string& token);
-
- Character
- Next ();
-
- bool
- HasAtLeast (Size s);
-
- bool
- HasAny (Character c);
-
- std::string
- GetUnlexed ();
-
- // This will assert if there are less than s characters preceding the cursor.
- void
- PutBack (Size s);
-
- StringLexer&
- operator = (const StringLexer& rhs);
-
+ typedef std::string::size_type Position;
+ typedef std::string::size_type Size;
+
+ typedef std::string::value_type Character;
+
+ StringLexer(std::string s);
+
+ StringLexer(const StringLexer &rhs);
+
+ // These APIs are not bounds-checked. Use HasAtLeast() if you're not sure.
+ Character Peek();
+
+ bool NextIf(Character c);
+
+ std::pair<bool, Character> NextIf(std::initializer_list<Character> cs);
+
+ bool AdvanceIf(const std::string &token);
+
+ Character Next();
+
+ bool HasAtLeast(Size s);
+
+ bool HasAny(Character c);
+
+ std::string GetUnlexed();
+
+ // This will assert if there are less than s characters preceding the cursor.
+ void PutBack(Size s);
+
+ StringLexer &operator=(const StringLexer &rhs);
+
private:
- std::string m_data;
- Position m_position;
-
- void
- Consume();
+ std::string m_data;
+ Position m_position;
+
+ void Consume();
};
} // namespace lldb_private
diff --git a/include/lldb/Utility/TaskPool.h b/include/lldb/Utility/TaskPool.h
index 443e2a5853e2..db15b208171b 100644
--- a/include/lldb/Utility/TaskPool.h
+++ b/include/lldb/Utility/TaskPool.h
@@ -23,7 +23,7 @@
// warnings in the Concurrency Runtime. This can be removed when we switch to
// MSVC 2015
#pragma warning(push)
-#pragma warning(disable:4062)
+#pragma warning(disable : 4062)
#endif
#include <cassert>
@@ -34,185 +34,174 @@
#include <thread>
#include <vector>
-// Global TaskPool class for running tasks in parallel on a set of worker thread created the first
-// time the task pool is used. The TaskPool provide no gurantee about the order the task will be run
-// and about what tasks will run in parrallel. None of the task added to the task pool should block
-// on something (mutex, future, condition variable) what will be set only by the completion of an
+// Global TaskPool class for running tasks in parallel on a set of worker thread
+// created the first
+// time the task pool is used. The TaskPool provide no guarantee about the order
+// the task will be run
+// and about what tasks will run in parallel. None of the task added to the task
+// pool should block
+// on something (mutex, future, condition variable) what will be set only by the
+// completion of an
// other task on the task pool as they may run on the same thread sequentally.
-class TaskPool
-{
+class TaskPool {
public:
- // Add a new task to the task pool and return a std::future belonging to the newly created task.
- // The caller of this function has to wait on the future for this task to complete.
- template<typename F, typename... Args>
- static std::future<typename std::result_of<F(Args...)>::type>
- AddTask(F&& f, Args&&... args);
-
- // Run all of the specified tasks on the task pool and wait until all of them are finished
- // before returning. This method is intended to be used for small number tasks where listing
- // them as function arguments is acceptable. For running large number of tasks you should use
- // AddTask for each task and then call wait() on each returned future.
- template<typename... T>
- static void
- RunTasks(T&&... tasks);
+ // Add a new task to the task pool and return a std::future belonging to the
+ // newly created task.
+ // The caller of this function has to wait on the future for this task to
+ // complete.
+ template <typename F, typename... Args>
+ static std::future<typename std::result_of<F(Args...)>::type>
+ AddTask(F &&f, Args &&... args);
+
+ // Run all of the specified tasks on the task pool and wait until all of them
+ // are finished
+ // before returning. This method is intended to be used for small number tasks
+ // where listing
+ // them as function arguments is acceptable. For running large number of tasks
+ // you should use
+ // AddTask for each task and then call wait() on each returned future.
+ template <typename... T> static void RunTasks(T &&... tasks);
private:
- TaskPool() = delete;
+ TaskPool() = delete;
- template<typename... T>
- struct RunTaskImpl;
+ template <typename... T> struct RunTaskImpl;
- static void
- AddTaskImpl(std::function<void()>&& task_fn);
+ static void AddTaskImpl(std::function<void()> &&task_fn);
};
-// Wrapper class around the global TaskPool implementation to make it possible to create a set of
-// tasks and then wait for the tasks to be completed by the WaitForNextCompletedTask call. This
-// class should be used when WaitForNextCompletedTask is needed because this class add no other
-// extra functionality to the TaskPool class and it have a very minor performance overhead.
-template <typename T> // The return type of the tasks what will be added to this task runner
-class TaskRunner
-{
+// Wrapper class around the global TaskPool implementation to make it possible
+// to create a set of
+// tasks and then wait for the tasks to be completed by the
+// WaitForNextCompletedTask call. This
+// class should be used when WaitForNextCompletedTask is needed because this
+// class add no other
+// extra functionality to the TaskPool class and it have a very minor
+// performance overhead.
+template <typename T> // The return type of the tasks what will be added to this
+ // task runner
+ class TaskRunner {
public:
- // Add a task to the task runner what will also add the task to the global TaskPool. The
- // function doesn't return the std::future for the task because it will be supplied by the
- // WaitForNextCompletedTask after the task is completed.
- template<typename F, typename... Args>
- void
- AddTask(F&& f, Args&&... args);
-
- // Wait for the next task in this task runner to finish and then return the std::future what
- // belongs to the finished task. If there is no task in this task runner (neither pending nor
- // comleted) then this function will return an invalid future. Usually this function should be
- // called in a loop processing the results of the tasks until it returns an invalid std::future
- // what means that all task in this task runner is completed.
- std::future<T>
- WaitForNextCompletedTask();
-
- // Convenience method to wait for all task in this TaskRunner to finish. Do NOT use this class
- // just because of this method. Use TaskPool instead and wait for each std::future returned by
- // AddTask in a loop.
- void
- WaitForAllTasks();
+ // Add a task to the task runner what will also add the task to the global
+ // TaskPool. The
+ // function doesn't return the std::future for the task because it will be
+ // supplied by the
+ // WaitForNextCompletedTask after the task is completed.
+ template <typename F, typename... Args> void AddTask(F &&f, Args &&... args);
+
+ // Wait for the next task in this task runner to finish and then return the
+ // std::future what
+ // belongs to the finished task. If there is no task in this task runner
+ // (neither pending nor
+ // comleted) then this function will return an invalid future. Usually this
+ // function should be
+ // called in a loop processing the results of the tasks until it returns an
+ // invalid std::future
+ // what means that all task in this task runner is completed.
+ std::future<T> WaitForNextCompletedTask();
+
+ // Convenience method to wait for all task in this TaskRunner to finish. Do
+ // NOT use this class
+ // just because of this method. Use TaskPool instead and wait for each
+ // std::future returned by
+ // AddTask in a loop.
+ void WaitForAllTasks();
private:
- std::list<std::future<T>> m_ready;
- std::list<std::future<T>> m_pending;
- std::mutex m_mutex;
- std::condition_variable m_cv;
+ std::list<std::future<T>> m_ready;
+ std::list<std::future<T>> m_pending;
+ std::mutex m_mutex;
+ std::condition_variable m_cv;
};
-template<typename F, typename... Args>
+template <typename F, typename... Args>
std::future<typename std::result_of<F(Args...)>::type>
-TaskPool::AddTask(F&& f, Args&&... args)
-{
- auto task_sp = std::make_shared<std::packaged_task<typename std::result_of<F(Args...)>::type()>>(
- std::bind(std::forward<F>(f), std::forward<Args>(args)...));
+TaskPool::AddTask(F &&f, Args &&... args) {
+ auto task_sp = std::make_shared<
+ std::packaged_task<typename std::result_of<F(Args...)>::type()>>(
+ std::bind(std::forward<F>(f), std::forward<Args>(args)...));
- AddTaskImpl([task_sp]() { (*task_sp)(); });
+ AddTaskImpl([task_sp]() { (*task_sp)(); });
- return task_sp->get_future();
+ return task_sp->get_future();
}
-template<typename... T>
-void
-TaskPool::RunTasks(T&&... tasks)
-{
- RunTaskImpl<T...>::Run(std::forward<T>(tasks)...);
+template <typename... T> void TaskPool::RunTasks(T &&... tasks) {
+ RunTaskImpl<T...>::Run(std::forward<T>(tasks)...);
}
-template<typename Head, typename... Tail>
-struct TaskPool::RunTaskImpl<Head, Tail...>
-{
- static void
- Run(Head&& h, Tail&&... t)
- {
- auto f = AddTask(std::forward<Head>(h));
- RunTaskImpl<Tail...>::Run(std::forward<Tail>(t)...);
- f.wait();
- }
+template <typename Head, typename... Tail>
+struct TaskPool::RunTaskImpl<Head, Tail...> {
+ static void Run(Head &&h, Tail &&... t) {
+ auto f = AddTask(std::forward<Head>(h));
+ RunTaskImpl<Tail...>::Run(std::forward<Tail>(t)...);
+ f.wait();
+ }
};
-template<>
-struct TaskPool::RunTaskImpl<>
-{
- static void
- Run() {}
+template <> struct TaskPool::RunTaskImpl<> {
+ static void Run() {}
};
template <typename T>
-template<typename F, typename... Args>
-void
-TaskRunner<T>::AddTask(F&& f, Args&&... args)
-{
- std::unique_lock<std::mutex> lock(m_mutex);
- auto it = m_pending.emplace(m_pending.end());
- *it = std::move(TaskPool::AddTask(
- [this, it](F f, Args... args)
- {
- T&& r = f(std::forward<Args>(args)...);
-
- std::unique_lock<std::mutex> lock(this->m_mutex);
- this->m_ready.splice(this->m_ready.end(), this->m_pending, it);
- lock.unlock();
-
- this->m_cv.notify_one();
- return r;
- },
- std::forward<F>(f),
- std::forward<Args>(args)...));
+template <typename F, typename... Args>
+void TaskRunner<T>::AddTask(F &&f, Args &&... args) {
+ std::unique_lock<std::mutex> lock(m_mutex);
+ auto it = m_pending.emplace(m_pending.end());
+ *it = std::move(TaskPool::AddTask(
+ [this, it](F f, Args... args) {
+ T &&r = f(std::forward<Args>(args)...);
+
+ std::unique_lock<std::mutex> lock(this->m_mutex);
+ this->m_ready.splice(this->m_ready.end(), this->m_pending, it);
+ lock.unlock();
+
+ this->m_cv.notify_one();
+ return r;
+ },
+ std::forward<F>(f), std::forward<Args>(args)...));
}
template <>
-template<typename F, typename... Args>
-void
-TaskRunner<void>::AddTask(F&& f, Args&&... args)
-{
- std::unique_lock<std::mutex> lock(m_mutex);
- auto it = m_pending.emplace(m_pending.end());
- *it = std::move(TaskPool::AddTask(
- [this, it](F f, Args... args)
- {
- f(std::forward<Args>(args)...);
-
- std::unique_lock<std::mutex> lock(this->m_mutex);
- this->m_ready.emplace_back(std::move(*it));
- this->m_pending.erase(it);
- lock.unlock();
-
- this->m_cv.notify_one();
- },
- std::forward<F>(f),
- std::forward<Args>(args)...));
+template <typename F, typename... Args>
+void TaskRunner<void>::AddTask(F &&f, Args &&... args) {
+ std::unique_lock<std::mutex> lock(m_mutex);
+ auto it = m_pending.emplace(m_pending.end());
+ *it = std::move(TaskPool::AddTask(
+ [this, it](F f, Args... args) {
+ f(std::forward<Args>(args)...);
+
+ std::unique_lock<std::mutex> lock(this->m_mutex);
+ this->m_ready.emplace_back(std::move(*it));
+ this->m_pending.erase(it);
+ lock.unlock();
+
+ this->m_cv.notify_one();
+ },
+ std::forward<F>(f), std::forward<Args>(args)...));
}
-template <typename T>
-std::future<T>
-TaskRunner<T>::WaitForNextCompletedTask()
-{
- std::unique_lock<std::mutex> lock(m_mutex);
- if (m_ready.empty() && m_pending.empty())
- return std::future<T>(); // No more tasks
-
- if (m_ready.empty())
- m_cv.wait(lock, [this](){ return !this->m_ready.empty(); });
-
- std::future<T> res = std::move(m_ready.front());
- m_ready.pop_front();
-
- lock.unlock();
- res.wait();
-
- return std::move(res);
-}
+template <typename T> std::future<T> TaskRunner<T>::WaitForNextCompletedTask() {
+ std::unique_lock<std::mutex> lock(m_mutex);
+ if (m_ready.empty() && m_pending.empty())
+ return std::future<T>(); // No more tasks
-template <typename T>
-void
-TaskRunner<T>::WaitForAllTasks()
-{
- while (WaitForNextCompletedTask().valid());
+ if (m_ready.empty())
+ m_cv.wait(lock, [this]() { return !this->m_ready.empty(); });
+
+ std::future<T> res = std::move(m_ready.front());
+ m_ready.pop_front();
+
+ lock.unlock();
+ res.wait();
+
+ return std::move(res);
}
+template <typename T> void TaskRunner<T>::WaitForAllTasks() {
+ while (WaitForNextCompletedTask().valid())
+ ;
+}
#if defined(_MSC_VER)
#pragma warning(pop)
diff --git a/include/lldb/Utility/Timeout.h b/include/lldb/Utility/Timeout.h
new file mode 100644
index 000000000000..6c6fd009acb0
--- /dev/null
+++ b/include/lldb/Utility/Timeout.h
@@ -0,0 +1,55 @@
+//===-- Timeout.h -----------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_Timeout_h_
+#define liblldb_Timeout_h_
+
+#include "llvm/ADT/Optional.h"
+#include <chrono>
+
+namespace lldb_private {
+
+// A general purpose class for representing timeouts for various APIs. It's
+// basically an llvm::Optional<std::chrono::duration<int64_t, Ratio>>, but we
+// customize it a bit to enable the standard chrono implicit conversions (e.g.
+// from Timeout<std::milli> to Timeout<std::micro>.
+//
+// The intended meaning of the values is:
+// - llvm::None - no timeout, the call should wait forever
+// - 0 - poll, only complete the call if it will not block
+// - >0 - wait for a given number of units for the result
+template <typename Ratio>
+class Timeout : public llvm::Optional<std::chrono::duration<int64_t, Ratio>> {
+private:
+ template <typename Ratio2> using Dur = std::chrono::duration<int64_t, Ratio2>;
+ template <typename Rep2, typename Ratio2>
+ using EnableIf = std::enable_if<
+ std::is_convertible<std::chrono::duration<Rep2, Ratio2>,
+ std::chrono::duration<int64_t, Ratio>>::value>;
+
+ using Base = llvm::Optional<Dur<Ratio>>;
+
+public:
+ Timeout(llvm::NoneType none) : Base(none) {}
+ Timeout(const Timeout &other) = default;
+
+ template <typename Ratio2,
+ typename = typename EnableIf<int64_t, Ratio2>::type>
+ Timeout(const Timeout<Ratio2> &other)
+ : Base(other ? Base(Dur<Ratio>(*other)) : llvm::None) {}
+
+ template <typename Rep2, typename Ratio2,
+ typename = typename EnableIf<Rep2, Ratio2>::type>
+ Timeout(const std::chrono::duration<Rep2, Ratio2> &other)
+ : Base(Dur<Ratio>(other)) {}
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_Timeout_h_
diff --git a/include/lldb/lldb-defines.h b/include/lldb/lldb-defines.h
index 175cecd7e322..a1318f4412e9 100644
--- a/include/lldb/lldb-defines.h
+++ b/include/lldb/lldb-defines.h
@@ -12,28 +12,28 @@
#include "lldb/lldb-types.h"
-#if defined (_MSC_VER)
- #if defined(EXPORT_LIBLLDB)
- #define LLDB_API __declspec(dllexport)
- #elif defined(IMPORT_LIBLLDB)
- #define LLDB_API __declspec(dllimport)
- #else
- #define LLDB_API
- #endif
+#if defined(_MSC_VER)
+#if defined(EXPORT_LIBLLDB)
+#define LLDB_API __declspec(dllexport)
+#elif defined(IMPORT_LIBLLDB)
+#define LLDB_API __declspec(dllimport)
+#else
+#define LLDB_API
+#endif
#else // defined (_MSC_VER)
- #define LLDB_API
+#define LLDB_API
#endif
#if !defined(INT32_MAX)
- #define INT32_MAX 2147483647
+#define INT32_MAX 2147483647
#endif
#if !defined(UINT32_MAX)
- #define UINT32_MAX 4294967295U
+#define UINT32_MAX 4294967295U
#endif
#if !defined(UINT64_MAX)
- #define UINT64_MAX 18446744073709551615ULL
+#define UINT64_MAX 18446744073709551615ULL
#endif
//----------------------------------------------------------------------
@@ -48,92 +48,102 @@
//----------------------------------------------------------------------
// LLDB defines
//----------------------------------------------------------------------
-#define LLDB_GENERIC_ERROR UINT32_MAX
+#define LLDB_GENERIC_ERROR UINT32_MAX
//----------------------------------------------------------------------
// Breakpoints
//----------------------------------------------------------------------
-#define LLDB_INVALID_BREAK_ID 0
-#define LLDB_DEFAULT_BREAK_SIZE 0
-#define LLDB_BREAK_ID_IS_VALID(bid) ((bid) != (LLDB_INVALID_BREAK_ID))
-#define LLDB_BREAK_ID_IS_INTERNAL(bid) ((bid) < 0)
+#define LLDB_INVALID_BREAK_ID 0
+#define LLDB_DEFAULT_BREAK_SIZE 0
+#define LLDB_BREAK_ID_IS_VALID(bid) ((bid) != (LLDB_INVALID_BREAK_ID))
+#define LLDB_BREAK_ID_IS_INTERNAL(bid) ((bid) < 0)
//----------------------------------------------------------------------
// Watchpoints
//----------------------------------------------------------------------
-#define LLDB_INVALID_WATCH_ID 0
-#define LLDB_WATCH_ID_IS_VALID(uid) ((uid) != (LLDB_INVALID_WATCH_ID))
-#define LLDB_WATCH_TYPE_READ (1u << 0)
-#define LLDB_WATCH_TYPE_WRITE (1u << 1)
-#define LLDB_WATCH_TYPE_IS_VALID(type) ((type | LLDB_WATCH_TYPE_READ) || (type | LLDB_WATCH_TYPE_WRITE))
+#define LLDB_INVALID_WATCH_ID 0
+#define LLDB_WATCH_ID_IS_VALID(uid) ((uid) != (LLDB_INVALID_WATCH_ID))
+#define LLDB_WATCH_TYPE_READ (1u << 0)
+#define LLDB_WATCH_TYPE_WRITE (1u << 1)
+#define LLDB_WATCH_TYPE_IS_VALID(type) \
+ ((type | LLDB_WATCH_TYPE_READ) || (type | LLDB_WATCH_TYPE_WRITE))
//----------------------------------------------------------------------
// Generic Register Numbers
//----------------------------------------------------------------------
-#define LLDB_REGNUM_GENERIC_PC 0 // Program Counter
-#define LLDB_REGNUM_GENERIC_SP 1 // Stack Pointer
-#define LLDB_REGNUM_GENERIC_FP 2 // Frame Pointer
-#define LLDB_REGNUM_GENERIC_RA 3 // Return Address
-#define LLDB_REGNUM_GENERIC_FLAGS 4 // Processor flags register
-#define LLDB_REGNUM_GENERIC_ARG1 5 // The register that would contain pointer size or less argument 1 (if any)
-#define LLDB_REGNUM_GENERIC_ARG2 6 // The register that would contain pointer size or less argument 2 (if any)
-#define LLDB_REGNUM_GENERIC_ARG3 7 // The register that would contain pointer size or less argument 3 (if any)
-#define LLDB_REGNUM_GENERIC_ARG4 8 // The register that would contain pointer size or less argument 4 (if any)
-#define LLDB_REGNUM_GENERIC_ARG5 9 // The register that would contain pointer size or less argument 5 (if any)
-#define LLDB_REGNUM_GENERIC_ARG6 10 // The register that would contain pointer size or less argument 6 (if any)
-#define LLDB_REGNUM_GENERIC_ARG7 11 // The register that would contain pointer size or less argument 7 (if any)
-#define LLDB_REGNUM_GENERIC_ARG8 12 // The register that would contain pointer size or less argument 8 (if any)
+#define LLDB_REGNUM_GENERIC_PC 0 // Program Counter
+#define LLDB_REGNUM_GENERIC_SP 1 // Stack Pointer
+#define LLDB_REGNUM_GENERIC_FP 2 // Frame Pointer
+#define LLDB_REGNUM_GENERIC_RA 3 // Return Address
+#define LLDB_REGNUM_GENERIC_FLAGS 4 // Processor flags register
+#define LLDB_REGNUM_GENERIC_ARG1 \
+ 5 // The register that would contain pointer size or less argument 1 (if any)
+#define LLDB_REGNUM_GENERIC_ARG2 \
+ 6 // The register that would contain pointer size or less argument 2 (if any)
+#define LLDB_REGNUM_GENERIC_ARG3 \
+ 7 // The register that would contain pointer size or less argument 3 (if any)
+#define LLDB_REGNUM_GENERIC_ARG4 \
+ 8 // The register that would contain pointer size or less argument 4 (if any)
+#define LLDB_REGNUM_GENERIC_ARG5 \
+ 9 // The register that would contain pointer size or less argument 5 (if any)
+#define LLDB_REGNUM_GENERIC_ARG6 \
+ 10 // The register that would contain pointer size or less argument 6 (if any)
+#define LLDB_REGNUM_GENERIC_ARG7 \
+ 11 // The register that would contain pointer size or less argument 7 (if any)
+#define LLDB_REGNUM_GENERIC_ARG8 \
+ 12 // The register that would contain pointer size or less argument 8 (if any)
//---------------------------------------------------------------------
/// Invalid value definitions
//----------------------------------------------------------------------
-#define LLDB_INVALID_ADDRESS UINT64_MAX
-#define LLDB_INVALID_INDEX32 UINT32_MAX
-#define LLDB_INVALID_IVAR_OFFSET UINT32_MAX
-#define LLDB_INVALID_IMAGE_TOKEN UINT32_MAX
-#define LLDB_INVALID_MODULE_VERSION UINT32_MAX
-#define LLDB_INVALID_REGNUM UINT32_MAX
-#define LLDB_INVALID_UID UINT64_MAX
-#define LLDB_INVALID_PROCESS_ID 0
-#define LLDB_INVALID_THREAD_ID 0
-#define LLDB_INVALID_FRAME_ID UINT32_MAX
-#define LLDB_INVALID_SIGNAL_NUMBER INT32_MAX
-#define LLDB_INVALID_OFFSET UINT64_MAX // Must match max of lldb::offset_t
-#define LLDB_INVALID_LINE_NUMBER UINT32_MAX
-#define LLDB_INVALID_QUEUE_ID 0
+#define LLDB_INVALID_ADDRESS UINT64_MAX
+#define LLDB_INVALID_INDEX32 UINT32_MAX
+#define LLDB_INVALID_IVAR_OFFSET UINT32_MAX
+#define LLDB_INVALID_IMAGE_TOKEN UINT32_MAX
+#define LLDB_INVALID_MODULE_VERSION UINT32_MAX
+#define LLDB_INVALID_REGNUM UINT32_MAX
+#define LLDB_INVALID_UID UINT64_MAX
+#define LLDB_INVALID_PROCESS_ID 0
+#define LLDB_INVALID_THREAD_ID 0
+#define LLDB_INVALID_FRAME_ID UINT32_MAX
+#define LLDB_INVALID_SIGNAL_NUMBER INT32_MAX
+#define LLDB_INVALID_OFFSET UINT64_MAX // Must match max of lldb::offset_t
+#define LLDB_INVALID_LINE_NUMBER UINT32_MAX
+#define LLDB_INVALID_QUEUE_ID 0
//----------------------------------------------------------------------
/// CPU Type definitions
//----------------------------------------------------------------------
-#define LLDB_ARCH_DEFAULT "systemArch"
-#define LLDB_ARCH_DEFAULT_32BIT "systemArch32"
-#define LLDB_ARCH_DEFAULT_64BIT "systemArch64"
-#define LLDB_INVALID_CPUTYPE (0xFFFFFFFEu)
+#define LLDB_ARCH_DEFAULT "systemArch"
+#define LLDB_ARCH_DEFAULT_32BIT "systemArch32"
+#define LLDB_ARCH_DEFAULT_64BIT "systemArch64"
+#define LLDB_INVALID_CPUTYPE (0xFFFFFFFEu)
//----------------------------------------------------------------------
/// Option Set definitions
//----------------------------------------------------------------------
// FIXME: I'm sure there's some #define magic that can create all 32 sets on the
// fly. That would have the added benefit of making this unreadable.
-#define LLDB_MAX_NUM_OPTION_SETS 32
-#define LLDB_OPT_SET_ALL 0xFFFFFFFFU
-#define LLDB_OPT_SET_1 (1U << 0)
-#define LLDB_OPT_SET_2 (1U << 1)
-#define LLDB_OPT_SET_3 (1U << 2)
-#define LLDB_OPT_SET_4 (1U << 3)
-#define LLDB_OPT_SET_5 (1U << 4)
-#define LLDB_OPT_SET_6 (1U << 5)
-#define LLDB_OPT_SET_7 (1U << 6)
-#define LLDB_OPT_SET_8 (1U << 7)
-#define LLDB_OPT_SET_9 (1U << 8)
-#define LLDB_OPT_SET_10 (1U << 9)
-#define LLDB_OPT_SET_FROM_TO(A, B) (((1U << (B)) - 1) ^ (((1U << (A))-1) >> 1))
-
-#if defined (_WIN32) && !defined (MAX_PATH)
+#define LLDB_MAX_NUM_OPTION_SETS 32
+#define LLDB_OPT_SET_ALL 0xFFFFFFFFU
+#define LLDB_OPT_SET_1 (1U << 0)
+#define LLDB_OPT_SET_2 (1U << 1)
+#define LLDB_OPT_SET_3 (1U << 2)
+#define LLDB_OPT_SET_4 (1U << 3)
+#define LLDB_OPT_SET_5 (1U << 4)
+#define LLDB_OPT_SET_6 (1U << 5)
+#define LLDB_OPT_SET_7 (1U << 6)
+#define LLDB_OPT_SET_8 (1U << 7)
+#define LLDB_OPT_SET_9 (1U << 8)
+#define LLDB_OPT_SET_10 (1U << 9)
+#define LLDB_OPT_SET_FROM_TO(A, B) \
+ (((1U << (B)) - 1) ^ (((1U << (A)) - 1) >> 1))
+
+#if defined(_WIN32) && !defined(MAX_PATH)
#define MAX_PATH 260
#endif
-#ifdef _MSC_VER
// ignore GCC function attributes
+#if defined(_MSC_VER) && !defined(__clang__)
#define __attribute__(X)
#endif
@@ -146,10 +156,10 @@
/// Macro definition for easily disallowing copy constructor and
/// assignment operators in C++ classes.
//----------------------------------------------------------------------
-#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
- TypeName(const TypeName&); \
- const TypeName& operator=(const TypeName&)
+#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
+ TypeName(const TypeName &) = delete; \
+ const TypeName &operator=(const TypeName &) = delete
#endif // #if defined(__cplusplus)
-#endif // LLDB_lldb_defines_h_
+#endif // LLDB_lldb_defines_h_
diff --git a/include/lldb/lldb-enumerations.h b/include/lldb/lldb-enumerations.h
index d8f076f00b0e..cf42828e2d5a 100644
--- a/include/lldb/lldb-enumerations.h
+++ b/include/lldb/lldb-enumerations.h
@@ -34,1032 +34,1040 @@
namespace lldb {
- //----------------------------------------------------------------------
- // Process and Thread States
- //----------------------------------------------------------------------
- enum StateType
- {
- eStateInvalid = 0,
- eStateUnloaded, ///< Process is object is valid, but not currently loaded
- eStateConnected, ///< Process is connected to remote debug services, but not launched or attached to anything yet
- eStateAttaching, ///< Process is currently trying to attach
- eStateLaunching, ///< Process is in the process of launching
- eStateStopped, ///< Process or thread is stopped and can be examined.
- eStateRunning, ///< Process or thread is running and can't be examined.
- eStateStepping, ///< Process or thread is in the process of stepping and can not be examined.
- eStateCrashed, ///< Process or thread has crashed and can be examined.
- eStateDetached, ///< Process has been detached and can't be examined.
- eStateExited, ///< Process has exited and can't be examined.
- eStateSuspended ///< Process or thread is in a suspended state as far
- ///< as the debugger is concerned while other processes
- ///< or threads get the chance to run.
- };
+//----------------------------------------------------------------------
+// Process and Thread States
+//----------------------------------------------------------------------
+enum StateType {
+ eStateInvalid = 0,
+ eStateUnloaded, ///< Process is object is valid, but not currently loaded
+ eStateConnected, ///< Process is connected to remote debug services, but not
+ ///launched or attached to anything yet
+ eStateAttaching, ///< Process is currently trying to attach
+ eStateLaunching, ///< Process is in the process of launching
+ eStateStopped, ///< Process or thread is stopped and can be examined.
+ eStateRunning, ///< Process or thread is running and can't be examined.
+ eStateStepping, ///< Process or thread is in the process of stepping and can
+ ///not be examined.
+ eStateCrashed, ///< Process or thread has crashed and can be examined.
+ eStateDetached, ///< Process has been detached and can't be examined.
+ eStateExited, ///< Process has exited and can't be examined.
+ eStateSuspended ///< Process or thread is in a suspended state as far
+ ///< as the debugger is concerned while other processes
+ ///< or threads get the chance to run.
+};
- //----------------------------------------------------------------------
- // Launch Flags
- //----------------------------------------------------------------------
- FLAGS_ENUM(LaunchFlags)
- {
- eLaunchFlagNone = 0u,
- eLaunchFlagExec = (1u << 0), ///< Exec when launching and turn the calling process into a new process
- eLaunchFlagDebug = (1u << 1), ///< Stop as soon as the process launches to allow the process to be debugged
- eLaunchFlagStopAtEntry = (1u << 2), ///< Stop at the program entry point instead of auto-continuing when launching or attaching at entry point
- eLaunchFlagDisableASLR = (1u << 3), ///< Disable Address Space Layout Randomization
- eLaunchFlagDisableSTDIO = (1u << 4), ///< Disable stdio for inferior process (e.g. for a GUI app)
- eLaunchFlagLaunchInTTY = (1u << 5), ///< Launch the process in a new TTY if supported by the host
- eLaunchFlagLaunchInShell= (1u << 6), ///< Launch the process inside a shell to get shell expansion
- eLaunchFlagLaunchInSeparateProcessGroup = (1u << 7), ///< Launch the process in a separate process group
- eLaunchFlagDontSetExitStatus = (1u << 8), ///< If you are going to hand the process off (e.g. to debugserver)
- ///< set this flag so lldb & the handee don't race to set its exit status.
- eLaunchFlagDetachOnError = (1u << 9), ///< If set, then the client stub should detach rather than killing the debugee
- ///< if it loses connection with lldb.
- eLaunchFlagShellExpandArguments = (1u << 10), ///< Perform shell-style argument expansion
- eLaunchFlagCloseTTYOnExit = (1u << 11), ///< Close the open TTY on exit
- };
-
- //----------------------------------------------------------------------
- // Thread Run Modes
- //----------------------------------------------------------------------
- enum RunMode
- {
- eOnlyThisThread,
- eAllThreads,
- eOnlyDuringStepping
- };
+//----------------------------------------------------------------------
+// Launch Flags
+//----------------------------------------------------------------------
+FLAGS_ENUM(LaunchFlags){
+ eLaunchFlagNone = 0u,
+ eLaunchFlagExec = (1u << 0), ///< Exec when launching and turn the calling
+ ///process into a new process
+ eLaunchFlagDebug = (1u << 1), ///< Stop as soon as the process launches to
+ ///allow the process to be debugged
+ eLaunchFlagStopAtEntry = (1u << 2), ///< Stop at the program entry point
+ ///instead of auto-continuing when
+ ///launching or attaching at entry point
+ eLaunchFlagDisableASLR =
+ (1u << 3), ///< Disable Address Space Layout Randomization
+ eLaunchFlagDisableSTDIO =
+ (1u << 4), ///< Disable stdio for inferior process (e.g. for a GUI app)
+ eLaunchFlagLaunchInTTY =
+ (1u << 5), ///< Launch the process in a new TTY if supported by the host
+ eLaunchFlagLaunchInShell =
+ (1u << 6), ///< Launch the process inside a shell to get shell expansion
+ eLaunchFlagLaunchInSeparateProcessGroup =
+ (1u << 7), ///< Launch the process in a separate process group
+ eLaunchFlagDontSetExitStatus = (1u << 8), ///< If you are going to hand the
+ ///process off (e.g. to
+ ///debugserver)
+ ///< set this flag so lldb & the handee don't race to set its exit status.
+ eLaunchFlagDetachOnError = (1u << 9), ///< If set, then the client stub
+ ///should detach rather than killing
+ ///the debugee
+ ///< if it loses connection with lldb.
+ eLaunchFlagShellExpandArguments =
+ (1u << 10), ///< Perform shell-style argument expansion
+ eLaunchFlagCloseTTYOnExit = (1u << 11), ///< Close the open TTY on exit
+};
- //----------------------------------------------------------------------
- // Byte ordering definitions
- //----------------------------------------------------------------------
- enum ByteOrder
- {
- eByteOrderInvalid = 0,
- eByteOrderBig = 1,
- eByteOrderPDP = 2,
- eByteOrderLittle = 4
- };
+//----------------------------------------------------------------------
+// Thread Run Modes
+//----------------------------------------------------------------------
+enum RunMode { eOnlyThisThread, eAllThreads, eOnlyDuringStepping };
- //----------------------------------------------------------------------
- // Register encoding definitions
- //----------------------------------------------------------------------
- enum Encoding
- {
- eEncodingInvalid = 0,
- eEncodingUint, // unsigned integer
- eEncodingSint, // signed integer
- eEncodingIEEE754, // float
- eEncodingVector // vector registers
- };
+//----------------------------------------------------------------------
+// Byte ordering definitions
+//----------------------------------------------------------------------
+enum ByteOrder {
+ eByteOrderInvalid = 0,
+ eByteOrderBig = 1,
+ eByteOrderPDP = 2,
+ eByteOrderLittle = 4
+};
- //----------------------------------------------------------------------
- // Display format definitions
- //----------------------------------------------------------------------
- enum Format
- {
- eFormatDefault = 0,
- eFormatInvalid = 0,
- eFormatBoolean,
- eFormatBinary,
- eFormatBytes,
- eFormatBytesWithASCII,
- eFormatChar,
- eFormatCharPrintable, // Only printable characters, space if not printable
- eFormatComplex, // Floating point complex type
- eFormatComplexFloat = eFormatComplex,
- eFormatCString, // NULL terminated C strings
- eFormatDecimal,
- eFormatEnum,
- eFormatHex,
- eFormatHexUppercase,
- eFormatFloat,
- eFormatOctal,
- eFormatOSType, // OS character codes encoded into an integer 'PICT' 'text' etc...
- eFormatUnicode16,
- eFormatUnicode32,
- eFormatUnsigned,
- eFormatPointer,
- eFormatVectorOfChar,
- eFormatVectorOfSInt8,
- eFormatVectorOfUInt8,
- eFormatVectorOfSInt16,
- eFormatVectorOfUInt16,
- eFormatVectorOfSInt32,
- eFormatVectorOfUInt32,
- eFormatVectorOfSInt64,
- eFormatVectorOfUInt64,
- eFormatVectorOfFloat16,
- eFormatVectorOfFloat32,
- eFormatVectorOfFloat64,
- eFormatVectorOfUInt128,
- eFormatComplexInteger, // Integer complex type
- eFormatCharArray, // Print characters with no single quotes, used for character arrays that can contain non printable characters
- eFormatAddressInfo, // Describe what an address points to (func + offset with file/line, symbol + offset, data, etc)
- eFormatHexFloat, // ISO C99 hex float string
- eFormatInstruction, // Disassemble an opcode
- eFormatVoid, // Do not print this
- kNumFormats
- };
+//----------------------------------------------------------------------
+// Register encoding definitions
+//----------------------------------------------------------------------
+enum Encoding {
+ eEncodingInvalid = 0,
+ eEncodingUint, // unsigned integer
+ eEncodingSint, // signed integer
+ eEncodingIEEE754, // float
+ eEncodingVector // vector registers
+};
- //----------------------------------------------------------------------
- // Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls
- //----------------------------------------------------------------------
- enum DescriptionLevel
- {
- eDescriptionLevelBrief = 0,
- eDescriptionLevelFull,
- eDescriptionLevelVerbose,
- eDescriptionLevelInitial,
- kNumDescriptionLevels
- };
+//----------------------------------------------------------------------
+// Display format definitions
+//----------------------------------------------------------------------
+enum Format {
+ eFormatDefault = 0,
+ eFormatInvalid = 0,
+ eFormatBoolean,
+ eFormatBinary,
+ eFormatBytes,
+ eFormatBytesWithASCII,
+ eFormatChar,
+ eFormatCharPrintable, // Only printable characters, space if not printable
+ eFormatComplex, // Floating point complex type
+ eFormatComplexFloat = eFormatComplex,
+ eFormatCString, // NULL terminated C strings
+ eFormatDecimal,
+ eFormatEnum,
+ eFormatHex,
+ eFormatHexUppercase,
+ eFormatFloat,
+ eFormatOctal,
+ eFormatOSType, // OS character codes encoded into an integer 'PICT' 'text'
+ // etc...
+ eFormatUnicode16,
+ eFormatUnicode32,
+ eFormatUnsigned,
+ eFormatPointer,
+ eFormatVectorOfChar,
+ eFormatVectorOfSInt8,
+ eFormatVectorOfUInt8,
+ eFormatVectorOfSInt16,
+ eFormatVectorOfUInt16,
+ eFormatVectorOfSInt32,
+ eFormatVectorOfUInt32,
+ eFormatVectorOfSInt64,
+ eFormatVectorOfUInt64,
+ eFormatVectorOfFloat16,
+ eFormatVectorOfFloat32,
+ eFormatVectorOfFloat64,
+ eFormatVectorOfUInt128,
+ eFormatComplexInteger, // Integer complex type
+ eFormatCharArray, // Print characters with no single quotes, used for
+ // character arrays that can contain non printable
+ // characters
+ eFormatAddressInfo, // Describe what an address points to (func + offset with
+ // file/line, symbol + offset, data, etc)
+ eFormatHexFloat, // ISO C99 hex float string
+ eFormatInstruction, // Disassemble an opcode
+ eFormatVoid, // Do not print this
+ kNumFormats
+};
- //----------------------------------------------------------------------
- // Script interpreter types
- //----------------------------------------------------------------------
- enum ScriptLanguage
- {
- eScriptLanguageNone,
- eScriptLanguagePython,
- eScriptLanguageDefault = eScriptLanguagePython
- };
+//----------------------------------------------------------------------
+// Description levels for "void GetDescription(Stream *, DescriptionLevel)"
+// calls
+//----------------------------------------------------------------------
+enum DescriptionLevel {
+ eDescriptionLevelBrief = 0,
+ eDescriptionLevelFull,
+ eDescriptionLevelVerbose,
+ eDescriptionLevelInitial,
+ kNumDescriptionLevels
+};
- //----------------------------------------------------------------------
- // Register numbering types
- // See RegisterContext::ConvertRegisterKindToRegisterNumber to convert
- // any of these to the lldb internal register numbering scheme
- // (eRegisterKindLLDB).
- //----------------------------------------------------------------------
- enum RegisterKind
- {
- eRegisterKindEHFrame = 0, // the register numbers seen in eh_frame
- eRegisterKindDWARF, // the register numbers seen DWARF
- eRegisterKindGeneric, // insn ptr reg, stack ptr reg, etc not specific to any particular target
- eRegisterKindProcessPlugin, // num used by the process plugin - e.g. by the remote gdb-protocol stub program
- eRegisterKindLLDB, // lldb's internal register numbers
- kNumRegisterKinds
- };
+//----------------------------------------------------------------------
+// Script interpreter types
+//----------------------------------------------------------------------
+enum ScriptLanguage {
+ eScriptLanguageNone,
+ eScriptLanguagePython,
+ eScriptLanguageDefault = eScriptLanguagePython,
+ eScriptLanguageUnknown
+};
- //----------------------------------------------------------------------
- // Thread stop reasons
- //----------------------------------------------------------------------
- enum StopReason
- {
- eStopReasonInvalid = 0,
- eStopReasonNone,
- eStopReasonTrace,
- eStopReasonBreakpoint,
- eStopReasonWatchpoint,
- eStopReasonSignal,
- eStopReasonException,
- eStopReasonExec, // Program was re-exec'ed
- eStopReasonPlanComplete,
- eStopReasonThreadExiting,
- eStopReasonInstrumentation
- };
+//----------------------------------------------------------------------
+// Register numbering types
+// See RegisterContext::ConvertRegisterKindToRegisterNumber to convert
+// any of these to the lldb internal register numbering scheme
+// (eRegisterKindLLDB).
+//----------------------------------------------------------------------
+enum RegisterKind {
+ eRegisterKindEHFrame = 0, // the register numbers seen in eh_frame
+ eRegisterKindDWARF, // the register numbers seen DWARF
+ eRegisterKindGeneric, // insn ptr reg, stack ptr reg, etc not specific to any
+ // particular target
+ eRegisterKindProcessPlugin, // num used by the process plugin - e.g. by the
+ // remote gdb-protocol stub program
+ eRegisterKindLLDB, // lldb's internal register numbers
+ kNumRegisterKinds
+};
- //----------------------------------------------------------------------
- // Command Return Status Types
- //----------------------------------------------------------------------
- enum ReturnStatus
- {
- eReturnStatusInvalid,
- eReturnStatusSuccessFinishNoResult,
- eReturnStatusSuccessFinishResult,
- eReturnStatusSuccessContinuingNoResult,
- eReturnStatusSuccessContinuingResult,
- eReturnStatusStarted,
- eReturnStatusFailed,
- eReturnStatusQuit
- };
+//----------------------------------------------------------------------
+// Thread stop reasons
+//----------------------------------------------------------------------
+enum StopReason {
+ eStopReasonInvalid = 0,
+ eStopReasonNone,
+ eStopReasonTrace,
+ eStopReasonBreakpoint,
+ eStopReasonWatchpoint,
+ eStopReasonSignal,
+ eStopReasonException,
+ eStopReasonExec, // Program was re-exec'ed
+ eStopReasonPlanComplete,
+ eStopReasonThreadExiting,
+ eStopReasonInstrumentation
+};
+//----------------------------------------------------------------------
+// Command Return Status Types
+//----------------------------------------------------------------------
+enum ReturnStatus {
+ eReturnStatusInvalid,
+ eReturnStatusSuccessFinishNoResult,
+ eReturnStatusSuccessFinishResult,
+ eReturnStatusSuccessContinuingNoResult,
+ eReturnStatusSuccessContinuingResult,
+ eReturnStatusStarted,
+ eReturnStatusFailed,
+ eReturnStatusQuit
+};
- //----------------------------------------------------------------------
- // The results of expression evaluation:
- //----------------------------------------------------------------------
- enum ExpressionResults
- {
- eExpressionCompleted = 0,
- eExpressionSetupError,
- eExpressionParseError,
- eExpressionDiscarded,
- eExpressionInterrupted,
- eExpressionHitBreakpoint,
- eExpressionTimedOut,
- eExpressionResultUnavailable,
- eExpressionStoppedForDebug
- };
+//----------------------------------------------------------------------
+// The results of expression evaluation:
+//----------------------------------------------------------------------
+enum ExpressionResults {
+ eExpressionCompleted = 0,
+ eExpressionSetupError,
+ eExpressionParseError,
+ eExpressionDiscarded,
+ eExpressionInterrupted,
+ eExpressionHitBreakpoint,
+ eExpressionTimedOut,
+ eExpressionResultUnavailable,
+ eExpressionStoppedForDebug
+};
- //----------------------------------------------------------------------
- // Connection Status Types
- //----------------------------------------------------------------------
- enum ConnectionStatus
- {
- eConnectionStatusSuccess, // Success
- eConnectionStatusEndOfFile, // End-of-file encountered
- eConnectionStatusError, // Check GetError() for details
- eConnectionStatusTimedOut, // Request timed out
- eConnectionStatusNoConnection, // No connection
- eConnectionStatusLostConnection, // Lost connection while connected to a valid connection
- eConnectionStatusInterrupted // Interrupted read
- };
+//----------------------------------------------------------------------
+// Connection Status Types
+//----------------------------------------------------------------------
+enum ConnectionStatus {
+ eConnectionStatusSuccess, // Success
+ eConnectionStatusEndOfFile, // End-of-file encountered
+ eConnectionStatusError, // Check GetError() for details
+ eConnectionStatusTimedOut, // Request timed out
+ eConnectionStatusNoConnection, // No connection
+ eConnectionStatusLostConnection, // Lost connection while connected to a valid
+ // connection
+ eConnectionStatusInterrupted // Interrupted read
+};
- enum ErrorType
- {
- eErrorTypeInvalid,
- eErrorTypeGeneric, ///< Generic errors that can be any value.
- eErrorTypeMachKernel, ///< Mach kernel error codes.
- eErrorTypePOSIX, ///< POSIX error codes.
- eErrorTypeExpression, ///< These are from the ExpressionResults enum.
- eErrorTypeWin32 ///< Standard Win32 error codes.
- };
+enum ErrorType {
+ eErrorTypeInvalid,
+ eErrorTypeGeneric, ///< Generic errors that can be any value.
+ eErrorTypeMachKernel, ///< Mach kernel error codes.
+ eErrorTypePOSIX, ///< POSIX error codes.
+ eErrorTypeExpression, ///< These are from the ExpressionResults enum.
+ eErrorTypeWin32 ///< Standard Win32 error codes.
+};
- enum ValueType
- {
- eValueTypeInvalid = 0,
- eValueTypeVariableGlobal = 1, // globals variable
- eValueTypeVariableStatic = 2, // static variable
- eValueTypeVariableArgument = 3, // function argument variables
- eValueTypeVariableLocal = 4, // function local variables
- eValueTypeRegister = 5, // stack frame register value
- eValueTypeRegisterSet = 6, // A collection of stack frame register values
- eValueTypeConstResult = 7, // constant result variables
- eValueTypeVariableThreadLocal = 8 // thread local storage variable
- };
+enum ValueType {
+ eValueTypeInvalid = 0,
+ eValueTypeVariableGlobal = 1, // globals variable
+ eValueTypeVariableStatic = 2, // static variable
+ eValueTypeVariableArgument = 3, // function argument variables
+ eValueTypeVariableLocal = 4, // function local variables
+ eValueTypeRegister = 5, // stack frame register value
+ eValueTypeRegisterSet = 6, // A collection of stack frame register values
+ eValueTypeConstResult = 7, // constant result variables
+ eValueTypeVariableThreadLocal = 8 // thread local storage variable
+};
- //----------------------------------------------------------------------
- // Token size/granularities for Input Readers
- //----------------------------------------------------------------------
+//----------------------------------------------------------------------
+// Token size/granularities for Input Readers
+//----------------------------------------------------------------------
- enum InputReaderGranularity
- {
- eInputReaderGranularityInvalid = 0,
- eInputReaderGranularityByte,
- eInputReaderGranularityWord,
- eInputReaderGranularityLine,
- eInputReaderGranularityAll
- };
+enum InputReaderGranularity {
+ eInputReaderGranularityInvalid = 0,
+ eInputReaderGranularityByte,
+ eInputReaderGranularityWord,
+ eInputReaderGranularityLine,
+ eInputReaderGranularityAll
+};
- //------------------------------------------------------------------
- /// These mask bits allow a common interface for queries that can
- /// limit the amount of information that gets parsed to only the
- /// information that is requested. These bits also can indicate what
- /// actually did get resolved during query function calls.
- ///
- /// Each definition corresponds to a one of the member variables
- /// in this class, and requests that that item be resolved, or
- /// indicates that the member did get resolved.
- //------------------------------------------------------------------
- FLAGS_ENUM(SymbolContextItem)
- {
- eSymbolContextTarget = (1u << 0), ///< Set when \a target is requested from a query, or was located in query results
- eSymbolContextModule = (1u << 1), ///< Set when \a module is requested from a query, or was located in query results
- eSymbolContextCompUnit = (1u << 2), ///< Set when \a comp_unit is requested from a query, or was located in query results
- eSymbolContextFunction = (1u << 3), ///< Set when \a function is requested from a query, or was located in query results
- eSymbolContextBlock = (1u << 4), ///< Set when the deepest \a block is requested from a query, or was located in query results
- eSymbolContextLineEntry = (1u << 5), ///< Set when \a line_entry is requested from a query, or was located in query results
- eSymbolContextSymbol = (1u << 6), ///< Set when \a symbol is requested from a query, or was located in query results
- eSymbolContextEverything = ((eSymbolContextSymbol << 1) - 1u), ///< Indicates to try and lookup everything up during a routine symbol context query.
- eSymbolContextVariable = (1u << 7) ///< Set when \a global or static variable is requested from a query, or was located in query results.
- ///< eSymbolContextVariable is potentially expensive to lookup so it isn't included in
- ///< eSymbolContextEverything which stops it from being used during frame PC lookups and
- ///< many other potential address to symbol context lookups.
- };
+//------------------------------------------------------------------
+/// These mask bits allow a common interface for queries that can
+/// limit the amount of information that gets parsed to only the
+/// information that is requested. These bits also can indicate what
+/// actually did get resolved during query function calls.
+///
+/// Each definition corresponds to a one of the member variables
+/// in this class, and requests that that item be resolved, or
+/// indicates that the member did get resolved.
+//------------------------------------------------------------------
+FLAGS_ENUM(SymbolContextItem){
+ eSymbolContextTarget = (1u << 0), ///< Set when \a target is requested from
+ ///a query, or was located in query
+ ///results
+ eSymbolContextModule = (1u << 1), ///< Set when \a module is requested from
+ ///a query, or was located in query
+ ///results
+ eSymbolContextCompUnit = (1u << 2), ///< Set when \a comp_unit is requested
+ ///from a query, or was located in query
+ ///results
+ eSymbolContextFunction = (1u << 3), ///< Set when \a function is requested
+ ///from a query, or was located in query
+ ///results
+ eSymbolContextBlock = (1u << 4), ///< Set when the deepest \a block is
+ ///requested from a query, or was located
+ ///in query results
+ eSymbolContextLineEntry = (1u << 5), ///< Set when \a line_entry is
+ ///requested from a query, or was
+ ///located in query results
+ eSymbolContextSymbol = (1u << 6), ///< Set when \a symbol is requested from
+ ///a query, or was located in query
+ ///results
+ eSymbolContextEverything = ((eSymbolContextSymbol << 1) -
+ 1u), ///< Indicates to try and lookup everything
+ ///up during a routine symbol context
+ ///query.
+ eSymbolContextVariable = (1u << 7) ///< Set when \a global or static
+ ///variable is requested from a query, or
+ ///was located in query results.
+ ///< eSymbolContextVariable is potentially expensive to lookup so it isn't
+ ///included in
+ ///< eSymbolContextEverything which stops it from being used during frame PC
+ ///lookups and
+ ///< many other potential address to symbol context lookups.
+};
- FLAGS_ENUM(Permissions)
- {
- ePermissionsWritable = (1u << 0),
- ePermissionsReadable = (1u << 1),
- ePermissionsExecutable = (1u << 2)
- };
+FLAGS_ENUM(Permissions){ePermissionsWritable = (1u << 0),
+ ePermissionsReadable = (1u << 1),
+ ePermissionsExecutable = (1u << 2)};
- enum InputReaderAction
- {
- eInputReaderActivate, // reader is newly pushed onto the reader stack
- eInputReaderAsynchronousOutputWritten, // an async output event occurred; the reader may want to do something
- eInputReaderReactivate, // reader is on top of the stack again after another reader was popped off
- eInputReaderDeactivate, // another reader was pushed on the stack
- eInputReaderGotToken, // reader got one of its tokens (granularity)
- eInputReaderInterrupt, // reader received an interrupt signal (probably from a control-c)
- eInputReaderEndOfFile, // reader received an EOF char (probably from a control-d)
- eInputReaderDone // reader was just popped off the stack and is done
- };
+enum InputReaderAction {
+ eInputReaderActivate, // reader is newly pushed onto the reader stack
+ eInputReaderAsynchronousOutputWritten, // an async output event occurred; the
+ // reader may want to do something
+ eInputReaderReactivate, // reader is on top of the stack again after another
+ // reader was popped off
+ eInputReaderDeactivate, // another reader was pushed on the stack
+ eInputReaderGotToken, // reader got one of its tokens (granularity)
+ eInputReaderInterrupt, // reader received an interrupt signal (probably from a
+ // control-c)
+ eInputReaderEndOfFile, // reader received an EOF char (probably from a
+ // control-d)
+ eInputReaderDone // reader was just popped off the stack and is done
+};
- FLAGS_ENUM(BreakpointEventType)
- {
- eBreakpointEventTypeInvalidType = (1u << 0),
- eBreakpointEventTypeAdded = (1u << 1),
- eBreakpointEventTypeRemoved = (1u << 2),
- eBreakpointEventTypeLocationsAdded = (1u << 3), // Locations added doesn't get sent when the breakpoint is created
- eBreakpointEventTypeLocationsRemoved = (1u << 4),
- eBreakpointEventTypeLocationsResolved = (1u << 5),
- eBreakpointEventTypeEnabled = (1u << 6),
- eBreakpointEventTypeDisabled = (1u << 7),
- eBreakpointEventTypeCommandChanged = (1u << 8),
- eBreakpointEventTypeConditionChanged = (1u << 9),
- eBreakpointEventTypeIgnoreChanged = (1u << 10),
- eBreakpointEventTypeThreadChanged = (1u << 11)
- };
+FLAGS_ENUM(BreakpointEventType){
+ eBreakpointEventTypeInvalidType = (1u << 0),
+ eBreakpointEventTypeAdded = (1u << 1),
+ eBreakpointEventTypeRemoved = (1u << 2),
+ eBreakpointEventTypeLocationsAdded = (1u << 3), // Locations added doesn't
+ // get sent when the
+ // breakpoint is created
+ eBreakpointEventTypeLocationsRemoved = (1u << 4),
+ eBreakpointEventTypeLocationsResolved = (1u << 5),
+ eBreakpointEventTypeEnabled = (1u << 6),
+ eBreakpointEventTypeDisabled = (1u << 7),
+ eBreakpointEventTypeCommandChanged = (1u << 8),
+ eBreakpointEventTypeConditionChanged = (1u << 9),
+ eBreakpointEventTypeIgnoreChanged = (1u << 10),
+ eBreakpointEventTypeThreadChanged = (1u << 11)};
- FLAGS_ENUM(WatchpointEventType)
- {
- eWatchpointEventTypeInvalidType = (1u << 0),
- eWatchpointEventTypeAdded = (1u << 1),
- eWatchpointEventTypeRemoved = (1u << 2),
- eWatchpointEventTypeEnabled = (1u << 6),
- eWatchpointEventTypeDisabled = (1u << 7),
- eWatchpointEventTypeCommandChanged = (1u << 8),
- eWatchpointEventTypeConditionChanged = (1u << 9),
- eWatchpointEventTypeIgnoreChanged = (1u << 10),
- eWatchpointEventTypeThreadChanged = (1u << 11),
- eWatchpointEventTypeTypeChanged = (1u << 12)
- };
+FLAGS_ENUM(WatchpointEventType){
+ eWatchpointEventTypeInvalidType = (1u << 0),
+ eWatchpointEventTypeAdded = (1u << 1),
+ eWatchpointEventTypeRemoved = (1u << 2),
+ eWatchpointEventTypeEnabled = (1u << 6),
+ eWatchpointEventTypeDisabled = (1u << 7),
+ eWatchpointEventTypeCommandChanged = (1u << 8),
+ eWatchpointEventTypeConditionChanged = (1u << 9),
+ eWatchpointEventTypeIgnoreChanged = (1u << 10),
+ eWatchpointEventTypeThreadChanged = (1u << 11),
+ eWatchpointEventTypeTypeChanged = (1u << 12)};
+//----------------------------------------------------------------------
+/// Programming language type.
+///
+/// These enumerations use the same language enumerations as the DWARF
+/// specification for ease of use and consistency.
+/// The enum -> string code is in Language.cpp, don't change this
+/// table without updating that code as well.
+//----------------------------------------------------------------------
+enum LanguageType {
+ eLanguageTypeUnknown = 0x0000, ///< Unknown or invalid language value.
+ eLanguageTypeC89 = 0x0001, ///< ISO C:1989.
+ eLanguageTypeC = 0x0002, ///< Non-standardized C, such as K&R.
+ eLanguageTypeAda83 = 0x0003, ///< ISO Ada:1983.
+ eLanguageTypeC_plus_plus = 0x0004, ///< ISO C++:1998.
+ eLanguageTypeCobol74 = 0x0005, ///< ISO Cobol:1974.
+ eLanguageTypeCobol85 = 0x0006, ///< ISO Cobol:1985.
+ eLanguageTypeFortran77 = 0x0007, ///< ISO Fortran 77.
+ eLanguageTypeFortran90 = 0x0008, ///< ISO Fortran 90.
+ eLanguageTypePascal83 = 0x0009, ///< ISO Pascal:1983.
+ eLanguageTypeModula2 = 0x000a, ///< ISO Modula-2:1996.
+ eLanguageTypeJava = 0x000b, ///< Java.
+ eLanguageTypeC99 = 0x000c, ///< ISO C:1999.
+ eLanguageTypeAda95 = 0x000d, ///< ISO Ada:1995.
+ eLanguageTypeFortran95 = 0x000e, ///< ISO Fortran 95.
+ eLanguageTypePLI = 0x000f, ///< ANSI PL/I:1976.
+ eLanguageTypeObjC = 0x0010, ///< Objective-C.
+ eLanguageTypeObjC_plus_plus = 0x0011, ///< Objective-C++.
+ eLanguageTypeUPC = 0x0012, ///< Unified Parallel C.
+ eLanguageTypeD = 0x0013, ///< D.
+ eLanguageTypePython = 0x0014, ///< Python.
+ // NOTE: The below are DWARF5 constants, subject to change upon
+ // completion of the DWARF5 specification
+ eLanguageTypeOpenCL = 0x0015, ///< OpenCL.
+ eLanguageTypeGo = 0x0016, ///< Go.
+ eLanguageTypeModula3 = 0x0017, ///< Modula 3.
+ eLanguageTypeHaskell = 0x0018, ///< Haskell.
+ eLanguageTypeC_plus_plus_03 = 0x0019, ///< ISO C++:2003.
+ eLanguageTypeC_plus_plus_11 = 0x001a, ///< ISO C++:2011.
+ eLanguageTypeOCaml = 0x001b, ///< OCaml.
+ eLanguageTypeRust = 0x001c, ///< Rust.
+ eLanguageTypeC11 = 0x001d, ///< ISO C:2011.
+ eLanguageTypeSwift = 0x001e, ///< Swift.
+ eLanguageTypeJulia = 0x001f, ///< Julia.
+ eLanguageTypeDylan = 0x0020, ///< Dylan.
+ eLanguageTypeC_plus_plus_14 = 0x0021, ///< ISO C++:2014.
+ eLanguageTypeFortran03 = 0x0022, ///< ISO Fortran 2003.
+ eLanguageTypeFortran08 = 0x0023, ///< ISO Fortran 2008.
+ // Vendor Extensions
+ // Note: Language::GetNameForLanguageType
+ // assumes these can be used as indexes into array language_names, and
+ // Language::SetLanguageFromCString and Language::AsCString
+ // assume these can be used as indexes into array g_languages.
+ eLanguageTypeMipsAssembler = 0x0024, ///< Mips_Assembler.
+ eLanguageTypeExtRenderScript = 0x0025, ///< RenderScript.
+ eNumLanguageTypes
+};
- //----------------------------------------------------------------------
- /// Programming language type.
- ///
- /// These enumerations use the same language enumerations as the DWARF
- /// specification for ease of use and consistency.
- /// The enum -> string code is in Language.cpp, don't change this
- /// table without updating that code as well.
- //----------------------------------------------------------------------
- enum LanguageType
- {
- eLanguageTypeUnknown = 0x0000, ///< Unknown or invalid language value.
- eLanguageTypeC89 = 0x0001, ///< ISO C:1989.
- eLanguageTypeC = 0x0002, ///< Non-standardized C, such as K&R.
- eLanguageTypeAda83 = 0x0003, ///< ISO Ada:1983.
- eLanguageTypeC_plus_plus = 0x0004, ///< ISO C++:1998.
- eLanguageTypeCobol74 = 0x0005, ///< ISO Cobol:1974.
- eLanguageTypeCobol85 = 0x0006, ///< ISO Cobol:1985.
- eLanguageTypeFortran77 = 0x0007, ///< ISO Fortran 77.
- eLanguageTypeFortran90 = 0x0008, ///< ISO Fortran 90.
- eLanguageTypePascal83 = 0x0009, ///< ISO Pascal:1983.
- eLanguageTypeModula2 = 0x000a, ///< ISO Modula-2:1996.
- eLanguageTypeJava = 0x000b, ///< Java.
- eLanguageTypeC99 = 0x000c, ///< ISO C:1999.
- eLanguageTypeAda95 = 0x000d, ///< ISO Ada:1995.
- eLanguageTypeFortran95 = 0x000e, ///< ISO Fortran 95.
- eLanguageTypePLI = 0x000f, ///< ANSI PL/I:1976.
- eLanguageTypeObjC = 0x0010, ///< Objective-C.
- eLanguageTypeObjC_plus_plus = 0x0011, ///< Objective-C++.
- eLanguageTypeUPC = 0x0012, ///< Unified Parallel C.
- eLanguageTypeD = 0x0013, ///< D.
- eLanguageTypePython = 0x0014, ///< Python.
- // NOTE: The below are DWARF5 constants, subject to change upon
- // completion of the DWARF5 specification
- eLanguageTypeOpenCL = 0x0015, ///< OpenCL.
- eLanguageTypeGo = 0x0016, ///< Go.
- eLanguageTypeModula3 = 0x0017, ///< Modula 3.
- eLanguageTypeHaskell = 0x0018, ///< Haskell.
- eLanguageTypeC_plus_plus_03 = 0x0019, ///< ISO C++:2003.
- eLanguageTypeC_plus_plus_11 = 0x001a, ///< ISO C++:2011.
- eLanguageTypeOCaml = 0x001b, ///< OCaml.
- eLanguageTypeRust = 0x001c, ///< Rust.
- eLanguageTypeC11 = 0x001d, ///< ISO C:2011.
- eLanguageTypeSwift = 0x001e, ///< Swift.
- eLanguageTypeJulia = 0x001f, ///< Julia.
- eLanguageTypeDylan = 0x0020, ///< Dylan.
- eLanguageTypeC_plus_plus_14 = 0x0021, ///< ISO C++:2014.
- eLanguageTypeFortran03 = 0x0022, ///< ISO Fortran 2003.
- eLanguageTypeFortran08 = 0x0023, ///< ISO Fortran 2008.
- // Vendor Extensions
- // Note: Language::GetNameForLanguageType
- // assumes these can be used as indexes into array language_names, and
- // Language::SetLanguageFromCString and Language::AsCString
- // assume these can be used as indexes into array g_languages.
- eLanguageTypeMipsAssembler = 0x0024, ///< Mips_Assembler.
- eLanguageTypeExtRenderScript = 0x0025, ///< RenderScript.
- eNumLanguageTypes
- };
-
- enum InstrumentationRuntimeType
- {
- eInstrumentationRuntimeTypeAddressSanitizer = 0x0000,
- eInstrumentationRuntimeTypeThreadSanitizer = 0x0001,
- eNumInstrumentationRuntimeTypes
- };
+enum InstrumentationRuntimeType {
+ eInstrumentationRuntimeTypeAddressSanitizer = 0x0000,
+ eInstrumentationRuntimeTypeThreadSanitizer = 0x0001,
+ eNumInstrumentationRuntimeTypes
+};
- enum DynamicValueType
- {
- eNoDynamicValues = 0,
- eDynamicCanRunTarget = 1,
- eDynamicDontRunTarget = 2
- };
-
- enum AccessType
- {
- eAccessNone,
- eAccessPublic,
- eAccessPrivate,
- eAccessProtected,
- eAccessPackage
- };
+enum DynamicValueType {
+ eNoDynamicValues = 0,
+ eDynamicCanRunTarget = 1,
+ eDynamicDontRunTarget = 2
+};
- enum CommandArgumentType
- {
- eArgTypeAddress = 0,
- eArgTypeAddressOrExpression,
- eArgTypeAliasName,
- eArgTypeAliasOptions,
- eArgTypeArchitecture,
- eArgTypeBoolean,
- eArgTypeBreakpointID,
- eArgTypeBreakpointIDRange,
- eArgTypeBreakpointName,
- eArgTypeByteSize,
- eArgTypeClassName,
- eArgTypeCommandName,
- eArgTypeCount,
- eArgTypeDescriptionVerbosity,
- eArgTypeDirectoryName,
- eArgTypeDisassemblyFlavor,
- eArgTypeEndAddress,
- eArgTypeExpression,
- eArgTypeExpressionPath,
- eArgTypeExprFormat,
- eArgTypeFilename,
- eArgTypeFormat,
- eArgTypeFrameIndex,
- eArgTypeFullName,
- eArgTypeFunctionName,
- eArgTypeFunctionOrSymbol,
- eArgTypeGDBFormat,
- eArgTypeHelpText,
- eArgTypeIndex,
- eArgTypeLanguage,
- eArgTypeLineNum,
- eArgTypeLogCategory,
- eArgTypeLogChannel,
- eArgTypeMethod,
- eArgTypeName,
- eArgTypeNewPathPrefix,
- eArgTypeNumLines,
- eArgTypeNumberPerLine,
- eArgTypeOffset,
- eArgTypeOldPathPrefix,
- eArgTypeOneLiner,
- eArgTypePath,
- eArgTypePermissionsNumber,
- eArgTypePermissionsString,
- eArgTypePid,
- eArgTypePlugin,
- eArgTypeProcessName,
- eArgTypePythonClass,
- eArgTypePythonFunction,
- eArgTypePythonScript,
- eArgTypeQueueName,
- eArgTypeRegisterName,
- eArgTypeRegularExpression,
- eArgTypeRunArgs,
- eArgTypeRunMode,
- eArgTypeScriptedCommandSynchronicity,
- eArgTypeScriptLang,
- eArgTypeSearchWord,
- eArgTypeSelector,
- eArgTypeSettingIndex,
- eArgTypeSettingKey,
- eArgTypeSettingPrefix,
- eArgTypeSettingVariableName,
- eArgTypeShlibName,
- eArgTypeSourceFile,
- eArgTypeSortOrder,
- eArgTypeStartAddress,
- eArgTypeSummaryString,
- eArgTypeSymbol,
- eArgTypeThreadID,
- eArgTypeThreadIndex,
- eArgTypeThreadName,
- eArgTypeTypeName,
- eArgTypeUnsignedInteger,
- eArgTypeUnixSignal,
- eArgTypeVarName,
- eArgTypeValue,
- eArgTypeWidth,
- eArgTypeNone,
- eArgTypePlatform,
- eArgTypeWatchpointID,
- eArgTypeWatchpointIDRange,
- eArgTypeWatchType,
- eArgRawInput,
- eArgTypeLastArg // Always keep this entry as the last entry in this enumeration!!
- };
+enum StopShowColumn {
+ eStopShowColumnAnsiOrCaret = 0,
+ eStopShowColumnAnsi = 1,
+ eStopShowColumnCaret = 2,
+ eStopShowColumnNone = 3
+};
- //----------------------------------------------------------------------
- // Symbol types
- //----------------------------------------------------------------------
- enum SymbolType
- {
- eSymbolTypeAny = 0,
- eSymbolTypeInvalid = 0,
- eSymbolTypeAbsolute,
- eSymbolTypeCode,
- eSymbolTypeResolver,
- eSymbolTypeData,
- eSymbolTypeTrampoline,
- eSymbolTypeRuntime,
- eSymbolTypeException,
- eSymbolTypeSourceFile,
- eSymbolTypeHeaderFile,
- eSymbolTypeObjectFile,
- eSymbolTypeCommonBlock,
- eSymbolTypeBlock,
- eSymbolTypeLocal,
- eSymbolTypeParam,
- eSymbolTypeVariable,
- eSymbolTypeVariableType,
- eSymbolTypeLineEntry,
- eSymbolTypeLineHeader,
- eSymbolTypeScopeBegin,
- eSymbolTypeScopeEnd,
- eSymbolTypeAdditional, // When symbols take more than one entry, the extra entries get this type
- eSymbolTypeCompiler,
- eSymbolTypeInstrumentation,
- eSymbolTypeUndefined,
- eSymbolTypeObjCClass,
- eSymbolTypeObjCMetaClass,
- eSymbolTypeObjCIVar,
- eSymbolTypeReExported
- };
-
- enum SectionType
- {
- eSectionTypeInvalid,
- eSectionTypeCode,
- eSectionTypeContainer, // The section contains child sections
- eSectionTypeData,
- eSectionTypeDataCString, // Inlined C string data
- eSectionTypeDataCStringPointers, // Pointers to C string data
- eSectionTypeDataSymbolAddress, // Address of a symbol in the symbol table
- eSectionTypeData4,
- eSectionTypeData8,
- eSectionTypeData16,
- eSectionTypeDataPointers,
- eSectionTypeDebug,
- eSectionTypeZeroFill,
- eSectionTypeDataObjCMessageRefs, // Pointer to function pointer + selector
- eSectionTypeDataObjCCFStrings, // Objective C const CFString/NSString objects
- eSectionTypeDWARFDebugAbbrev,
- eSectionTypeDWARFDebugAddr,
- eSectionTypeDWARFDebugAranges,
- eSectionTypeDWARFDebugFrame,
- eSectionTypeDWARFDebugInfo,
- eSectionTypeDWARFDebugLine,
- eSectionTypeDWARFDebugLoc,
- eSectionTypeDWARFDebugMacInfo,
- eSectionTypeDWARFDebugMacro,
- eSectionTypeDWARFDebugPubNames,
- eSectionTypeDWARFDebugPubTypes,
- eSectionTypeDWARFDebugRanges,
- eSectionTypeDWARFDebugStr,
- eSectionTypeDWARFDebugStrOffsets,
- eSectionTypeDWARFAppleNames,
- eSectionTypeDWARFAppleTypes,
- eSectionTypeDWARFAppleNamespaces,
- eSectionTypeDWARFAppleObjC,
- eSectionTypeELFSymbolTable, // Elf SHT_SYMTAB section
- eSectionTypeELFDynamicSymbols, // Elf SHT_DYNSYM section
- eSectionTypeELFRelocationEntries, // Elf SHT_REL or SHT_REL section
- eSectionTypeELFDynamicLinkInfo, // Elf SHT_DYNAMIC section
- eSectionTypeEHFrame,
- eSectionTypeARMexidx,
- eSectionTypeARMextab,
- eSectionTypeCompactUnwind, // compact unwind section in Mach-O, __TEXT,__unwind_info
- eSectionTypeGoSymtab,
- eSectionTypeAbsoluteAddress, // Dummy section for symbols with absolute address
- eSectionTypeOther
- };
+enum AccessType {
+ eAccessNone,
+ eAccessPublic,
+ eAccessPrivate,
+ eAccessProtected,
+ eAccessPackage
+};
- FLAGS_ENUM(EmulateInstructionOptions)
- {
- eEmulateInstructionOptionNone = (0u),
- eEmulateInstructionOptionAutoAdvancePC = (1u << 0),
- eEmulateInstructionOptionIgnoreConditions = (1u << 1)
- };
+enum CommandArgumentType {
+ eArgTypeAddress = 0,
+ eArgTypeAddressOrExpression,
+ eArgTypeAliasName,
+ eArgTypeAliasOptions,
+ eArgTypeArchitecture,
+ eArgTypeBoolean,
+ eArgTypeBreakpointID,
+ eArgTypeBreakpointIDRange,
+ eArgTypeBreakpointName,
+ eArgTypeByteSize,
+ eArgTypeClassName,
+ eArgTypeCommandName,
+ eArgTypeCount,
+ eArgTypeDescriptionVerbosity,
+ eArgTypeDirectoryName,
+ eArgTypeDisassemblyFlavor,
+ eArgTypeEndAddress,
+ eArgTypeExpression,
+ eArgTypeExpressionPath,
+ eArgTypeExprFormat,
+ eArgTypeFilename,
+ eArgTypeFormat,
+ eArgTypeFrameIndex,
+ eArgTypeFullName,
+ eArgTypeFunctionName,
+ eArgTypeFunctionOrSymbol,
+ eArgTypeGDBFormat,
+ eArgTypeHelpText,
+ eArgTypeIndex,
+ eArgTypeLanguage,
+ eArgTypeLineNum,
+ eArgTypeLogCategory,
+ eArgTypeLogChannel,
+ eArgTypeMethod,
+ eArgTypeName,
+ eArgTypeNewPathPrefix,
+ eArgTypeNumLines,
+ eArgTypeNumberPerLine,
+ eArgTypeOffset,
+ eArgTypeOldPathPrefix,
+ eArgTypeOneLiner,
+ eArgTypePath,
+ eArgTypePermissionsNumber,
+ eArgTypePermissionsString,
+ eArgTypePid,
+ eArgTypePlugin,
+ eArgTypeProcessName,
+ eArgTypePythonClass,
+ eArgTypePythonFunction,
+ eArgTypePythonScript,
+ eArgTypeQueueName,
+ eArgTypeRegisterName,
+ eArgTypeRegularExpression,
+ eArgTypeRunArgs,
+ eArgTypeRunMode,
+ eArgTypeScriptedCommandSynchronicity,
+ eArgTypeScriptLang,
+ eArgTypeSearchWord,
+ eArgTypeSelector,
+ eArgTypeSettingIndex,
+ eArgTypeSettingKey,
+ eArgTypeSettingPrefix,
+ eArgTypeSettingVariableName,
+ eArgTypeShlibName,
+ eArgTypeSourceFile,
+ eArgTypeSortOrder,
+ eArgTypeStartAddress,
+ eArgTypeSummaryString,
+ eArgTypeSymbol,
+ eArgTypeThreadID,
+ eArgTypeThreadIndex,
+ eArgTypeThreadName,
+ eArgTypeTypeName,
+ eArgTypeUnsignedInteger,
+ eArgTypeUnixSignal,
+ eArgTypeVarName,
+ eArgTypeValue,
+ eArgTypeWidth,
+ eArgTypeNone,
+ eArgTypePlatform,
+ eArgTypeWatchpointID,
+ eArgTypeWatchpointIDRange,
+ eArgTypeWatchType,
+ eArgRawInput,
+ eArgTypeLastArg // Always keep this entry as the last entry in this
+ // enumeration!!
+};
- FLAGS_ENUM(FunctionNameType)
- {
- eFunctionNameTypeNone = 0u,
- eFunctionNameTypeAuto = (1u << 1), // Automatically figure out which FunctionNameType
- // bits to set based on the function name.
- eFunctionNameTypeFull = (1u << 2), // The function name.
- // For C this is the same as just the name of the function
- // For C++ this is the mangled or demangled version of the mangled name.
- // For ObjC this is the full function signature with the + or
- // - and the square brackets and the class and selector
- eFunctionNameTypeBase = (1u << 3), // The function name only, no namespaces or arguments and no class
- // methods or selectors will be searched.
- eFunctionNameTypeMethod = (1u << 4), // Find function by method name (C++) with no namespace or arguments
- eFunctionNameTypeSelector = (1u << 5), // Find function by selector name (ObjC) names
- eFunctionNameTypeAny = eFunctionNameTypeAuto // DEPRECATED: use eFunctionNameTypeAuto
- };
-
-
- //----------------------------------------------------------------------
- // Basic types enumeration for the public API SBType::GetBasicType()
- //----------------------------------------------------------------------
- enum BasicType
- {
- eBasicTypeInvalid = 0,
- eBasicTypeVoid = 1,
- eBasicTypeChar,
- eBasicTypeSignedChar,
- eBasicTypeUnsignedChar,
- eBasicTypeWChar,
- eBasicTypeSignedWChar,
- eBasicTypeUnsignedWChar,
- eBasicTypeChar16,
- eBasicTypeChar32,
- eBasicTypeShort,
- eBasicTypeUnsignedShort,
- eBasicTypeInt,
- eBasicTypeUnsignedInt,
- eBasicTypeLong,
- eBasicTypeUnsignedLong,
- eBasicTypeLongLong,
- eBasicTypeUnsignedLongLong,
- eBasicTypeInt128,
- eBasicTypeUnsignedInt128,
- eBasicTypeBool,
- eBasicTypeHalf,
- eBasicTypeFloat,
- eBasicTypeDouble,
- eBasicTypeLongDouble,
- eBasicTypeFloatComplex,
- eBasicTypeDoubleComplex,
- eBasicTypeLongDoubleComplex,
- eBasicTypeObjCID,
- eBasicTypeObjCClass,
- eBasicTypeObjCSel,
- eBasicTypeNullPtr,
- eBasicTypeOther
- };
+//----------------------------------------------------------------------
+// Symbol types
+//----------------------------------------------------------------------
+enum SymbolType {
+ eSymbolTypeAny = 0,
+ eSymbolTypeInvalid = 0,
+ eSymbolTypeAbsolute,
+ eSymbolTypeCode,
+ eSymbolTypeResolver,
+ eSymbolTypeData,
+ eSymbolTypeTrampoline,
+ eSymbolTypeRuntime,
+ eSymbolTypeException,
+ eSymbolTypeSourceFile,
+ eSymbolTypeHeaderFile,
+ eSymbolTypeObjectFile,
+ eSymbolTypeCommonBlock,
+ eSymbolTypeBlock,
+ eSymbolTypeLocal,
+ eSymbolTypeParam,
+ eSymbolTypeVariable,
+ eSymbolTypeVariableType,
+ eSymbolTypeLineEntry,
+ eSymbolTypeLineHeader,
+ eSymbolTypeScopeBegin,
+ eSymbolTypeScopeEnd,
+ eSymbolTypeAdditional, // When symbols take more than one entry, the extra
+ // entries get this type
+ eSymbolTypeCompiler,
+ eSymbolTypeInstrumentation,
+ eSymbolTypeUndefined,
+ eSymbolTypeObjCClass,
+ eSymbolTypeObjCMetaClass,
+ eSymbolTypeObjCIVar,
+ eSymbolTypeReExported
+};
- FLAGS_ENUM(TypeClass)
- {
- eTypeClassInvalid = (0u),
- eTypeClassArray = (1u << 0),
- eTypeClassBlockPointer = (1u << 1),
- eTypeClassBuiltin = (1u << 2),
- eTypeClassClass = (1u << 3),
- eTypeClassComplexFloat = (1u << 4),
- eTypeClassComplexInteger = (1u << 5),
- eTypeClassEnumeration = (1u << 6),
- eTypeClassFunction = (1u << 7),
- eTypeClassMemberPointer = (1u << 8),
- eTypeClassObjCObject = (1u << 9),
- eTypeClassObjCInterface = (1u << 10),
- eTypeClassObjCObjectPointer = (1u << 11),
- eTypeClassPointer = (1u << 12),
- eTypeClassReference = (1u << 13),
- eTypeClassStruct = (1u << 14),
- eTypeClassTypedef = (1u << 15),
- eTypeClassUnion = (1u << 16),
- eTypeClassVector = (1u << 17),
- // Define the last type class as the MSBit of a 32 bit value
- eTypeClassOther = (1u << 31),
- // Define a mask that can be used for any type when finding types
- eTypeClassAny = (0xffffffffu)
- };
+enum SectionType {
+ eSectionTypeInvalid,
+ eSectionTypeCode,
+ eSectionTypeContainer, // The section contains child sections
+ eSectionTypeData,
+ eSectionTypeDataCString, // Inlined C string data
+ eSectionTypeDataCStringPointers, // Pointers to C string data
+ eSectionTypeDataSymbolAddress, // Address of a symbol in the symbol table
+ eSectionTypeData4,
+ eSectionTypeData8,
+ eSectionTypeData16,
+ eSectionTypeDataPointers,
+ eSectionTypeDebug,
+ eSectionTypeZeroFill,
+ eSectionTypeDataObjCMessageRefs, // Pointer to function pointer + selector
+ eSectionTypeDataObjCCFStrings, // Objective C const CFString/NSString objects
+ eSectionTypeDWARFDebugAbbrev,
+ eSectionTypeDWARFDebugAddr,
+ eSectionTypeDWARFDebugAranges,
+ eSectionTypeDWARFDebugFrame,
+ eSectionTypeDWARFDebugInfo,
+ eSectionTypeDWARFDebugLine,
+ eSectionTypeDWARFDebugLoc,
+ eSectionTypeDWARFDebugMacInfo,
+ eSectionTypeDWARFDebugMacro,
+ eSectionTypeDWARFDebugPubNames,
+ eSectionTypeDWARFDebugPubTypes,
+ eSectionTypeDWARFDebugRanges,
+ eSectionTypeDWARFDebugStr,
+ eSectionTypeDWARFDebugStrOffsets,
+ eSectionTypeDWARFAppleNames,
+ eSectionTypeDWARFAppleTypes,
+ eSectionTypeDWARFAppleNamespaces,
+ eSectionTypeDWARFAppleObjC,
+ eSectionTypeELFSymbolTable, // Elf SHT_SYMTAB section
+ eSectionTypeELFDynamicSymbols, // Elf SHT_DYNSYM section
+ eSectionTypeELFRelocationEntries, // Elf SHT_REL or SHT_REL section
+ eSectionTypeELFDynamicLinkInfo, // Elf SHT_DYNAMIC section
+ eSectionTypeEHFrame,
+ eSectionTypeARMexidx,
+ eSectionTypeARMextab,
+ eSectionTypeCompactUnwind, // compact unwind section in Mach-O,
+ // __TEXT,__unwind_info
+ eSectionTypeGoSymtab,
+ eSectionTypeAbsoluteAddress, // Dummy section for symbols with absolute
+ // address
+ eSectionTypeOther
+};
- enum TemplateArgumentKind
- {
- eTemplateArgumentKindNull = 0,
- eTemplateArgumentKindType,
- eTemplateArgumentKindDeclaration,
- eTemplateArgumentKindIntegral,
- eTemplateArgumentKindTemplate,
- eTemplateArgumentKindTemplateExpansion,
- eTemplateArgumentKindExpression,
- eTemplateArgumentKindPack
+FLAGS_ENUM(EmulateInstructionOptions){
+ eEmulateInstructionOptionNone = (0u),
+ eEmulateInstructionOptionAutoAdvancePC = (1u << 0),
+ eEmulateInstructionOptionIgnoreConditions = (1u << 1)};
- };
+FLAGS_ENUM(FunctionNameType){
+ eFunctionNameTypeNone = 0u,
+ eFunctionNameTypeAuto =
+ (1u << 1), // Automatically figure out which FunctionNameType
+ // bits to set based on the function name.
+ eFunctionNameTypeFull = (1u << 2), // The function name.
+ // For C this is the same as just the name of the function
+ // For C++ this is the mangled or demangled version of the mangled name.
+ // For ObjC this is the full function signature with the + or
+ // - and the square brackets and the class and selector
+ eFunctionNameTypeBase = (1u << 3), // The function name only, no namespaces
+ // or arguments and no class
+ // methods or selectors will be searched.
+ eFunctionNameTypeMethod = (1u << 4), // Find function by method name (C++)
+ // with no namespace or arguments
+ eFunctionNameTypeSelector =
+ (1u << 5), // Find function by selector name (ObjC) names
+ eFunctionNameTypeAny =
+ eFunctionNameTypeAuto // DEPRECATED: use eFunctionNameTypeAuto
+};
- //----------------------------------------------------------------------
- // Options that can be set for a formatter to alter its behavior
- // Not all of these are applicable to all formatter types
- //----------------------------------------------------------------------
- FLAGS_ENUM(TypeOptions)
- {
- eTypeOptionNone = (0u),
- eTypeOptionCascade = (1u << 0),
- eTypeOptionSkipPointers = (1u << 1),
- eTypeOptionSkipReferences = (1u << 2),
- eTypeOptionHideChildren = (1u << 3),
- eTypeOptionHideValue = (1u << 4),
- eTypeOptionShowOneLiner = (1u << 5),
- eTypeOptionHideNames = (1u << 6),
- eTypeOptionNonCacheable = (1u << 7),
- eTypeOptionHideEmptyAggregates = (1u << 8)
- };
+//----------------------------------------------------------------------
+// Basic types enumeration for the public API SBType::GetBasicType()
+//----------------------------------------------------------------------
+enum BasicType {
+ eBasicTypeInvalid = 0,
+ eBasicTypeVoid = 1,
+ eBasicTypeChar,
+ eBasicTypeSignedChar,
+ eBasicTypeUnsignedChar,
+ eBasicTypeWChar,
+ eBasicTypeSignedWChar,
+ eBasicTypeUnsignedWChar,
+ eBasicTypeChar16,
+ eBasicTypeChar32,
+ eBasicTypeShort,
+ eBasicTypeUnsignedShort,
+ eBasicTypeInt,
+ eBasicTypeUnsignedInt,
+ eBasicTypeLong,
+ eBasicTypeUnsignedLong,
+ eBasicTypeLongLong,
+ eBasicTypeUnsignedLongLong,
+ eBasicTypeInt128,
+ eBasicTypeUnsignedInt128,
+ eBasicTypeBool,
+ eBasicTypeHalf,
+ eBasicTypeFloat,
+ eBasicTypeDouble,
+ eBasicTypeLongDouble,
+ eBasicTypeFloatComplex,
+ eBasicTypeDoubleComplex,
+ eBasicTypeLongDoubleComplex,
+ eBasicTypeObjCID,
+ eBasicTypeObjCClass,
+ eBasicTypeObjCSel,
+ eBasicTypeNullPtr,
+ eBasicTypeOther
+};
+
+FLAGS_ENUM(TypeClass){
+ eTypeClassInvalid = (0u), eTypeClassArray = (1u << 0),
+ eTypeClassBlockPointer = (1u << 1), eTypeClassBuiltin = (1u << 2),
+ eTypeClassClass = (1u << 3), eTypeClassComplexFloat = (1u << 4),
+ eTypeClassComplexInteger = (1u << 5), eTypeClassEnumeration = (1u << 6),
+ eTypeClassFunction = (1u << 7), eTypeClassMemberPointer = (1u << 8),
+ eTypeClassObjCObject = (1u << 9), eTypeClassObjCInterface = (1u << 10),
+ eTypeClassObjCObjectPointer = (1u << 11), eTypeClassPointer = (1u << 12),
+ eTypeClassReference = (1u << 13), eTypeClassStruct = (1u << 14),
+ eTypeClassTypedef = (1u << 15), eTypeClassUnion = (1u << 16),
+ eTypeClassVector = (1u << 17),
+ // Define the last type class as the MSBit of a 32 bit value
+ eTypeClassOther = (1u << 31),
+ // Define a mask that can be used for any type when finding types
+ eTypeClassAny = (0xffffffffu)};
+
+enum TemplateArgumentKind {
+ eTemplateArgumentKindNull = 0,
+ eTemplateArgumentKindType,
+ eTemplateArgumentKindDeclaration,
+ eTemplateArgumentKindIntegral,
+ eTemplateArgumentKindTemplate,
+ eTemplateArgumentKindTemplateExpansion,
+ eTemplateArgumentKindExpression,
+ eTemplateArgumentKindPack
+
+};
- //----------------------------------------------------------------------
- // This is the return value for frame comparisons. If you are comparing frame A to frame B
- // the following cases arise:
- // 1) When frame A pushes frame B (or a frame that ends up pushing B) A is Older than B.
- // 2) When frame A pushed frame B (or if frame A is on the stack but B is not) A is Younger than B
- // 3) When frame A and frame B have the same StackID, they are Equal.
- // 4) When frame A and frame B have the same immediate parent frame, but are not equal, the comparision yields
- // SameParent.
- // 5) If the two frames are on different threads or processes the comparision is Invalid
- // 6) If for some reason we can't figure out what went on, we return Unknown.
- //----------------------------------------------------------------------
- enum FrameComparison
- {
- eFrameCompareInvalid,
- eFrameCompareUnknown,
- eFrameCompareEqual,
- eFrameCompareSameParent,
- eFrameCompareYounger,
- eFrameCompareOlder
- };
-
+//----------------------------------------------------------------------
+// Options that can be set for a formatter to alter its behavior
+// Not all of these are applicable to all formatter types
+//----------------------------------------------------------------------
+FLAGS_ENUM(TypeOptions){eTypeOptionNone = (0u),
+ eTypeOptionCascade = (1u << 0),
+ eTypeOptionSkipPointers = (1u << 1),
+ eTypeOptionSkipReferences = (1u << 2),
+ eTypeOptionHideChildren = (1u << 3),
+ eTypeOptionHideValue = (1u << 4),
+ eTypeOptionShowOneLiner = (1u << 5),
+ eTypeOptionHideNames = (1u << 6),
+ eTypeOptionNonCacheable = (1u << 7),
+ eTypeOptionHideEmptyAggregates = (1u << 8)};
+
+//----------------------------------------------------------------------
+// This is the return value for frame comparisons. If you are comparing frame A
+// to frame B
+// the following cases arise:
+// 1) When frame A pushes frame B (or a frame that ends up pushing B) A is Older
+// than B.
+// 2) When frame A pushed frame B (or if frame A is on the stack but B is not) A
+// is Younger than B
+// 3) When frame A and frame B have the same StackID, they are Equal.
+// 4) When frame A and frame B have the same immediate parent frame, but are not
+// equal, the comparison yields
+// SameParent.
+// 5) If the two frames are on different threads or processes the comparison is
+// Invalid
+// 6) If for some reason we can't figure out what went on, we return Unknown.
+//----------------------------------------------------------------------
+enum FrameComparison {
+ eFrameCompareInvalid,
+ eFrameCompareUnknown,
+ eFrameCompareEqual,
+ eFrameCompareSameParent,
+ eFrameCompareYounger,
+ eFrameCompareOlder
+};
+
+//----------------------------------------------------------------------
+// Address Class
+//
+// A way of classifying an address used for disassembling and setting
+// breakpoints. Many object files can track exactly what parts of their
+// object files are code, data and other information. This is of course
+// above and beyond just looking at the section types. For example, code
+// might contain PC relative data and the object file might be able to
+// tell us that an address in code is data.
+//----------------------------------------------------------------------
+enum AddressClass {
+ eAddressClassInvalid,
+ eAddressClassUnknown,
+ eAddressClassCode,
+ eAddressClassCodeAlternateISA,
+ eAddressClassData,
+ eAddressClassDebug,
+ eAddressClassRuntime
+};
+
+//----------------------------------------------------------------------
+// File Permissions
+//
+// Designed to mimic the unix file permission bits so they can be
+// used with functions that set 'mode_t' to certain values for
+// permissions.
+//----------------------------------------------------------------------
+FLAGS_ENUM(FilePermissions){
+ eFilePermissionsUserRead = (1u << 8), eFilePermissionsUserWrite = (1u << 7),
+ eFilePermissionsUserExecute = (1u << 6),
+ eFilePermissionsGroupRead = (1u << 5),
+ eFilePermissionsGroupWrite = (1u << 4),
+ eFilePermissionsGroupExecute = (1u << 3),
+ eFilePermissionsWorldRead = (1u << 2),
+ eFilePermissionsWorldWrite = (1u << 1),
+ eFilePermissionsWorldExecute = (1u << 0),
+
+ eFilePermissionsUserRW = (eFilePermissionsUserRead |
+ eFilePermissionsUserWrite | 0),
+ eFileFilePermissionsUserRX = (eFilePermissionsUserRead | 0 |
+ eFilePermissionsUserExecute),
+ eFilePermissionsUserRWX = (eFilePermissionsUserRead |
+ eFilePermissionsUserWrite |
+ eFilePermissionsUserExecute),
+
+ eFilePermissionsGroupRW = (eFilePermissionsGroupRead |
+ eFilePermissionsGroupWrite | 0),
+ eFilePermissionsGroupRX = (eFilePermissionsGroupRead | 0 |
+ eFilePermissionsGroupExecute),
+ eFilePermissionsGroupRWX = (eFilePermissionsGroupRead |
+ eFilePermissionsGroupWrite |
+ eFilePermissionsGroupExecute),
+
+ eFilePermissionsWorldRW = (eFilePermissionsWorldRead |
+ eFilePermissionsWorldWrite | 0),
+ eFilePermissionsWorldRX = (eFilePermissionsWorldRead | 0 |
+ eFilePermissionsWorldExecute),
+ eFilePermissionsWorldRWX = (eFilePermissionsWorldRead |
+ eFilePermissionsWorldWrite |
+ eFilePermissionsWorldExecute),
+
+ eFilePermissionsEveryoneR = (eFilePermissionsUserRead |
+ eFilePermissionsGroupRead |
+ eFilePermissionsWorldRead),
+ eFilePermissionsEveryoneW = (eFilePermissionsUserWrite |
+ eFilePermissionsGroupWrite |
+ eFilePermissionsWorldWrite),
+ eFilePermissionsEveryoneX = (eFilePermissionsUserExecute |
+ eFilePermissionsGroupExecute |
+ eFilePermissionsWorldExecute),
+
+ eFilePermissionsEveryoneRW = (eFilePermissionsEveryoneR |
+ eFilePermissionsEveryoneW | 0),
+ eFilePermissionsEveryoneRX = (eFilePermissionsEveryoneR | 0 |
+ eFilePermissionsEveryoneX),
+ eFilePermissionsEveryoneRWX = (eFilePermissionsEveryoneR |
+ eFilePermissionsEveryoneW |
+ eFilePermissionsEveryoneX),
+ eFilePermissionsFileDefault = eFilePermissionsUserRW,
+ eFilePermissionsDirectoryDefault = eFilePermissionsUserRWX,
+};
+
+//----------------------------------------------------------------------
+// Queue work item types
+//
+// The different types of work that can be enqueued on a libdispatch
+// aka Grand Central Dispatch (GCD) queue.
+//----------------------------------------------------------------------
+enum QueueItemKind {
+ eQueueItemKindUnknown = 0,
+ eQueueItemKindFunction,
+ eQueueItemKindBlock
+};
+
+//----------------------------------------------------------------------
+// Queue type
+// libdispatch aka Grand Central Dispatch (GCD) queues can be either serial
+// (executing on one thread) or concurrent (executing on multiple threads).
+//----------------------------------------------------------------------
+enum QueueKind {
+ eQueueKindUnknown = 0,
+ eQueueKindSerial,
+ eQueueKindConcurrent
+};
+
+//----------------------------------------------------------------------
+// Expression Evaluation Stages
+// These are the cancellable stages of expression evaluation, passed to the
+// expression evaluation callback, so that you can interrupt expression
+// evaluation at the various points in its lifecycle.
+//----------------------------------------------------------------------
+enum ExpressionEvaluationPhase {
+ eExpressionEvaluationParse = 0,
+ eExpressionEvaluationIRGen,
+ eExpressionEvaluationExecution,
+ eExpressionEvaluationComplete
+};
+
+//----------------------------------------------------------------------
+// Watchpoint Kind
+// Indicates what types of events cause the watchpoint to fire.
+// Used by Native*Protocol-related classes.
+//----------------------------------------------------------------------
+FLAGS_ENUM(WatchpointKind){eWatchpointKindRead = (1u << 0),
+ eWatchpointKindWrite = (1u << 1)};
+
+enum GdbSignal {
+ eGdbSignalBadAccess = 0x91,
+ eGdbSignalBadInstruction = 0x92,
+ eGdbSignalArithmetic = 0x93,
+ eGdbSignalEmulation = 0x94,
+ eGdbSignalSoftware = 0x95,
+ eGdbSignalBreakpoint = 0x96
+};
+
+//----------------------------------------------------------------------
+// Used with SBHost::GetPath (lldb::PathType) to find files that are
+// related to LLDB on the current host machine. Most files are relative
+// to LLDB or are in known locations.
+//----------------------------------------------------------------------
+enum PathType {
+ ePathTypeLLDBShlibDir, // The directory where the lldb.so (unix) or LLDB
+ // mach-o file in LLDB.framework (MacOSX) exists
+ ePathTypeSupportExecutableDir, // Find LLDB support executable directory
+ // (debugserver, etc)
+ ePathTypeHeaderDir, // Find LLDB header file directory
+ ePathTypePythonDir, // Find Python modules (PYTHONPATH) directory
+ ePathTypeLLDBSystemPlugins, // System plug-ins directory
+ ePathTypeLLDBUserPlugins, // User plug-ins directory
+ ePathTypeLLDBTempSystemDir, // The LLDB temp directory for this system that
+ // will be cleaned up on exit
+ ePathTypeGlobalLLDBTempSystemDir, // The LLDB temp directory for this system,
+ // NOT cleaned up on a process exit.
+ ePathTypeClangDir // Find path to Clang builtin headers
+};
+
+//----------------------------------------------------------------------
+// Kind of member function
+// Used by the type system
+//----------------------------------------------------------------------
+enum MemberFunctionKind {
+ eMemberFunctionKindUnknown = 0, // Not sure what the type of this is
+ eMemberFunctionKindConstructor, // A function used to create instances
+ eMemberFunctionKindDestructor, // A function used to tear down existing
+ // instances
+ eMemberFunctionKindInstanceMethod, // A function that applies to a specific
+ // instance
+ eMemberFunctionKindStaticMethod // A function that applies to a type rather
+ // than any instance
+};
+
+//----------------------------------------------------------------------
+// String matching algorithm used by SBTarget
+//----------------------------------------------------------------------
+enum MatchType { eMatchTypeNormal, eMatchTypeRegex, eMatchTypeStartsWith };
+
+//----------------------------------------------------------------------
+// Bitmask that describes details about a type
+//----------------------------------------------------------------------
+FLAGS_ENUM(TypeFlags){
+ eTypeHasChildren = (1u << 0), eTypeHasValue = (1u << 1),
+ eTypeIsArray = (1u << 2), eTypeIsBlock = (1u << 3),
+ eTypeIsBuiltIn = (1u << 4), eTypeIsClass = (1u << 5),
+ eTypeIsCPlusPlus = (1u << 6), eTypeIsEnumeration = (1u << 7),
+ eTypeIsFuncPrototype = (1u << 8), eTypeIsMember = (1u << 9),
+ eTypeIsObjC = (1u << 10), eTypeIsPointer = (1u << 11),
+ eTypeIsReference = (1u << 12), eTypeIsStructUnion = (1u << 13),
+ eTypeIsTemplate = (1u << 14), eTypeIsTypedef = (1u << 15),
+ eTypeIsVector = (1u << 16), eTypeIsScalar = (1u << 17),
+ eTypeIsInteger = (1u << 18), eTypeIsFloat = (1u << 19),
+ eTypeIsComplex = (1u << 20), eTypeIsSigned = (1u << 21),
+ eTypeInstanceIsPointer = (1u << 22)};
+
+FLAGS_ENUM(CommandFlags){
//----------------------------------------------------------------------
- // Address Class
+ // eCommandRequiresTarget
//
- // A way of classifying an address used for disassembling and setting
- // breakpoints. Many object files can track exactly what parts of their
- // object files are code, data and other information. This is of course
- // above and beyond just looking at the section types. For example, code
- // might contain PC relative data and the object file might be able to
- // tell us that an address in code is data.
+ // Ensures a valid target is contained in m_exe_ctx prior to executing
+ // the command. If a target doesn't exist or is invalid, the command
+ // will fail and CommandObject::GetInvalidTargetDescription() will be
+ // returned as the error. CommandObject subclasses can override the
+ // virtual function for GetInvalidTargetDescription() to provide custom
+ // strings when needed.
//----------------------------------------------------------------------
- enum AddressClass
- {
- eAddressClassInvalid,
- eAddressClassUnknown,
- eAddressClassCode,
- eAddressClassCodeAlternateISA,
- eAddressClassData,
- eAddressClassDebug,
- eAddressClassRuntime
- };
-
+ eCommandRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
- // File Permissions
+ // eCommandRequiresProcess
//
- // Designed to mimic the unix file permission bits so they can be
- // used with functions that set 'mode_t' to certain values for
- // permissions.
+ // Ensures a valid process is contained in m_exe_ctx prior to executing
+ // the command. If a process doesn't exist or is invalid, the command
+ // will fail and CommandObject::GetInvalidProcessDescription() will be
+ // returned as the error. CommandObject subclasses can override the
+ // virtual function for GetInvalidProcessDescription() to provide custom
+ // strings when needed.
//----------------------------------------------------------------------
- FLAGS_ENUM(FilePermissions)
- {
- eFilePermissionsUserRead = (1u << 8),
- eFilePermissionsUserWrite = (1u << 7),
- eFilePermissionsUserExecute = (1u << 6),
- eFilePermissionsGroupRead = (1u << 5),
- eFilePermissionsGroupWrite = (1u << 4),
- eFilePermissionsGroupExecute = (1u << 3),
- eFilePermissionsWorldRead = (1u << 2),
- eFilePermissionsWorldWrite = (1u << 1),
- eFilePermissionsWorldExecute = (1u << 0),
-
- eFilePermissionsUserRW = (eFilePermissionsUserRead | eFilePermissionsUserWrite | 0 ),
- eFileFilePermissionsUserRX = (eFilePermissionsUserRead | 0 | eFilePermissionsUserExecute ),
- eFilePermissionsUserRWX = (eFilePermissionsUserRead | eFilePermissionsUserWrite | eFilePermissionsUserExecute ),
-
- eFilePermissionsGroupRW = (eFilePermissionsGroupRead | eFilePermissionsGroupWrite | 0 ),
- eFilePermissionsGroupRX = (eFilePermissionsGroupRead | 0 | eFilePermissionsGroupExecute ),
- eFilePermissionsGroupRWX = (eFilePermissionsGroupRead | eFilePermissionsGroupWrite | eFilePermissionsGroupExecute ),
-
- eFilePermissionsWorldRW = (eFilePermissionsWorldRead | eFilePermissionsWorldWrite | 0 ),
- eFilePermissionsWorldRX = (eFilePermissionsWorldRead | 0 | eFilePermissionsWorldExecute ),
- eFilePermissionsWorldRWX = (eFilePermissionsWorldRead | eFilePermissionsWorldWrite | eFilePermissionsWorldExecute ),
-
- eFilePermissionsEveryoneR = (eFilePermissionsUserRead | eFilePermissionsGroupRead | eFilePermissionsWorldRead ),
- eFilePermissionsEveryoneW = (eFilePermissionsUserWrite | eFilePermissionsGroupWrite | eFilePermissionsWorldWrite ),
- eFilePermissionsEveryoneX = (eFilePermissionsUserExecute | eFilePermissionsGroupExecute | eFilePermissionsWorldExecute ),
-
- eFilePermissionsEveryoneRW = (eFilePermissionsEveryoneR | eFilePermissionsEveryoneW | 0 ),
- eFilePermissionsEveryoneRX = (eFilePermissionsEveryoneR | 0 | eFilePermissionsEveryoneX ),
- eFilePermissionsEveryoneRWX = (eFilePermissionsEveryoneR | eFilePermissionsEveryoneW | eFilePermissionsEveryoneX ),
- eFilePermissionsFileDefault = eFilePermissionsUserRW,
- eFilePermissionsDirectoryDefault = eFilePermissionsUserRWX,
- };
-
+ eCommandRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
- // Queue work item types
+ // eCommandRequiresThread
//
- // The different types of work that can be enqueued on a libdispatch
- // aka Grand Central Dispatch (GCD) queue.
+ // Ensures a valid thread is contained in m_exe_ctx prior to executing
+ // the command. If a thread doesn't exist or is invalid, the command
+ // will fail and CommandObject::GetInvalidThreadDescription() will be
+ // returned as the error. CommandObject subclasses can override the
+ // virtual function for GetInvalidThreadDescription() to provide custom
+ // strings when needed.
//----------------------------------------------------------------------
- enum QueueItemKind
- {
- eQueueItemKindUnknown = 0,
- eQueueItemKindFunction,
- eQueueItemKindBlock
- };
-
+ eCommandRequiresThread = (1u << 2),
//----------------------------------------------------------------------
- // Queue type
- // libdispatch aka Grand Central Dispatch (GCD) queues can be either serial
- // (executing on one thread) or concurrent (executing on multiple threads).
+ // eCommandRequiresFrame
+ //
+ // Ensures a valid frame is contained in m_exe_ctx prior to executing
+ // the command. If a frame doesn't exist or is invalid, the command
+ // will fail and CommandObject::GetInvalidFrameDescription() will be
+ // returned as the error. CommandObject subclasses can override the
+ // virtual function for GetInvalidFrameDescription() to provide custom
+ // strings when needed.
//----------------------------------------------------------------------
- enum QueueKind
- {
- eQueueKindUnknown = 0,
- eQueueKindSerial,
- eQueueKindConcurrent
- };
-
+ eCommandRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
- // Expression Evaluation Stages
- // These are the cancellable stages of expression evaluation, passed to the
- // expression evaluation callback, so that you can interrupt expression
- // evaluation at the various points in its lifecycle.
+ // eCommandRequiresRegContext
+ //
+ // Ensures a valid register context (from the selected frame if there
+ // is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
+ // is available from m_exe_ctx prior to executing the command. If a
+ // target doesn't exist or is invalid, the command will fail and
+ // CommandObject::GetInvalidRegContextDescription() will be returned as
+ // the error. CommandObject subclasses can override the virtual function
+ // for GetInvalidRegContextDescription() to provide custom strings when
+ // needed.
//----------------------------------------------------------------------
- enum ExpressionEvaluationPhase
- {
- eExpressionEvaluationParse = 0,
- eExpressionEvaluationIRGen,
- eExpressionEvaluationExecution,
- eExpressionEvaluationComplete
- };
-
-
+ eCommandRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
- // Watchpoint Kind
- // Indicates what types of events cause the watchpoint to fire.
- // Used by Native*Protocol-related classes.
+ // eCommandTryTargetAPILock
+ //
+ // Attempts to acquire the target lock if a target is selected in the
+ // command interpreter. If the command object fails to acquire the API
+ // lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
- FLAGS_ENUM(WatchpointKind)
- {
- eWatchpointKindRead = (1u << 0),
- eWatchpointKindWrite = (1u << 1)
- };
-
- enum GdbSignal
- {
- eGdbSignalBadAccess = 0x91,
- eGdbSignalBadInstruction = 0x92,
- eGdbSignalArithmetic = 0x93,
- eGdbSignalEmulation = 0x94,
- eGdbSignalSoftware = 0x95,
- eGdbSignalBreakpoint = 0x96
- };
-
+ eCommandTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
- // Used with SBHost::GetPath (lldb::PathType) to find files that are
- // related to LLDB on the current host machine. Most files are relative
- // to LLDB or are in known locations.
+ // eCommandProcessMustBeLaunched
+ //
+ // Verifies that there is a launched process in m_exe_ctx, if there
+ // isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
- enum PathType
- {
- ePathTypeLLDBShlibDir, // The directory where the lldb.so (unix) or LLDB mach-o file in LLDB.framework (MacOSX) exists
- ePathTypeSupportExecutableDir, // Find LLDB support executable directory (debugserver, etc)
- ePathTypeHeaderDir, // Find LLDB header file directory
- ePathTypePythonDir, // Find Python modules (PYTHONPATH) directory
- ePathTypeLLDBSystemPlugins, // System plug-ins directory
- ePathTypeLLDBUserPlugins, // User plug-ins directory
- ePathTypeLLDBTempSystemDir, // The LLDB temp directory for this system that will be cleaned up on exit
- ePathTypeGlobalLLDBTempSystemDir, // The LLDB temp directory for this system, NOT cleaned up on a process exit.
- ePathTypeClangDir // Find path to Clang builtin headers
- };
-
+ eCommandProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
- // Kind of member function
- // Used by the type system
+ // eCommandProcessMustBePaused
+ //
+ // Verifies that there is a paused process in m_exe_ctx, if there
+ // isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
- enum MemberFunctionKind
- {
- eMemberFunctionKindUnknown = 0, // Not sure what the type of this is
- eMemberFunctionKindConstructor, // A function used to create instances
- eMemberFunctionKindDestructor, // A function used to tear down existing instances
- eMemberFunctionKindInstanceMethod, // A function that applies to a specific instance
- eMemberFunctionKindStaticMethod // A function that applies to a type rather than any instance
- };
-
+ eCommandProcessMustBePaused = (1u << 7)};
- //----------------------------------------------------------------------
- // String matching algorithm used by SBTarget
- //----------------------------------------------------------------------
- enum MatchType
- {
- eMatchTypeNormal,
- eMatchTypeRegex,
- eMatchTypeStartsWith
- };
-
- //----------------------------------------------------------------------
- // Bitmask that describes details about a type
- //----------------------------------------------------------------------
- FLAGS_ENUM(TypeFlags)
- {
- eTypeHasChildren = (1u << 0),
- eTypeHasValue = (1u << 1),
- eTypeIsArray = (1u << 2),
- eTypeIsBlock = (1u << 3),
- eTypeIsBuiltIn = (1u << 4),
- eTypeIsClass = (1u << 5),
- eTypeIsCPlusPlus = (1u << 6),
- eTypeIsEnumeration = (1u << 7),
- eTypeIsFuncPrototype = (1u << 8),
- eTypeIsMember = (1u << 9),
- eTypeIsObjC = (1u << 10),
- eTypeIsPointer = (1u << 11),
- eTypeIsReference = (1u << 12),
- eTypeIsStructUnion = (1u << 13),
- eTypeIsTemplate = (1u << 14),
- eTypeIsTypedef = (1u << 15),
- eTypeIsVector = (1u << 16),
- eTypeIsScalar = (1u << 17),
- eTypeIsInteger = (1u << 18),
- eTypeIsFloat = (1u << 19),
- eTypeIsComplex = (1u << 20),
- eTypeIsSigned = (1u << 21),
- eTypeInstanceIsPointer = (1u << 22)
- };
-
- FLAGS_ENUM(CommandFlags)
- {
- //----------------------------------------------------------------------
- // eCommandRequiresTarget
- //
- // Ensures a valid target is contained in m_exe_ctx prior to executing
- // the command. If a target doesn't exist or is invalid, the command
- // will fail and CommandObject::GetInvalidTargetDescription() will be
- // returned as the error. CommandObject subclasses can override the
- // virtual function for GetInvalidTargetDescription() to provide custom
- // strings when needed.
- //----------------------------------------------------------------------
- eCommandRequiresTarget = (1u << 0),
- //----------------------------------------------------------------------
- // eCommandRequiresProcess
- //
- // Ensures a valid process is contained in m_exe_ctx prior to executing
- // the command. If a process doesn't exist or is invalid, the command
- // will fail and CommandObject::GetInvalidProcessDescription() will be
- // returned as the error. CommandObject subclasses can override the
- // virtual function for GetInvalidProcessDescription() to provide custom
- // strings when needed.
- //----------------------------------------------------------------------
- eCommandRequiresProcess = (1u << 1),
- //----------------------------------------------------------------------
- // eCommandRequiresThread
- //
- // Ensures a valid thread is contained in m_exe_ctx prior to executing
- // the command. If a thread doesn't exist or is invalid, the command
- // will fail and CommandObject::GetInvalidThreadDescription() will be
- // returned as the error. CommandObject subclasses can override the
- // virtual function for GetInvalidThreadDescription() to provide custom
- // strings when needed.
- //----------------------------------------------------------------------
- eCommandRequiresThread = (1u << 2),
- //----------------------------------------------------------------------
- // eCommandRequiresFrame
- //
- // Ensures a valid frame is contained in m_exe_ctx prior to executing
- // the command. If a frame doesn't exist or is invalid, the command
- // will fail and CommandObject::GetInvalidFrameDescription() will be
- // returned as the error. CommandObject subclasses can override the
- // virtual function for GetInvalidFrameDescription() to provide custom
- // strings when needed.
- //----------------------------------------------------------------------
- eCommandRequiresFrame = (1u << 3),
- //----------------------------------------------------------------------
- // eCommandRequiresRegContext
- //
- // Ensures a valid register context (from the selected frame if there
- // is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
- // is available from m_exe_ctx prior to executing the command. If a
- // target doesn't exist or is invalid, the command will fail and
- // CommandObject::GetInvalidRegContextDescription() will be returned as
- // the error. CommandObject subclasses can override the virtual function
- // for GetInvalidRegContextDescription() to provide custom strings when
- // needed.
- //----------------------------------------------------------------------
- eCommandRequiresRegContext = (1u << 4),
- //----------------------------------------------------------------------
- // eCommandTryTargetAPILock
- //
- // Attempts to acquire the target lock if a target is selected in the
- // command interpreter. If the command object fails to acquire the API
- // lock, the command will fail with an appropriate error message.
- //----------------------------------------------------------------------
- eCommandTryTargetAPILock = (1u << 5),
- //----------------------------------------------------------------------
- // eCommandProcessMustBeLaunched
- //
- // Verifies that there is a launched process in m_exe_ctx, if there
- // isn't, the command will fail with an appropriate error message.
- //----------------------------------------------------------------------
- eCommandProcessMustBeLaunched = (1u << 6),
- //----------------------------------------------------------------------
- // eCommandProcessMustBePaused
- //
- // Verifies that there is a paused process in m_exe_ctx, if there
- // isn't, the command will fail with an appropriate error message.
- //----------------------------------------------------------------------
- eCommandProcessMustBePaused = (1u << 7)
- };
-
- //----------------------------------------------------------------------
- // Whether a summary should cap how much data it returns to users or not
- //----------------------------------------------------------------------
- enum TypeSummaryCapping
- {
- eTypeSummaryCapped = true,
- eTypeSummaryUncapped = false
- };
+//----------------------------------------------------------------------
+// Whether a summary should cap how much data it returns to users or not
+//----------------------------------------------------------------------
+enum TypeSummaryCapping {
+ eTypeSummaryCapped = true,
+ eTypeSummaryUncapped = false
+};
} // namespace lldb
-#endif // LLDB_lldb_enumerations_h_
+#endif // LLDB_lldb_enumerations_h_
diff --git a/include/lldb/lldb-forward.h b/include/lldb/lldb-forward.h
index cb7979370849..8f70a59ca5fc 100644
--- a/include/lldb/lldb-forward.h
+++ b/include/lldb/lldb-forward.h
@@ -19,280 +19,281 @@
//----------------------------------------------------------------------
namespace lldb_private {
-class ABI;
-class Address;
-class AddressImpl;
-class AddressRange;
-class AddressResolver;
-class ArchSpec;
-class ArmUnwindInfo;
-class Args;
-class ASTResultSynthesizer;
-class ASTStructExtractor;
-class Baton;
-class Block;
-class Breakpoint;
-class BreakpointID;
-class BreakpointIDList;
-class BreakpointList;
-class BreakpointLocation;
-class BreakpointLocationCollection;
-class BreakpointLocationList;
-class BreakpointOptions;
-class BreakpointResolver;
-class BreakpointSite;
-class BreakpointSiteList;
-class BroadcastEventSpec;
-class Broadcaster;
-class BroadcasterManager;
-class CPPLanguageRuntime;
-class ClangASTContext;
-class ClangASTImporter;
-class ClangASTMetadata;
-class ClangASTSource;
-class ClangExpressionDeclMap;
-class ClangExpressionParser;
-class ClangExpressionVariable;
-class ClangExpressionVariables;
-class ClangModulesDeclVendor;
-class ClangPersistentVariables;
-class CommandInterpreter;
-class CommandInterpreterRunOptions;
-class CommandObject;
-class CommandObjectMultiword;
-class CommandReturnObject;
-class Communication;
-class CompactUnwindInfo;
-struct CompilerContext;
-class CompilerDecl;
-class CompilerDeclContext;
-class CompilerType;
-class CompileUnit;
-class Condition;
-class Connection;
-class ConnectionFileDescriptor;
-class ConstString;
-class CXXSyntheticChildren;
-class DWARFCallFrameInfo;
-class DWARFExpression;
-class DataBuffer;
-class DataEncoder;
-class DataExtractor;
-class Debugger;
-class Declaration;
-class DiagnosticManager;
-class Disassembler;
-class DumpValueObjectOptions;
-class DynamicCheckerFunctions;
-class DynamicLoader;
-class Editline;
-class EmulateInstruction;
-class Error;
-class EvaluateExpressionOptions;
-class Event;
-class EventData;
-class ExecutionContext;
-class ExecutionContextRef;
-class ExecutionContextRefLocker;
-class ExecutionContextScope;
-class Expression;
-class ExpressionVariable;
-class ExpressionVariableList;
-class ExpressionTypeSystemHelper;
-class File;
-class FileSpec;
-class FileSpecList;
-class Flags;
-class GoASTContext;
-class TypeCategoryImpl;
-class FormatManager;
-class FormattersMatchCandidate;
-class FuncUnwinders;
-class Function;
-class FunctionInfo;
-class InlineFunctionInfo;
-class Instruction;
-class InstructionList;
-class InstrumentationRuntime;
-class IOHandler;
-class IOObject;
-class IRExecutionUnit;
-class JITLoader;
-class JITLoaderList;
-class Language;
-class LanguageCategory;
-class LanguageRuntime;
-class MemoryRegionInfo;
-class LineTable;
-class Listener;
-class Log;
-class LogChannel;
-class Mangled;
-class Materializer;
-class MemoryHistory;
-class Module;
-class ModuleList;
-class ModuleSpec;
-class ModuleSpecList;
-class Mutex;
-struct NameSearchContext;
-class ObjCLanguageRuntime;
-class ObjCRuntimeSyntheticProvider;
-class ObjectContainer;
-class OptionGroup;
-class OptionGroupOptions;
-class OptionGroupPlatform;
-class ObjectFile;
-class ObjectFileJITDelegate;
-class OperatingSystem;
-class Options;
-class OptionValue;
-class OptionValueArch;
-class OptionValueArgs;
-class OptionValueArray;
-class OptionValueBoolean;
-class OptionValueChar;
-class OptionValueDictionary;
-class OptionValueEnumeration;
-class OptionValueFileSpec;
-class OptionValueFileSpecList;
-class OptionValueFormat;
-class OptionValueLanguage;
-class OptionValueFormatEntity;
-class OptionValuePathMappings;
-class OptionValueProperties;
-class OptionValueRegex;
-class OptionValueSInt64;
-class OptionValueString;
-class OptionValueUInt64;
-class OptionValueUUID;
-class NamedOption;
-class PathMappingList;
-class FunctionCaller;
-class PersistentExpressionState;
-class Platform;
-class Process;
-class ProcessAttachInfo;
-class ProcessModID;
-class ProcessInfo;
-class ProcessInstanceInfo;
-class ProcessInstanceInfoList;
-class ProcessInstanceInfoMatch;
-class ProcessLaunchInfo;
-class Property;
-struct PropertyDefinition;
-class RegisterCheckpoint;
-class RegisterContext;
-class RegisterLocation;
-class RegisterLocationList;
-class RegisterValue;
-class RegularExpression;
-class REPL;
-class Scalar;
-class ScriptInterpreter;
-class ScriptInterpreterLocker;
-struct ScriptSummaryFormat;
-class SearchFilter;
-class Section;
-class SectionImpl;
-class SectionList;
-class SectionLoadHistory;
-class SectionLoadList;
-class Settings;
-class SourceManager;
-class SourceManagerImpl;
-class StackFrame;
-class StackFrameImpl;
-class StackFrameList;
-class StackID;
-class StopInfo;
-class Stoppoint;
-class StoppointCallbackContext;
-class StoppointLocation;
-class Stream;
+class ABI;
+class Address;
+class AddressImpl;
+class AddressRange;
+class AddressResolver;
+class ArchSpec;
+class ArmUnwindInfo;
+class Args;
+class ASTResultSynthesizer;
+class ASTStructExtractor;
+class Baton;
+class Block;
+class Breakpoint;
+class BreakpointID;
+class BreakpointIDList;
+class BreakpointList;
+class BreakpointLocation;
+class BreakpointLocationCollection;
+class BreakpointLocationList;
+class BreakpointOptions;
+class BreakpointResolver;
+class BreakpointSite;
+class BreakpointSiteList;
+class BroadcastEventSpec;
+class Broadcaster;
+class BroadcasterManager;
+class CPPLanguageRuntime;
+class ClangASTContext;
+class ClangASTImporter;
+class ClangASTMetadata;
+class ClangASTSource;
+class ClangExpressionDeclMap;
+class ClangExpressionParser;
+class ClangExpressionVariable;
+class ClangExpressionVariables;
+class ClangModulesDeclVendor;
+class ClangPersistentVariables;
+class CommandInterpreter;
+class CommandInterpreterRunOptions;
+class CommandObject;
+class CommandObjectMultiword;
+class CommandReturnObject;
+class Communication;
+class CompactUnwindInfo;
+struct CompilerContext;
+class CompilerDecl;
+class CompilerDeclContext;
+class CompilerType;
+class CompileUnit;
+class Condition;
+class Connection;
+class ConnectionFileDescriptor;
+class ConstString;
+class CXXSyntheticChildren;
+class DWARFCallFrameInfo;
+class DWARFExpression;
+class DataBuffer;
+class DataEncoder;
+class DataExtractor;
+class Debugger;
+class Declaration;
+class DiagnosticManager;
+class Disassembler;
+class DumpValueObjectOptions;
+class DynamicCheckerFunctions;
+class DynamicLoader;
+class Editline;
+class EmulateInstruction;
+class Error;
+class EvaluateExpressionOptions;
+class Event;
+class EventData;
+class EventDataStructuredData;
+class ExecutionContext;
+class ExecutionContextRef;
+class ExecutionContextRefLocker;
+class ExecutionContextScope;
+class Expression;
+class ExpressionVariable;
+class ExpressionVariableList;
+class ExpressionTypeSystemHelper;
+class File;
+class FileSpec;
+class FileSpecList;
+class Flags;
+class GoASTContext;
+class TypeCategoryImpl;
+class FormatManager;
+class FormattersMatchCandidate;
+class FuncUnwinders;
+class Function;
+class FunctionInfo;
+class InlineFunctionInfo;
+class Instruction;
+class InstructionList;
+class InstrumentationRuntime;
+class IOHandler;
+class IOObject;
+class IRExecutionUnit;
+class JITLoader;
+class JITLoaderList;
+class Language;
+class LanguageCategory;
+class LanguageRuntime;
+class MemoryRegionInfo;
+class LineTable;
+class Listener;
+class Log;
+class LogChannel;
+class Mangled;
+class Materializer;
+class MemoryHistory;
+class Module;
+class ModuleList;
+class ModuleSpec;
+class ModuleSpecList;
+class Mutex;
+struct NameSearchContext;
+class ObjCLanguageRuntime;
+class ObjCRuntimeSyntheticProvider;
+class ObjectContainer;
+class OptionGroup;
+class OptionGroupOptions;
+class OptionGroupPlatform;
+class ObjectFile;
+class ObjectFileJITDelegate;
+class OperatingSystem;
+class Options;
+class OptionValue;
+class OptionValueArch;
+class OptionValueArgs;
+class OptionValueArray;
+class OptionValueBoolean;
+class OptionValueChar;
+class OptionValueDictionary;
+class OptionValueEnumeration;
+class OptionValueFileSpec;
+class OptionValueFileSpecList;
+class OptionValueFormat;
+class OptionValueLanguage;
+class OptionValueFormatEntity;
+class OptionValuePathMappings;
+class OptionValueProperties;
+class OptionValueRegex;
+class OptionValueSInt64;
+class OptionValueString;
+class OptionValueUInt64;
+class OptionValueUUID;
+class NamedOption;
+class PathMappingList;
+class FunctionCaller;
+class PersistentExpressionState;
+class Platform;
+class Process;
+class ProcessAttachInfo;
+class ProcessModID;
+class ProcessInfo;
+class ProcessInstanceInfo;
+class ProcessInstanceInfoList;
+class ProcessInstanceInfoMatch;
+class ProcessLaunchInfo;
+class Property;
+struct PropertyDefinition;
+class RegisterCheckpoint;
+class RegisterContext;
+class RegisterLocation;
+class RegisterLocationList;
+class RegisterValue;
+class RegularExpression;
+class REPL;
+class Scalar;
+class ScriptInterpreter;
+class ScriptInterpreterLocker;
+struct ScriptSummaryFormat;
+class SearchFilter;
+class Section;
+class SectionImpl;
+class SectionList;
+class SectionLoadHistory;
+class SectionLoadList;
+class Settings;
+class SourceManager;
+class SourceManagerImpl;
+class StackFrame;
+class StackFrameImpl;
+class StackFrameList;
+class StackID;
+class StopInfo;
+class Stoppoint;
+class StoppointCallbackContext;
+class StoppointLocation;
+class Stream;
template <unsigned N> class StreamBuffer;
-class StreamFile;
-class StreamString;
-class StringList;
-struct StringSummaryFormat;
-class SystemRuntime;
-class TypeSummaryImpl;
-class TypeSummaryOptions;
-class Symbol;
-class SymbolContext;
-class SymbolContextList;
-class SymbolContextScope;
-class SymbolContextSpecifier;
-class SymbolFile;
-class SymbolFileType;
-class SymbolVendor;
-class Symtab;
-class SyntheticChildren;
-class SyntheticChildrenFrontEnd;
-class TypeFilterImpl;
-class TypeSystem;
+class StreamFile;
+class StreamString;
+class StringList;
+struct StringSummaryFormat;
+class StructuredDataPlugin;
+class SystemRuntime;
+class TypeSummaryImpl;
+class TypeSummaryOptions;
+class Symbol;
+class SymbolContext;
+class SymbolContextList;
+class SymbolContextScope;
+class SymbolContextSpecifier;
+class SymbolFile;
+class SymbolFileType;
+class SymbolVendor;
+class Symtab;
+class SyntheticChildren;
+class SyntheticChildrenFrontEnd;
+class TypeFilterImpl;
+class TypeSystem;
#ifndef LLDB_DISABLE_PYTHON
-class ScriptedSyntheticChildren;
+class ScriptedSyntheticChildren;
#endif
-class Queue;
-class QueueItem;
-class QueueImpl;
-class Target;
-class TargetList;
-class TargetProperties;
-class Thread;
-class ThreadCollection;
-class ThreadList;
-class ThreadPlan;
-class ThreadPlanBase;
-class ThreadPlanRunToAddress;
-class ThreadPlanStepInstruction;
-class ThreadPlanStepOut;
-class ThreadPlanStepOverBreakpoint;
-class ThreadPlanStepRange;
-class ThreadPlanStepThrough;
-class ThreadPlanTracer;
-class ThreadSpec;
-class TimeValue;
-class Type;
-class TypeAndOrName;
-class TypeCategoryMap;
-class TypeImpl;
-class TypeList;
-class TypeMap;
-class TypeListImpl;
-class TypeMemberImpl;
-class TypeMemberFunctionImpl;
-class TypeEnumMemberImpl;
-class TypeEnumMemberListImpl;
-class TypeFormatImpl;
-class TypeNameSpecifierImpl;
-class TypePair;
-class TypeValidatorImpl;
-class UUID;
-class UnixSignals;
-class Unwind;
-class UnwindAssembly;
-class UnwindPlan;
-class UnwindTable;
-class UserExpression;
-class UtilityFunction;
-class VMRange;
-class Value;
-class ValueList;
-class ValueObject;
-class ValueObjectChild;
-class ValueObjectConstResult;
-class ValueObjectConstResultChild;
-class ValueObjectConstResultImpl;
-class ValueObjectList;
-class ValueObjectPrinter;
-class Variable;
-class VariableList;
-class Watchpoint;
-class WatchpointList;
-class WatchpointOptions;
-struct LineEntry;
+class Queue;
+class QueueItem;
+class QueueImpl;
+class Target;
+class TargetList;
+class TargetProperties;
+class Thread;
+class ThreadCollection;
+class ThreadList;
+class ThreadPlan;
+class ThreadPlanBase;
+class ThreadPlanRunToAddress;
+class ThreadPlanStepInstruction;
+class ThreadPlanStepOut;
+class ThreadPlanStepOverBreakpoint;
+class ThreadPlanStepRange;
+class ThreadPlanStepThrough;
+class ThreadPlanTracer;
+class ThreadSpec;
+class Type;
+class TypeAndOrName;
+class TypeCategoryMap;
+class TypeImpl;
+class TypeList;
+class TypeMap;
+class TypeListImpl;
+class TypeMemberImpl;
+class TypeMemberFunctionImpl;
+class TypeEnumMemberImpl;
+class TypeEnumMemberListImpl;
+class TypeFormatImpl;
+class TypeNameSpecifierImpl;
+class TypePair;
+class TypeValidatorImpl;
+class UUID;
+class UnixSignals;
+class Unwind;
+class UnwindAssembly;
+class UnwindPlan;
+class UnwindTable;
+class UserExpression;
+class UtilityFunction;
+class VMRange;
+class Value;
+class ValueList;
+class ValueObject;
+class ValueObjectChild;
+class ValueObjectConstResult;
+class ValueObjectConstResultChild;
+class ValueObjectConstResultImpl;
+class ValueObjectList;
+class ValueObjectPrinter;
+class Variable;
+class VariableList;
+class Watchpoint;
+class WatchpointList;
+class WatchpointOptions;
+struct LineEntry;
} // namespace lldb_private
@@ -300,167 +301,191 @@ struct LineEntry;
// lldb forward declarations
//----------------------------------------------------------------------
namespace lldb {
-
- typedef std::shared_ptr<lldb_private::ABI> ABISP;
- typedef std::shared_ptr<lldb_private::Baton> BatonSP;
- typedef std::shared_ptr<lldb_private::Block> BlockSP;
- typedef std::shared_ptr<lldb_private::Breakpoint> BreakpointSP;
- typedef std::weak_ptr<lldb_private::Breakpoint> BreakpointWP;
- typedef std::shared_ptr<lldb_private::BreakpointSite> BreakpointSiteSP;
- typedef std::weak_ptr<lldb_private::BreakpointSite> BreakpointSiteWP;
- typedef std::shared_ptr<lldb_private::BreakpointLocation> BreakpointLocationSP;
- typedef std::weak_ptr<lldb_private::BreakpointLocation> BreakpointLocationWP;
- typedef std::shared_ptr<lldb_private::BreakpointResolver> BreakpointResolverSP;
- typedef std::shared_ptr<lldb_private::Broadcaster> BroadcasterSP;
- typedef std::shared_ptr<lldb_private::BroadcasterManager> BroadcasterManagerSP;
- typedef std::weak_ptr<lldb_private::BroadcasterManager> BroadcasterManagerWP;
- typedef std::unique_ptr<lldb_private::ClangASTContext> ClangASTContextUP;
- typedef std::shared_ptr<lldb_private::ClangASTImporter> ClangASTImporterSP;
- typedef std::unique_ptr<lldb_private::ClangModulesDeclVendor> ClangModulesDeclVendorUP;
- typedef std::unique_ptr<lldb_private::ClangPersistentVariables> ClangPersistentVariablesUP;
- typedef std::shared_ptr<lldb_private::UserExpression> UserExpressionSP;
- typedef std::shared_ptr<lldb_private::CommandObject> CommandObjectSP;
- typedef std::shared_ptr<lldb_private::Communication> CommunicationSP;
- typedef std::shared_ptr<lldb_private::Connection> ConnectionSP;
- typedef std::shared_ptr<lldb_private::CompileUnit> CompUnitSP;
- typedef std::shared_ptr<lldb_private::DataBuffer> DataBufferSP;
- typedef std::shared_ptr<lldb_private::DataExtractor> DataExtractorSP;
- typedef std::shared_ptr<lldb_private::Debugger> DebuggerSP;
- typedef std::weak_ptr<lldb_private::Debugger> DebuggerWP;
- typedef std::shared_ptr<lldb_private::Disassembler> DisassemblerSP;
- typedef std::unique_ptr<lldb_private::DynamicCheckerFunctions> DynamicCheckerFunctionsUP;
- typedef std::shared_ptr<lldb_private::DynamicLoader> DynamicLoaderSP;
- typedef std::unique_ptr<lldb_private::DynamicLoader> DynamicLoaderUP;
- typedef std::shared_ptr<lldb_private::Event> EventSP;
- typedef std::shared_ptr<lldb_private::EventData> EventDataSP;
- typedef std::shared_ptr<lldb_private::ExecutionContextRef> ExecutionContextRefSP;
- typedef std::shared_ptr<lldb_private::ExpressionVariable> ExpressionVariableSP;
- typedef std::shared_ptr<lldb_private::File> FileSP;
- typedef std::shared_ptr<lldb_private::Function> FunctionSP;
- typedef std::shared_ptr<lldb_private::FunctionCaller> FunctionCallerSP;
- typedef std::shared_ptr<lldb_private::FuncUnwinders> FuncUnwindersSP;
- typedef std::unique_ptr<lldb_private::GoASTContext> GoASTContextUP;
- typedef std::shared_ptr<lldb_private::InlineFunctionInfo> InlineFunctionInfoSP;
- typedef std::shared_ptr<lldb_private::Instruction> InstructionSP;
- typedef std::shared_ptr<lldb_private::InstrumentationRuntime> InstrumentationRuntimeSP;
- typedef std::shared_ptr<lldb_private::IOHandler> IOHandlerSP;
- typedef std::shared_ptr<lldb_private::IOObject> IOObjectSP;
- typedef std::shared_ptr<lldb_private::IRExecutionUnit> IRExecutionUnitSP;
- typedef std::shared_ptr<lldb_private::JITLoader> JITLoaderSP;
- typedef std::unique_ptr<lldb_private::JITLoaderList> JITLoaderListUP;
- typedef std::shared_ptr<lldb_private::LanguageRuntime> LanguageRuntimeSP;
- typedef std::shared_ptr<lldb_private::SystemRuntime> SystemRuntimeSP;
- typedef std::unique_ptr<lldb_private::SystemRuntime> SystemRuntimeUP;
- typedef std::shared_ptr<lldb_private::LineTable> LineTableSP;
- typedef std::shared_ptr<lldb_private::Listener> ListenerSP;
- typedef std::weak_ptr<lldb_private::Listener> ListenerWP;
- typedef std::shared_ptr<lldb_private::LogChannel> LogChannelSP;
- typedef std::shared_ptr<lldb_private::MemoryHistory> MemoryHistorySP;
- typedef std::shared_ptr<lldb_private::MemoryRegionInfo> MemoryRegionInfoSP;
- typedef std::unique_ptr<lldb_private::MemoryRegionInfo> MemoryRegionInfoUP;
- typedef std::shared_ptr<lldb_private::Module> ModuleSP;
- typedef std::weak_ptr<lldb_private::Module> ModuleWP;
- typedef std::shared_ptr<lldb_private::ObjectFile> ObjectFileSP;
- typedef std::weak_ptr<lldb_private::ObjectFile> ObjectFileWP;
- typedef std::shared_ptr<lldb_private::ObjectFileJITDelegate> ObjectFileJITDelegateSP;
- typedef std::weak_ptr<lldb_private::ObjectFileJITDelegate> ObjectFileJITDelegateWP;
- typedef std::unique_ptr<lldb_private::OperatingSystem> OperatingSystemUP;
- typedef std::shared_ptr<lldb_private::OptionValue> OptionValueSP;
- typedef std::weak_ptr<lldb_private::OptionValue> OptionValueWP;
- typedef std::shared_ptr<lldb_private::OptionValueArch> OptionValueArchSP;
- typedef std::shared_ptr<lldb_private::OptionValueArgs> OptionValueArgsSP;
- typedef std::shared_ptr<lldb_private::OptionValueArray> OptionValueArraySP;
- typedef std::shared_ptr<lldb_private::OptionValueBoolean> OptionValueBooleanSP;
- typedef std::shared_ptr<lldb_private::OptionValueDictionary> OptionValueDictionarySP;
- typedef std::shared_ptr<lldb_private::OptionValueFileSpec> OptionValueFileSpecSP;
- typedef std::shared_ptr<lldb_private::OptionValueFileSpecList> OptionValueFileSpecListSP;
- typedef std::shared_ptr<lldb_private::OptionValueFormat> OptionValueFormatSP;
- typedef std::shared_ptr<lldb_private::OptionValuePathMappings> OptionValuePathMappingsSP;
- typedef std::shared_ptr<lldb_private::OptionValueProperties> OptionValuePropertiesSP;
- typedef std::shared_ptr<lldb_private::OptionValueRegex> OptionValueRegexSP;
- typedef std::shared_ptr<lldb_private::OptionValueSInt64> OptionValueSInt64SP;
- typedef std::shared_ptr<lldb_private::OptionValueString> OptionValueStringSP;
- typedef std::shared_ptr<lldb_private::OptionValueUInt64> OptionValueUInt64SP;
- typedef std::shared_ptr<lldb_private::OptionValueUUID> OptionValueUUIDSP;
- typedef std::shared_ptr<lldb_private::Platform> PlatformSP;
- typedef std::shared_ptr<lldb_private::Process> ProcessSP;
- typedef std::shared_ptr<lldb_private::ProcessAttachInfo> ProcessAttachInfoSP;
- typedef std::shared_ptr<lldb_private::ProcessLaunchInfo> ProcessLaunchInfoSP;
- typedef std::weak_ptr<lldb_private::Process> ProcessWP;
- typedef std::shared_ptr<lldb_private::Property> PropertySP;
- typedef std::shared_ptr<lldb_private::RegisterCheckpoint> RegisterCheckpointSP;
- typedef std::shared_ptr<lldb_private::RegisterContext> RegisterContextSP;
- typedef std::shared_ptr<lldb_private::RegularExpression> RegularExpressionSP;
- typedef std::shared_ptr<lldb_private::Queue> QueueSP;
- typedef std::weak_ptr<lldb_private::Queue> QueueWP;
- typedef std::shared_ptr<lldb_private::QueueItem> QueueItemSP;
- typedef std::shared_ptr<lldb_private::REPL> REPLSP;
- typedef std::shared_ptr<lldb_private::ScriptSummaryFormat> ScriptSummaryFormatSP;
- typedef std::shared_ptr<lldb_private::ScriptInterpreter> ScriptInterpreterSP;
- typedef std::unique_ptr<lldb_private::ScriptInterpreter> ScriptInterpreterUP;
- typedef std::shared_ptr<lldb_private::Section> SectionSP;
- typedef std::unique_ptr<lldb_private::SectionList> SectionListUP;
- typedef std::weak_ptr<lldb_private::Section> SectionWP;
- typedef std::shared_ptr<lldb_private::SectionLoadList> SectionLoadListSP;
- typedef std::shared_ptr<lldb_private::SearchFilter> SearchFilterSP;
- typedef std::shared_ptr<lldb_private::Settings> SettingsSP;
- typedef std::unique_ptr<lldb_private::SourceManager> SourceManagerUP;
- typedef std::shared_ptr<lldb_private::StackFrame> StackFrameSP;
- typedef std::unique_ptr<lldb_private::StackFrame> StackFrameUP;
- typedef std::weak_ptr<lldb_private::StackFrame> StackFrameWP;
- typedef std::shared_ptr<lldb_private::StackFrameList> StackFrameListSP;
- typedef std::shared_ptr<lldb_private::StopInfo> StopInfoSP;
- typedef std::shared_ptr<lldb_private::StoppointLocation> StoppointLocationSP;
- typedef std::shared_ptr<lldb_private::Stream> StreamSP;
- typedef std::weak_ptr<lldb_private::Stream> StreamWP;
- typedef std::shared_ptr<lldb_private::StreamFile> StreamFileSP;
- typedef std::shared_ptr<lldb_private::StringSummaryFormat> StringTypeSummaryImplSP;
- typedef std::shared_ptr<lldb_private::SymbolFile> SymbolFileSP;
- typedef std::shared_ptr<lldb_private::SymbolFileType> SymbolFileTypeSP;
- typedef std::weak_ptr<lldb_private::SymbolFileType> SymbolFileTypeWP;
- typedef std::shared_ptr<lldb_private::SymbolContextSpecifier> SymbolContextSpecifierSP;
- typedef std::unique_ptr<lldb_private::SymbolVendor> SymbolVendorUP;
- typedef std::shared_ptr<lldb_private::SyntheticChildren> SyntheticChildrenSP;
- typedef std::shared_ptr<lldb_private::SyntheticChildrenFrontEnd> SyntheticChildrenFrontEndSP;
- typedef std::shared_ptr<lldb_private::Target> TargetSP;
- typedef std::weak_ptr<lldb_private::Target> TargetWP;
- typedef std::shared_ptr<lldb_private::TargetProperties> TargetPropertiesSP;
- typedef std::shared_ptr<lldb_private::Thread> ThreadSP;
- typedef std::weak_ptr<lldb_private::Thread> ThreadWP;
- typedef std::shared_ptr<lldb_private::ThreadCollection> ThreadCollectionSP;
- typedef std::shared_ptr<lldb_private::ThreadPlan> ThreadPlanSP;
- typedef std::shared_ptr<lldb_private::ThreadPlanTracer> ThreadPlanTracerSP;
- typedef std::shared_ptr<lldb_private::Type> TypeSP;
- typedef std::weak_ptr<lldb_private::Type> TypeWP;
- typedef std::shared_ptr<lldb_private::TypeCategoryImpl> TypeCategoryImplSP;
- typedef std::shared_ptr<lldb_private::TypeImpl> TypeImplSP;
- typedef std::shared_ptr<lldb_private::TypeMemberFunctionImpl> TypeMemberFunctionImplSP;
- typedef std::shared_ptr<lldb_private::TypeEnumMemberImpl> TypeEnumMemberImplSP;
- typedef std::shared_ptr<lldb_private::TypeFilterImpl> TypeFilterImplSP;
- typedef std::shared_ptr<lldb_private::TypeSystem> TypeSystemSP;
- typedef std::shared_ptr<lldb_private::TypeFormatImpl> TypeFormatImplSP;
- typedef std::shared_ptr<lldb_private::TypeNameSpecifierImpl> TypeNameSpecifierImplSP;
- typedef std::shared_ptr<lldb_private::TypeSummaryImpl> TypeSummaryImplSP;
- typedef std::shared_ptr<lldb_private::TypeSummaryOptions> TypeSummaryOptionsSP;
- typedef std::shared_ptr<lldb_private::TypeValidatorImpl> TypeValidatorImplSP;
+
+typedef std::shared_ptr<lldb_private::ABI> ABISP;
+typedef std::shared_ptr<lldb_private::Baton> BatonSP;
+typedef std::shared_ptr<lldb_private::Block> BlockSP;
+typedef std::shared_ptr<lldb_private::Breakpoint> BreakpointSP;
+typedef std::weak_ptr<lldb_private::Breakpoint> BreakpointWP;
+typedef std::shared_ptr<lldb_private::BreakpointSite> BreakpointSiteSP;
+typedef std::weak_ptr<lldb_private::BreakpointSite> BreakpointSiteWP;
+typedef std::shared_ptr<lldb_private::BreakpointLocation> BreakpointLocationSP;
+typedef std::weak_ptr<lldb_private::BreakpointLocation> BreakpointLocationWP;
+typedef std::shared_ptr<lldb_private::BreakpointResolver> BreakpointResolverSP;
+typedef std::shared_ptr<lldb_private::Broadcaster> BroadcasterSP;
+typedef std::shared_ptr<lldb_private::BroadcasterManager> BroadcasterManagerSP;
+typedef std::weak_ptr<lldb_private::BroadcasterManager> BroadcasterManagerWP;
+typedef std::unique_ptr<lldb_private::ClangASTContext> ClangASTContextUP;
+typedef std::shared_ptr<lldb_private::ClangASTImporter> ClangASTImporterSP;
+typedef std::unique_ptr<lldb_private::ClangModulesDeclVendor>
+ ClangModulesDeclVendorUP;
+typedef std::unique_ptr<lldb_private::ClangPersistentVariables>
+ ClangPersistentVariablesUP;
+typedef std::shared_ptr<lldb_private::UserExpression> UserExpressionSP;
+typedef std::shared_ptr<lldb_private::CommandObject> CommandObjectSP;
+typedef std::shared_ptr<lldb_private::Communication> CommunicationSP;
+typedef std::shared_ptr<lldb_private::Connection> ConnectionSP;
+typedef std::shared_ptr<lldb_private::CompileUnit> CompUnitSP;
+typedef std::shared_ptr<lldb_private::DataBuffer> DataBufferSP;
+typedef std::shared_ptr<lldb_private::DataExtractor> DataExtractorSP;
+typedef std::shared_ptr<lldb_private::Debugger> DebuggerSP;
+typedef std::weak_ptr<lldb_private::Debugger> DebuggerWP;
+typedef std::shared_ptr<lldb_private::Disassembler> DisassemblerSP;
+typedef std::unique_ptr<lldb_private::DynamicCheckerFunctions>
+ DynamicCheckerFunctionsUP;
+typedef std::shared_ptr<lldb_private::DynamicLoader> DynamicLoaderSP;
+typedef std::unique_ptr<lldb_private::DynamicLoader> DynamicLoaderUP;
+typedef std::shared_ptr<lldb_private::Event> EventSP;
+typedef std::shared_ptr<lldb_private::EventData> EventDataSP;
+typedef std::shared_ptr<lldb_private::EventDataStructuredData>
+ EventDataStructuredDataSP;
+typedef std::shared_ptr<lldb_private::ExecutionContextRef>
+ ExecutionContextRefSP;
+typedef std::shared_ptr<lldb_private::ExpressionVariable> ExpressionVariableSP;
+typedef std::shared_ptr<lldb_private::File> FileSP;
+typedef std::shared_ptr<lldb_private::Function> FunctionSP;
+typedef std::shared_ptr<lldb_private::FunctionCaller> FunctionCallerSP;
+typedef std::shared_ptr<lldb_private::FuncUnwinders> FuncUnwindersSP;
+typedef std::unique_ptr<lldb_private::GoASTContext> GoASTContextUP;
+typedef std::shared_ptr<lldb_private::InlineFunctionInfo> InlineFunctionInfoSP;
+typedef std::shared_ptr<lldb_private::Instruction> InstructionSP;
+typedef std::shared_ptr<lldb_private::InstrumentationRuntime>
+ InstrumentationRuntimeSP;
+typedef std::shared_ptr<lldb_private::IOHandler> IOHandlerSP;
+typedef std::shared_ptr<lldb_private::IOObject> IOObjectSP;
+typedef std::shared_ptr<lldb_private::IRExecutionUnit> IRExecutionUnitSP;
+typedef std::shared_ptr<lldb_private::JITLoader> JITLoaderSP;
+typedef std::unique_ptr<lldb_private::JITLoaderList> JITLoaderListUP;
+typedef std::shared_ptr<lldb_private::LanguageRuntime> LanguageRuntimeSP;
+typedef std::shared_ptr<lldb_private::SystemRuntime> SystemRuntimeSP;
+typedef std::unique_ptr<lldb_private::SystemRuntime> SystemRuntimeUP;
+typedef std::shared_ptr<lldb_private::LineTable> LineTableSP;
+typedef std::shared_ptr<lldb_private::Listener> ListenerSP;
+typedef std::weak_ptr<lldb_private::Listener> ListenerWP;
+typedef std::shared_ptr<lldb_private::LogChannel> LogChannelSP;
+typedef std::shared_ptr<lldb_private::MemoryHistory> MemoryHistorySP;
+typedef std::shared_ptr<lldb_private::MemoryRegionInfo> MemoryRegionInfoSP;
+typedef std::unique_ptr<lldb_private::MemoryRegionInfo> MemoryRegionInfoUP;
+typedef std::shared_ptr<lldb_private::Module> ModuleSP;
+typedef std::weak_ptr<lldb_private::Module> ModuleWP;
+typedef std::shared_ptr<lldb_private::ObjectFile> ObjectFileSP;
+typedef std::weak_ptr<lldb_private::ObjectFile> ObjectFileWP;
+typedef std::shared_ptr<lldb_private::ObjectFileJITDelegate>
+ ObjectFileJITDelegateSP;
+typedef std::weak_ptr<lldb_private::ObjectFileJITDelegate>
+ ObjectFileJITDelegateWP;
+typedef std::unique_ptr<lldb_private::OperatingSystem> OperatingSystemUP;
+typedef std::shared_ptr<lldb_private::OptionValue> OptionValueSP;
+typedef std::weak_ptr<lldb_private::OptionValue> OptionValueWP;
+typedef std::shared_ptr<lldb_private::OptionValueArch> OptionValueArchSP;
+typedef std::shared_ptr<lldb_private::OptionValueArgs> OptionValueArgsSP;
+typedef std::shared_ptr<lldb_private::OptionValueArray> OptionValueArraySP;
+typedef std::shared_ptr<lldb_private::OptionValueBoolean> OptionValueBooleanSP;
+typedef std::shared_ptr<lldb_private::OptionValueDictionary>
+ OptionValueDictionarySP;
+typedef std::shared_ptr<lldb_private::OptionValueFileSpec>
+ OptionValueFileSpecSP;
+typedef std::shared_ptr<lldb_private::OptionValueFileSpecList>
+ OptionValueFileSpecListSP;
+typedef std::shared_ptr<lldb_private::OptionValueFormat> OptionValueFormatSP;
+typedef std::shared_ptr<lldb_private::OptionValuePathMappings>
+ OptionValuePathMappingsSP;
+typedef std::shared_ptr<lldb_private::OptionValueProperties>
+ OptionValuePropertiesSP;
+typedef std::shared_ptr<lldb_private::OptionValueRegex> OptionValueRegexSP;
+typedef std::shared_ptr<lldb_private::OptionValueSInt64> OptionValueSInt64SP;
+typedef std::shared_ptr<lldb_private::OptionValueString> OptionValueStringSP;
+typedef std::shared_ptr<lldb_private::OptionValueUInt64> OptionValueUInt64SP;
+typedef std::shared_ptr<lldb_private::OptionValueUUID> OptionValueUUIDSP;
+typedef std::shared_ptr<lldb_private::Platform> PlatformSP;
+typedef std::shared_ptr<lldb_private::Process> ProcessSP;
+typedef std::shared_ptr<lldb_private::ProcessAttachInfo> ProcessAttachInfoSP;
+typedef std::shared_ptr<lldb_private::ProcessLaunchInfo> ProcessLaunchInfoSP;
+typedef std::weak_ptr<lldb_private::Process> ProcessWP;
+typedef std::shared_ptr<lldb_private::Property> PropertySP;
+typedef std::shared_ptr<lldb_private::RegisterCheckpoint> RegisterCheckpointSP;
+typedef std::shared_ptr<lldb_private::RegisterContext> RegisterContextSP;
+typedef std::shared_ptr<lldb_private::RegularExpression> RegularExpressionSP;
+typedef std::shared_ptr<lldb_private::Queue> QueueSP;
+typedef std::weak_ptr<lldb_private::Queue> QueueWP;
+typedef std::shared_ptr<lldb_private::QueueItem> QueueItemSP;
+typedef std::shared_ptr<lldb_private::REPL> REPLSP;
+typedef std::shared_ptr<lldb_private::ScriptSummaryFormat>
+ ScriptSummaryFormatSP;
+typedef std::shared_ptr<lldb_private::ScriptInterpreter> ScriptInterpreterSP;
+typedef std::unique_ptr<lldb_private::ScriptInterpreter> ScriptInterpreterUP;
+typedef std::shared_ptr<lldb_private::Section> SectionSP;
+typedef std::unique_ptr<lldb_private::SectionList> SectionListUP;
+typedef std::weak_ptr<lldb_private::Section> SectionWP;
+typedef std::shared_ptr<lldb_private::SectionLoadList> SectionLoadListSP;
+typedef std::shared_ptr<lldb_private::SearchFilter> SearchFilterSP;
+typedef std::shared_ptr<lldb_private::Settings> SettingsSP;
+typedef std::unique_ptr<lldb_private::SourceManager> SourceManagerUP;
+typedef std::shared_ptr<lldb_private::StackFrame> StackFrameSP;
+typedef std::unique_ptr<lldb_private::StackFrame> StackFrameUP;
+typedef std::weak_ptr<lldb_private::StackFrame> StackFrameWP;
+typedef std::shared_ptr<lldb_private::StackFrameList> StackFrameListSP;
+typedef std::shared_ptr<lldb_private::StopInfo> StopInfoSP;
+typedef std::shared_ptr<lldb_private::StoppointLocation> StoppointLocationSP;
+typedef std::shared_ptr<lldb_private::Stream> StreamSP;
+typedef std::weak_ptr<lldb_private::Stream> StreamWP;
+typedef std::shared_ptr<lldb_private::StreamFile> StreamFileSP;
+typedef std::shared_ptr<lldb_private::StringSummaryFormat>
+ StringTypeSummaryImplSP;
+typedef std::shared_ptr<lldb_private::StructuredDataPlugin>
+ StructuredDataPluginSP;
+typedef std::weak_ptr<lldb_private::StructuredDataPlugin>
+ StructuredDataPluginWP;
+typedef std::shared_ptr<lldb_private::SymbolFile> SymbolFileSP;
+typedef std::shared_ptr<lldb_private::SymbolFileType> SymbolFileTypeSP;
+typedef std::weak_ptr<lldb_private::SymbolFileType> SymbolFileTypeWP;
+typedef std::shared_ptr<lldb_private::SymbolContextSpecifier>
+ SymbolContextSpecifierSP;
+typedef std::unique_ptr<lldb_private::SymbolVendor> SymbolVendorUP;
+typedef std::shared_ptr<lldb_private::SyntheticChildren> SyntheticChildrenSP;
+typedef std::shared_ptr<lldb_private::SyntheticChildrenFrontEnd>
+ SyntheticChildrenFrontEndSP;
+typedef std::shared_ptr<lldb_private::Target> TargetSP;
+typedef std::weak_ptr<lldb_private::Target> TargetWP;
+typedef std::shared_ptr<lldb_private::TargetProperties> TargetPropertiesSP;
+typedef std::shared_ptr<lldb_private::Thread> ThreadSP;
+typedef std::weak_ptr<lldb_private::Thread> ThreadWP;
+typedef std::shared_ptr<lldb_private::ThreadCollection> ThreadCollectionSP;
+typedef std::shared_ptr<lldb_private::ThreadPlan> ThreadPlanSP;
+typedef std::shared_ptr<lldb_private::ThreadPlanTracer> ThreadPlanTracerSP;
+typedef std::shared_ptr<lldb_private::Type> TypeSP;
+typedef std::weak_ptr<lldb_private::Type> TypeWP;
+typedef std::shared_ptr<lldb_private::TypeCategoryImpl> TypeCategoryImplSP;
+typedef std::shared_ptr<lldb_private::TypeImpl> TypeImplSP;
+typedef std::shared_ptr<lldb_private::TypeMemberFunctionImpl>
+ TypeMemberFunctionImplSP;
+typedef std::shared_ptr<lldb_private::TypeEnumMemberImpl> TypeEnumMemberImplSP;
+typedef std::shared_ptr<lldb_private::TypeFilterImpl> TypeFilterImplSP;
+typedef std::shared_ptr<lldb_private::TypeSystem> TypeSystemSP;
+typedef std::shared_ptr<lldb_private::TypeFormatImpl> TypeFormatImplSP;
+typedef std::shared_ptr<lldb_private::TypeNameSpecifierImpl>
+ TypeNameSpecifierImplSP;
+typedef std::shared_ptr<lldb_private::TypeSummaryImpl> TypeSummaryImplSP;
+typedef std::shared_ptr<lldb_private::TypeSummaryOptions> TypeSummaryOptionsSP;
+typedef std::shared_ptr<lldb_private::TypeValidatorImpl> TypeValidatorImplSP;
#ifndef LLDB_DISABLE_PYTHON
- typedef std::shared_ptr<lldb_private::ScriptedSyntheticChildren> ScriptedSyntheticChildrenSP;
+typedef std::shared_ptr<lldb_private::ScriptedSyntheticChildren>
+ ScriptedSyntheticChildrenSP;
#endif
- typedef std::shared_ptr<lldb_private::UnixSignals> UnixSignalsSP;
- typedef std::weak_ptr<lldb_private::UnixSignals> UnixSignalsWP;
- typedef std::shared_ptr<lldb_private::UnwindAssembly> UnwindAssemblySP;
- typedef std::shared_ptr<lldb_private::UnwindPlan> UnwindPlanSP;
- typedef std::shared_ptr<lldb_private::UtilityFunction> UtilityFunctionSP;
- typedef lldb_private::SharingPtr<lldb_private::ValueObject> ValueObjectSP;
- typedef std::shared_ptr<lldb_private::Value> ValueSP;
- typedef std::shared_ptr<lldb_private::ValueList> ValueListSP;
- typedef std::shared_ptr<lldb_private::Variable> VariableSP;
- typedef std::shared_ptr<lldb_private::VariableList> VariableListSP;
- typedef std::shared_ptr<lldb_private::ValueObjectList> ValueObjectListSP;
- typedef std::shared_ptr<lldb_private::Watchpoint> WatchpointSP;
+typedef std::shared_ptr<lldb_private::UnixSignals> UnixSignalsSP;
+typedef std::weak_ptr<lldb_private::UnixSignals> UnixSignalsWP;
+typedef std::shared_ptr<lldb_private::UnwindAssembly> UnwindAssemblySP;
+typedef std::shared_ptr<lldb_private::UnwindPlan> UnwindPlanSP;
+typedef std::shared_ptr<lldb_private::UtilityFunction> UtilityFunctionSP;
+typedef lldb_private::SharingPtr<lldb_private::ValueObject> ValueObjectSP;
+typedef std::shared_ptr<lldb_private::Value> ValueSP;
+typedef std::shared_ptr<lldb_private::ValueList> ValueListSP;
+typedef std::shared_ptr<lldb_private::Variable> VariableSP;
+typedef std::shared_ptr<lldb_private::VariableList> VariableListSP;
+typedef std::shared_ptr<lldb_private::ValueObjectList> ValueObjectListSP;
+typedef std::shared_ptr<lldb_private::Watchpoint> WatchpointSP;
} // namespace lldb
-
-#endif // #if defined(__cplusplus)
-#endif // LLDB_lldb_forward_h_
+#endif // #if defined(__cplusplus)
+#endif // LLDB_lldb_forward_h_
diff --git a/include/lldb/lldb-private-defines.h b/include/lldb/lldb-private-defines.h
index 4b261ad4712b..53c5f31bab8c 100644
--- a/include/lldb/lldb-private-defines.h
+++ b/include/lldb/lldb-private-defines.h
@@ -12,14 +12,15 @@
#if defined(__cplusplus)
-// Include Compiler.h here so we don't define LLVM_FALLTHROUGH and then Compiler.h
+// Include Compiler.h here so we don't define LLVM_FALLTHROUGH and then
+// Compiler.h
// later tries to redefine it.
#include "llvm/Support/Compiler.h"
#ifndef LLVM_FALLTHROUGH
#ifndef __has_cpp_attribute
-# define __has_cpp_attribute(x) 0
+#define __has_cpp_attribute(x) 0
#endif
/// \macro LLVM_FALLTHROUGH
@@ -32,8 +33,6 @@
#endif // ifndef LLVM_FALLTHROUGH
+#endif // #if defined(__cplusplus)
-
-#endif // #if defined(__cplusplus)
-
-#endif // liblldb_lldb_private_defines_h_
+#endif // liblldb_lldb_private_defines_h_
diff --git a/include/lldb/lldb-private-enumerations.h b/include/lldb/lldb-private-enumerations.h
index 366970a39f2f..d6e30b33b3eb 100644
--- a/include/lldb/lldb-private-enumerations.h
+++ b/include/lldb/lldb-private-enumerations.h
@@ -15,45 +15,40 @@ namespace lldb_private {
//----------------------------------------------------------------------
// Thread Step Types
//----------------------------------------------------------------------
-typedef enum StepType
-{
- eStepTypeNone,
- eStepTypeTrace, ///< Single step one instruction.
- eStepTypeTraceOver, ///< Single step one instruction, stepping over.
- eStepTypeInto, ///< Single step into a specified context.
- eStepTypeOver, ///< Single step over a specified context.
- eStepTypeOut, ///< Single step out a specified context.
- eStepTypeScripted ///< A step type implemented by the script interpreter.
+typedef enum StepType {
+ eStepTypeNone,
+ eStepTypeTrace, ///< Single step one instruction.
+ eStepTypeTraceOver, ///< Single step one instruction, stepping over.
+ eStepTypeInto, ///< Single step into a specified context.
+ eStepTypeOver, ///< Single step over a specified context.
+ eStepTypeOut, ///< Single step out a specified context.
+ eStepTypeScripted ///< A step type implemented by the script interpreter.
} StepType;
//----------------------------------------------------------------------
// Address Types
//----------------------------------------------------------------------
-typedef enum AddressType
-{
- eAddressTypeInvalid = 0,
- eAddressTypeFile, ///< Address is an address as found in an object or symbol file
- eAddressTypeLoad, ///< Address is an address as in the current target inferior process
- eAddressTypeHost ///< Address is an address in the process that is running this code
+typedef enum AddressType {
+ eAddressTypeInvalid = 0,
+ eAddressTypeFile, ///< Address is an address as found in an object or symbol
+ ///file
+ eAddressTypeLoad, ///< Address is an address as in the current target inferior
+ ///process
+ eAddressTypeHost ///< Address is an address in the process that is running
+ ///this code
} AddressType;
//----------------------------------------------------------------------
// Votes - Need a tri-state, yes, no, no opinion...
//----------------------------------------------------------------------
-typedef enum Vote
-{
- eVoteNo = -1,
- eVoteNoOpinion = 0,
- eVoteYes = 1
-} Vote;
+typedef enum Vote { eVoteNo = -1, eVoteNoOpinion = 0, eVoteYes = 1 } Vote;
-typedef enum ArchitectureType
-{
- eArchTypeInvalid,
- eArchTypeMachO,
- eArchTypeELF,
- eArchTypeCOFF,
- kNumArchTypes
+typedef enum ArchitectureType {
+ eArchTypeInvalid,
+ eArchTypeMachO,
+ eArchTypeELF,
+ eArchTypeCOFF,
+ kNumArchTypes
} ArchitectureType;
//----------------------------------------------------------------------
@@ -61,7 +56,7 @@ typedef enum ArchitectureType
///
//----------------------------------------------------------------------
-//typedef enum SettableVariableType
+// typedef enum SettableVariableType
//{
// eSetVarTypeInt,
// eSetVarTypeBoolean,
@@ -72,38 +67,37 @@ typedef enum ArchitectureType
// eSetVarTypeNone
//} SettableVariableType;
-typedef enum VarSetOperationType
-{
- eVarSetOperationReplace,
- eVarSetOperationInsertBefore,
- eVarSetOperationInsertAfter,
- eVarSetOperationRemove,
- eVarSetOperationAppend,
- eVarSetOperationClear,
- eVarSetOperationAssign,
- eVarSetOperationInvalid
+typedef enum VarSetOperationType {
+ eVarSetOperationReplace,
+ eVarSetOperationInsertBefore,
+ eVarSetOperationInsertAfter,
+ eVarSetOperationRemove,
+ eVarSetOperationAppend,
+ eVarSetOperationClear,
+ eVarSetOperationAssign,
+ eVarSetOperationInvalid
} VarSetOperationType;
-typedef enum ArgumentRepetitionType
-{
- eArgRepeatPlain, // Exactly one occurrence
- eArgRepeatOptional, // At most one occurrence, but it's optional
- eArgRepeatPlus, // One or more occurrences
- eArgRepeatStar, // Zero or more occurrences
- eArgRepeatRange, // Repetition of same argument, from 1 to n
- eArgRepeatPairPlain, // A pair of arguments that must always go together ([arg-type arg-value]), occurs exactly once
- eArgRepeatPairOptional, // A pair that occurs at most once (optional)
- eArgRepeatPairPlus, // One or more occurrences of a pair
- eArgRepeatPairStar, // Zero or more occurrences of a pair
- eArgRepeatPairRange, // A pair that repeats from 1 to n
- eArgRepeatPairRangeOptional // A pair that repeats from 1 to n, but is optional
+typedef enum ArgumentRepetitionType {
+ eArgRepeatPlain, // Exactly one occurrence
+ eArgRepeatOptional, // At most one occurrence, but it's optional
+ eArgRepeatPlus, // One or more occurrences
+ eArgRepeatStar, // Zero or more occurrences
+ eArgRepeatRange, // Repetition of same argument, from 1 to n
+ eArgRepeatPairPlain, // A pair of arguments that must always go together
+ // ([arg-type arg-value]), occurs exactly once
+ eArgRepeatPairOptional, // A pair that occurs at most once (optional)
+ eArgRepeatPairPlus, // One or more occurrences of a pair
+ eArgRepeatPairStar, // Zero or more occurrences of a pair
+ eArgRepeatPairRange, // A pair that repeats from 1 to n
+ eArgRepeatPairRangeOptional // A pair that repeats from 1 to n, but is
+ // optional
} ArgumentRepetitionType;
-typedef enum SortOrder
-{
- eSortOrderNone,
- eSortOrderByAddress,
- eSortOrderByName
+typedef enum SortOrder {
+ eSortOrderNone,
+ eSortOrderByAddress,
+ eSortOrderByName
} SortOrder;
//----------------------------------------------------------------------
@@ -112,157 +106,155 @@ typedef enum SortOrder
// calculated once and set to eLazyBoolNo or eLazyBoolYes.
//----------------------------------------------------------------------
typedef enum LazyBool {
- eLazyBoolCalculate = -1,
- eLazyBoolNo = 0,
- eLazyBoolYes = 1
+ eLazyBoolCalculate = -1,
+ eLazyBoolNo = 0,
+ eLazyBoolYes = 1
} LazyBool;
//------------------------------------------------------------------
/// Name matching
//------------------------------------------------------------------
-typedef enum NameMatchType
-{
- eNameMatchIgnore,
- eNameMatchEquals,
- eNameMatchContains,
- eNameMatchStartsWith,
- eNameMatchEndsWith,
- eNameMatchRegularExpression
-
-} NameMatchType;
+typedef enum NameMatchType {
+ eNameMatchIgnore,
+ eNameMatchEquals,
+ eNameMatchContains,
+ eNameMatchStartsWith,
+ eNameMatchEndsWith,
+ eNameMatchRegularExpression
+} NameMatchType;
//------------------------------------------------------------------
/// Instruction types
-//------------------------------------------------------------------
-typedef enum InstructionType
-{
- eInstructionTypeAny, // Support for any instructions at all (at least one)
- eInstructionTypePrologueEpilogue, // All prologue and epilogue instructions that push and pop register values and modify sp/fp
- eInstructionTypePCModifying, // Any instruction that modifies the program counter/instruction pointer
- eInstructionTypeAll // All instructions of any kind
+//------------------------------------------------------------------
+typedef enum InstructionType {
+ eInstructionTypeAny, // Support for any instructions at all (at least one)
+ eInstructionTypePrologueEpilogue, // All prologue and epilogue instructions
+ // that push and pop register values and
+ // modify sp/fp
+ eInstructionTypePCModifying, // Any instruction that modifies the program
+ // counter/instruction pointer
+ eInstructionTypeAll // All instructions of any kind
+
+} InstructionType;
-} InstructionType;
-
-
//------------------------------------------------------------------
/// Format category entry types
-//------------------------------------------------------------------
-typedef enum FormatCategoryItem
-{
- eFormatCategoryItemSummary = 0x0001,
- eFormatCategoryItemRegexSummary = 0x0002,
- eFormatCategoryItemFilter = 0x0004,
- eFormatCategoryItemRegexFilter = 0x0008,
- eFormatCategoryItemSynth = 0x0010,
- eFormatCategoryItemRegexSynth = 0x0020,
- eFormatCategoryItemValue = 0x0040,
- eFormatCategoryItemRegexValue = 0x0080,
- eFormatCategoryItemValidator = 0x0100,
- eFormatCategoryItemRegexValidator = 0x0200
+//------------------------------------------------------------------
+typedef enum FormatCategoryItem {
+ eFormatCategoryItemSummary = 0x0001,
+ eFormatCategoryItemRegexSummary = 0x0002,
+ eFormatCategoryItemFilter = 0x0004,
+ eFormatCategoryItemRegexFilter = 0x0008,
+ eFormatCategoryItemSynth = 0x0010,
+ eFormatCategoryItemRegexSynth = 0x0020,
+ eFormatCategoryItemValue = 0x0040,
+ eFormatCategoryItemRegexValue = 0x0080,
+ eFormatCategoryItemValidator = 0x0100,
+ eFormatCategoryItemRegexValidator = 0x0200
} FormatCategoryItem;
//------------------------------------------------------------------
/// Expression execution policies
//------------------------------------------------------------------
typedef enum {
- eExecutionPolicyOnlyWhenNeeded,
- eExecutionPolicyNever,
- eExecutionPolicyAlways,
- eExecutionPolicyTopLevel // used for top-level code
+ eExecutionPolicyOnlyWhenNeeded,
+ eExecutionPolicyNever,
+ eExecutionPolicyAlways,
+ eExecutionPolicyTopLevel // used for top-level code
} ExecutionPolicy;
//----------------------------------------------------------------------
// Ways that the FormatManager picks a particular format for a type
//----------------------------------------------------------------------
-typedef enum FormatterChoiceCriterion
-{
- eFormatterChoiceCriterionDirectChoice = 0x00000000,
- eFormatterChoiceCriterionStrippedPointerReference = 0x00000001,
- eFormatterChoiceCriterionNavigatedTypedefs = 0x00000002,
- eFormatterChoiceCriterionRegularExpressionSummary = 0x00000004,
- eFormatterChoiceCriterionRegularExpressionFilter = 0x00000004,
- eFormatterChoiceCriterionLanguagePlugin = 0x00000008,
- eFormatterChoiceCriterionStrippedBitField = 0x00000010,
- eFormatterChoiceCriterionWentToStaticValue = 0x00000020
+typedef enum FormatterChoiceCriterion {
+ eFormatterChoiceCriterionDirectChoice = 0x00000000,
+ eFormatterChoiceCriterionStrippedPointerReference = 0x00000001,
+ eFormatterChoiceCriterionNavigatedTypedefs = 0x00000002,
+ eFormatterChoiceCriterionRegularExpressionSummary = 0x00000004,
+ eFormatterChoiceCriterionRegularExpressionFilter = 0x00000004,
+ eFormatterChoiceCriterionLanguagePlugin = 0x00000008,
+ eFormatterChoiceCriterionStrippedBitField = 0x00000010,
+ eFormatterChoiceCriterionWentToStaticValue = 0x00000020
} FormatterChoiceCriterion;
//----------------------------------------------------------------------
// Synchronicity behavior of scripted commands
//----------------------------------------------------------------------
-typedef enum ScriptedCommandSynchronicity
-{
- eScriptedCommandSynchronicitySynchronous,
- eScriptedCommandSynchronicityAsynchronous,
- eScriptedCommandSynchronicityCurrentValue // use whatever the current synchronicity is
+typedef enum ScriptedCommandSynchronicity {
+ eScriptedCommandSynchronicitySynchronous,
+ eScriptedCommandSynchronicityAsynchronous,
+ eScriptedCommandSynchronicityCurrentValue // use whatever the current
+ // synchronicity is
} ScriptedCommandSynchronicity;
//----------------------------------------------------------------------
// Verbosity mode of "po" output
//----------------------------------------------------------------------
-typedef enum LanguageRuntimeDescriptionDisplayVerbosity
-{
- eLanguageRuntimeDescriptionDisplayVerbosityCompact, // only print the description string, if any
- eLanguageRuntimeDescriptionDisplayVerbosityFull, // print the full-blown output
+typedef enum LanguageRuntimeDescriptionDisplayVerbosity {
+ eLanguageRuntimeDescriptionDisplayVerbosityCompact, // only print the
+ // description string, if
+ // any
+ eLanguageRuntimeDescriptionDisplayVerbosityFull, // print the full-blown
+ // output
} LanguageRuntimeDescriptionDisplayVerbosity;
//----------------------------------------------------------------------
// Loading modules from memory
//----------------------------------------------------------------------
typedef enum MemoryModuleLoadLevel {
- eMemoryModuleLoadLevelMinimal, // Load sections only
- eMemoryModuleLoadLevelPartial, // Load function bounds but no symbols
- eMemoryModuleLoadLevelComplete, // Load sections and all symbols
+ eMemoryModuleLoadLevelMinimal, // Load sections only
+ eMemoryModuleLoadLevelPartial, // Load function bounds but no symbols
+ eMemoryModuleLoadLevelComplete, // Load sections and all symbols
} MemoryModuleLoadLevel;
-
//----------------------------------------------------------------------
// Result enums for when reading multiple lines from IOHandlers
//----------------------------------------------------------------------
enum class LineStatus {
- Success, // The line that was just edited if good and should be added to the lines
- Error, // There is an error with the current line and it needs to be re-edited before it can be accepted
- Done // Lines are complete
+ Success, // The line that was just edited if good and should be added to the
+ // lines
+ Error, // There is an error with the current line and it needs to be re-edited
+ // before it can be accepted
+ Done // Lines are complete
};
//----------------------------------------------------------------------
// Exit Type for inferior processes
//----------------------------------------------------------------------
typedef enum ExitType {
- eExitTypeInvalid,
- eExitTypeExit, // The exit status represents the return code from normal program exit (i.e. WIFEXITED() was true)
- eExitTypeSignal, // The exit status represents the signal number that caused the program to exit (i.e. WIFSIGNALED() was true)
- eExitTypeStop, // The exit status represents the stop signal that caused the program to exit (i.e. WIFSTOPPED() was true)
+ eExitTypeInvalid,
+ eExitTypeExit, // The exit status represents the return code from normal
+ // program exit (i.e. WIFEXITED() was true)
+ eExitTypeSignal, // The exit status represents the signal number that caused
+ // the program to exit (i.e. WIFSIGNALED() was true)
+ eExitTypeStop, // The exit status represents the stop signal that caused the
+ // program to exit (i.e. WIFSTOPPED() was true)
} ExitType;
//----------------------------------------------------------------------
// Boolean result of running a Type Validator
//----------------------------------------------------------------------
-enum class TypeValidatorResult : bool {
- Success = true,
- Failure = false
-};
+enum class TypeValidatorResult : bool { Success = true, Failure = false };
//----------------------------------------------------------------------
// Enumerations that can be used to specify scopes types when looking up
// types.
//----------------------------------------------------------------------
-enum class CompilerContextKind
-{
- Invalid = 0,
- TranslationUnit,
- Module,
- Namespace,
- Class,
- Structure,
- Union,
- Function,
- Variable,
- Enumeration,
- Typedef
+enum class CompilerContextKind {
+ Invalid = 0,
+ TranslationUnit,
+ Module,
+ Namespace,
+ Class,
+ Structure,
+ Union,
+ Function,
+ Variable,
+ Enumeration,
+ Typedef
};
-
-} // namespace lldb_private
+} // namespace lldb_private
-#endif // LLDB_lldb_private_enumerations_h_
+#endif // LLDB_lldb_private_enumerations_h_
diff --git a/include/lldb/lldb-private-forward.h b/include/lldb/lldb-private-forward.h
index bcfeb68b0b25..69a231132982 100644
--- a/include/lldb/lldb-private-forward.h
+++ b/include/lldb/lldb-private-forward.h
@@ -14,26 +14,30 @@
#include <memory>
-namespace lldb_private
-{
- // ---------------------------------------------------------------
- // Class forward decls.
- // ---------------------------------------------------------------
- class NativeBreakpoint;
- class NativeBreakpointList;
- class NativeProcessProtocol;
- class NativeRegisterContext;
- class NativeThreadProtocol;
- class UnixSignals;
+namespace lldb_private {
+// ---------------------------------------------------------------
+// Class forward decls.
+// ---------------------------------------------------------------
+class NativeBreakpoint;
+class NativeBreakpointList;
+class NativeProcessProtocol;
+class NativeRegisterContext;
+class NativeThreadProtocol;
+class ResumeActionList;
+class UnixSignals;
- // ---------------------------------------------------------------
- // SP/WP decls.
- // ---------------------------------------------------------------
- typedef std::shared_ptr<NativeBreakpoint> NativeBreakpointSP;
- typedef std::shared_ptr<lldb_private::NativeProcessProtocol> NativeProcessProtocolSP;
- typedef std::weak_ptr<lldb_private::NativeProcessProtocol> NativeProcessProtocolWP;
- typedef std::shared_ptr<lldb_private::NativeRegisterContext> NativeRegisterContextSP;
- typedef std::shared_ptr<lldb_private::NativeThreadProtocol> NativeThreadProtocolSP;
+// ---------------------------------------------------------------
+// SP/WP decls.
+// ---------------------------------------------------------------
+typedef std::shared_ptr<NativeBreakpoint> NativeBreakpointSP;
+typedef std::shared_ptr<lldb_private::NativeProcessProtocol>
+ NativeProcessProtocolSP;
+typedef std::weak_ptr<lldb_private::NativeProcessProtocol>
+ NativeProcessProtocolWP;
+typedef std::shared_ptr<lldb_private::NativeRegisterContext>
+ NativeRegisterContextSP;
+typedef std::shared_ptr<lldb_private::NativeThreadProtocol>
+ NativeThreadProtocolSP;
}
#endif // #if defined(__cplusplus)
diff --git a/include/lldb/lldb-private-interfaces.h b/include/lldb/lldb-private-interfaces.h
index 8775ce6bc565..c0d5c859a44e 100644
--- a/include/lldb/lldb-private-interfaces.h
+++ b/include/lldb/lldb-private-interfaces.h
@@ -12,51 +12,103 @@
#if defined(__cplusplus)
-#include "lldb/lldb-private.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-forward.h"
+#include "lldb/lldb-types.h"
#include <set>
-namespace lldb_private
-{
- typedef lldb::ABISP (*ABICreateInstance) (const ArchSpec &arch);
- typedef Disassembler* (*DisassemblerCreateInstance) (const ArchSpec &arch, const char *flavor);
- typedef DynamicLoader* (*DynamicLoaderCreateInstance) (Process* process, bool force);
- typedef lldb::JITLoaderSP (*JITLoaderCreateInstance) (Process *process, bool force);
- typedef ObjectContainer* (*ObjectContainerCreateInstance) (const lldb::ModuleSP &module_sp, lldb::DataBufferSP& data_sp, lldb::offset_t data_offset, const FileSpec *file, lldb::offset_t offset, lldb::offset_t length);
- typedef size_t (*ObjectFileGetModuleSpecifications) (const FileSpec &file, lldb::DataBufferSP& data_sp, lldb::offset_t data_offset, lldb::offset_t file_offset, lldb::offset_t length, ModuleSpecList &module_specs);
- typedef ObjectFile* (*ObjectFileCreateInstance) (const lldb::ModuleSP &module_sp, lldb::DataBufferSP& data_sp, lldb::offset_t data_offset, const FileSpec* file, lldb::offset_t file_offset, lldb::offset_t length);
- typedef ObjectFile* (*ObjectFileCreateMemoryInstance) (const lldb::ModuleSP &module_sp, lldb::DataBufferSP& data_sp, const lldb::ProcessSP &process_sp, lldb::addr_t offset);
- typedef bool (*ObjectFileSaveCore) (const lldb::ProcessSP &process_sp, const FileSpec &outfile, Error &error);
- typedef LogChannel* (*LogChannelCreateInstance) ();
- typedef EmulateInstruction * (*EmulateInstructionCreateInstance) (const ArchSpec &arch, InstructionType inst_type);
- typedef OperatingSystem* (*OperatingSystemCreateInstance) (Process *process, bool force);
- typedef Language *(*LanguageCreateInstance) (lldb::LanguageType language);
- typedef LanguageRuntime *(*LanguageRuntimeCreateInstance) (Process *process, lldb::LanguageType language);
- typedef lldb::CommandObjectSP (*LanguageRuntimeGetCommandObject) (CommandInterpreter& interpreter);
- typedef SystemRuntime *(*SystemRuntimeCreateInstance) (Process *process);
- typedef lldb::PlatformSP (*PlatformCreateInstance) (bool force, const ArchSpec *arch);
- typedef lldb::ProcessSP (*ProcessCreateInstance) (lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec *crash_file_path);
- typedef lldb::ScriptInterpreterSP (*ScriptInterpreterCreateInstance)(CommandInterpreter &interpreter);
- typedef SymbolFile* (*SymbolFileCreateInstance) (ObjectFile* obj_file);
- typedef SymbolVendor* (*SymbolVendorCreateInstance) (const lldb::ModuleSP &module_sp, lldb_private::Stream *feedback_strm); // Module can be NULL for default system symbol vendor
- typedef bool (*BreakpointHitCallback) (void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
- typedef bool (*WatchpointHitCallback) (void *baton, StoppointCallbackContext *context, lldb::user_id_t watch_id);
- typedef void (*OptionValueChangedCallback) (void *baton, OptionValue *option_value);
- typedef bool (*ThreadPlanShouldStopHereCallback) (ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, void *baton);
- typedef lldb::ThreadPlanSP (*ThreadPlanStepFromHereCallback) (ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, void *baton);
- typedef UnwindAssembly* (*UnwindAssemblyCreateInstance) (const ArchSpec &arch);
- typedef lldb::MemoryHistorySP (*MemoryHistoryCreateInstance) (const lldb::ProcessSP &process_sp);
- typedef lldb::InstrumentationRuntimeType (*InstrumentationRuntimeGetType) ();
- typedef lldb::InstrumentationRuntimeSP (*InstrumentationRuntimeCreateInstance) (const lldb::ProcessSP &process_sp);
- typedef lldb::TypeSystemSP (*TypeSystemCreateInstance) (lldb::LanguageType language, Module *module, Target *target);
- typedef lldb::REPLSP (*REPLCreateInstance) (Error &error, lldb::LanguageType language, Debugger *debugger, Target *target, const char *repl_options);
- typedef void (*TypeSystemEnumerateSupportedLanguages) (std::set<lldb::LanguageType> &languages_for_types, std::set<lldb::LanguageType> &languages_for_expressions);
- typedef void (*REPLEnumerateSupportedLanguages) (std::set<lldb::LanguageType> &languages);
- typedef int (*ComparisonFunction)(const void *, const void *);
- typedef void (*DebuggerInitializeCallback)(Debugger &debugger);
+namespace lldb_private {
+typedef lldb::ABISP (*ABICreateInstance)(const ArchSpec &arch);
+typedef Disassembler *(*DisassemblerCreateInstance)(const ArchSpec &arch,
+ const char *flavor);
+typedef DynamicLoader *(*DynamicLoaderCreateInstance)(Process *process,
+ bool force);
+typedef lldb::JITLoaderSP (*JITLoaderCreateInstance)(Process *process,
+ bool force);
+typedef ObjectContainer *(*ObjectContainerCreateInstance)(
+ const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
+ lldb::offset_t data_offset, const FileSpec *file, lldb::offset_t offset,
+ lldb::offset_t length);
+typedef size_t (*ObjectFileGetModuleSpecifications)(
+ const FileSpec &file, lldb::DataBufferSP &data_sp,
+ lldb::offset_t data_offset, lldb::offset_t file_offset,
+ lldb::offset_t length, ModuleSpecList &module_specs);
+typedef ObjectFile *(*ObjectFileCreateInstance)(const lldb::ModuleSP &module_sp,
+ lldb::DataBufferSP &data_sp,
+ lldb::offset_t data_offset,
+ const FileSpec *file,
+ lldb::offset_t file_offset,
+ lldb::offset_t length);
+typedef ObjectFile *(*ObjectFileCreateMemoryInstance)(
+ const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
+ const lldb::ProcessSP &process_sp, lldb::addr_t offset);
+typedef bool (*ObjectFileSaveCore)(const lldb::ProcessSP &process_sp,
+ const FileSpec &outfile, Error &error);
+typedef LogChannel *(*LogChannelCreateInstance)();
+typedef EmulateInstruction *(*EmulateInstructionCreateInstance)(
+ const ArchSpec &arch, InstructionType inst_type);
+typedef OperatingSystem *(*OperatingSystemCreateInstance)(Process *process,
+ bool force);
+typedef Language *(*LanguageCreateInstance)(lldb::LanguageType language);
+typedef LanguageRuntime *(*LanguageRuntimeCreateInstance)(
+ Process *process, lldb::LanguageType language);
+typedef lldb::CommandObjectSP (*LanguageRuntimeGetCommandObject)(
+ CommandInterpreter &interpreter);
+typedef lldb::StructuredDataPluginSP (*StructuredDataPluginCreateInstance)(
+ Process &process);
+typedef Error (*StructuredDataFilterLaunchInfo)(ProcessLaunchInfo &launch_info,
+ Target *target);
+typedef SystemRuntime *(*SystemRuntimeCreateInstance)(Process *process);
+typedef lldb::PlatformSP (*PlatformCreateInstance)(bool force,
+ const ArchSpec *arch);
+typedef lldb::ProcessSP (*ProcessCreateInstance)(
+ lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
+ const FileSpec *crash_file_path);
+typedef lldb::ScriptInterpreterSP (*ScriptInterpreterCreateInstance)(
+ CommandInterpreter &interpreter);
+typedef SymbolFile *(*SymbolFileCreateInstance)(ObjectFile *obj_file);
+typedef SymbolVendor *(*SymbolVendorCreateInstance)(
+ const lldb::ModuleSP &module_sp,
+ lldb_private::Stream
+ *feedback_strm); // Module can be NULL for default system symbol vendor
+typedef bool (*BreakpointHitCallback)(void *baton,
+ StoppointCallbackContext *context,
+ lldb::user_id_t break_id,
+ lldb::user_id_t break_loc_id);
+typedef bool (*WatchpointHitCallback)(void *baton,
+ StoppointCallbackContext *context,
+ lldb::user_id_t watch_id);
+typedef void (*OptionValueChangedCallback)(void *baton,
+ OptionValue *option_value);
+typedef bool (*ThreadPlanShouldStopHereCallback)(
+ ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation,
+ void *baton);
+typedef lldb::ThreadPlanSP (*ThreadPlanStepFromHereCallback)(
+ ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation,
+ void *baton);
+typedef UnwindAssembly *(*UnwindAssemblyCreateInstance)(const ArchSpec &arch);
+typedef lldb::MemoryHistorySP (*MemoryHistoryCreateInstance)(
+ const lldb::ProcessSP &process_sp);
+typedef lldb::InstrumentationRuntimeType (*InstrumentationRuntimeGetType)();
+typedef lldb::InstrumentationRuntimeSP (*InstrumentationRuntimeCreateInstance)(
+ const lldb::ProcessSP &process_sp);
+typedef lldb::TypeSystemSP (*TypeSystemCreateInstance)(
+ lldb::LanguageType language, Module *module, Target *target);
+typedef lldb::REPLSP (*REPLCreateInstance)(Error &error,
+ lldb::LanguageType language,
+ Debugger *debugger, Target *target,
+ const char *repl_options);
+typedef void (*TypeSystemEnumerateSupportedLanguages)(
+ std::set<lldb::LanguageType> &languages_for_types,
+ std::set<lldb::LanguageType> &languages_for_expressions);
+typedef void (*REPLEnumerateSupportedLanguages)(
+ std::set<lldb::LanguageType> &languages);
+typedef int (*ComparisonFunction)(const void *, const void *);
+typedef void (*DebuggerInitializeCallback)(Debugger &debugger);
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
+#endif // #if defined(__cplusplus)
-#endif // liblldb_lldb_private_interfaces_h_
+#endif // liblldb_lldb_private_interfaces_h_
diff --git a/include/lldb/lldb-private-types.h b/include/lldb/lldb-private-types.h
index f5d986e2e993..4f192b66369f 100644
--- a/include/lldb/lldb-private-types.h
+++ b/include/lldb/lldb-private-types.h
@@ -14,103 +14,119 @@
#include "lldb/lldb-private.h"
-namespace llvm
-{
-namespace sys
-{
+#include "llvm/ADT/ArrayRef.h"
+
+namespace llvm {
+namespace sys {
class DynamicLibrary;
}
}
-namespace lldb_private
-{
- class Platform;
- class ExecutionContext;
-
- typedef llvm::sys::DynamicLibrary (*LoadPluginCallbackType)(const lldb::DebuggerSP &debugger_sp,
- const FileSpec &spec, Error &error);
-
- //----------------------------------------------------------------------
- // Every register is described in detail including its name, alternate
- // name (optional), encoding, size in bytes and the default display
- // format.
- //----------------------------------------------------------------------
- struct RegisterInfo
- {
- const char *name; // Name of this register, can't be NULL
- const char *alt_name; // Alternate name of this register, can be NULL
- uint32_t byte_size; // Size in bytes of the register
- uint32_t byte_offset; // The byte offset in the register context data where this register's value is found.
- // This is optional, and can be 0 if a particular RegisterContext does not need to
- // address its registers by byte offset.
- lldb::Encoding encoding; // Encoding of the register bits
- lldb::Format format; // Default display format
- uint32_t kinds[lldb::kNumRegisterKinds]; // Holds all of the various register numbers for all register kinds
- uint32_t *value_regs; // List of registers (terminated with LLDB_INVALID_REGNUM). If this value is not
- // null, all registers in this list will be read first, at which point the value
- // for this register will be valid. For example, the value list for ah
- // would be eax (x86) or rax (x64).
- uint32_t *invalidate_regs; // List of registers (terminated with LLDB_INVALID_REGNUM). If this value is not
- // null, all registers in this list will be invalidated when the value of this
- // register changes. For example, the invalidate list for eax would be rax
- // ax, ah, and al.
- const uint8_t *dynamic_size_dwarf_expr_bytes; // A DWARF expression that when evaluated gives
- // the byte size of this register.
- size_t dynamic_size_dwarf_len; // The length of the DWARF expression in bytes
- // in the dynamic_size_dwarf_expr_bytes member.
- };
-
- //----------------------------------------------------------------------
- // Registers are grouped into register sets
- //----------------------------------------------------------------------
- struct RegisterSet
- {
- const char *name; // Name of this register set
- const char *short_name; // A short name for this register set
- size_t num_registers; // The number of registers in REGISTERS array below
- const uint32_t *registers; // An array of register indices in this set. The values in this array are
- // *indices* (not register numbers) into a particular RegisterContext's
- // register array. For example, if eax is defined at index 4 for a
- // particular RegisterContext, eax would be included in this RegisterSet
- // by adding the value 4. Not by adding the value lldb_eax_i386.
- };
-
- struct OptionEnumValueElement
- {
- int64_t value;
- const char *string_value;
- const char *usage;
- };
-
- struct OptionValidator
- {
- virtual ~OptionValidator() { }
- virtual bool IsValid(Platform &platform, const ExecutionContext &target) const = 0;
- virtual const char * ShortConditionString() const = 0;
- virtual const char * LongConditionString() const = 0;
- };
-
- struct OptionDefinition
- {
- uint32_t usage_mask; // Used to mark options that can be used together. If (1 << n & usage_mask) != 0
- // then this option belongs to option set n.
- bool required; // This option is required (in the current usage level)
- const char *long_option; // Full name for this option.
- int short_option; // Single character for this option.
- int option_has_arg; // no_argument, required_argument or optional_argument
- OptionValidator* validator; // If non-NULL, option is valid iff |validator->IsValid()|, otherwise always valid.
- OptionEnumValueElement *enum_values; // If non-NULL an array of enum values.
- uint32_t completion_type; // Cookie the option class can use to do define the argument completion.
- lldb::CommandArgumentType argument_type; // Type of argument this option takes
- const char *usage_text; // Full text explaining what this options does and what (if any) argument to
- // pass it.
- };
-
- typedef struct type128 { uint64_t x[2]; } type128;
- typedef struct type256 { uint64_t x[4]; } type256;
+namespace lldb_private {
+class Platform;
+class ExecutionContext;
+
+typedef llvm::sys::DynamicLibrary (*LoadPluginCallbackType)(
+ const lldb::DebuggerSP &debugger_sp, const FileSpec &spec, Error &error);
+
+//----------------------------------------------------------------------
+// Every register is described in detail including its name, alternate
+// name (optional), encoding, size in bytes and the default display
+// format.
+//----------------------------------------------------------------------
+struct RegisterInfo {
+ const char *name; // Name of this register, can't be NULL
+ const char *alt_name; // Alternate name of this register, can be NULL
+ uint32_t byte_size; // Size in bytes of the register
+ uint32_t byte_offset; // The byte offset in the register context data where
+ // this register's value is found.
+ // This is optional, and can be 0 if a particular RegisterContext does not
+ // need to
+ // address its registers by byte offset.
+ lldb::Encoding encoding; // Encoding of the register bits
+ lldb::Format format; // Default display format
+ uint32_t kinds[lldb::kNumRegisterKinds]; // Holds all of the various register
+ // numbers for all register kinds
+ uint32_t *value_regs; // List of registers (terminated with
+ // LLDB_INVALID_REGNUM). If this value is not
+ // null, all registers in this list will be read first, at which point the
+ // value
+ // for this register will be valid. For example, the value list for ah
+ // would be eax (x86) or rax (x64).
+ uint32_t *invalidate_regs; // List of registers (terminated with
+ // LLDB_INVALID_REGNUM). If this value is not
+ // null, all registers in this list will be invalidated when the value of this
+ // register changes. For example, the invalidate list for eax would be rax
+ // ax, ah, and al.
+ const uint8_t *dynamic_size_dwarf_expr_bytes; // A DWARF expression that when
+ // evaluated gives
+ // the byte size of this register.
+ size_t dynamic_size_dwarf_len; // The length of the DWARF expression in bytes
+ // in the dynamic_size_dwarf_expr_bytes member.
+
+ llvm::ArrayRef<uint8_t> data(const uint8_t *context_base) const {
+ return llvm::ArrayRef<uint8_t>(context_base + byte_offset, byte_size);
+ }
+
+ llvm::MutableArrayRef<uint8_t> mutable_data(uint8_t *context_base) const {
+ return llvm::MutableArrayRef<uint8_t>(context_base + byte_offset,
+ byte_size);
+ }
+};
+
+//----------------------------------------------------------------------
+// Registers are grouped into register sets
+//----------------------------------------------------------------------
+struct RegisterSet {
+ const char *name; // Name of this register set
+ const char *short_name; // A short name for this register set
+ size_t num_registers; // The number of registers in REGISTERS array below
+ const uint32_t *registers; // An array of register indices in this set. The
+ // values in this array are
+ // *indices* (not register numbers) into a particular RegisterContext's
+ // register array. For example, if eax is defined at index 4 for a
+ // particular RegisterContext, eax would be included in this RegisterSet
+ // by adding the value 4. Not by adding the value lldb_eax_i386.
+};
+
+struct OptionEnumValueElement {
+ int64_t value;
+ const char *string_value;
+ const char *usage;
+};
+
+struct OptionValidator {
+ virtual ~OptionValidator() {}
+ virtual bool IsValid(Platform &platform,
+ const ExecutionContext &target) const = 0;
+ virtual const char *ShortConditionString() const = 0;
+ virtual const char *LongConditionString() const = 0;
+};
+
+struct OptionDefinition {
+ uint32_t usage_mask; // Used to mark options that can be used together. If (1
+ // << n & usage_mask) != 0
+ // then this option belongs to option set n.
+ bool required; // This option is required (in the current usage level)
+ const char *long_option; // Full name for this option.
+ int short_option; // Single character for this option.
+ int option_has_arg; // no_argument, required_argument or optional_argument
+ OptionValidator *validator; // If non-NULL, option is valid iff
+ // |validator->IsValid()|, otherwise always valid.
+ OptionEnumValueElement *enum_values; // If non-NULL an array of enum values.
+ uint32_t completion_type; // Cookie the option class can use to do define the
+ // argument completion.
+ lldb::CommandArgumentType argument_type; // Type of argument this option takes
+ const char *usage_text; // Full text explaining what this options does and
+ // what (if any) argument to
+ // pass it.
+};
+
+typedef struct type128 { uint64_t x[2]; } type128;
+typedef struct type256 { uint64_t x[4]; } type256;
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
+#endif // #if defined(__cplusplus)
-#endif // liblldb_lldb_private_types_h_
+#endif // liblldb_lldb_private_types_h_
diff --git a/include/lldb/lldb-private.h b/include/lldb/lldb-private.h
index cd6f1470e81d..252ca09fae29 100644
--- a/include/lldb/lldb-private.h
+++ b/include/lldb/lldb-private.h
@@ -12,29 +12,18 @@
#if defined(__cplusplus)
-#ifdef _WIN32
-#include "lldb/Host/windows/win32.h"
-#endif
-
-#ifdef __ANDROID_NDK__
-#include "lldb/Host/android/Android.h"
-#endif
-
-#include "lldb/lldb-public.h"
+#include "lldb/lldb-private-defines.h"
#include "lldb/lldb-private-enumerations.h"
#include "lldb/lldb-private-interfaces.h"
#include "lldb/lldb-private-types.h"
-#include "lldb/lldb-private-defines.h"
+#include "lldb/lldb-public.h"
namespace lldb_private {
-const char *
-GetVersion ();
+const char *GetVersion();
} // namespace lldb_private
+#endif // defined(__cplusplus)
-#endif // defined(__cplusplus)
-
-
-#endif // lldb_lldb_private_h_
+#endif // lldb_lldb_private_h_
diff --git a/include/lldb/lldb-public.h b/include/lldb/lldb-public.h
index b010edf5859a..290ff6e6d501 100644
--- a/include/lldb/lldb-public.h
+++ b/include/lldb/lldb-public.h
@@ -15,4 +15,4 @@
#include "lldb/lldb-forward.h"
#include "lldb/lldb-types.h"
-#endif // LLDB_lldb_h_
+#endif // LLDB_lldb_h_
diff --git a/include/lldb/lldb-types.h b/include/lldb/lldb-types.h
index 2cf9904bd9d3..07e9f5ac7161 100644
--- a/include/lldb/lldb-types.h
+++ b/include/lldb/lldb-types.h
@@ -19,12 +19,18 @@
//----------------------------------------------------------------------
// All host systems must define:
-// lldb::condition_t The native condition type (or a substitute class) for conditions on the host system.
-// lldb::mutex_t The native mutex type for mutex objects on the host system.
-// lldb::thread_t The native thread type for spawned threads on the system
-// lldb::thread_arg_t The type of the one any only thread creation argument for the host system
-// lldb::thread_result_t The return type that gets returned when a thread finishes.
-// lldb::thread_func_t The function prototype used to spawn a thread on the host system.
+// lldb::condition_t The native condition type (or a substitute class)
+// for conditions on the host system.
+// lldb::mutex_t The native mutex type for mutex objects on the host
+// system.
+// lldb::thread_t The native thread type for spawned threads on the
+// system
+// lldb::thread_arg_t The type of the one any only thread creation
+// argument for the host system
+// lldb::thread_result_t The return type that gets returned when a thread
+// finishes.
+// lldb::thread_func_t The function prototype used to spawn a thread on the
+// host system.
// #define LLDB_INVALID_PROCESS_ID ...
// #define LLDB_INVALID_THREAD_ID ...
// #define LLDB_INVALID_HOST_THREAD ...
@@ -44,75 +50,71 @@
#include <process.h>
-namespace lldb
-{
- typedef void* mutex_t;
- typedef void* condition_t;
- typedef void* rwlock_t;
- typedef void* process_t; // Process type is HANDLE
- typedef void* thread_t; // Host thread type
- typedef void* file_t; // Host file type
- typedef void* pipe_t; // Host pipe type
- typedef unsigned int __w64 socket_t; // Host socket type
- typedef uint32_t thread_key_t;
- typedef void* thread_arg_t; // Host thread argument type
- typedef unsigned thread_result_t; // Host thread result type
- typedef thread_result_t (*thread_func_t)(void *); // Host thread function type
+namespace lldb {
+typedef void *mutex_t;
+typedef void *condition_t;
+typedef void *rwlock_t;
+typedef void *process_t; // Process type is HANDLE
+typedef void *thread_t; // Host thread type
+typedef void *file_t; // Host file type
+typedef void *pipe_t; // Host pipe type
+typedef unsigned int __w64 socket_t; // Host socket type
+typedef uint32_t thread_key_t;
+typedef void *thread_arg_t; // Host thread argument type
+typedef unsigned thread_result_t; // Host thread result type
+typedef thread_result_t (*thread_func_t)(void *); // Host thread function type
}
#else
#include <pthread.h>
-namespace lldb
-{
- //----------------------------------------------------------------------
- // MacOSX Types
- //----------------------------------------------------------------------
- typedef ::pthread_mutex_t mutex_t;
- typedef pthread_cond_t condition_t;
- typedef pthread_rwlock_t rwlock_t;
- typedef uint64_t process_t; // Process type is just a pid.
- typedef pthread_t thread_t; // Host thread type
- typedef int file_t; // Host file type
- typedef int pipe_t; // Host pipe type
- typedef int socket_t; // Host socket type
- typedef pthread_key_t thread_key_t;
- typedef void * thread_arg_t; // Host thread argument type
- typedef void * thread_result_t; // Host thread result type
- typedef void * (*thread_func_t)(void *); // Host thread function type
+namespace lldb {
+//----------------------------------------------------------------------
+// MacOSX Types
+//----------------------------------------------------------------------
+typedef ::pthread_mutex_t mutex_t;
+typedef pthread_cond_t condition_t;
+typedef pthread_rwlock_t rwlock_t;
+typedef uint64_t process_t; // Process type is just a pid.
+typedef pthread_t thread_t; // Host thread type
+typedef int file_t; // Host file type
+typedef int pipe_t; // Host pipe type
+typedef int socket_t; // Host socket type
+typedef pthread_key_t thread_key_t;
+typedef void *thread_arg_t; // Host thread argument type
+typedef void *thread_result_t; // Host thread result type
+typedef void *(*thread_func_t)(void *); // Host thread function type
} // namespace lldb
#endif
-namespace lldb
-{
- typedef void (*LogOutputCallback) (const char *, void *baton);
- typedef bool (*CommandOverrideCallback)(void *baton, const char **argv);
- typedef bool (*CommandOverrideCallbackWithResult)(void *baton,
- const char **argv,
- lldb_private::CommandReturnObject &result);
- typedef bool (*ExpressionCancelCallback) (ExpressionEvaluationPhase phase, void *baton);
+namespace lldb {
+typedef void (*LogOutputCallback)(const char *, void *baton);
+typedef bool (*CommandOverrideCallback)(void *baton, const char **argv);
+typedef bool (*CommandOverrideCallbackWithResult)(
+ void *baton, const char **argv, lldb_private::CommandReturnObject &result);
+typedef bool (*ExpressionCancelCallback)(ExpressionEvaluationPhase phase,
+ void *baton);
}
-#define LLDB_INVALID_PROCESS ((lldb::process_t)-1)
-#define LLDB_INVALID_HOST_THREAD ((lldb::thread_t)NULL)
-#define IS_VALID_LLDB_HOST_THREAD(t) ((t) != LLDB_INVALID_HOST_THREAD)
-
-#define LLDB_INVALID_HOST_TIME { 0, 0 }
-
-namespace lldb
-{
- typedef uint64_t addr_t;
- typedef uint64_t user_id_t;
- typedef uint64_t pid_t;
- typedef uint64_t tid_t;
- typedef uint64_t offset_t;
- typedef int32_t break_id_t;
- typedef int32_t watch_id_t;
- typedef void * opaque_compiler_type_t;
- typedef uint64_t queue_id_t;
+#define LLDB_INVALID_PROCESS ((lldb::process_t)-1)
+#define LLDB_INVALID_HOST_THREAD ((lldb::thread_t)NULL)
+#define IS_VALID_LLDB_HOST_THREAD(t) ((t) != LLDB_INVALID_HOST_THREAD)
+
+#define LLDB_INVALID_HOST_TIME \
+ { 0, 0 }
+
+namespace lldb {
+typedef uint64_t addr_t;
+typedef uint64_t user_id_t;
+typedef uint64_t pid_t;
+typedef uint64_t tid_t;
+typedef uint64_t offset_t;
+typedef int32_t break_id_t;
+typedef int32_t watch_id_t;
+typedef void *opaque_compiler_type_t;
+typedef uint64_t queue_id_t;
}
-
-#endif // LLDB_lldb_types_h_
+#endif // LLDB_lldb_types_h_
diff --git a/include/lldb/lldb-versioning.h b/include/lldb/lldb-versioning.h
index d0498a569f58..b0af5dc64b47 100644
--- a/include/lldb/lldb-versioning.h
+++ b/include/lldb/lldb-versioning.h
@@ -1,4 +1,5 @@
-//===-- lldb-versioning.h ----------------------------------------*- C++ -*-===//
+//===-- lldb-versioning.h ----------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -19,64 +20,87 @@
/*
API versioning
---------------------------------
-
+
The LLDB API is versioned independently of the LLDB source base
Our API version numbers are composed of a major and a minor number
- The major number means a complete and stable revision of the API. Major numbers are compatibility breakers
- (i.e. when we change the API major number, there is no promise of compatibility with the previous major version
+ The major number means a complete and stable revision of the API. Major numbers
+ are compatibility breakers
+ (i.e. when we change the API major number, there is no promise of compatibility
+ with the previous major version
and we are free to remove and/or change any APIs)
- Minor numbers are a work-in-progress evolution of the API. APIs will not be removed or changed across minor versions
- (minors do not break compatibility). However, we can deprecate APIs in minor versions or add new APIs in minor versions
- A deprecated API is supposedly going to be removed in the next major version and will generate a warning if used
- APIs we add in minor versions will not be removed (at least until the following major) but they might theoretically be deprecated
+ Minor numbers are a work-in-progress evolution of the API. APIs will not be
+ removed or changed across minor versions
+ (minors do not break compatibility). However, we can deprecate APIs in minor
+ versions or add new APIs in minor versions
+ A deprecated API is supposedly going to be removed in the next major version
+ and will generate a warning if used
+ APIs we add in minor versions will not be removed (at least until the following
+ major) but they might theoretically be deprecated
in a following minor version
- Users are discouraged from using the LLDB version number to test for API features and should instead use the API version checking
+ Users are discouraged from using the LLDB version number to test for API
+ features and should instead use the API version checking
as discussed below
-
+
API version checking
---------------------------------
-
+
You can (optionally) sign into an API version checking feature
To do so you need to define three macros:
LLDB_API_CHECK_VERSIONING - define to any value (or no value)
- LLDB_API_MAJOR_VERSION_WANTED - which major version of the LLDB API you are targeting
- LLDB_API_MINOR_VERSION_WANTED - which minor version of the LLDB API you are targeting
-
+ LLDB_API_MAJOR_VERSION_WANTED - which major version of the LLDB API you are
+ targeting
+ LLDB_API_MINOR_VERSION_WANTED - which minor version of the LLDB API you are
+ targeting
+
If these macros exist - LLDB will enable version checking of the public API
-
- If LLDB_API_MAJOR_VERSION is not equal to LLDB_API_MAJOR_VERSION_WANTED we will immediately halt your compilation with an error
- This is by design, since we do not make any promise of compatibility across major versions - if you really want to test your luck, disable the versioning altogether
-
- If the major version test passes, you have signed up for a specific minor version of the API
- Whenever we add or deprecate an API in a minor version, we will mark it with either
+
+ If LLDB_API_MAJOR_VERSION is not equal to LLDB_API_MAJOR_VERSION_WANTED we will
+ immediately halt your compilation with an error
+ This is by design, since we do not make any promise of compatibility across
+ major versions - if you really want to test your luck, disable the versioning
+ altogether
+
+ If the major version test passes, you have signed up for a specific minor
+ version of the API
+ Whenever we add or deprecate an API in a minor version, we will mark it with
+ either
LLDB_API_NEW_IN_DOT_x - this API is new in LLDB .x
LLDB_API_DEPRECATED_IN_DOT_x - this API is deprecated as of .x
-
+
If you are using an API new in DOT_x
- if LLDB_API_MINOR_VERSION_WANTED >= x then all is well, else you will get a compilation error
- This is meant to prevent you from using APIs that are newer than whatever LLDB you want to target
+ if LLDB_API_MINOR_VERSION_WANTED >= x then all is well, else you will get a
+ compilation error
+ This is meant to prevent you from using APIs that are newer than whatever
+ LLDB you want to target
If you are using an API deprecated in DOT_x
- if LLDB_API_MINOR_VERSION_WANTED >= x then you will get a compilation warning, else all is well
- This is meant to let you know that you are using an API that is deprecated and might go away
-
+ if LLDB_API_MINOR_VERSION_WANTED >= x then you will get a compilation warning,
+ else all is well
+ This is meant to let you know that you are using an API that is deprecated and
+ might go away
+
Caveats
---------------------------------
-
- Version checking only works on clang on OSX - you will get an error if you try to enable it on any other OS/compiler
- If you want to enable version checking on other platforms, you will need to define appropriate implementations for
- LLDB_API_IMPL_DEPRECATED and LLDB_API_IMPL_TOONEW and any other infrastructure your compiler needs for this purpose
-
+
+ Version checking only works on clang on OSX - you will get an error if you try
+ to enable it on any other OS/compiler
+ If you want to enable version checking on other platforms, you will need to
+ define appropriate implementations for
+ LLDB_API_IMPL_DEPRECATED and LLDB_API_IMPL_TOONEW and any other infrastructure
+ your compiler needs for this purpose
+
We have no deprecation-as-error mode
-
+
There is no support for API versioning in Python
-
- We reserve to use macros whose names begin with LLDB_API_ and you should not use them in your source code as they might conflict
+
+ We reserve to use macros whose names begin with LLDB_API_ and you should not
+ use them in your source code as they might conflict
with present or future macro names we are using to implement versioning
*/
-// if you want the version checking to work on other OS/compiler, define appropriate IMPL_DEPRECATED/IMPL_TOONEW
+// if you want the version checking to work on other OS/compiler, define
+// appropriate IMPL_DEPRECATED/IMPL_TOONEW
// and define LLDB_API_CHECK_VERSIONING_WORKS when you are ready to go live
#if defined(__APPLE__) && defined(__clang__)
#define LLDB_API_IMPL_DEPRECATED __attribute__((deprecated))
@@ -84,18 +108,26 @@
#define LLDB_API_CHECK_VERSIONING_WORKS
#endif
-#if defined(LLDB_API_CHECK_VERSIONING) && !defined(LLDB_API_CHECK_VERSIONING_WORKS)
-#error "API version checking will not work here - please disable or create and submit patches to lldb-versioning.h"
+#if defined(LLDB_API_CHECK_VERSIONING) && \
+ !defined(LLDB_API_CHECK_VERSIONING_WORKS)
+#error \
+ "API version checking will not work here - please disable or create and submit patches to lldb-versioning.h"
#endif
-#if defined(LLDB_API_CHECK_VERSIONING_WORKS) && (!defined(LLDB_API_IMPL_DEPRECATED) || !defined(LLDB_API_IMPL_TOONEW))
-#error "LLDB_API_CHECK_VERSIONING_WORKS needs LLDB_API_IMPL_DEPRECATED and LLDB_API_IMPL_TOONEW to be defined"
+#if defined(LLDB_API_CHECK_VERSIONING_WORKS) && \
+ (!defined(LLDB_API_IMPL_DEPRECATED) || !defined(LLDB_API_IMPL_TOONEW))
+#error \
+ "LLDB_API_CHECK_VERSIONING_WORKS needs LLDB_API_IMPL_DEPRECATED and LLDB_API_IMPL_TOONEW to be defined"
#endif
-#if defined(LLDB_API_CHECK_VERSIONING) && defined(LLDB_API_MAJOR_VERSION_WANTED) && defined(LLDB_API_MINOR_VERSION_WANTED)
+#if defined(LLDB_API_CHECK_VERSIONING) && \
+ defined(LLDB_API_MAJOR_VERSION_WANTED) && \
+ defined(LLDB_API_MINOR_VERSION_WANTED)
-#if defined (LLDB_API_MAJOR_VERSION) && (LLDB_API_MAJOR_VERSION != LLDB_API_MAJOR_VERSION_WANTED)
-#error "Cannot link using this LLDB version - public API versions are incompatible"
+#if defined(LLDB_API_MAJOR_VERSION) && \
+ (LLDB_API_MAJOR_VERSION != LLDB_API_MAJOR_VERSION_WANTED)
+#error \
+ "Cannot link using this LLDB version - public API versions are incompatible"
#endif
#define LLDB_API_MINOR_VERSION_DOT_0 0
@@ -205,7 +237,6 @@
#define LLDB_API_NEW_IN_DOT_0
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_0
#define LLDB_API_DEPRECATED_IN_DOT_0 LLDB_API_IMPL_DEPRECATED
#else
@@ -217,7 +248,6 @@
#define LLDB_API_NEW_IN_DOT_1
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_1
#define LLDB_API_DEPRECATED_IN_DOT_1 LLDB_API_IMPL_DEPRECATED
#else
@@ -229,7 +259,6 @@
#define LLDB_API_NEW_IN_DOT_2
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_2
#define LLDB_API_DEPRECATED_IN_DOT_2 LLDB_API_IMPL_DEPRECATED
#else
@@ -241,7 +270,6 @@
#define LLDB_API_NEW_IN_DOT_3
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_3
#define LLDB_API_DEPRECATED_IN_DOT_3 LLDB_API_IMPL_DEPRECATED
#else
@@ -253,7 +281,6 @@
#define LLDB_API_NEW_IN_DOT_4
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_4
#define LLDB_API_DEPRECATED_IN_DOT_4 LLDB_API_IMPL_DEPRECATED
#else
@@ -265,7 +292,6 @@
#define LLDB_API_NEW_IN_DOT_5
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_5
#define LLDB_API_DEPRECATED_IN_DOT_5 LLDB_API_IMPL_DEPRECATED
#else
@@ -277,7 +303,6 @@
#define LLDB_API_NEW_IN_DOT_6
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_6
#define LLDB_API_DEPRECATED_IN_DOT_6 LLDB_API_IMPL_DEPRECATED
#else
@@ -289,7 +314,6 @@
#define LLDB_API_NEW_IN_DOT_7
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_7
#define LLDB_API_DEPRECATED_IN_DOT_7 LLDB_API_IMPL_DEPRECATED
#else
@@ -301,7 +325,6 @@
#define LLDB_API_NEW_IN_DOT_8
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_8
#define LLDB_API_DEPRECATED_IN_DOT_8 LLDB_API_IMPL_DEPRECATED
#else
@@ -313,7 +336,6 @@
#define LLDB_API_NEW_IN_DOT_9
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_9
#define LLDB_API_DEPRECATED_IN_DOT_9 LLDB_API_IMPL_DEPRECATED
#else
@@ -325,7 +347,6 @@
#define LLDB_API_NEW_IN_DOT_10
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_10
#define LLDB_API_DEPRECATED_IN_DOT_10 LLDB_API_IMPL_DEPRECATED
#else
@@ -337,7 +358,6 @@
#define LLDB_API_NEW_IN_DOT_11
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_11
#define LLDB_API_DEPRECATED_IN_DOT_11 LLDB_API_IMPL_DEPRECATED
#else
@@ -349,7 +369,6 @@
#define LLDB_API_NEW_IN_DOT_12
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_12
#define LLDB_API_DEPRECATED_IN_DOT_12 LLDB_API_IMPL_DEPRECATED
#else
@@ -361,7 +380,6 @@
#define LLDB_API_NEW_IN_DOT_13
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_13
#define LLDB_API_DEPRECATED_IN_DOT_13 LLDB_API_IMPL_DEPRECATED
#else
@@ -373,7 +391,6 @@
#define LLDB_API_NEW_IN_DOT_14
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_14
#define LLDB_API_DEPRECATED_IN_DOT_14 LLDB_API_IMPL_DEPRECATED
#else
@@ -385,7 +402,6 @@
#define LLDB_API_NEW_IN_DOT_15
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_15
#define LLDB_API_DEPRECATED_IN_DOT_15 LLDB_API_IMPL_DEPRECATED
#else
@@ -397,7 +413,6 @@
#define LLDB_API_NEW_IN_DOT_16
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_16
#define LLDB_API_DEPRECATED_IN_DOT_16 LLDB_API_IMPL_DEPRECATED
#else
@@ -409,7 +424,6 @@
#define LLDB_API_NEW_IN_DOT_17
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_17
#define LLDB_API_DEPRECATED_IN_DOT_17 LLDB_API_IMPL_DEPRECATED
#else
@@ -421,7 +435,6 @@
#define LLDB_API_NEW_IN_DOT_18
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_18
#define LLDB_API_DEPRECATED_IN_DOT_18 LLDB_API_IMPL_DEPRECATED
#else
@@ -433,7 +446,6 @@
#define LLDB_API_NEW_IN_DOT_19
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_19
#define LLDB_API_DEPRECATED_IN_DOT_19 LLDB_API_IMPL_DEPRECATED
#else
@@ -445,7 +457,6 @@
#define LLDB_API_NEW_IN_DOT_20
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_20
#define LLDB_API_DEPRECATED_IN_DOT_20 LLDB_API_IMPL_DEPRECATED
#else
@@ -457,7 +468,6 @@
#define LLDB_API_NEW_IN_DOT_21
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_21
#define LLDB_API_DEPRECATED_IN_DOT_21 LLDB_API_IMPL_DEPRECATED
#else
@@ -469,7 +479,6 @@
#define LLDB_API_NEW_IN_DOT_22
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_22
#define LLDB_API_DEPRECATED_IN_DOT_22 LLDB_API_IMPL_DEPRECATED
#else
@@ -481,7 +490,6 @@
#define LLDB_API_NEW_IN_DOT_23
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_23
#define LLDB_API_DEPRECATED_IN_DOT_23 LLDB_API_IMPL_DEPRECATED
#else
@@ -493,7 +501,6 @@
#define LLDB_API_NEW_IN_DOT_24
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_24
#define LLDB_API_DEPRECATED_IN_DOT_24 LLDB_API_IMPL_DEPRECATED
#else
@@ -505,7 +512,6 @@
#define LLDB_API_NEW_IN_DOT_25
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_25
#define LLDB_API_DEPRECATED_IN_DOT_25 LLDB_API_IMPL_DEPRECATED
#else
@@ -517,7 +523,6 @@
#define LLDB_API_NEW_IN_DOT_26
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_26
#define LLDB_API_DEPRECATED_IN_DOT_26 LLDB_API_IMPL_DEPRECATED
#else
@@ -529,7 +534,6 @@
#define LLDB_API_NEW_IN_DOT_27
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_27
#define LLDB_API_DEPRECATED_IN_DOT_27 LLDB_API_IMPL_DEPRECATED
#else
@@ -541,7 +545,6 @@
#define LLDB_API_NEW_IN_DOT_28
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_28
#define LLDB_API_DEPRECATED_IN_DOT_28 LLDB_API_IMPL_DEPRECATED
#else
@@ -553,7 +556,6 @@
#define LLDB_API_NEW_IN_DOT_29
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_29
#define LLDB_API_DEPRECATED_IN_DOT_29 LLDB_API_IMPL_DEPRECATED
#else
@@ -565,7 +567,6 @@
#define LLDB_API_NEW_IN_DOT_30
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_30
#define LLDB_API_DEPRECATED_IN_DOT_30 LLDB_API_IMPL_DEPRECATED
#else
@@ -577,7 +578,6 @@
#define LLDB_API_NEW_IN_DOT_31
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_31
#define LLDB_API_DEPRECATED_IN_DOT_31 LLDB_API_IMPL_DEPRECATED
#else
@@ -589,7 +589,6 @@
#define LLDB_API_NEW_IN_DOT_32
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_32
#define LLDB_API_DEPRECATED_IN_DOT_32 LLDB_API_IMPL_DEPRECATED
#else
@@ -601,7 +600,6 @@
#define LLDB_API_NEW_IN_DOT_33
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_33
#define LLDB_API_DEPRECATED_IN_DOT_33 LLDB_API_IMPL_DEPRECATED
#else
@@ -613,7 +611,6 @@
#define LLDB_API_NEW_IN_DOT_34
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_34
#define LLDB_API_DEPRECATED_IN_DOT_34 LLDB_API_IMPL_DEPRECATED
#else
@@ -625,7 +622,6 @@
#define LLDB_API_NEW_IN_DOT_35
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_35
#define LLDB_API_DEPRECATED_IN_DOT_35 LLDB_API_IMPL_DEPRECATED
#else
@@ -637,7 +633,6 @@
#define LLDB_API_NEW_IN_DOT_36
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_36
#define LLDB_API_DEPRECATED_IN_DOT_36 LLDB_API_IMPL_DEPRECATED
#else
@@ -649,7 +644,6 @@
#define LLDB_API_NEW_IN_DOT_37
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_37
#define LLDB_API_DEPRECATED_IN_DOT_37 LLDB_API_IMPL_DEPRECATED
#else
@@ -661,7 +655,6 @@
#define LLDB_API_NEW_IN_DOT_38
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_38
#define LLDB_API_DEPRECATED_IN_DOT_38 LLDB_API_IMPL_DEPRECATED
#else
@@ -673,7 +666,6 @@
#define LLDB_API_NEW_IN_DOT_39
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_39
#define LLDB_API_DEPRECATED_IN_DOT_39 LLDB_API_IMPL_DEPRECATED
#else
@@ -685,7 +677,6 @@
#define LLDB_API_NEW_IN_DOT_40
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_40
#define LLDB_API_DEPRECATED_IN_DOT_40 LLDB_API_IMPL_DEPRECATED
#else
@@ -697,7 +688,6 @@
#define LLDB_API_NEW_IN_DOT_41
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_41
#define LLDB_API_DEPRECATED_IN_DOT_41 LLDB_API_IMPL_DEPRECATED
#else
@@ -709,7 +699,6 @@
#define LLDB_API_NEW_IN_DOT_42
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_42
#define LLDB_API_DEPRECATED_IN_DOT_42 LLDB_API_IMPL_DEPRECATED
#else
@@ -721,7 +710,6 @@
#define LLDB_API_NEW_IN_DOT_43
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_43
#define LLDB_API_DEPRECATED_IN_DOT_43 LLDB_API_IMPL_DEPRECATED
#else
@@ -733,7 +721,6 @@
#define LLDB_API_NEW_IN_DOT_44
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_44
#define LLDB_API_DEPRECATED_IN_DOT_44 LLDB_API_IMPL_DEPRECATED
#else
@@ -745,7 +732,6 @@
#define LLDB_API_NEW_IN_DOT_45
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_45
#define LLDB_API_DEPRECATED_IN_DOT_45 LLDB_API_IMPL_DEPRECATED
#else
@@ -757,7 +743,6 @@
#define LLDB_API_NEW_IN_DOT_46
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_46
#define LLDB_API_DEPRECATED_IN_DOT_46 LLDB_API_IMPL_DEPRECATED
#else
@@ -769,7 +754,6 @@
#define LLDB_API_NEW_IN_DOT_47
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_47
#define LLDB_API_DEPRECATED_IN_DOT_47 LLDB_API_IMPL_DEPRECATED
#else
@@ -781,7 +765,6 @@
#define LLDB_API_NEW_IN_DOT_48
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_48
#define LLDB_API_DEPRECATED_IN_DOT_48 LLDB_API_IMPL_DEPRECATED
#else
@@ -793,7 +776,6 @@
#define LLDB_API_NEW_IN_DOT_49
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_49
#define LLDB_API_DEPRECATED_IN_DOT_49 LLDB_API_IMPL_DEPRECATED
#else
@@ -805,7 +787,6 @@
#define LLDB_API_NEW_IN_DOT_50
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_50
#define LLDB_API_DEPRECATED_IN_DOT_50 LLDB_API_IMPL_DEPRECATED
#else
@@ -817,7 +798,6 @@
#define LLDB_API_NEW_IN_DOT_51
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_51
#define LLDB_API_DEPRECATED_IN_DOT_51 LLDB_API_IMPL_DEPRECATED
#else
@@ -829,7 +809,6 @@
#define LLDB_API_NEW_IN_DOT_52
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_52
#define LLDB_API_DEPRECATED_IN_DOT_52 LLDB_API_IMPL_DEPRECATED
#else
@@ -841,7 +820,6 @@
#define LLDB_API_NEW_IN_DOT_53
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_53
#define LLDB_API_DEPRECATED_IN_DOT_53 LLDB_API_IMPL_DEPRECATED
#else
@@ -853,7 +831,6 @@
#define LLDB_API_NEW_IN_DOT_54
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_54
#define LLDB_API_DEPRECATED_IN_DOT_54 LLDB_API_IMPL_DEPRECATED
#else
@@ -865,7 +842,6 @@
#define LLDB_API_NEW_IN_DOT_55
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_55
#define LLDB_API_DEPRECATED_IN_DOT_55 LLDB_API_IMPL_DEPRECATED
#else
@@ -877,7 +853,6 @@
#define LLDB_API_NEW_IN_DOT_56
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_56
#define LLDB_API_DEPRECATED_IN_DOT_56 LLDB_API_IMPL_DEPRECATED
#else
@@ -889,7 +864,6 @@
#define LLDB_API_NEW_IN_DOT_57
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_57
#define LLDB_API_DEPRECATED_IN_DOT_57 LLDB_API_IMPL_DEPRECATED
#else
@@ -901,7 +875,6 @@
#define LLDB_API_NEW_IN_DOT_58
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_58
#define LLDB_API_DEPRECATED_IN_DOT_58 LLDB_API_IMPL_DEPRECATED
#else
@@ -913,7 +886,6 @@
#define LLDB_API_NEW_IN_DOT_59
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_59
#define LLDB_API_DEPRECATED_IN_DOT_59 LLDB_API_IMPL_DEPRECATED
#else
@@ -925,7 +897,6 @@
#define LLDB_API_NEW_IN_DOT_60
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_60
#define LLDB_API_DEPRECATED_IN_DOT_60 LLDB_API_IMPL_DEPRECATED
#else
@@ -937,7 +908,6 @@
#define LLDB_API_NEW_IN_DOT_61
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_61
#define LLDB_API_DEPRECATED_IN_DOT_61 LLDB_API_IMPL_DEPRECATED
#else
@@ -949,7 +919,6 @@
#define LLDB_API_NEW_IN_DOT_62
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_62
#define LLDB_API_DEPRECATED_IN_DOT_62 LLDB_API_IMPL_DEPRECATED
#else
@@ -961,7 +930,6 @@
#define LLDB_API_NEW_IN_DOT_63
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_63
#define LLDB_API_DEPRECATED_IN_DOT_63 LLDB_API_IMPL_DEPRECATED
#else
@@ -973,7 +941,6 @@
#define LLDB_API_NEW_IN_DOT_64
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_64
#define LLDB_API_DEPRECATED_IN_DOT_64 LLDB_API_IMPL_DEPRECATED
#else
@@ -985,7 +952,6 @@
#define LLDB_API_NEW_IN_DOT_65
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_65
#define LLDB_API_DEPRECATED_IN_DOT_65 LLDB_API_IMPL_DEPRECATED
#else
@@ -997,7 +963,6 @@
#define LLDB_API_NEW_IN_DOT_66
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_66
#define LLDB_API_DEPRECATED_IN_DOT_66 LLDB_API_IMPL_DEPRECATED
#else
@@ -1009,7 +974,6 @@
#define LLDB_API_NEW_IN_DOT_67
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_67
#define LLDB_API_DEPRECATED_IN_DOT_67 LLDB_API_IMPL_DEPRECATED
#else
@@ -1021,7 +985,6 @@
#define LLDB_API_NEW_IN_DOT_68
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_68
#define LLDB_API_DEPRECATED_IN_DOT_68 LLDB_API_IMPL_DEPRECATED
#else
@@ -1033,7 +996,6 @@
#define LLDB_API_NEW_IN_DOT_69
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_69
#define LLDB_API_DEPRECATED_IN_DOT_69 LLDB_API_IMPL_DEPRECATED
#else
@@ -1045,7 +1007,6 @@
#define LLDB_API_NEW_IN_DOT_70
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_70
#define LLDB_API_DEPRECATED_IN_DOT_70 LLDB_API_IMPL_DEPRECATED
#else
@@ -1057,7 +1018,6 @@
#define LLDB_API_NEW_IN_DOT_71
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_71
#define LLDB_API_DEPRECATED_IN_DOT_71 LLDB_API_IMPL_DEPRECATED
#else
@@ -1069,7 +1029,6 @@
#define LLDB_API_NEW_IN_DOT_72
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_72
#define LLDB_API_DEPRECATED_IN_DOT_72 LLDB_API_IMPL_DEPRECATED
#else
@@ -1081,7 +1040,6 @@
#define LLDB_API_NEW_IN_DOT_73
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_73
#define LLDB_API_DEPRECATED_IN_DOT_73 LLDB_API_IMPL_DEPRECATED
#else
@@ -1093,7 +1051,6 @@
#define LLDB_API_NEW_IN_DOT_74
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_74
#define LLDB_API_DEPRECATED_IN_DOT_74 LLDB_API_IMPL_DEPRECATED
#else
@@ -1105,7 +1062,6 @@
#define LLDB_API_NEW_IN_DOT_75
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_75
#define LLDB_API_DEPRECATED_IN_DOT_75 LLDB_API_IMPL_DEPRECATED
#else
@@ -1117,7 +1073,6 @@
#define LLDB_API_NEW_IN_DOT_76
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_76
#define LLDB_API_DEPRECATED_IN_DOT_76 LLDB_API_IMPL_DEPRECATED
#else
@@ -1129,7 +1084,6 @@
#define LLDB_API_NEW_IN_DOT_77
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_77
#define LLDB_API_DEPRECATED_IN_DOT_77 LLDB_API_IMPL_DEPRECATED
#else
@@ -1141,7 +1095,6 @@
#define LLDB_API_NEW_IN_DOT_78
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_78
#define LLDB_API_DEPRECATED_IN_DOT_78 LLDB_API_IMPL_DEPRECATED
#else
@@ -1153,7 +1106,6 @@
#define LLDB_API_NEW_IN_DOT_79
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_79
#define LLDB_API_DEPRECATED_IN_DOT_79 LLDB_API_IMPL_DEPRECATED
#else
@@ -1165,7 +1117,6 @@
#define LLDB_API_NEW_IN_DOT_80
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_80
#define LLDB_API_DEPRECATED_IN_DOT_80 LLDB_API_IMPL_DEPRECATED
#else
@@ -1177,7 +1128,6 @@
#define LLDB_API_NEW_IN_DOT_81
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_81
#define LLDB_API_DEPRECATED_IN_DOT_81 LLDB_API_IMPL_DEPRECATED
#else
@@ -1189,7 +1139,6 @@
#define LLDB_API_NEW_IN_DOT_82
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_82
#define LLDB_API_DEPRECATED_IN_DOT_82 LLDB_API_IMPL_DEPRECATED
#else
@@ -1201,7 +1150,6 @@
#define LLDB_API_NEW_IN_DOT_83
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_83
#define LLDB_API_DEPRECATED_IN_DOT_83 LLDB_API_IMPL_DEPRECATED
#else
@@ -1213,7 +1161,6 @@
#define LLDB_API_NEW_IN_DOT_84
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_84
#define LLDB_API_DEPRECATED_IN_DOT_84 LLDB_API_IMPL_DEPRECATED
#else
@@ -1225,7 +1172,6 @@
#define LLDB_API_NEW_IN_DOT_85
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_85
#define LLDB_API_DEPRECATED_IN_DOT_85 LLDB_API_IMPL_DEPRECATED
#else
@@ -1237,7 +1183,6 @@
#define LLDB_API_NEW_IN_DOT_86
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_86
#define LLDB_API_DEPRECATED_IN_DOT_86 LLDB_API_IMPL_DEPRECATED
#else
@@ -1249,7 +1194,6 @@
#define LLDB_API_NEW_IN_DOT_87
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_87
#define LLDB_API_DEPRECATED_IN_DOT_87 LLDB_API_IMPL_DEPRECATED
#else
@@ -1261,7 +1205,6 @@
#define LLDB_API_NEW_IN_DOT_88
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_88
#define LLDB_API_DEPRECATED_IN_DOT_88 LLDB_API_IMPL_DEPRECATED
#else
@@ -1273,7 +1216,6 @@
#define LLDB_API_NEW_IN_DOT_89
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_89
#define LLDB_API_DEPRECATED_IN_DOT_89 LLDB_API_IMPL_DEPRECATED
#else
@@ -1285,7 +1227,6 @@
#define LLDB_API_NEW_IN_DOT_90
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_90
#define LLDB_API_DEPRECATED_IN_DOT_90 LLDB_API_IMPL_DEPRECATED
#else
@@ -1297,7 +1238,6 @@
#define LLDB_API_NEW_IN_DOT_91
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_91
#define LLDB_API_DEPRECATED_IN_DOT_91 LLDB_API_IMPL_DEPRECATED
#else
@@ -1309,7 +1249,6 @@
#define LLDB_API_NEW_IN_DOT_92
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_92
#define LLDB_API_DEPRECATED_IN_DOT_92 LLDB_API_IMPL_DEPRECATED
#else
@@ -1321,7 +1260,6 @@
#define LLDB_API_NEW_IN_DOT_93
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_93
#define LLDB_API_DEPRECATED_IN_DOT_93 LLDB_API_IMPL_DEPRECATED
#else
@@ -1333,7 +1271,6 @@
#define LLDB_API_NEW_IN_DOT_94
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_94
#define LLDB_API_DEPRECATED_IN_DOT_94 LLDB_API_IMPL_DEPRECATED
#else
@@ -1345,7 +1282,6 @@
#define LLDB_API_NEW_IN_DOT_95
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_95
#define LLDB_API_DEPRECATED_IN_DOT_95 LLDB_API_IMPL_DEPRECATED
#else
@@ -1357,7 +1293,6 @@
#define LLDB_API_NEW_IN_DOT_96
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_96
#define LLDB_API_DEPRECATED_IN_DOT_96 LLDB_API_IMPL_DEPRECATED
#else
@@ -1369,7 +1304,6 @@
#define LLDB_API_NEW_IN_DOT_97
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_97
#define LLDB_API_DEPRECATED_IN_DOT_97 LLDB_API_IMPL_DEPRECATED
#else
@@ -1381,7 +1315,6 @@
#define LLDB_API_NEW_IN_DOT_98
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_98
#define LLDB_API_DEPRECATED_IN_DOT_98 LLDB_API_IMPL_DEPRECATED
#else
@@ -1393,14 +1326,16 @@
#define LLDB_API_NEW_IN_DOT_99
#endif
-
#if LLDB_API_MINOR_VERSION_WANTED >= LLDB_API_MINOR_VERSION_DOT_99
#define LLDB_API_DEPRECATED_IN_DOT_99 LLDB_API_IMPL_DEPRECATED
#else
#define LLDB_API_DEPRECATED_IN_DOT_99
#endif
-#else // defined(LLDB_CHECK_API_VERSIONING) && defined(LLDB_API_MAJOR_VERSION_WANTED) && defined(LLDB_API_MINOR_VERSION_WANTED) && defined (LLDB_API_MAJOR_VERSION)
+#else // defined(LLDB_CHECK_API_VERSIONING) &&
+ // defined(LLDB_API_MAJOR_VERSION_WANTED) &&
+ // defined(LLDB_API_MINOR_VERSION_WANTED) && defined
+ // (LLDB_API_MAJOR_VERSION)
#define LLDB_API_NEW_IN_DOT_0
#define LLDB_API_DEPRECATED_IN_DOT_0
@@ -1602,6 +1537,9 @@
#define LLDB_API_DEPRECATED_IN_DOT_98
#define LLDB_API_NEW_IN_DOT_99
#define LLDB_API_DEPRECATED_IN_DOT_99
-#endif // defined(LLDB_CHECK_API_VERSIONING) && defined(LLDB_API_MAJOR_VERSION_WANTED) && defined(LLDB_API_MINOR_VERSION_WANTED) && defined (LLDB_API_MAJOR_VERSION)
+#endif // defined(LLDB_CHECK_API_VERSIONING) &&
+ // defined(LLDB_API_MAJOR_VERSION_WANTED) &&
+ // defined(LLDB_API_MINOR_VERSION_WANTED) && defined
+ // (LLDB_API_MAJOR_VERSION)
#endif // LLDB_lldb_versioning_h_